#!/usr/bin/make -f

export DEB_BUILD_MAINT_OPTIONS = hardening=+all

%:
	dh $@ --buildsystem=cmake

# The macro bc_compute_lib_version (among others) from
# /usr/share/bctoolbox/cmake/bctoolboxCMakeUtils.cmake expects the
# .git directory to be available.  We fool it with a shellscript
# that returns the version from debian/changelog
CONFIGURE_ARGS += -DGIT_EXECUTABLE=$(shell pwd)/debian/upstream-version-from-changelog.sh

# this enables the unified call+chat database; it requires sqlite3 and
# a version of libsoci-dev built with C++11 support
CONFIGURE_ARGS += -DENABLE_DB_STORAGE=YES

# needs libXsd which is not packaged in Debian
CONFIGURE_ARGS += -DENABLE_ADVANCED_IM=NO

# Upstream unconditionally sets CMAKE_INSTALL_RPATH. Make it ineffective by
# setting CMAKE_SKIP_RPATH
override_dh_auto_configure:
	dh_auto_configure -- \
		-DCMAKE_SKIP_RPATH=ON \
		-DENABLE_ROOTCA_DOWNLOAD=NO \
		-DENABLE_LIME=NO \
		-DENABLE_LIME_X3DH=NO \
		-DENABLE_UNIT_TESTS=NO \
		-DENABLE_STATIC=NO \
		$(CONFIGURE_ARGS)

override_dh_installchangelogs:
	dh_installchangelogs NEWS

# shlibdeps generates a dependency to libsoci-core, but we actually need
# the sqlite3 interface implementation
override_dh_shlibdeps:
	dh_shlibdeps
	sed -i s/libsoci-core/libsoci-sqlite3-/g debian/*.substvars

override_dh_strip:
	dh_strip --dbgsym-migration='linphone-dbg (<< 3.12.0-1~)'
