#!/usr/bin/make -f

# Comment this to turn off verbose mode.
#export DH_VERBOSE=1

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

DEB_BUILD_GNU_CPU ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_CPU)
DEB_BUILD_GNU_SYSTEM ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_SYSTEM)
DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)

build: build-arch build-indep
build-arch: build-stamp
build-indep: build-stamp

build-stamp:
	dh_testdir

	dh_autoreconf

	./configure --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) \
		    --prefix=/usr --mandir=\$${prefix}/share/man        \
	            --infodir=\$${prefix}/share/info --enable-slpv1     \
		    --enable-async-api

	# Compile the package.
	$(MAKE)

	touch build-stamp

clean:
	dh_testdir
	dh_testroot

	# Clean up after the build process.
	[ ! -f Makefile ] || $(MAKE) distclean

	dh_autoreconf_clean

	dh_clean

install: build
	dh_testdir
	dh_testroot
	dh_prep
	dh_installdirs

	# Install the package into debian/tmp.
	$(MAKE) install DESTDIR=$(CURDIR)/debian/tmp


# Build architecture-independent files here.
binary-indep: 
	dh_testdir -i
	dh_testroot -i
	dh_installdocs -i -XCVS
	dh_installchangelogs -i ChangeLog
	dh_compress -i
	dh_installdeb -i
	dh_gencontrol -i
	dh_md5sums -i
	dh_builddeb -i

# Build architecture-dependent files here.
binary-arch: build install
	dh_testdir -a
	dh_testroot -a
	dh_installinit -a -u"start 18 2 3 4 5 . stop 22 0 1 6 ."
	dh_installdocs -a -XCVS
	dh_install -a

	dh_installexamples -a
#	dh_installmenu
#	dh_installcron
#	dh_installdebconf -a
	dh_installman -pslpd debian/slpd.8 
	dh_installman -pslptool debian/slptool.1
	dh_installchangelogs -a ChangeLog
	dh_link -a
	dh_strip -a
	dh_compress -a
	dh_fixperms -a
	dh_makeshlibs -a
	dh_installdeb -a
	dh_shlibdeps -a
	dh_gencontrol -a
	dh_md5sums -a 
	dh_builddeb -a

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