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

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

export DEB_BUILD_MAINT_OPTIONS = hardening=+all

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

confflags = \
 --libexecdir=/usr/lib/colord \
 --disable-examples \
 --disable-static \
 --disable-volume-search \
 --with-daemon-user=colord \
 --with-systemdsystemunitdir=/lib/systemd/system \
 --disable-systemd-login \
 --enable-vala

ifeq ($(DEB_HOST_ARCH_OS),linux)
	confflags += --enable-gudev --enable-sane
else
	confflags += --disable-gudev --disable-sane
endif

override_dh_clean:
	-rm -r build-libraries
	-rm -r build-daemon
	dh_clean

override_dh_install:
	# The .la file(s) are entirely useless; kill them with fire.
	find debian/tmp -name '*.la' -delete
	# The sensor libraries are private; remove development symlink
	-rm debian/tmp/usr/lib/*/libdtp94-private.so
	-rm debian/tmp/usr/lib/*/libhuey-private.so
	-rm debian/tmp/usr/lib/*/libmunki-private.so

	dh_install --list-missing

override_dh_auto_configure:
	dh_auto_configure -B build-libraries -- $(confflags)
	dh_auto_configure -B build-daemon -- $(confflags) --libdir=/usr/lib

override_dh_auto_build:
	dh_auto_build -B build-libraries
	dh_auto_build -B build-daemon

override_dh_auto_install:
	dh_auto_install -B build-libraries
	dh_auto_install -B build-daemon

override_dh_auto_test:
	@echo "TODO: Test suite disabled - requires running dbus daemon, currently fails"

override_dh_makeshlibs:
	# The semi-private sensor libraries have no ABI guarantee;
	# Mark anything using them with a strict version dependency
	sed s/@pkgver@/$(shell dpkg-parsechangelog | grep Version | cut -f 2 -d' ')/g \
		debian/libcolord1.symbols.in > debian/libcolord1.symbols
	dh_makeshlibs -- -c4

override_dh_gencontrol:
	dh_girepository
	dh_gencontrol

override_dh_autoreconf:
	NOCONFIGURE=1 dh_autoreconf ./autogen.sh

%:
	dh $@ --parallel --with autoreconf
