#!/usr/bin/make -f

export DH_OPTIONS

TMP=$(PWD)/debian/tmp/

build: build-stamp
build-stamp:
	dh_testdir

	./configure --prefix=/usr/
	-$(MAKE)

	touch build-stamp

clean:
	dh_testdir
	dh_testroot
	rm -f build-stamp

	-$(MAKE) clean
	-$(MAKE) distclean

	dh_clean

install: DH_OPTIONS=
install: build
	dh_testdir
	dh_testroot
	dh_clean -k
	dh_installdirs

	$(MAKE) prefix=$(TMP)/usr install

	# install the examples
	mkdir -p $(TMP)/usr/share/doc/libtntdb-dev/examples
	cp -f demo/*.{cpp,h} $(TMP)/usr/share/doc/libtntdb-dev/examples/

	# create /usr/lib/tnt/
	mkdir -p $(TMP)/usr/lib/tnt
	mv -f $(TMP)/usr/lib/tntdb* $(TMP)/usr/lib/tnt/

	dh_install --sourcedir=$(TMP)

# This single target is used to build all the packages, all at once, or
# one at a time. So keep in mind: any options passed to commands here will
# affect _all_ packages. Anything you want to only affect one package
# should be put in another target, such as the install target.
binary-common:
	dh_testdir
	dh_testroot
	dh_installchangelogs
	dh_installdocs
	dh_installexamples
	dh_installmenu
#	dh_installdebconf
#	dh_installlogrotate
#	dh_installemacsen
#	dh_installcatalogs
#	dh_installpam
#	dh_installmime
#	dh_installinit
#	dh_installman
#	dh_installcron
#	dh_installinfo
	dh_strip
	dh_link
	dh_compress
	dh_fixperms
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb

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

# Build architecture dependant packages using the common target.
binary-arch: build install
	-$(MAKE) -f debian/rules DH_OPTIONS=-a 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-common binary install
