#!/usr/bin/make -f

export DEB_LDFLAGS_MAINT_APPEND := -Wl,--as-needed
export DEB_CFLAGS_MAINT_APPEND := -Wall -Wno-format-contains-nul

override_dh_auto_configure:
	dh_auto_configure --verbose -- \
		--disable-silent-rules \
		--with-libxml2-libs="$(shell pkg-config --libs libxml-2.0)" \
		--with-libxml2-cflags="$(shell pkg-config --cflags libxml-2.0)"

override_dh_auto_build:
	dh_auto_build --verbose
	$(MAKE) -C doc autogen.ps info
	cd doc && texi2html -split=chapter -subdir=html autogen.texi


override_dh_auto_clean:
	rm -Rf doc/html
	rm -vf agen5/test/defs autoopts/test/*.o autoopts/test/*.c \
		autoopts/test/*.h autoopts/test/getopt.def getdefs/opts.c \
		snprintfv/snv.c snprintfv/snprintfv.h xml2ag/fork.c \
		xml2ag/xmlopts.c xml2ag/xmlopts.h autoopts/autoopts.pc \
		autoopts/pathfind.3 autoopts/*.tar.gz
	dh_auto_clean --verbose

override_dh_auto_install:
	dh_auto_install  --verbose
	rm -vf $(CURDIR)/debian/tmp/usr/share/autogen/*.tar.gz \
		$(CURDIR)/debian/tmp/usr/share/info/dir \
		$(CURDIR)/debian/tmp/usr/lib/*/libopts.la


override_dh_install:
	dh_install --fail-missing

override_dh_makeshlibs:
	dh_makeshlibs -V

%:
	dh $@ --with autoreconf
