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

NULL =

export DEB_BUILD_MAINT_OPTIONS = hardening=+all

%:
	dh $@

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 -makeresultsfile false .
	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 --builddirectory=build-qt5 -- \
	        -DCMAKE_INSTALL_LIBEXECDIR=/usr/lib/$(DEB_HOST_MULTIARCH)/lomiri-location-service \
	        -DENABLE_TRUST_STORE=OFF \
	        -DLOCATION_SERVICE_ENABLE_GPS_PROVIDER=OFF \
	        -DLOCATION_SERVICE_ENABLE_GEOCLUE_PROVIDER=ON \
	        -DENABLE_QT6=OFF \
	        $(NULL)
	dh_auto_configure --builddirectory=build-qt6 -- \
	        -DCMAKE_INSTALL_LIBEXECDIR=/usr/lib/$(DEB_HOST_MULTIARCH)/lomiri-location-service \
	        -DENABLE_TRUST_STORE=OFF \
	        -DLOCATION_SERVICE_ENABLE_GPS_PROVIDER=OFF \
	        -DLOCATION_SERVICE_ENABLE_GEOCLUE_PROVIDER=ON \
	        -DENABLE_QT6=ON \
	        $(NULL)

override_dh_auto_build:
	dh_auto_build --builddirectory=build-qt5
	dh_auto_build --builddirectory=build-qt6

# Don't run tests in parallel as fake web servers all bind to same port
override_dh_auto_test:
	dh_auto_test --builddirectory=build-qt5 --no-parallel
	dh_auto_test --builddirectory=build-qt6 --no-parallel

override_dh_auto_install:
	dh_auto_install --builddirectory=build-qt6
	dh_auto_install --builddirectory=build-qt5

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

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