#!/usr/bin/make -f
# -*- makefile -*-
# 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

package=axyl
dt=debian/$(package)
instroot=usr/share/$(package)
dataroot=var/lib/$(package)

package-doc=axyl-doc
dt-doc=debian/$(package-doc)
instroot-doc=usr/share/$(package-doc)

clean:
	dh_testdir
	dh_testroot
	debconf-updatepo
	dh_clean 

configure-stamp:
	dh_testdir
	# Add here commands to configure the package.
	touch configure-stamp

configure: configure-stamp

build-stamp: configure
	dh_testdir
	# Add here commands to compile the package.
	touch build-stamp

build: build-stamp
	dh_testdir
	dh_clean -k
	dh_installdirs

install-axyl: build
	# INSTALL axyl
	install -d $(dt)/DEBIAN \
		$(dt)/$(instroot)
	cp README $(dt)/$(instroot)
	cp -a etc $(dt)
	cp -a etc $(dt)/$(instroot)
	cp -a compat $(dt)/$(instroot)
	cp -a db $(dt)/$(instroot)
	cp -a install $(dt)/$(instroot)
	cp -a lib $(dt)/$(instroot)
	# Remove any ./lucene symlink..
	rm -f $(dt)/$(instroot)/lucene
	# Remove axyl-doc content..
	rm -f $(dt)/$(instroot)/db/postgres/axyl_demo.db
	# Xmenu license is included in the 'copyright' file
	# and INSTALL is not required here either..
	rm -f $(dt)/$(instroot)/lib/js/xmenu/COPYING
	rm -f $(dt)/$(instroot)/lib/js/xmenu/INSTALL
	# HTMLArea license is included in the 'copyright' file
	rm -f $(dt)/$(instroot)/lib/js/htmlarea/license.txt
	cp -a scripts $(dt)/$(instroot)
	cp -a www $(dt)/$(instroot)
	find $(dt) -depth -type d -name "CVS" -exec rm -rf {} \;
	find $(dt) -name ".cvsignore" -exec rm -f {} \;
	find $(dt) -name ".#*" -exec rm -f {} \;
	find $(dt) -name "diffs.sql" -exec rm -f {} \;
	find $(dt) -iname "*.log" -exec rm -f {} \;
	find $(dt) -iname "*.bak" -exec rm -f {} \;
	find $(dt) -iname "*.pdb" -exec rm -f {} \;

install-axyl-doc: build
	# INSTALL axyl-doc
	install -d $(dt-doc)/DEBIAN \
		$(dt-doc)/$(instroot-doc) \
		$(dt-doc)/$(instroot-doc)/db \
		$(dt-doc)/$(instroot-doc)/db/postgres
	cp -a db/postgres/axyl_demo.db $(dt-doc)/$(instroot-doc)/db/postgres
	cp -a demo $(dt-doc)/$(instroot-doc)
	find $(dt-doc) -depth -type d -name "CVS" -exec rm -rf {} \;
	find $(dt-doc) -name ".cvsignore" -exec rm -f {} \;
	find $(dt-doc) -name ".#*" -exec rm -f {} \;
	find $(dt-doc) -name "diffs.sql" -exec rm -f {} \;
	find $(dt-doc) -iname "*.log" -exec rm -f {} \;
	find $(dt-doc) -iname "*.bak" -exec rm -f {} \;
	find $(dt-doc) -iname "*.pdb" -exec rm -f {} \;

# Build architecture-independent files here.
binary-indep: build install-axyl install-axyl-doc
	dh_testdir
	dh_testroot
	dh_installchangelogs ChangeLog
	dh_installdocs
	dh_installexamples
	find $(dt) -depth -type d -name "CVS" -exec rm -rf {} \;
	find $(dt) -name ".cvsignore" -exec rm -f {} \;
#	dh_install
#	dh_installmenu
	dh_installdebconf	
#	dh_installlogrotate
#	dh_installemacsen
#	dh_installpam
#	dh_installmime
#	dh_installinit
	dh_installcron
#	dh_installinfo
	dh_installman debian/axyl.7
	dh_link
#	dh_strip
	dh_compress
	dh_fixperms
#	dh_perl
#	dh_python
#	dh_makeshlibs
	dh_installdeb
#	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb

# Build architecture-dependent files here.
binary-arch:
# Nothing to do here.

binary: binary-indep binary-arch
.PHONY: build install-axyl install-axyl-doc clean binary-indep binary-arch binary configure
