#!/usr/bin/make -f

include /usr/share/cdbs/1/class/autotools.mk
include /usr/share/cdbs/1/rules/debhelper.mk

# (Re)create autotools
include /usr/share/cdbs/1/rules/autoreconf.mk
export AUTOHEADER = true
DEB_UPSTREAM_CRUFT_MOVE = aclocal.m4 configure libtool stamp-h1

DEB_CONFIGURE_EXTRA_FLAGS = \
	--enable-warnings \
	--enable-docs --enable-pam --enable-pcre \
	--enable-ssl --with-ssl=/usr \
	--with-mysql --with-mysql-dir=/usr \
	--with-sqlite2 \
	--with-sqlite3 \
	--with-pgsql --with-pgsql-dir=/usr \
	--with-redis --with-redis-dir=/usr \
	--with-mssql=/usr

# Debian sgml-data collection apparently not in upstream path list
DEB_CONFIGURE_EXTRA_FLAGS += XML_DCL=/usr/share/xml/declaration/xml.dcl

DEB_MAKE_INSTALL_TARGET = install install-contrib install-checks install-test DESTDIR=$(cdbs_make_curdestdir)

# avoid regenerating code
# TODO: always regenerate instead: Move aside and build-depend on bison
pre-build::
	touch wmlscript/wsgram.c wmlscript/wsgram.h

# 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
