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

export DH_VERBOSE=1

# Set temporary HOME for lazarus primary config directory
export HOME = $(CURDIR)/tmphome

%:
	dh $@

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

override_dh_auto_build-arch:
	lazbuild --widgetset=qt5 -B winff/winff.lpr
	mv winff/winff winff/winff-qt

override_dh_auto_build-indep:
# bug 768733: if $HOME does not exist, soffice fails to build pdf's
	mkdir -p $(CURDIR)/tmpoffice
	HOME=$(CURDIR)/tmpoffice soffice --headless --convert-to pdf --outdir winff/docs winff/docs/WinFF.*.od?

# The pdf files are searched only for the first two characters of the
# language code, and we don't have a european Spanish or Portuguese translation yet.
	if [ ! -f winff/docs/WinFF.es.pdf ] ; then \
		mv winff/docs/WinFF.es_AR.pdf winff/docs/WinFF.es.pdf ; \
	fi ; true

	if [ ! -f winff/docs/WinFF.pt.pdf ] ; then \
		mv winff/docs/WinFF.pt_BR.pdf winff/docs/WinFF.pt.pdf ; \
	fi ; true

override_dh_compress:
	dh_compress -X.pdf

execute_before_dh_clean:
	if [ -f winff/presets-orig.xml ] ; then mv winff/presets-orig.xml winff/presets.xml; fi
