#!/usr/bin/make -f
# based on the sample debian/rules file for debhelper by Joey Hess.

#export DH_VERBOSE=1

build: build-stamp
build-stamp:
	dh_testdir
	./configure --with-serverbindir=/usr/sbin --with-serverlibdir=/etc/afbackup --with-servervardir=/var/lib/afbackup --with-serverlogdir=/var/log/afbackup --with-clientbindir=/usr/sbin --with-clientlibdir=/etc/afbackup --with-clientvardir=/var/lib/afbackup --with-clientlogdir=/var/log/afbackup --with-rexecdir=/usr/lib/afbackup/rexec --with-clientconf=client.conf --with-serverconf=server.conf 
	make all DEBUG='-Wall -g' < debian/cryptkey
	touch build-stamp

clean:
	dh_testdir
	dh_testroot
	rm -f build-stamp
	-make distclean
	dh_clean

binary-indep: build
# There are no architecture-independent files to be uploaded
# generated by this package.  If there were any they would be
# made here.

binary-arch: build
	dh_testdir
	dh_testroot
	dh_clean
	dh_installdirs
	make install.rclient SERVERBINDIR=`pwd`/debian/tmp/usr/sbin SERVERLIBDIR=`pwd`/debian/tmp/etc/afbackup SERVERVARDIR=`pwd`/debian/tmp/var/lib/afbackup CLIENTBINDIR=`pwd`/debian/afbackup-client/usr/sbin CLIENTLIBDIR=`pwd`/debian/afbackup-client/etc/afbackup CLIENTVARDIR=`pwd`debian/afbackup-client/var/lib/afbackup SERVERREXECDIR=`pwd`/debian/afbackup-client/usr/lib/afbackup/rexec
	dh_installdocs CONFIG HOWTO.FAQ.DO-DONT INTRO README debian/README.server.Debian
	dh_installdocs -pafbackup-client -Pdebian/afbackup-client CONFIG HOWTO.FAQ.DO-DONT debian/README.client.Debian
	dh_installcron
	cp afclient.8 debian/afbackup-client/usr/man/man8
	cp afrestore.8 debian/afbackup-client/usr/man/man8
	cp afserver.8 debian/tmp/usr/man/man8
	cp afverify.8 debian/afbackup-client/usr/man/man8
	cp cartis.8 debian/tmp/usr/man/man8
	cp cartready.8 debian/tmp/usr/man/man8
	cp full_backup.8 debian/afbackup-client/usr/man/man8
	cp incr_backup.8 debian/afbackup-client/usr/man/man8
	cp label_tape.8 debian/tmp/usr/man/man8
	cp print_errors.8 debian/afbackup-client/usr/man/man8
	(cd debian/afbackup-client/usr/man/man8; ln -s afclient.8 afbackup.8)
	(cd debian/afbackup-client/usr/man/man8; ln -s afclient.8 backout.8)
	dh_undocumented
	dh_installchangelogs Changes
	dh_strip
	dh_compress
	dh_fixperms
	dh_suidregister
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
#	dh_du
	dh_md5sums
	dh_builddeb

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