#! /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 \
	--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.17-0)'
DEB_DH_MAKESHLIBS_ARGS_libgnutlsxx27 := -V 'libgnutlsxx27 (>= 2.12.17-0)'
DEB_DH_MAKESHLIBS_ARGS_guile-gnutls := -V 'guile-gnutls (>= 2.12.17-0)'
DEB_COMPRESS_EXCLUDE := gnutls.pdf

# Do not build guile-gnutls on these archs, as we would need to build with
# --disable-largefile
ifeq (,$(filter $(DEB_BUILD_ARCH),armel armhf mipsel))
	DEB_CONFIGURE_EXTRA_FLAGS += --enable-guile \
		--with-guile-site-dir=/usr/share/guile/site
else
	DEB_CONFIGURE_EXTRA_FLAGS += --disable-guile
endif

# pre-clean rule: save gnutls.pdf since it is expensive to regenerate.
# See README.source
cleanbuilddir/gnutls26-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/gnutls26-doc::
	$(MAKE) html

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

# gnutls-bin and guile-gnutls were built from gnutls28 but we chose
# to not ship this sourcepackage in wheezy. Bump the binary package version
# to supersede the gnutls28-built versions.
binary-makedeb/gnutls-bin:: DEB_DH_GENCONTROL_ARGS := -- -v3.0.22-3+really$(DEB_VERSION)

binary-makedeb/guile-gnutls: DEB_DH_GENCONTROL_ARGS := -- -v3.0.22-3+really$(DEB_VERSION)
