#!/usr/bin/make -f

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

export DEB_BUILD_MAINT_OPTIONS = hardening=+all
export DEB_CFLAGS_MAINT_APPEND := -Wall
export DEB_CXXFLAGS_MAINT_APPEND := -Wall

%:
	dh $@

# Do not re-run autoreconf: the bundled neon m4 macros are not compatible
# with autoconf 2.72 (SOCKLEN_ARG_TYPE is not expanded and $(top_builddir)
# is substituted as a shell command), which makes the regenerated
# configure/config.status fail. The shipped configure (generated with
# autoconf 2.61) expands all macros correctly, so keep it as is.
override_dh_autoreconf:

include /usr/share/dpkg/architecture.mk

ifneq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
CONFIGURE_HOST := --host=$(DEB_HOST_GNU_TYPE)
endif

override_dh_auto_configure: configure
	./configure --build=$(DEB_BUILD_GNU_TYPE) \
		$(CONFIGURE_HOST) \
		--prefix=/usr \
		--includedir='$${prefix}/include' \
		--mandir='$${prefix}/share/man' \
		--infodir='$${prefix}/share/info' \
		--sysconfdir=/etc \
		--localstatedir=/var \
		--disable-option-checking \
		--disable-silent-rules \
		--libdir='$${prefix}/lib/$(DEB_HOST_MULTIARCH)' \
		--disable-maintainer-mode \
		--disable-dependency-tracking \
		--with-libxml2 \
		--with-expat \
		--with-included-expat=no \
		--with-neon \
		--with-included-neon=no \
		--with-ssl=gnutls

override_dh_auto_install:
	dh_auto_install --verbose
	rm -rf $(CURDIR)/debian/sitecopy/usr/doc

override_dh_clean:
	dh_clean ABOUT-NLS po/ChangeLog po/gettext.m4 po/host-cpu-c-abi.m4 \
	po/iconv.m4 po/intlmacosx.m4 po/lib-ld.m4 po/lib-link.m4 \
	po/lib-prefix.m4 po/nls.m4 po/po.m4 po/progtest.m4 po/POTFILES \
	po/stamp-po po/Makefile.in po/*.gmo sitecopy config.log \
	config.status config.h

	find -name Makefile -delete
