#!/usr/bin/make -f

# Turn on all hardening flags, as we're a networked daemon.
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
# see EXAMPLES in dpkg-buildflags(1) and read /usr/share/dpkg/*
DPKG_EXPORT_BUILDFLAGS = 1
include /usr/share/dpkg/default.mk

D = $(CURDIR)/debian/tmp

%:
	dh $@

override_dh_auto_configure:
	dh_auto_configure -- \
		--disable-silent-rules \
		--enable-warnings \
		--enable-docs --enable-pam \
		--enable-ssl --with-ssl=/usr \
		--with-mysql --with-mysql-dir=/usr \
		--without-sqlite2 \
		--with-sqlite3 \
		--with-pgsql --with-pgsql-dir=/usr \
		--with-redis --with-redis-dir=/usr \
		--with-mssql=/usr

override_dh_auto_build-arch:
	dh_auto_build -- DOCSTARGET=

override_dh_auto_build-indep:
	# Parallel building is disabled because otherwise some documentation
	# build fails.
	dh_auto_build -- -j1 docs

# Tests appear to hang on the ppc64 and ppc64el buildds.
ifneq (,$(filter $(DEB_HOST_ARCH_CPU),ppc64 ppc64el))
override_dh_auto_test:
endif

override_dh_auto_install-arch:
	$(MAKE) -- \
		DESTDIR=$(D) \
		AM_UPDATE_INFO_DIR=no \
		DOCSTARGET= \
		install \
		install-contrib \
		install-checks \
		install-test \
		# EOL
	# Replace the build directory so that the build is
	# reproducible regardless of build path
	sed -i -e "s,$(CURDIR),BUILDDIR,g" $(D)/usr/bin/gw-config

override_dh_auto_install-indep:
	$(MAKE) -- \
		DESTDIR=$(D) \
		AM_UPDATE_INFO_DIR=no \
		install-docs \
		# EOL
