#!/usr/bin/make -f
# Sample debian/rules that uses debhelper. GNU copyright 1997 by Joey Hess.
# Adapted for gnucash by Dirk Eddelbuettel. March 1999. GPL'ed

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

package=gnucash

id= $(shell pwd)/debian/tmp

#perlpriv =  $(id)$(shell perl -V:installprivlib | perl -pe 's/.*\'(.*)\'.*/\1/;')
#perlarch = $(id)$(shell perl -V:installarchlib | perl -pe 's/.*\'(.*)\'.*/\1/;')

configure: configure.in
	automake
	autoconf

Makefile: Makefile.in configure
	dh_testdir
	$(checkdir)
	./autogen.sh --prefix=/usr \
		--sysconfdir=/etc \
		--infodir=/usr/share/info \
		--mandir=/usr/share/man \
		--enable-error-on-warnings

# --enable-efence \
# --enable-profile \

build: build-stamp
build-stamp: Makefile 
	dh_testdir
	$(checkdir)
	make 
#	touch build-stamp

clean:
	dh_testdir
	dh_testroot
	rm -f build-stamp install-stamp
	-$(MAKE) distclean
	-rm `find . -name "*.cache"`
	-rm `find . -name "*.log"`
	dh_clean

install: install-stamp
install-stamp: build-stamp
	dh_testdir
	dh_testroot
	dh_clean -k
	dh_installdirs
	make install prefix=$(id)/usr sysconfdir=$(id)/etc GNC_DOC_INSTALL_DIR=$(id)/usr/share/doc/gnucash infodir=$(id)/usr/share/info mandir=$(id)/usr/share/man
	rm -f $(id)/usr/share/doc/gnucash/COPYING.gz

	# no perl anymore
	#mkdir -p $(perlpriv)
	#mv $(id)/usr/share/gnucash/perl/gnucash.pm $(perlpriv)
	#mkdir -p $(perlarch)
	#mv $(id)/usr/share/gnucash/perl/* $(perlarch)
	#-rmdir -p $(id)/usr/share/gnucash/perl

	touch install-stamp

binary-indep: build install

binary-arch: build install
#	dh_testversion
	dh_testdir
	dh_testroot
	dh_installdocs
	dh_installexamples	doc/examples/*.xac
	dh_installmenu
#	dh_installemacsen
#	dh_installinit
	dh_installcron
	dh_installmanpages
#	dh_undocumented		gnc-prices.1 gnucash.1x gnucash.motif.1x
	dh_installchangelogs	ChangeLog
#	dh_strip
#	cp src/.libs/gnucash $(id)/usr/bin/gnucash.debug
	dh_compress
	dh_fixperms
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
#	dh_makeshlibs
	dh_md5sums
	dh_builddeb

source diff:                                                                  
	@echo >&2 'source and diff are obsolete - use dpkg-source -b'; false

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

 
