#!/usr/bin/make -f
#export DH_VERBOSE=1

BINPKG = $(first $(shell dh_listpackages))

export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed

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

override_dh_autoreconf:
	-mkdir $(CURDIR)/m4
	intltoolize --copy --force
	-mkdir libghwp/m4
	cd libghwp && intltoolize --copy --force
	dh_autoreconf --as-needed

override_dh_auto_configure:
	cd libghwp && ./configure
	dh_auto_configure

override_dh_auto_build:
	$(MAKE) -C libghwp
	dh_auto_build

override_dh_auto_clean:
	cd libghwp && dh_auto_clean
	rm -f -r libghwp/$(CURDIR)/m4
	dh_auto_clean
	rm -f -r $(CURDIR)/m4

override_dh_strip:
	dh_strip --dbg-package=evince-hwp-dbg

override_dh_auto_install:
	dh_auto_install
	# remove *.la files
	find $(CURDIR)/debian/$(BINPKG) -name "*.la" -exec rm -f '{}' ';'
