#!/usr/bin/make -f

# Backends
backends := ldap pipe gmysql gpgsql gsqlite3 geo lua

DEB_HOST_MULTIARCH  ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)

# Use new build system
%:
	dh $@ --with autoreconf --parallel

override_dh_auto_configure:
	./configure \
		--host=$(DEB_HOST_GNU_TYPE) \
		--build=$(DEB_BUILD_GNU_TYPE) \
		--prefix=/usr \
		--sysconfdir=/etc/powerdns \
		--mandir=\$${prefix}/share/man \
		--infodir=\$${prefix}/share/info \
		--libdir='$${prefix}/lib/$(DEB_HOST_MULTIARCH)' \
		--libexecdir='$${prefix}/lib' \
		--with-dynmodules="$(backends)" \
		--with-modules="" \
		--with-pgsql-includes=`pg_config --includedir` \
		--enable-cryptopp \
		--enable-botan1.10 \
		--enable-tools \
		--enable-unit-tests

# pdns-server has a debug package
override_dh_strip:
	dh_strip --dbg-package=pdns-server-dbg

# Additional permissions
override_dh_fixperms:
	dh_fixperms
	chmod 755 debian/pdns-server/etc/resolvconf/update.d/pdns

# init script needs to be named pdns, not pdns-server
override_dh_installinit:
	dh_installinit --name=pdns

# Verbose build (shows used compiler/linker and their flags)
override_dh_auto_build-arch:
	dh_auto_build -- V=1

# we need to zap generated files
override_dh_auto_clean:
	dh_auto_clean
	rm -f pdns/backends/bind/dnslabeltext.cc
