#!/usr/bin/make -f

# Turn on all hardening flags, as we're a networked daemon.
export DEB_BUILD_MAINT_OPTIONS=hardening=+all
# see EXAMPLES in dpkg-buildflags(1) and read /usr/share/dpkg/*
DPKG_EXPORT_BUILDFLAGS = 1
include /usr/share/dpkg/default.mk

# Tests appear to hang on the ppc64el buildds.
ifeq ($(DEB_HOST_ARCH_CPU),ppc64el)
DEB_BUILD_OPTIONS += nocheck
endif

# TODO: Build arch-indep parts separately to lower burden in build daemons
#build/kannel-docs:: debian/stamp-kannel-docs-build
#debian/stamp-kannel-docs-build:
#	$(DEB_MAKE_INVOKE) docs
#	touch $@
#install/kannel-docs:: debian/stamp-kannel-docs-install
#debian/stamp-kannel-docs-install:
#	$(DEB_MAKE_INVOKE) install-docs DESTDIR=$(cdbs_make_curdestdir)
#	touch $@
#clean::
#	rm -f debian/stamp-kannel-docs-build debian/stamp-kannel-docs-install

# Parallel building is disabled because otherwise some documentation build fails.
%:
	dh $@ --no-parallel

override_dh_auto_configure:
	# avoid regenerating code
	# TODO: always regenerate instead: Move aside and build-depend on bison
	touch wmlscript/wsgram.c wmlscript/wsgram.h
	env
	dh_auto_configure -- \
		--disable-silent-rules \
		--enable-warnings \
		--enable-docs --enable-pam --enable-pcre \
		--enable-ssl --with-ssl=/usr \
		--with-mysql --with-mysql-dir=/usr \
		--without-sqlite2 \
		--with-sqlite3 \
		--with-pgsql --with-pgsql-dir=/usr \
		--with-redis --with-redis-dir=/usr \
		--with-mssql=/usr

override_dh_auto_install:
	make -j1 install install-contrib install-checks install-docs install-test DESTDIR=$(CURDIR)/debian/tmp AM_UPDATE_INFO_DIR=no
