#!/usr/bin/make -f

export DEB_BUILD_MAINT_OPTIONS = hardening=+all
export DEB_CFLAGS_MAINT_APPEND  = -Wall -pedantic
export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed

# Some variables:
DEB_HOST_ARCH_OS  ?= $(shell dpkg-architecture -qDEB_HOST_ARCH_OS)
DEB_HOST_ARCH_CPU ?= $(shell dpkg-architecture -qDEB_HOST_ARCH_CPU)

%:
	dh $@ --exclude=.la

override_dh_auto_configure:
	dh_auto_configure -- \
		--enable-tools=yes \
		$(NULL)

# Architecture: all only: build the doxygen documentation
override_dh_auto_build-indep:
ifeq (,$(filter nodoc,$(DEB_BUILD_OPTIONS)))
	dh_auto_build -- doc
endif

# doxygen documentation is installed using dh_installdocs
override_dh_auto_install-indep:

override_dh_installdocs:
	# fix lintian useless-autogenerated-doxygen-file
	dh_installdocs -X.md5

override_dh_clean:
	dh_clean
	find -name "lt~obsolete.m4" | xargs rm -rf
	find -name "ltversion.m4" | xargs rm -rf
	find -name "ltsugar.m4" | xargs rm -rf
	find -name "ltoptions.m4" | xargs rm -rf
	find -name "libtool.m4" | xargs rm -rf
	find -name "aclocal.m4" | xargs rm -rf
	rm -rf confdefs.h
	rm -rf autostuff
	rm -rf doc/*

override_dh_missing:
	dh_missing --fail-missing
