#!/usr/bin/make -f

# DH_VERBOSE := 1

export DEB_BUILD_MAINT_OPTIONS=hardening=+all
export DEB_LDFLAGS_MAINT_APPEND+=-pthread

%:
	dh $@

override_dh_auto_configure:
	rm -Rf vendor/*
	ln -s /usr/src/googletest ./vendor/
	dh_auto_configure -- -Dthread_pool_build_tests=ON

override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	./obj-*/bin/thread_pool_test
endif

override_dh_install:
	dh_install
	file-rename 's/_static\.a/.a/' `find debian -name "lib*_static.a"`
	mv debian/tmp/usr/lib/*.a debian/tmp/usr/lib/`dpkg-architecture -qDEB_HOST_MULTIARCH` # this somehow inserts i686-linux-gnu which is wrong: $(DEB_HOST_MULTIARCH)
	d-shlibmove --commit \
		    --multiarch \
		    --devunversioned \
		    --exclude-la \
		    --movedev debian/tmp/usr/include/* usr/include \
		    debian/tmp/usr/lib/*/*.so
