#!/usr/bin/make -f

# Enable compiler hardening flags.
export DEB_BUILD_MAINT_OPTIONS = hardening=+all

# Force linking with -lpthread, working around a bug in libtool that drops
# the linkage because it uses -nostdlib.  See #468555.
export DEB_LDFLAGS_MAINT_APPEND = -lpthread

ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
    DEBUG = --enable-debug
else
    DEBUG =
endif

%:
	dh $@ --with autoreconf

AXCPI=ax_create_pkgconfig_info.m4
# use the fixed macro from autoconf-archive:
# don't add user CPPFLAGS/LDFLAGS to pc files
override_dh_autoreconf:
	mv -t debian "m4/$(AXCPI)"
	dh_autoreconf

override_dh_auto_configure:
	dh_auto_configure -- $(DEBUG)

override_dh_install:
	set -e; \
	for i in README.txt LICENSE.txt NOTICE.txt OPENSSL.LICENSE LOG4CPP.LICENSE \
	    CURL.LICENSE; do \
		rm debian/tmp/usr/share/doc/xmltooling-*/$$i; \
	done
	dh_install --fail-missing

override_dh_installdocs:
	dh_installdocs -A doc/README.txt doc/NOTICE.txt

override_dh_clean:
	dh_clean
	-mv -t m4 "debian/$(AXCPI)"
