#!/usr/bin/make -f
# -*- makefile -*-

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
include /usr/share/dpkg/pkg-info.mk
export DEB_VERSION_UPSTREAM

export DEB_BUILD_MAINT_OPTIONS = hardening=+all

# On some arches (mips64el, s390x, alpha) antlr3 is extremely slow
# and throws a heap space OutOfMemory exception. Workaround by increasing
# heap space
export _JAVA_OPTIONS = -Xms512m -Xmx1024m

CONFIGURE_FEATURES += -DENABLE_TESTS=no

# Seems useful enough to enable.
CONFIGURE_FEATURES += -DENABLE_MDNS=ON

# No one should need the static library, file a bug if you do.
CONFIGURE_FEATURES += -DENABLE_STATIC=no

%:
	dh $@ --buildsystem=cmake --no-parallel --without autoreconf

# Upstream unconditionally sets CMAKE_INSTALL_RPATH. Make it ineffective by
# setting CMAKE_SKIP_RPATH
# Disable tests as this would require bctoolbox to be built with tests
# enabled as well, which has additional dependencies not yet in Debian
override_dh_auto_configure:
	dh_auto_configure -- -DCMAKE_SKIP_RPATH=ON \
		-DDEB_VERSION_UPSTREAM=$${DEB_VERSION_UPSTREAM%+dfsg*} \
		$(CONFIGURE_FEATURES)

execute_after_dh_auto_install:
	echo 'Requires.private: bctoolbox >= '$${DEB_VERSION_UPSTREAM%+dfsg*}', belr >= '$${DEB_VERSION_UPSTREAM%+dfsg*} \
		>> debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/pkgconfig/belle-sip.pc

# No need for autoreconf as we use CMake
override_dh_autoreconf:
override_dh_autotools_update_config:
