#!/usr/bin/make -f
#DH_VERBOSE = 1

include /usr/share/dpkg/pkg-info.mk

CHANGELOG_DATE ?= $(shell LC_ALL=C date -u -d @$(SOURCE_DATE_EPOCH) +"%d %B %Y")

#export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed
export DEB_BUILD_MAINT_OPTIONS = hardening=+all

%:
	dh $@ --with autoreconf


override_dh_auto_clean:
	dh_auto_clean
	$(RM) tests/testsuite tests/package.m4 tests/testsuite.log .tarball-version tests/testsuite.dir/at-job-fifo
	$(RM) CommonLibs/Makefile
	$(RM) GSM/Makefile
	$(RM) Makefile
	$(RM) Transceiver52M/Makefile
	$(RM) Transceiver52M/arch/Makefile
	$(RM) Transceiver52M/arch/arm/Makefile
	$(RM) Transceiver52M/arch/common/Makefile
	$(RM) Transceiver52M/arch/x86/Makefile
	$(RM) Transceiver52M/device/Makefile
	$(RM) Transceiver52M/device/bladerf/Makefile
	$(RM) Transceiver52M/device/common/Makefile
	$(RM) Transceiver52M/device/ipc/Makefile
	$(RM) Transceiver52M/device/lms/Makefile
	$(RM) Transceiver52M/device/uhd/Makefile
	$(RM) Transceiver52M/device/usrp1/Makefile
	$(RM) Transceiver52M/grgsm_vitac/.dirstamp
	$(RM) config.h
	$(RM) config.log
	$(RM) config.status
	$(RM) contrib/Makefile
	$(RM) contrib/osmo-trx.spec
	$(RM) contrib/systemd/Makefile
	$(RM) doc/Makefile
	$(RM) doc/examples/Makefile
	$(RM) doc/manuals/Makefile
	$(RM) libtool
	$(RM) stamp-h1
	$(RM) tests/CommonLibs/Makefile
	$(RM) tests/Makefile
	$(RM) tests/Transceiver52M/Makefile
	$(RM) tests/atconfig
	$(RM) utils/Makefile

override_dh_autoreconf:
	echo $(DEB_VERSION_UPSTREAM) > .tarball-version
	dh_autoreconf

override_dh_auto_configure:
	dh_auto_configure -- --with-lms

override_dh_auto_test:
	dh_auto_test
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	./debian/autotest/autotest
endif

override_dh_installsystemd:
	dh_installsystemd --no-enable --no-start
