#!/usr/bin/make -f

DPKG_EXPORT_BUILDFLAGS = 1
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
include /usr/share/dpkg/default.mk
export MAN_PAGE_DATE ?= $(shell LC_ALL=C date -u -d"@$(SOURCE_DATE_EPOCH)" "+%d %b %Y")

%:
	dh $@

override_dh_autoreconf:
	## Instead of repackaging the upstream source, we remove the files included
	## from gnulib before the build.
	rm -rf doc/complexity.info doc/gendocs_template m4/ lib/
	## Regenerate src/opts.[ch] from src/opts.def - current upstream source uses
	## newer autogen version than the system one
	cd src && autogen opts.def
	## This is unfortunate, but we are forced to invoke gnulib-tool manually
	## and list modules here, since bootstrap script assumes presence of git
	## and network connection, and policy is to avoid bundled copies of
	## another project code.
	gnulib-tool --import close fdl gendocs gpl-3.0 malloc-posix snprintf stdbool
	## liboptschk.m4 was bundled m4/ alongside with gnulib macros,
	## but we dropped it. This way is even better, since we for sure get
	## the newest version of liboptschk.m4.
	ln -s /usr/share/autogen/liboptschk.m4 m4/
	dh_autoreconf
