#!/usr/bin/make -f
# Made with the aid of dh_make, by Craig Small
# Sample debian/rules that uses debhelper. GNU copyright 1997 by Joey Hess.
# Some lines taken from debmake, by Cristoph Lameter.

build: 
	#***Here we go****

clean:
	dh_testdir
	-rm -f install-stamp
	-rm -f debian/files
	-rm -f debian/substvars
	dh_clean

install: install-stamp
install-stamp: 
	dh_testdir
	dh_testroot
	dh_clean -k
	dh_installdirs
	#### Move all the stuff over to the debian dir ###
	cp -R * debian/tmp/usr/share/horde 
	#### Get rid of the debian sub dir ####
	rm -rf debian/tmp/usr/share/horde/debian
	rm -rf debian/tmp/usr/share/horde/packaging
	#### Get rid of the documentation (it get's put back later) ###
	cd debian/tmp/usr/share/horde && rm -f COPYING README
	#### Remove all the CVS files and dirs ####
	-rm -rf `find debian/tmp -print | grep CVS`
	### Move stuff around so it plays nicely on Debian ####
	#cp debian/HordeLibVersion.def debian/tmp/usr/share/horde/lib/src/defines
	mv debian/tmp/usr/share/horde/config/scripts debian/tmp/usr/share/doc/horde/examples
	mv debian/tmp/usr/share/horde/config/* debian/tmp/etc/horde/
	cp debian/horde.options debian/tmp/etc/horde/
	mv debian/tmp/usr/share/horde/phplib/* debian/tmp/etc/horde/
	cp debian/tmp/etc/horde/html.php3.dist debian/tmp/etc/horde/html.php3
	mv debian/tmp/etc/horde/*.dist debian/tmp/usr/share/doc/horde/examples
	-rm -f debian/tmp/etc/horde/horde_phplib.inc
	-rm -rf debian/tmp/usr/share/horde/phplib 
	-rm -rf debian/tmp/usr/share/horde/config
	mv debian/tmp/usr/share/horde/docs/* debian/tmp/usr/share/doc/horde/
	mv debian/tmp/usr/share/horde/scripts/* debian/tmp/usr/share/doc/horde/examples/
	cp debian/*.sql debian/tmp/usr/share/doc/horde/examples
	cp debian/pgsql_cuser.sh debian/tmp/usr/share/doc/horde/examples
	cp debian/prepend.php3 debian/tmp/etc/horde
	cp debian/horde_phplib.in debian/tmp/etc/horde
	-rm -rf debian/tmp/usr/share/horde/scripts \
	debian/tmp/usr/share/horde/docs
	chmod 644 `find debian/tmp -type f -print`
	chmod 755 debian/tmp/usr/share/doc/horde/examples/*.sh \
	debian/tmp/usr/share/horde/*.sh debian/tmp/usr/share/horde/lib/src/*.pl \
	debian/tmp/usr/share/horde/locale/buildLang.sh \
	debian/tmp/etc/horde/modules/create_config.pl

	### Done ###

	touch install-stamp

binary-indep: build install
	dh_testdir
	dh_testroot
	dh_installdebconf
	dh_installdocs 
	dh_installexamples
	dh_undocumented 
	dh_installchangelogs docs/CHANGES
	dh_link
	dh_strip
	dh_compress
	dh_fixperms
	chmod 755 debian/tmp/usr/share/doc/horde/examples/*.sh \
		debian/tmp/usr/share/doc/horde/examples/*.pl \
		debian/tmp/usr/share/horde/*.sh \
		debian/tmp/usr/share/horde/lib/src/*.pl 
	-rm -f install debian/tmp/usr/share/horde/install
	chown -R www-data.root debian/tmp/usr/share/horde debian/tmp/etc/horde
	dh_suidregister
	dh_installdeb
	dh_perl
	dh_shlibdeps
	dh_gencontrol
	cd debian/tmp && find ./etc/horde -type f -print | sed -e 's#^./#/#' > DEBIAN/conffiles
	dh_md5sums
	dh_builddeb

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

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