#!/usr/bin/make -f
# -*- makefile -*-

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

%:
	dh ${@} --ddeb-migration='winff-dbg (<< 1.5.3-7~)'

override_dh_auto_configure:
	if [ -f presets.xml ] ; then mv presets.xml presets-orig.xml; fi 

override_dh_auto_build-arch:
# bug 713492: if primary-config-path is not set, lazarus is using $HOME
# $HOME is not garanteed to be useful so prevent writing setting it
	lazbuild --widgetset=gtk2 -B --pcp=/etc/lazarus winff.lpr
	mv winff winff-gtk2
	lazbuild --widgetset=qt5 -B --pcp=/etc/lazarus winff.lpr
	mv winff winff-qt

override_dh_auto_build-indep:
# bug 768733: if $HOME does not exist, soffice fails to build pdf's
	mkdir -p $(CURDIR)/tmp-home
	HOME=$(CURDIR)/tmp-home soffice --headless --convert-to pdf --outdir docs docs/WinFF.*.od?
	rm -r $(CURDIR)/tmp-home
# The language files are searched only for the first two characters of the
# language code, and we don't have a proper Spanish translation yet.
	if [ ! -f docs/WinFF.es.pdf ] ; then \
		mv docs/WinFF.es_AR.pdf docs/WinFF.es.pdf ;\
	fi

override_dh_clean:
	if [ -f presets-orig.xml ] ; then mv presets-orig.xml presets.xml; fi 
	dh_clean

override_dh_fixperms-indep:
	dh_fixperms
# Release 1.5.3 was improperly build and all files were set executable
	find debian/winff-data -type f -exec chmod a-x {} \;
