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

export CPPFLAGS:=$(shell dpkg-buildflags --get CPPFLAGS)
export CFLAGS:=$(shell dpkg-buildflags --get CFLAGS) $(CPPFLAGS)
export CXXFLAGS:=$(shell dpkg-buildflags --get CXXFLAGS)
export LDFLAGS:=$(shell dpkg-buildflags --get LDFLAGS)

LDFLAGS+=-Wl,--as-needed

%:
	dh $@ --parallel --with=autoreconf,systemd

override_dh_autoreconf:
	dh_autoreconf ./autogen.sh

override_dh_shlibdeps:
	dh_shlibdeps
	dh_girepository -l src:debian/libaccountsservice-dev/usr/share/gir-1.0

override_dh_auto_configure:
	dh_auto_configure -- \
		--enable-gtk-doc \
		--enable-static=no \
		--with-systemdsystemunitdir=/lib/systemd/system

# Disabled to avoid FTBFS
override_dh_auto_test:

override_dh_installchangelogs:
	dh_installchangelogs NEWS

override_dh_install:
	cat debian/accountsservice.install debian/accountsservice.install.linux.in > debian/accountsservice.install.linux
	dh_install
	# patch is only applied conditionally, only install when present
	if [ -d debian/tmp/usr/share/language-tools ]; then \
	    cp -r debian/tmp/usr/share/language-tools debian/accountsservice/usr/share/; \
	fi

override_dh_strip:
	dh_strip -plibaccountsservice0 --dbg-package=libaccountsservice-dbg
	dh_strip --remaining-packages
