#!/usr/bin/make -f
# Made with the aid of dh_make, by Craig Small
# Sample debian/rules that uses debhelper. GNU copyright 1997 by Joey Hess.
# Some lines taken from debmake, by Cristoph Lameter.

SHELL+= -e

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

# This is the debhelper compatability version to use.
export DH_COMPAT=4

DEB_BUILD_GNU_TYPE = $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
DEB_HOST_GNU_TYPE  = $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
ifneq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
CONFARGS= --host=$(DEB_HOST_GNU_TYPE)
endif

build: build-stamp
build-stamp:
	dh_testdir

	env CFLAGS="-O2 -g -Wall" CXXFLAGS="-O2 -g -Wall" \
		./configure --prefix=/usr -v \
		--mandir=/usr/share/man --infodir=/usr/share/info $(CONFARGS)
	make all
ifeq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
	make check
endif

	touch build-stamp

clean:
	dh_testdir
	dh_testroot
	rm -f build-stamp

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

	dh_clean

# Build architecture-independent files here.
binary-indep: build
# We have nothing to do by default.

# Build architecture-dependent files here.
binary-arch: build
#	dh_testversion
	dh_testdir
	dh_testroot
	dh_clean -k
	dh_installdirs

	# Add here commands to install the files into debian/tmp
	$(MAKE) install INSTALL="install -p" \
		prefix=`pwd`/debian/gperf/usr \
		docdir=`pwd`/debian/gperf/usr/share/doc/gperf/ \
		mandir=`pwd`/debian/gperf/usr/share/man \
		infodir=`pwd`/debian/gperf/usr/share/info
	rm -rf debian/gperf/usr/share/man/dvi
	rm -rf debian/gperf/usr/share/man/html

	dh_installdocs
	dh_installexamples
	dh_installmenu
#	dh_installinit
	dh_installcron
	#dh_installmanpages
#	dh_undocumented
	dh_installchangelogs ChangeLog
	dh_strip
	dh_compress
	dh_fixperms
	dh_installdeb
	dh_shlibdeps
	dh_buildinfo
	dh_gencontrol
#	dh_makeshlibs
	dh_md5sums
	dh_builddeb

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