#!/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.

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

build: build-stamp
build-stamp:

	#***Here we go****
	touch build-stamp

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

install: install-stamp
install-stamp: build-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
	#### Get rid of the documentation (it get's put back later) ###
	cd debian/tmp/usr/share/horde && rm -f COPYING CHANGES CREDITS \
	HELP INSTALL README TODO
	#### 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
	touch debian/tmp/etc/horde/build.opts
	cp debian/defaults.php3 debian/tmp/etc/horde 
	cp debian/menu.txt debian/tmp/etc/horde
	cp debian/horde.php3 debian/tmp/etc/horde
	mv debian/tmp/usr/share/horde/config/examples debian/tmp/usr/doc/horde-core/ 
	mv debian/tmp/usr/share/horde/config/scripts debian/tmp/usr/doc/horde-core
	mv debian/tmp/usr/share/horde/config/* debian/tmp/etc/horde/
	rm -rf debian/tmp/usr/share/horde/config
	mv debian/tmp/usr/share/horde/docs/* debian/tmp/usr/doc/horde-core/
	mv debian/tmp/usr/share/horde/scripts/* debian/tmp/usr/doc/horde-core/scripts/
	-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/doc/horde-core/scripts/*.sh \
	debian/tmp/usr/share/horde/*.sh debian/tmp/usr/share/horde/lib/src/*.pl
	### Done ###

	touch install-stamp

binary-indep: build install
	dh_testdir
	dh_testroot
	dh_installdocs 
	dh_installexamples
	dh_undocumented 
	dh_installchangelogs CHANGES
	dh_link
	dh_strip
	dh_compress
	dh_fixperms
	chmod 755 debian/tmp/usr/doc/horde-core/scripts/*.sh \
		debian/tmp/usr/doc/horde-core/scripts/*.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_shlibdeps
	dh_gencontrol
	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
