#!/usr/bin/make -f

export DEB_BUILD_MAINT_OPTIONS = hardening=+all
export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed

%:
	dh $@ --with=gir

override_dh_autoreconf:
	dh_autoreconf --as-needed

override_dh_auto_configure:
	aclocal --force
	automake
	dh_auto_configure -- \
		--disable-silent-rules \
		--enable-docbook-docs \
		--enable-gtk-doc \
		--enable-installed-tests \
		--libexecdir=/usr/lib/flatpak \
		--with-priv-mode=none \
		--with-html-dir=/usr/share/doc/libflatpak-doc \
		--with-privileged-group=sudo \
		--with-systemdsystemunitdir=/lib/systemd/system \
		$(NULL)

override_dh_install:
	rm -f debian/tmp/usr/lib/*/*.la
	dh_install --fail-missing

# On Debian, unprivileged user namespaces are not available by default,
# so install bwrap setuid. On Ubuntu, they're available by default, so
# don't install it setuid. Assume that derivatives are like Debian, since
# that will make Flatpak work regardless.
override_dh_fixperms-arch:
	dh_fixperms -a
	if ! dpkg-vendor --is Ubuntu; then \
		chmod 4755 debian/flatpak/usr/lib/flatpak/flatpak-bwrap; \
	fi

override_dh_auto_test:
	debian/test.sh
