#!/usr/bin/make -f

# DH_VERBOSE := 1
export LC_ALL=C.UTF-8

include /usr/share/dpkg/default.mk
# this provides:
# DEB_SOURCE: the source package name
# DEB_VERSION: the full version of the package (epoch + upstream vers. + revision)
# DEB_VERSION_EPOCH_UPSTREAM: the package's version without the Debian revision
# DEB_VERSION_UPSTREAM_REVISION: the package's version without the Debian epoch
# DEB_VERSION_UPSTREAM: the package's upstream version
# DEB_DISTRIBUTION: the distribution(s) listed in the current entry of debian/changelog
# SOURCE_DATE_EPOCH: the source release date as seconds since the epoch, as
#                    specified by <https://reproducible-builds.org/specs/source-date-epoch/>

export DEB_BUILD_MAINT_OPTIONS=hardening=+all

%:
	dh $@

# dh_missing warned about files not installed
override_dh_auto_install:
	dh_auto_install
	mkdir -p  debian/libhtscodecs-dev/usr/lib/$(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
	mv debian/tmp/usr/lib/$(shell dpkg-architecture -qDEB_HOST_MULTIARCH)/libhtscodecs.a debian/libhtscodecs-dev/usr/lib/$(shell dpkg-architecture -qDEB_HOST_MULTIARCH)/
	rm -f debian/tmp/usr/lib/$(shell dpkg-architecture -qDEB_HOST_MULTIARCH)/libhtscodecs.la


override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	make check
endif

override_dh_installexamples:
	rm -Rf tests/.libs tests/tok* tests/test.out tests/*.o tests/*log \
		tests/Makefile tests/Makefile.in tests/arith_dynamic tests/fqzcomp_qual \
		tests/rans4x16pr tests/rans4x8 tests/varint
	dh_installexamples

override_dh_auto_clean:
	dh_auto_clean
	find . -name "*.o" -o -name "*.lo" -delete
