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

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

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

DROOT=`pwd`/debian/lbdb

DEBUGSYMS=
ifneq (,$(findstring debug,$(DEB_BUILD_OPTIONS)))
	DEBUGSYMS=-g
endif

build: build-stamp
build-stamp:
	dh_testdir

	env PGP=/usr/bin/pgp PGPK=/usr/bin/pgpk GPG=/usr/bin/gpg \
		FINGER=/usr/bin/finger ABOOK=/usr/bin/abook \
		ADDR_EMAIL=/usr/bin/addr-email SH=/bin/sh \
		YPCAT=/usr/bin/ypcat MAWK=/usr/bin/awk \
		./configure --prefix=/usr --libdir='$${prefix}/lib/lbdb' \
			--mandir='$${prefix}/share/man' --sysconfdir=/etc \
			--enable-lbdb-dotlock
	$(MAKE) CFLAGS="-O2 -Wall $(DEBUGSYMS)"

	touch build-stamp

clean:
	dh_testdir
	dh_testroot
	rm -f build-stamp

	-$(MAKE) distclean
	rm -f lbdb.spec

	dh_clean

install: build
	dh_testdir
	dh_testroot
	dh_clean -k
	dh_installdirs

	$(MAKE) install_prefix=$(DROOT) install
	install -m644 -oroot -groot lbdb.el \
		$(DROOT)/usr/share/emacs/site-lisp/lbdb/lbdb.el
	install -m644 -oroot -groot debian/override.Lintian \
		$(DROOT)/usr/share/lintian/overrides/lbdb

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

# Build architecture-dependent files here.
binary-arch: build install
	dh_testdir
	dh_testroot
#	dh_installdebconf	
	dh_installdocs
	dh_installexamples
	dh_installmenu
	dh_installlogrotate
	dh_installemacsen
#	dh_installpam
#	dh_installmime
#	dh_installinit
	dh_installcron
	dh_installman
	dh_installinfo
#	dh_undocumented
	dh_installchangelogs
	dh_link
	dh_strip
	dh_compress
	dh_fixperms
#	dh_makeshlibs
	dh_installdeb
	dh_perl
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb

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