#!/usr/bin/make -f
#
# (C) 1999-2015 Roland Rosenfeld <roland@debian.org>, based on
#
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
#export DH_OPTIONS=-v

# some of the SED scripts require uni-byte characters:
export LC_ALL=C

DROOT=`pwd`/debian
ADIR=$(DROOT)/aspell-de-alt

%:
	dh $@

override_dh_auto_build:
	$(MAKE) all.words
	$(MAKE) isowordlist
	$(MAKE) myspelldic
	$(MAKE) aspell

override_dh_clean:
	dh_clean
	[ ! -f Makefile ] || $(MAKE) clean
	rm -f debian/iogerman.config debian/iogerman.templates
	rm -f debian/wogerman.config debian/wogerman.templates

override_dh_install-indep:
	dh_install
#	iogerman (binary-indep):
	install -o root -g root -m644 deutsch.aff \
		$(DROOT)/iogerman/usr/lib/ispell/ogerman.aff
	gzip -9n < all.words > $(DROOT)/iogerman/usr/share/ispell/ogerman.mwl.gz
	(cd $(DROOT)/iogerman/usr/lib/ispell; \
		ln -s ogerman.aff odeutsch.aff; \
		ln -s ogerman.hash odeutsch.hash;)

#	wogerman (binary-indep):
	iconv -f iso-8859-1 -t utf-8 < isowordlist \
		> $(DROOT)/wogerman/usr/share/dict/ogerman

#	myspell-de-de-oldspell (binary-indep):
	install -o root -g root -m644 myspell.dic \
	  $(DROOT)/myspell-de-de-oldspell/usr/share/hunspell/de_DE.dic
	install -o root -g root -m644 myspell.aff \
	  $(DROOT)/myspell-de-de-oldspell/usr/share/hunspell/de_DE.aff

#	aspell (binary-indep):
	$(MAKE) DESTDIR=$(ADIR) aspell-install
	gzip -9n < de-alt-common.cwl \
		> $(ADIR)/usr/share/aspell/de-alt-common.cwl.gz
	gzip -9n < de-alt-CH.cwl > $(ADIR)/usr/share/aspell/de-alt-CH.cwl.gz
	gzip -9n < de-alt-DE.cwl > $(ADIR)/usr/share/aspell/de-alt-DE.cwl.gz

	installdeb-wordlist -pwogerman # Internally calls dh_installdebconf
	installdeb-myspell -pmyspell-de-de-oldspell
	installdeb-aspell -paspell-de-alt
	installdeb-ispell -piogerman  # Internally calls dh_installdebconf

override_dh_installchangelogs:
	dh_installchangelogs Changes
