#!/usr/bin/make -f
# -*- makefile -*-
# Sample debian/rules that uses debhelper.
# This file was originally written by Joey Hess and Craig Small.
# As a special exception, when this file is copied by dh-make into a
# dh-make output file, you may use that output file without restriction.
# This special exception was added by Craig Small in version 0.37 of dh-make.

NULL =

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

export DEB_BUILD_MAINT_OPTIONS = hardening=+all
DPKG_EXPORT_BUILDFLAGS = 1
include /usr/share/dpkg/buildflags.mk

DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)

export DPKG_GENSYMBOLS_CHECK_LEVEL=4

include /usr/share/dpkg/default.mk

%:
	dh $@

override_dh_auto_install:
	dh_auto_install
	mkdir -p debian/tmp/usr/share/dbus-1
	mv debian/tmp/etc/dbus-1/system.d/ debian/tmp/usr/share/dbus-1/
	mv debian/tmp/lib/systemd/system/ debian/tmp/usr/lib/systemd/

override_dh_install:
	rm -Rv debian/tmp/usr/lib/*/lomiri-location-service/examples/
	rm -Rv debian/tmp/usr/share/lomiri-location-service/examples/
	cd debian/tmp/usr/share/doc/lomiri-location-service/html/ && rdfind -makesymlinks true .
	cd debian/tmp/usr/share/doc/lomiri-location-service/html/ && symlinks -rc .
	dh_install -Xlomiri-location-service.1

override_dh_auto_configure:
	if [ ! -e po/lomiri-location-service.pot.deb-bak ]; then cp po/lomiri-location-service.pot po/lomiri-location-service.pot.deb-bak; fi
	dh_auto_configure -- \
	        -DCMAKE_INSTALL_LIBEXECDIR=/usr/lib/$(DEB_HOST_MULTIARCH)/lomiri-location-service \
	        -DCMAKE_C_COMPILER=$(CC) \
	        -DCMAKE_CXX_COMPILER=$(CXX) \
	        -DENABLE_TRUST_STORE=OFF \
	        -DLOCATION_SERVICE_ENABLE_GPS_PROVIDER=OFF \
	        -DLOCATION_SERVICE_ENABLE_GEOCLUE_PROVIDER=ON \
	        $(NULL)

override_dh_auto_test:
	# Don't run tests in parallel as fake web servers all bind to same port
	dh_auto_test --no-parallel -- ARGS+="-E '^(remote_providerd_test|delayed_service_test|daemon_and_cli_tests)'"

override_dh_clean:
	-mv po/lomiri-location-service.pot.deb-bak po/lomiri-location-service.pot
	dh_clean

get-orig-source:
	uscan --noconf --force-download --rename --download-current-version --destdir=..
