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

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

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

build: build-stamp
build-stamp:
	dh_testdir

	if test "$$ZORP_DEBUG" = ""; then \
		./configure --enable-debug \
			--prefix=/usr \
			--mandir=\$${prefix}/share/man \
			--infodir=\$${prefix}/share/info \
			--sysconfdir=/etc \
			--disable-dmalloc \
			--with-python-headers=/usr/include/python1.5 \
			--with-python-libs=/usr/lib; \
        else \
		./configure --enable-debug \
			--prefix=/usr \
			--mandir=\$${prefix}/share/man \
			--infodir=\$${prefix}/share/info \
			--sysconfdir=/etc \
			--disable-dmalloc \
			--with-python-headers=/usr/include/python1.5 \
			--with-python-libs=/usr/lib \
			--enable-debug --enable-trace; \
	fi
	#for i in modules/zorp-module*; do ( cd $$i; ./configure --with-zorp=`pwd`/../..); done
	cd modules; make config-stamp
	# Add here commands to compile the package.
	$(MAKE)

	touch build-stamp

clean:
	dh_testdir
	dh_testroot
	rm -f build-stamp
	rm -f modules/config-stamp

	# Add here commands to clean up after the build process.
	-$(MAKE) distclean

	dh_clean

install: build
	dh_testdir
	dh_testroot
	dh_clean -k
	dh_installdirs

	# Add here commands to install the package into debian/tmp.
	$(MAKE) install DESTDIR=`pwd`/debian/tmp/
	chmod 700 `pwd`/debian/tmp/etc/zorp
	
	dh_movefiles
	if [ x`find `pwd`/debian/tmp -type f` != x ]; then (echo "Maradt file a tmp-ben!"; exit 1); fi
	

# Build architecture-independent files here.
binary-indep: build install
# We have nothing to do by default.
#	dh_testversion -i
	dh_testdir -i
	dh_testroot -i
#	dh_installdebconf -i
	dh_installdocs -i
#	dh_installexamples -i
#	dh_installmenu -i
#	dh_installemacsen -i
#	dh_installpam -i
#	dh_installinit -i --package=zorp
#	dh_installcron -i
#	dh_installmanpages
#	dh_installinfo -i
	dh_installchangelogs -i ChangeLog ChangeLog.0
	dh_link -i
	dh_strip -i
	dh_compress -i
	dh_fixperms -i
	# You may want to make some executables suid here.
	dh_suidregister -i
#	dh_makeshlibs -i
	dh_installdeb -i
#	dh_perl -i
	dh_shlibdeps -i
	dh_gencontrol -i
	dh_md5sums -i
	dh_builddeb -i

# Build architecture-dependent files here.
binary-arch: build install
#	dh_testversion -a
	dh_testdir -a
	dh_testroot -a
#	dh_installdebconf -a
	dh_installdocs --package=zorp-doc
#	dh_installexamples -a
#	dh_installmenu -a
#	dh_installemacsen -a
#	dh_installpam -a
	dh_installinit --package=zorp
#	dh_installcron -a
	dh_installmanpages --package=zorp zorp.8 zorpctl.8 instances.conf.5
#	dh_installinfo -a
	dh_undocumented -a --package=zorp-dev zorp-config.1 
	dh_installchangelogs -a ChangeLog
	dh_link -a

	if test "$$ZORP_DEBUG" = ""; then \
		dh_strip -a; \
	fi

	dh_compress -a
	dh_fixperms -a
	# You may want to make some executables suid here.
	dh_suidregister -a
#	dh_makeshlibs -a
	dh_installdeb -a
#	dh_perl -a
	dh_shlibdeps -a -l`pwd`/debian/zorp-lib/usr/lib:`pwd`/debian/zorp/usr/lib
	dh_gencontrol -a
	dh_md5sums -a
	dh_builddeb -a

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