#!/usr/bin/make -f

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

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

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

override_dh_auto_configure:
	dh_auto_configure -- $(DEBUG) \
	    --with-xmlsec

override_dh_auto_build-indep:
	$(MAKE) doxygen-doc
	$(MAKE) -C schemas

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

override_dh_auto_test-indep:

override_dh_auto_test-arch:
	dh_auto_test -- XMLTOOLINGTEST_SKIP_NETWORKED=1

docdir = debian/tmp/usr/share/doc/xmltooling-*
override_dh_install:
	cd $(docdir) && \
	    rm README.txt LICENSE.txt NOTICE.txt OPENSSL.LICENSE LOG4CPP.LICENSE \
	       CURL.LICENSE
	# The tag file is unreproducible (it captures the full build path),
	# but is used as a "stamp" file during the build.
	cd $(docdir) && rm -f api/xmltooling.tag api/html/*.md5 api/html/*.map
	dh_install --fail-missing

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