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

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 --with-vcodacon
	# Add here commands to compile the package.
	$(MAKE)

	touch build-stamp

clean:
	dh_testdir
	dh_auto_clean
	dh_clean

install: install-stamp
install-stamp: build-stamp
	dh_testdir
	dh_testroot
	dh_prep
	dh_installdirs

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

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

	# Change venus-setup to run dpkg-reconfigure
	echo -e '#!/bin/sh\necho "Starting \"dpkg-reconfigure coda-client\""\ndpkg-reconfigure coda-client' > "`pwd`/debian/tmp/usr/sbin/venus-setup"
	chmod 755 "`pwd`/debian/tmp/usr/sbin/venus-setup"

	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
#	dh_installman
#	dh_installmodules
	dh_installchangelogs
	dh_strip --dbg-package=coda-dbg
	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
