#!/usr/bin/make -f

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

# This has to be exported to make some magic below work.
export DH_OPTIONS

build: build-stamp
build-stamp:
	dh_testdir

	mkdir -p debian/tmpdir/usr/lib/locale
	localedef -i "lt_LT" -f "ISO-8859-13" "debian/tmpdir/usr/lib/locale/lt_LT.ISO-8859-13"
	# Using the locale
	(export LOCPATH=debian/tmpdir/usr/lib/locale; export LC_ALL=lt_LT.ISO-8859-13; $(MAKE) myspell)

	gzip -cn lietuviu.dict > lietuviu.mwl.gz

	cp lietuviu.dict lt.wl
	prezip lt.wl
	gzip -n lt.cwl

	$(MAKE) aspell

	touch build-stamp

clean:
	dh_testdir
	dh_testroot
	rm -f build-stamp
	$(MAKE) clean

	-rm lietuviu.mwl.gz
	rm -rf debian/tmpdir
	rm -f lt.cwl.gz

	dh_clean

install: build
	dh_testdir
	dh_testroot
	dh_prep
	dh_installdirs
	dh_install

	install -m 644 lietuviu.mwl.gz $(CURDIR)/debian/ilithuanian/usr/share/ispell

	install -m 644 lt_LT.aff $(CURDIR)/debian/aspell-lt/usr/lib/aspell/lt_affix.dat

	installdeb-ispell -pilithuanian

#	installdeb-myspell --srcdir=$(CURDIR) -pmyspell-lt
	cp debian/myspell-lt.info-myspell $(CURDIR)/debian/myspell-lt/usr/share/myspell/infos/ooo/myspell-lt

#	installdeb-myspell -popenoffice.org-hyphenation-lt
	mkdir -p $(CURDIR)/debian/openoffice.org-hyphenation-lt/usr/share/myspell/infos/ooo
	install -m644 debian/openoffice.org-hyphenation-lt.dictlistinfo \
		$(CURDIR)/debian/openoffice.org-hyphenation-lt/usr/share/myspell/infos/ooo/openoffice.org-hyphenation-lt

	installdeb-aspell   -paspell-lt
	dh_installdebconf -paspell-lt

binary-arch:

# Build architecture-independent files here.
binary-indep: build install
	dh_testdir
	dh_testroot
	dh_installchangelogs -i ChangeLog
	dh_installdocs

	dh_link
	dh_compress
	dh_fixperms
	dh_installdeb
	dh_gencontrol
	dh_md5sums
	dh_builddeb

binary:	binary-indep
.PHONY: build clean binary binary-indep binary-arch install
