#!/usr/bin/make -f
# Copyright © 2010-2011, 2013, 2015-2017 Jonas Smedegaard <dr@jones.dk>
# Description: Main Debian packaging script for Kannel
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

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

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
