#!/usr/bin/make -f

include /usr/share/dpkg/default.mk

export DEB_BUILD_MAINT_OPTIONS=hardening=+all
export DEB_CFLAGS_MAINT_APPEND=-std=gnu++11
export DEB_CXXFLAGS_MAINT_APPEND=-D_FILE_OFFSET_BITS=64

%:
	dh $@ --no-parallel

override_dh_auto_build:
	dh_auto_build -- CXXFLAGS="$(CXXFLAGS)"

override_dh_auto_install:
	echo "Skip autoinstall process - files are moved around by dh_install"

override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	mkdir -p $(CURDIR)/test/bash-tap/
	for bt in $(CURDIR)/debian/bash-tap/* ; do ln -s $${bt} $(CURDIR)/test/bash-tap/`basename $${bt}` ; done
	ln -s $(CURDIR)/debian/test-simple-bash/lib test/test-simple-bash
	chmod +x vcflib/scripts/vcffirstheader
	# export PATH=/usr/lib/vcflib/binaries/:$(PATH) dh_auto_test
	echo "Tests should be run" && PATH=/usr/lib/vcflib/binaries/:$(PATH) dh_auto_test && echo "Tests were running successfully"
	rm -rf $(CURDIR)/test/bash-tap
	rm test/test-simple-bash/lib
endif
