#!/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

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

export DPKG_GENSYMBOLS_CHECK_LEVEL=4

include /usr/share/dpkg/default.mk

LOCATION_SERVICE_ENABLE_GPS_PROVIDER = OFF

ifneq ($(filter noplatformapi,$(DEB_BUILD_PROFILES)),)
    # platform-api disabled by build profile
    # Do nothing, remains OFF
else ifneq ($(filter $(DEB_HOST_ARCH),ppc64el powerpc),)
    # Do nothing, remains OFF
else ifeq ($(shell dpkg-vendor --derives-from Ubuntu && echo yes),yes)
    LOCATION_SERVICE_ENABLE_GPS_PROVIDER = ON
endif

%:
	dh $@

override_dh_missing:
	dh_missing --fail-missing

override_dh_install:
	dh_install -Xlomiri-location-service.1
ifeq ($(filter $(LOCATION_SERVICE_ENABLE_GPS_PROVIDER),ON),ON)
	dh_install -p liblomiri-location-service3 etc/gps.conf etc/
endif

override_dh_auto_configure:
	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=ON \
	        -DLOCATION_SERVICE_ENABLE_GPS_PROVIDER=$(LOCATION_SERVICE_ENABLE_GPS_PROVIDER) \
	        -DLOCATION_SERVICE_ENABLE_GEOCLUE_PROVIDER=OFF \
	        $(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 '^(acceptance_tests|ichnaea_reporter_test|remote_providerd_test|delayed_service_test|daemon_and_cli_tests)'"
