#!/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

override_dh_auto_configure:
	dh_auto_configure -- --disable-static $(DEBUG)

override_dh_auto_build-indep:
	$(MAKE) docs

# the test target would build the software
override_dh_auto_test-indep:

override_dh_auto_install-indep:
	$(MAKE) -C doc DESTDIR=$(CURDIR)/debian/tmp install

APIDOCS=debian/tmp/usr/share/doc/log4shib-*/api/html
override_dh_install:
	pod2man --release='$(word 3,$(shell ./config.status --version))' \
	    --section=1 --center=log4shib \
	    debian/log4shib-config.pod debian/log4shib-config.1
	rm -f debian/tmp/usr/lib/*/liblog4shib.la
	rm -rf debian/tmp/usr/share/man/man3
	if [ -d $(APIDOCS) ]; then find $(APIDOCS) -name "*.md5" -delete; fi
	dh_install --fail-missing

%:
	dh $@ --parallel --with autoreconf
