#! /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)
ifneq ($(DEB_HOST_GNU_TYPE),$(DEB_BUILD_GNU_TYPE))
  DEB_CONFIGURE_EXTRA_FLAGS += CC=$(DEB_HOST_GNU_TYPE)-gcc
endif
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_COMPRESS_EXCLUDE := gnutls.pdf

# If the architecture does not have libffi then p11-kit will not be
# available either.
p11_no_cpus := or1k
ifneq (,$(findstring $(DEB_HOST_ARCH_CPU),$(p11_no_cpus)))
DEB_CONFIGURE_EXTRA_FLAGS += --without-p11-kit
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::
	printenv
ifeq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
	find debian/tmp/usr/lib/* -name '*.so.*.*' -type f -exec \
		chrpath -d {} +
	find debian/tmp/usr/bin/ -type f -exec \
		chrpath -d {} +
endif

# gnutls-bin was 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 its
# version to supersede the gnutls28 version.
binary-makedeb/gnutls-bin:: DEB_DH_GENCONTROL_ARGS := -- -v3.0.11+really$(DEB_VERSION)
