#!/usr/bin/make -f

export DEB_BUILD_MAINT_OPTIONS = hardening=+all
# linphone-app/CMakeLists.txt using PREPEND() probably results in goofy paths.
updirs=$(shell pwd|sed 's|[^/]\+|..|g;s|^/||')

%:
	dh $@ --buildsystem=cmake --builddirectory=build

override_dh_auto_configure:
	dh_auto_configure -- -DCMAKE_SKIP_RPATH=ON \
		-DGIT_EXECUTABLE=/usr/share/bctoolbox/upstream-version-from-changelog \
		-DLINPHONE_QT_ONLY=ON \
		-DENABLE_BUILD_VERBOSE=ON \
		-DENABLE_UPDATE_CHECK=NO

execute_after_dh_auto_build-arch:
#	false

execute_before_dh_shlibdeps-arch:
	patchelf --set-rpath '$$ORIGIN/../lib/$(DEB_HOST_MULTIARCH)/linphone-desktop' \
		debian/linphone-desktop/usr/bin/linphone

execute_before_dh_auto_install:
	sed -i '/linphone-sdk/d' build/linphone-app/cmake_builder/linphone_package/cmake_install.cmake
	sed -i "s|$(CURDIR)/build/OUTPUT|$(updirs)/../usr|" \
		build/linphone-app/cmake_install.cmake \
		build/cmake_install.cmake
