#!/usr/bin/make -f

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

include /usr/share/dpkg/default.mk

ifneq (,$(filter $(DEB_HOST_ARCH), hurd-i386 kfreebsd-i386 kfreebsd-amd64))
	ADMIN_BACKEND=-Dadmin=false
else
	ADMIN_BACKEND=
endif

ifeq (yes,$(shell dpkg-vendor --derives-from Ubuntu && echo yes))
        BLURAY_BACKEND = -Dbluray=false
endif

%:
	dh $@ --with gnome

override_dh_auto_configure:
	dh_auto_configure -- \
		--libexecdir=/usr/lib/gvfs \
		-Dman=true \
		$(ADMIN_BACKEND) \
		$(BLURAY_BACKEND)

override_dh_auto_build:
	dh_auto_build
	dh_auto_build --buildsystem=makefile -- -C debian/extra

override_dh_auto_clean:
	dh_auto_clean
	make -C debian/extra clean

override_dh_strip:
	dh_strip --dbgsym-migration='gvfs-dbg (<< 1.28.0-1~)'

override_dh_install:
	find debian/tmp -name '*.h' -print -delete
	dh_install
	rm -f debian/gvfs-bin/usr/bin/gvfs-less.xml

override_dh_installman:
	# debian/gvfs-bin.install contains debian/gvfs-* and we don't want this
	# to match the manpages
	dh_auto_build --buildsystem=makefile -- -C debian/extra all-man
	dh_installman
	dh_auto_build --buildsystem=makefile -- -C debian/extra clean-man

override_dh_missing:
	dh_missing --fail-missing

override_dh_makeshlibs:
	dh_makeshlibs --no-act

override_dh_shlibdeps:
	dh_shlibdeps -Lgvfs-libs -l/usr/lib/$(DEB_HOST_MULTIARCH)/gvfs

override_dh_auto_test:
	echo "Skipping testsuite as it's better run as an autopkgtest with machine isolation"
