#!/usr/bin/make -f

export DEB_BUILD_MAINT_OPTIONS = hardening=+all

ifeq ($(filter nodoc, $(DEB_BUILD_PROFILES)),)
	# Rebuild the docs to propagate procServ.txt patch
	ENABLE_DOCS_FLAG=--enable-doc=yes

	# Disable parallelism to prevent unsafe concurrent writes to procServ.xml by
	# different a2x processes
	AUTO_BUILD_FLAGS=-O--no-parallel
else
	ENABLE_DOCS_FLAG=--enable-doc=no
endif

%:
	dh $@ --buildsystem=autoconf

override_dh_auto_configure:
	dh_auto_configure -- --docdir=\$${prefix}/share/doc/procserv $(ENABLE_DOCS_FLAG)

override_dh_auto_build:
	dh_auto_build $(AUTO_BUILD_FLAGS)

execute_after_dh_auto_install:
	# Remove extra ChangeLog and COPYING files installed by upstream make
	rm $(CURDIR)/debian/procserv/usr/share/doc/procserv/ChangeLog
	rm $(CURDIR)/debian/procserv/usr/share/doc/procserv/COPYING

	# Remove non-descriptive release note file
	rm $(CURDIR)/debian/procserv/usr/share/doc/procserv/NEWS
