#!/usr/bin/make -f

# Backends (mongodb removed for now, fails to compile)
backends := ldap pipe gmysql gpgsql gsqlite gsqlite3 geo lua

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

# Need to run the bootstrap first, and we have some custom flags for ./configure
override_dh_auto_configure:
	
	# First run the bootstrap.
	./bootstrap
	
	# Add here commands to configure the package.
	CFLAGS="$(CFLAGS)" CXXFLAGS="$(CXXFLAGS)" ./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/powerdns' \
		--libexecdir='$${prefix}/lib' \
		--with-dynmodules="$(backends)" \
		--with-modules="" \
		--with-pgsql-includes=`pg_config --includedir` \
		--with-mysql-lib=/usr/lib/$(DEB_HOST_MULTIARCH) \
		--with-boost=/usr \
		--enable-cryptopp \
		--disable-recursor

# 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

