#!/usr/bin/make -f

FT := $(shell pwd)/debian/festival
FDT := $(shell pwd)/debian/festival-dev

DPKG_EXPORT_BUILDFLAGS = 1
-include /usr/share/dpkg/buildflags.mk

DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
export DEB_HOST_MULTIARCH

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:
ifneq "$(wildcard /usr/share/misc/config.sub)" ""
	cp -f /usr/share/misc/config.sub config.sub
endif
ifneq "$(wildcard /usr/share/misc/config.guess)" ""
	cp -f /usr/share/misc/config.guess config.guess
endif
	$(MAKE)
	cd doc && $(MAKE) festival.info

override_dh_auto_clean:
	-QUILT_PATCHES=debian/patches quilt push 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)
	rm -rf doc/*.1 doc/festfeat.texi doc/festvars.texi doc/festfunc.texi \
	       doc/info src/modules/hts21_engine/*.o \
	       src/modules/hts21_engine/.buildlib_Festival
	rm -f config/modincludes.inc config/system.mak
	rm -f bin/festival*
	rm -f config.sub config.guess config.log config.status config.cache
	-rmdir src/modules/hts21_engine
	dh_clean

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

override_dh_installchangelogs:
	dh_installchangelogs -a -k NEWS

override_dh_installdocs:
	dh_installdocs -a README ACKNOWLEDGMENTS

override_dh_installman:
	dh_installman -pfestival doc/festival.1 doc/festival_client.1 doc/text2wave.1

override_dh_installinfo:
	dh_installinfo -pfestival doc/info/festival.info*

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

%:
	dh $@
#
