#! /usr/bin/make -f
# Build the gnutls package for Debian.

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

DEB_CONFIGURE_EXTRA_FLAGS = --enable-ld-version-script --enable-cxx \
	--without-lzo --disable-guile \
	--cache-file=$(CURDIR)/config.cache --with-libgcrypt \
	--with-packager=Debian \
	--with-packager-bug-reports=http://bugs.debian.org/ \
	--with-packager-version="$(DEB_VERSION)" \
	--libdir=\$${prefix}/lib/$(DEB_HOST_MULTIARCH)
DEB_MAKE_CHECK_TARGET = check
DEB_DH_MAKESHLIBS_ARGS_libgnutls26 := -V 'libgnutls26 (>= 2.12.6.1-0)'
DEB_COMPRESS_EXCLUDE := gnutls.pdf

# pre-clean rule: save gnutls.pdf since it is expensive to regenerate.
# See README.source
cleanbuilddir/gnutls-doc::
	if [ -e doc/gnutls.pdf ] ; then mv doc/gnutls.pdf doc/gnutls.pdf.debbackup ; fi


# additional commands for clean
clean::
	mkdir -p m4

	-rm -rf autom4te.cache

	-rm -f tests/stamp-tests
	# stupid conflicts
	-rm -f doc/*.info* lib/po/libgnutls26.pot
	# restore gnutls.pdf
	if [ -e doc/gnutls.pdf.debbackup ] && [ ! -e doc/gnutls.pdf ] ; then mv doc/gnutls.pdf.debbackup doc/gnutls.pdf ; fi

# additional comands for build rule
build/gnutls-doc::
	$(MAKE) html

# add post deb preparation (including debhelper stuff) actions
# generate symlinks manually and use dh_link to make them policy-conform.
binary-install/gnutls-doc::
	cd debian/gnutls-doc && \
	for i in usr/share/doc/gnutls-doc/html/gnutls*.png ; do \
		i=`basename "$$i"` ; \
		ln -s "/usr/share/doc/gnutls-doc/html/$$i" \
			usr/share/info/ ; \
	done && \
	cd ../.. && \
	dh_link -pgnutls-doc

common-install-arch::
	find debian/tmp/usr/lib/* -name '*.so.*.*' -type f -exec \
		chrpath -d {} +

# gnutls-bin and gnutls-doc were built from gnutls28 for a while, but we no
# longer want this to be the case at least for Ubuntu 12.04 LTS, because
# gnutls28's licensing is too strict for many of the free software packages
# built against it in Ubuntu main and we only want to support a single
# version.  Bump their versions to supersede the gnutls28 version.
binary-makedeb/gnutls-bin:: DEB_DH_GENCONTROL_ARGS := -- -v3.0.11+really$(DEB_VERSION)
binary-makedeb/gnutls-doc:: DEB_DH_GENCONTROL_ARGS := -- -v3.0.11+really$(DEB_VERSION)
