#!/usr/bin/make -f
# -*- makefile -*-
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

# Make sure build is always done in a reproducible and working
# language environment
LC_ALL = C
export LC_ALL

TMP_BUILD    = debian/tmp-build

%:
	dh $@

override_dh_auto_build:
	mkdir -p $(TMP_BUILD)

	# iportuguese
	$(MAKE) portugues.hash
	gzip -nc --best portugues.dic > $(TMP_BUILD)/portugues.mwl.gz

	# wportuguese
	ispell -e -d ./portugues.hash < portugues.dic \
		| perl -pe 's/ +/\n/g' | \
		iconv -f ISO-8859-1 -t UTF-8 > $(TMP_BUILD)/portuguese

	# aspell-pt-pt
	cat portugues.dic | prezip -s -c | \
		gzip -9n -c > $(TMP_BUILD)/pt_PT.cwl.gz
	ispellaff2myspell --charset=latin1 \
                --myheader=debian/aspell-files/pt_PT.header portugues.aff \
		> $(TMP_BUILD)/pt_PT_affix.dat

override_dh_auto_install:
	installdeb-ispell   -piportuguese
	installdeb-aspell   -paspell-pt-pt
	installdeb-wordlist -pwportuguese

override_dh_auto_clean:
        # Do not call missing upstream clean target.
	rm -rf $(TMP_BUILD)
	rm -f core *.hash *.stat *.cnt
