#!/usr/bin/make -f
# Sample debian/rules that uses debhelper. 
# GNU copyright 1997 by Joey Hess.
#
# This version is for a hypothetical package that builds an
# architecture-dependant package, as well as an architecture-independent
# package.

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

# This has to be exported to make some magic below work.
export DH_OPTIONS

DEB_BUILD_GNU_TYPE=$(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
DEB_HOST_GNU_TYPE=$(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)

# As we're not yet 'stable' we default to building unstripped binaries.
# This can be overridden by setting an empty DEB_BUILD_OPTIONS.
export DEB_BUILD_OPTIONS=nostrip

CFLAGS += -Wall
export CFLAGS

build: build-stamp
build-stamp:
	dh_testdir

	./configure --build=${DEB_BUILD_GNU_TYPE} --host=${DEB_HOST_GNU_TYPE} --prefix=/usr --mandir=\$${prefix}/share/man
	# Add here commands to compile the package.
	$(MAKE)

	touch build-stamp

clean:
	dh_testdir
	rm -f build-stamp install-stamp

	# Add here commands to clean up after the build process.
	-$(MAKE) distclean

	dh_clean

install: install-stamp
install-stamp: build-stamp
	dh_testdir
	dh_testroot
	dh_clean -k
	dh_installdirs

	# Add here commands to install the package into debian/tmp.
	$(MAKE) client-install prefix=`pwd`/debian/tmp/usr
	$(MAKE) server-install prefix=`pwd`/debian/tmp/usr

	mkdir -p `pwd`/debian/tmp/coda
	touch `pwd`/debian/tmp/coda/NOT_REALLY_CODA

	# remove things we really don't need
	rm -f `pwd`/debian/tmp/etc/init.d/update.init
	rm -f `pwd`/debian/tmp/etc/init.d/venus.init
	rm -f `pwd`/debian/tmp/usr/sbin/venus-setup
	rm -f `pwd`/debian/tmp/usr/share/man/man8/venus-setup.8

	touch install-stamp

# Build architecture-independent files here.
# Pass -i to all debhelper commands in this target to reduce clutter.
binary-indep: build install
# Nothing to do

# Build architecture-dependent files here.
# Pass -a to all debhelper commands in this target to reduce clutter.
binary-arch: build install
	dh_testdir
	dh_testroot
	dh_install
	dh_installdebconf
	dh_installdocs
	dh_installinit --update-rcd-params="defaults 60"
#	dh_installman
	dh_installmodules
	dh_installchangelogs
	dh_strip
	dh_link
	dh_compress
	dh_fixperms
	dh_installdeb
#	dh_makeshlibs
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb

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