#!/usr/bin/make -f
# Sample debian/rules that uses debhelper.
# GNU copyright 1997 to 1999 by Joey Hess.

# Modified (stripped) by Kimmo Hmlinen 20 Apr 2004

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

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

IDIR1=`pwd`/debian/defoma
IDIR2=`pwd`/debian/psfontmgr
IDIR3=`pwd`/debian/defoma-doc
IDIR4=`pwd`/debian/dfontmgr

configure: configure-stamp
configure-stamp:
	dh_testdir

	touch configure-stamp

build: configure-stamp build-stamp
build-stamp:
	dh_testdir

#	$(MAKE)

# mkdir build
#	cd build && debiandoc2html -lC ../doc/developers.sgml
#	cd build && debiandoc2html -lC ../doc/defoma-script.sgml
#	cd build && debiandoc2text -lC ../doc/developers.sgml
#	cd build && debiandoc2text -lC ../doc/defoma-script.sgml

	touch build-stamp

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

	-$(MAKE) clean

	find -type f -name "*~" | xargs rm -f
	-rm -fr build

	dh_clean

install: build
	dh_testdir
	dh_testroot
	dh_clean -k
	dh_installdirs

	install -m 755 src/* $(IDIR1)/usr/bin
	install -m 644 pm/Defoma/*.pm $(IDIR1)/usr/share/perl5/Debian/Defoma
	install -m 644 man/*.1 $(IDIR1)/usr/share/man/man1
	install -m 644 man/*.3pm $(IDIR1)/usr/share/man/man3
	install -m 644 libs/* $(IDIR1)/usr/share/defoma
	chmod +x $(IDIR1)/usr/share/defoma/defoma-test.sh
	install -m 644 conf/* $(IDIR1)/etc/defoma
	install -m 644 debhelper-files/* $(IDIR1)/usr/share/debhelper/autoscripts
	install -m 644 examples/* $(IDIR1)/usr/share/doc/defoma/examples

	install -m 755 psfontmgr/src/* $(IDIR2)/usr/bin
	install -m 644 psfontmgr/libs/* $(IDIR2)/usr/share/defoma
	install -m 644 psfontmgr/man/*.1 $(IDIR2)/usr/share/man/man1
	install -m 644 debian/psfontmgr.defoma $(IDIR2)/usr/share/defoma/scripts

#	cp -r build/* $(IDIR3)/usr/share/doc/defoma-doc
	install -m 644 doc/* $(IDIR3)/usr/share/doc/defoma-doc

	install -m 644 dfontmgr/libs/* $(IDIR4)/usr/share/defoma
	install -m 644 dfontmgr/man/* $(IDIR4)/usr/share/man/man1
	install -m 644 dfontmgr/Dfontmgr/*.pm $(IDIR4)/usr/share/perl5/Debian/Dfontmgr
	install -m 644 dfontmgr/DefomaWizard/*.pm $(IDIR4)/usr/share/perl5/Debian/DefomaWizard
	install -m 755 dfontmgr/Dfontmgr/dfontmgr $(IDIR4)/usr/bin


# Build architecture-independent files here.
binary-indep: DH_OPTIONS=-i
binary-indep: build install
	dh_testdir
	dh_testroot
	dh_installdebconf	
	dh_installdocs
	dh_installexamples
	dh_installmenu
#	dh_installemacsen
#	dh_installpam
#	dh_installinit
#	dh_installcron
	dh_installman
#	dh_installinfo
#	dh_undocumented
	dh_installchangelogs 
	dh_link
	dh_compress
	dh_fixperms
#	You may want to make some executables suid here.
#	dh_suidregister
	dh_installdeb
	dh_perl
	dh_gencontrol
	dh_md5sums
	dh_builddeb

# Build architecture-dependent files here.
binary-arch: build install

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