#!/usr/bin/make -f
# Sample debian/rules that uses debhelper. 
# This file is public domain software, originally written by Joey Hess.
#
# This version is for packages that are architecture independent.

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

build: build-stamp
build-stamp:
	dh_testdir

	# Add here commands to compile the package.
	#$(MAKE)
	# Note that the configure script expects the eprints user and group to
	# exist before it is run. I couldn't figure out how to create the user
	# and group within the pbuilder chroot, so instead I've fallen back to
	# installing as user/group www-data, then fixing the user/group details
	# in the postinst script (this seems to be how other packages deal with
	# this). The SMTP server gets sorted out at the same time, using debconf
	# (assume localhost given that we depend on mail-transport-agent anyway).

	./configure --with-user=www-data --with-group=www-data \
	            --with-smtp-server=localhost

	touch build-stamp

clean:
	dh_testdir
	dh_testroot
	rm -f build-stamp

	# Add here commands to clean up after the build process.
	#-$(MAKE) clean
	#-$(MAKE) distclean
	-rm config.log
	-rm config.status
	-rm install.pl

	dh_clean

install: build
	dh_testdir
	dh_testroot
	dh_clean -k
	dh_installdirs

	# Add here commands to install the package into debian/<packagename>.
	#$(MAKE) prefix=`pwd`/debian/`dh_listpackages`/usr install
	# Call install script with a path argument to override the default
	# installation prefix.
	./install.pl $(CURDIR)/debian/`dh_listpackages`/opt/eprints3

# Build architecture-independent files here.
binary-indep: build install
	dh_testdir
	dh_testroot
	dh_installchangelogs
	dh_installdocs
#	dh_installexamples
#	dh_installmenu
#	dh_installdebconf
#	dh_installlogrotate
#	dh_installemacsen
#	dh_installcatalogs
#	dh_installpam
#	dh_installmime
	dh_installinit --name=epindexer
	dh_installcron
#	dh_installinfo
#	dh_undocumented
	dh_installman
	dh_link
	dh_compress
	dh_fixperms
#	dh_perl
#	dh_python
	dh_installdeb
	dh_gencontrol
	dh_md5sums
	dh_builddeb

# Build architecture-dependent files here.
binary-arch: build install
# We have nothing to do by default.

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