#!/usr/bin/make -f
# -*- makefile -*-
# Sample debian/rules that uses debhelper.
# This file was originally written by Joey Hess and Craig Small.
# As a special exception, when this file is copied by dh-make into a
# dh-make output file, you may use that output file without restriction.
# This special exception was added by Craig Small in version 0.37 of dh-make.

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

# include /usr/share/dpatch/dpatch.make

OOOTMP = ooo-tmp

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

configure: configure-stamp
configure-stamp:
	dh_testdir
	# Add here commands to configure the package.

	touch configure-stamp


build: build-arch build-indep
build-arch: build-stamp
build-indep: build-stamp
build-stamp: configure-stamp  #patch-stamp
	dh_testdir
        # -- aspell
	sed -e '1d' -e '/[\. ]/d' pt_PT.dic | prezip -s -c | gzip -9n -c > debian/aspell-files/pt_PT.cwl.gz
	install -m 0644 pt_PT.aff debian/aspell-files/pt_PT_affix.dat
        # -- myspell
	mkdir -p $(OOOTMP)
	install -m 0644 pt_PT.aff $(OOOTMP)/pt.aff
	install -m 0644 pt_PT.dic $(OOOTMP)/pt.dic

	touch $@

clean: #unpatch
	dh_testdir
	dh_testroot
	rm -f build-stamp configure-stamp

	# Add here commands to clean up after the build process.
	#$(MAKE) clean
	rm -f debian/aspell-files/pt_PT_affix.dat debian/aspell-files/pt_PT.cwl.gz
	rm -f debian/aspell-files/pt_PT.compat debian/aspell-files/pt_PT.rws
	rm -rf $(OOOTMP)

	dh_clean

install: build
	dh_testdir
	dh_testroot
	dh_prep
	dh_installdirs

        # -- aspell-pt-pt
	dh_install -paspell-pt-pt
	installdeb-aspell -paspell-pt-pt
        # Add here commands to install the package into debian/myspell-pt-pt
	installdeb-myspell --srcdir=$(OOOTMP) -pmyspell-pt-pt
	installdeb-hunspell -pmyspell-pt-pt

# Build architecture-independent files here.
binary-indep: install
	dh_testdir
	dh_testroot
	dh_installchangelogs
	dh_installdocs
	dh_link
	dh_compress
	dh_fixperms
	dh_installdeb
	dh_gencontrol
	dh_md5sums
	dh_builddeb

# Build architecture-dependent files here.
binary-arch: install
# We have nothing to do by default.

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