#!/usr/bin/make -f
SHELL+= -e

CONFFLAGS = --enable-zlib

DPKG_EXPORT_BUILDFLAGS = 1
DEB_BUILD_MAINT_OPTIONS=hardening=+bindnow
-include /usr/share/dpkg/buildflags.mk

clean:
	dh_testdir
	rm -f debian/build-stamp
	[ ! -f Makefile ] || $(MAKE) distclean
	dh_clean

config: config.h Makefile
config.h Makefile: configure Makefile.in
	dh_testdir
	CFLAGS="$(CFLAGS) $(CPPFLAGS)" LDFLAGS="$(LDFLAGS)" \
	       ./configure $(CONFFLAGS)

build: build-arch build-indep
build-arch: debian/build-stamp
binary-indep: debian/build-stamp
debian/build-stamp: config.h
	dh_testdir
	$(MAKE)
	touch $@

binary-arch: build
	dh_testdir
	dh_testroot
	dh_prep

	dh_installdirs /usr/sbin/
	install --mode=755 rbldnsd debian/rbldnsd/usr/sbin/
	dh_installinit --restart-after-upgrade
	dh_installman rbldnsd.8
	dh_installdocs README.user TODO CHANGES-0.81
	dh_installchangelogs NEWS
	dh_strip
	dh_compress
	dh_fixperms
	dh_shlibdeps
	dh_installdeb
	dh_gencontrol
	dh_md5sums
	dh_builddeb

binary: binary-arch binary-indep

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