#!/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.  Add --as-needed to
# drop a few unnecessary dependencies.
export DEB_LDFLAGS_MAINT_APPEND = -lpthread -Wl,--as-needed

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

%:
	dh $@ --with autoreconf

override_dh_auto_configure:
	dh_auto_configure -- $(DEBUG)

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

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

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 --as-needed

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