#!/usr/bin/make -f
# debian/rules file - for GNUPG (1.9)
# Copyright 1994,1995 by Ian Jackson.
# Copyright 1998-2003 by James Troup.
# Copyright 2003-2004 by Matthias Urlichs.
# 
# I hereby give you perpetual unlimited permission to copy,
# modify and relicense this file, provided that you do not remove
# my name from the file itself.  (I assert my moral right of
# paternity under the Copyright, Designs and Patents Act 1988.)
# This file may have to be extensively modified

include /usr/share/dpkg/architecture.mk

export DEB_BUILD_MAINT_OPTIONS = hardening=+all
export LDFLAGS += -lsocket -lnsl

%:
	dh $@ --with autoreconf

GPGV_UDEB_UNNEEDED = gpgtar bzip2 gpgsm scdaemon dirmngr doc tofu exec ldap gnutls dns-srv sqlite

#WIN32_FLAGS=LDFLAGS="-Xlinker --no-insert-timestamp -static" CFLAGS="-g -Os" CPPFLAGS=

override_dh_auto_configure:
#	dh_auto_configure --builddirectory=build-gpgv-udeb -- \
#	   	$(foreach x, $(GPGV_UDEB_UNNEEDED), --disable-$(x))
	dh_auto_configure --builddirectory=build -- --libexecdir=\$${prefix}/lib/gnupg2 \
		--disable-gpgtar \
		--disable-rpath \
		--disable-ldap \
		 --enable-large-secmem

#		--enable-symcryptrun

override_dh_auto_build-arch:
#	dh_auto_build --builddirectory=build-gpgv-udeb
#	ln build-gpgv-udeb/g10/gpgv2 build-gpgv-udeb/g10/gpgv
	dh_auto_build --builddirectory=build

override_dh_shlibdeps:
# Make ldap a recommends rather than a hard dependency.
#	dpkg-shlibdeps -Tdebian/dirmngr.substvars -dRecommends debian/dirmngr/usr/lib/gnupg2/dirmngr_ldap -dDepends debian/dirmngr/usr/bin/dirmngr*
	dpkg-shlibdeps -Tdebian/dirmngr.substvars -dDepends debian/dirmngr/usr/bin/dirmngr*
#	dh_shlibdeps -Ndirmngr

override_dh_auto_install-arch:
	dh_auto_install --builddirectory=build
	install -d debian/gnupg-agent/etc/X11/Xsession.d
	install -m 644 debian/gnupg-agent.xsession \
		debian/gnupg-agent/etc/X11/Xsession.d/90gpg-agent

#override_dh_auto_install-indep:

override_dh_auto_test:
#	if ! dh_auto_test; then echo xxx; cat tests/openpgp/gpgtar.test.log; echo xxx; false; fi
