#!/usr/bin/make -f

export DEB_BUILD_MAINT_OPTIONS = hardening=+all

ifneq ($(SOURCE_DATE_EPOCH),)
# Force fixed %%CreationDate in ps files created by dvips (for a Reproducible Build)
export FORCE_SOURCE_DATE=1

# Also force "TeX output" string in dvi file, thus %DVIPSSource in the ps file.
FAKETIME = TZ=UTC faketime "$(shell TZ=UTC date +"%Y-%m-%d %T" --date=@$(SOURCE_DATE_EPOCH))"
endif

override_dh_auto_configure:
#Avoid conflicting with upstreams build system

override_dh_auto_test:
#Upstream states test is only for their local development not a functional test

override_dh_auto_build-arch:
	dh_auto_build --no-parallel --buildsystem=makefile

override_dh_auto_build-indep: override_dh_auto_build-arch
	cd doc && $(FAKETIME) $(MAKE) festival.info festival.html festival.ps

override_dh_auto_clean:
	-QUILT_PATCHES=debian/patches quilt push 01-config_config.diff
	[ ! -f Makefile ] || $(MAKE) clean

override_dh_clean:
	find . -name make.depend -print0 | xargs -0r $(RM)
	find . -name make.include -print0 | xargs -0r $(RM)
	find bin/ \( -name SCCS -o -name RCS -o -name CVS \) -prune \
	     -o -type f ! -name Makefile -print0 | xargs -0r $(RM)
	dh_clean

override_dh_installinit:
#Init script has BAD security Debian switches it off by default

override_dh_installchangelogs:
	dh_installchangelogs -a -k NEWS
	dh_installchangelogs -pfestival-doc -a -k NEWS

override_dh_installexamples:
	dh_installexamples -pfestival examples/* -Xexamples/text2utt -Xexamples/text2wave debian/festival.init debian/festival.scm

%:
	dh $@
