#!/bin/sh
set -e

dpkg-source --before-build `pwd`

# Use installed squid binary
sed -i 's;^sbindir=\$2;sbindir=/usr/sbin;w /tmp/use_installed_bin' test-suite/test-squid-conf.sh
if [ ! -s /tmp/use_installed_bin ]; then
    echo "The substitution to use the installed bin failed. Was the file changed?"
    rm -f /tmp/use_installed_bin
    exit 1
fi
rm -f /tmp/use_installed_bin

dh_update_autotools_config
dh_autoreconf
dh_auto_configure -- ${DEB_CONFIGURE_EXTRA_FLAGS} --with-gnutls
make -C src/base libbase.la
make -C src/comm libminimal.la
make -C src/debug libdebug.la
make -C src/mem libmem.la
make -C src/time libtime.la
make -C src globals.o
make -C lib all
make -C compat
make -C src squid.conf.default
make -C test-suite check
