#!/usr/bin/make -f
# Sample debian/rules that uses debhelper.
# GNU copyright 1997 by Joey Hess.
#
# This version is for a hypothetical package that builds an
# architecture-dependant package, as well as an architecture-independent
# package.

# Modified for the Debian GNU/Linux system packages 'ibrazilian' and
# 'brazilian-conjugate' by Carlos Laviola, with aid of rules file
# made by the previous maintainer, Rafael Laboissiere.

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

# This is the debhelper compatability version to use.
export DH_COMPAT=3

debdir := $(CURDIR)/debian
tmpdir := $(debdir)/tmp
usrdir := $(tmpdir)/usr
libdir := $(usrdir)/lib

configure: configure-stamp
configure-stamp:
	dh_testdir

	touch configure_stamp

build: build-stamp
build-stamp:
	dh_testdir

	# Add here commands to compile the package.
	cp conjugue conjugue-orig
	cp conjugue.1 conjugue.1-orig
	$(MAKE) AWK=/usr/bin/awk

	touch build-stamp

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

	# Add here commands to clean up after the build process.
	-$(MAKE) clean
	if [ -f conjugue-orig ] ; then mv conjugue-orig conjugue ; fi
	if [ -f conjugue.1-orig ] ; then mv conjugue.1-orig conjugue.1 ; fi
	rm -f pt_BR-only.rws

	dh_clean

install: DH_OPTIONS=
install: build
	dh_testdir
	dh_testroot

	# Add here commands to install the package into debian/ibrazilian.
	$(MAKE) install prefix=$(usrdir) DESTDIR=$(tmpdir) \
          MANDIR=$(usrdir)/share/man HASHDIR=$(usrdir)/lib/ispell \
	  VDIR=/usr/lib/brazilian-conjugate AWK=/usr/bin/awk
	( cd $(libdir)/ispell ; \
          mv br.hash brasileiro.hash ; mv br.aff brasileiro.aff )
	dh_install --no-package=aspell-pt-br --no-package=myspell-pt-br --sourcedir=$(tmpdir)
	cp pt_BR pt_BR-only.rws
	dh_install --package=aspell-pt-br
	dh_install --package=myspell-pt-br


# Build architecture-independent files here.
# Pass -i to all debhelper commands in this target to reduce clutter.
binary-indep: build install
	dh_testdir -i
	dh_testroot -i
	dh_installdocs -i README ANUNCIO FAQ.i
	dh_installchangelogs -i CHANGELOG
	dh_compress -i
	dh_fixperms -i
	dh_installman -i
	installdeb-myspell --package=myspell-pt-br --srcdir=.
	dh_installdeb -i
	dh_link -i
	dh_gencontrol -i
	dh_md5sums -i
	dh_builddeb -i

# Build architecture-dependent files here.
binary-arch: build install
	dh_testdir -a
	dh_testroot -a
	dh_installdocs -a README ANUNCIO FAQ.i
	dh_installemacsen -a
	dh_installchangelogs -a CHANGELOG
	dh_compress -a
	dh_fixperms -a
	installdeb-ispell --package=ibrazilian
	dh_installdeb -a
	dh_shlibdeps -a
	dh_gencontrol -a
	dh_md5sums -a
	dh_builddeb -a

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