#!/usr/bin/make -f

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

# This is the debhelper compatibility version to use.
export DH_COMPAT=3

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

build: build-stamp
build-stamp:
	dh_testdir
	if [ -x ./autogen.sh ] ; then ./autogen.sh ; fi
	./configure --prefix=/usr --mandir=\$${prefix}/share/man
	$(MAKE)
	touch build-stamp

clean:
	dh_testdir
	dh_testroot
	rm -f build-stamp install-stamp
	-$(MAKE) clean
	-$(MAKE) distclean
	dh_clean

install: DH_OPTIONS=
install: install-stamp
install-stamp: build
	dh_testdir
	dh_testroot
	dh_clean -k
	dh_installdirs
	# Add here commands to install the package into debian/tmp.
	$(MAKE) prefix=`pwd`/debian/tmp/usr install
	dh_movefiles
	# Copy class documentation (html) to doc/ directory of -doc package.
	mkdir -p debian/liblog4shib-doc/usr/share/doc/liblog4shib-doc/html
	mv debian/tmp/usr/doc/log4shib-*/html/* debian/liblog4shib-doc/usr/share/doc/liblog4shib-doc/html/
	touch install-stamp

binary-common:
	dh_testdir
	dh_testroot
#	dh_installdebconf
	dh_installdocs
	dh_installexamples
	dh_installmenu
#	dh_installlogrotate
#	dh_installemacsen
#	dh_installpam
#	dh_installmime
#	dh_installinit
	dh_installman
	dh_installcron
	dh_installinfo
#	dh_undocumented
	dh_installchangelogs
	dh_link
	dh_compress
	dh_fixperms
	dh_makeshlibs --noscripts
	dh_installdeb
#	dh_perl
	dh_strip
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb

# Build architecture dependant packages using the common target.
binary-arch: build install
	$(MAKE) -f debian/rules DH_OPTIONS=-a binary-common

# Build architecture independant packages using the common target.
binary-indep: build install
	$(MAKE) -f debian/rules DH_OPTIONS=-i binary-common

# Any other binary targets build just one binary package at a time.
binary-%: build install
	$(MAKE) -f debian/rules binary-common DH_OPTIONS=-p$*

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