#!/usr/bin/make -f

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
export DEB_BUILD_MAINT_OPTIONS = hardening=+all

DEBIAN  := $(shell dpkg-parsechangelog | grep ^Version: | cut -d' ' -f2)
DEBVERS := $(shell echo '$(DEBIAN)' | cut -d- -f1)
VERSION := $(shell echo '$(DEBVERS)' | sed -e 's/[+-].*//' -e 's/~//g')

%:
	dh $@ --with autoreconf

override_dh_strip:
	dh_strip -plibosmo-sigtran12 --dbg-package=libosmo-sigtran-dbg
	dh_strip -posmo-stp --dbg-package=osmo-stp-dbg

override_dh_install:
	sed -i "/dependency_libs/ s/'.*'/''/" `find . -name '*.la'`
	dh_install

# enable-static: we require the tests to link to the static libosmo-sigtran
# library to access symbols not starting with osmo_*
override_dh_auto_configure:
	dh_auto_configure -- \
		--enable-manuals \
		--enable-static \
		--enable-tcap-loadsharing \
		--with-systemdsystemunitdir=/lib/systemd/system \
		$(NULL)

# Print test results in case of a failure
override_dh_auto_test:
	dh_auto_test || (find . -name testsuite.log -exec cat {} \; ; false)

override_dh_clean:
	dh_clean
	rm -f .version tests/package.m4 tests/testsuite

# Don't create .pdf.gz files (barely saves space and they can't be opened directly by most pdf readers)
override_dh_compress:
	dh_compress -X.pdf
