#!/usr/bin/make -f

export DEB_BUILD_MAINT_OPTIONS = hardening=+all

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

export DEB_CXXFLAGS_MAINT_APPEND = -D__DEBIAN__ -O2 -g -Wno-write-strings -DUSE_EXTERNAL_CLUSTALW -DHOMEDIR=\"/usr/share/gentle\"
include /usr/share/dpkg/default.mk

%:
	dh $@

execute_before_dh_auto_build:
	mv tips_de.txt tips_de.iso8859
	iconv -f ISO-8859-15 -t UTF-8 < tips_de.iso8859 > tips_de.txt

execute_after_dh_auto_build:
	mv  tips_de.iso8859 tips_de.txt

override_dh_install:
	dh_install
	cd debian/$(DEB_SOURCE)/usr/share/$(DEB_SOURCE); for i in help/*.html help/*.css *.db help/*.htm */*.png */*.x[bp]m */*.bmp *.txt */*.txt *.csv; do chmod -x "$$i"; done
	find debian -name "license.txt" | xargs -r rm

docs/manual.pdf: docs/manual.adoc
	asciidoctor-pdf docs/manual.adoc

override_dh_installdocs:
	dh_installdocs
#	cp -a docs/manual.pdf    debian/$(DEB_SOURCE)/usr/share/doc/$(DEB_SOURCE)/GENtle_manual.pdf
	find debian -name todo.txt -delete

override_dh_auto_clean:
	dh_auto_clean
	find src/ -name "*.o"  | xargs -r rm
	if [ -e tips_de.iso8859 ]; then mv tips_de.iso8859 tips_de.txt; fi
	rm -f src/GENtle
	rm -f docs/manual.html docs/manual.pdf
	rm -f config.cache config.guess config.sub gconfig.log

override_dh_compress:
	dh_compress --exclude=.pdf