#!/usr/bin/make -f

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

%:
	dh $@ --with gnome

ifneq ($(DEB_HOST_ARCH_OS), hurd)
ENABLE_TDB=--enable-tdb
endif

override_dh_autoreconf:
	dh_autoreconf debian/autogen.sh

DEB_CONFIGURE_EXTRA_FLAGS = 			\
	--libdir=\$${prefix}/lib/$(DEB_HOST_MULTIARCH) \
	--enable-pulse				\
	--enable-gstreamer			\
	--enable-gtk				\
	--enable-gtk-doc 			\
	$(ENABLE_TDB) 				\
	--with-builtin=dso

# Linux-specific flags:
ifeq ($(DEB_HOST_ARCH_OS), linux)
DEB_CONFIGURE_EXTRA_FLAGS += --enable-alsa --disable-oss
else
DEB_CONFIGURE_EXTRA_FLAGS += --disable-alsa --enable-oss
endif

override_dh_auto_configure:
	dh_auto_configure -- $(DEB_CONFIGURE_EXTRA_FLAGS)

override_dh_makeshlibs:
	dh_makeshlibs \
		--exclude=usr/lib/$(DEB_HOST_MULTIARCH)/gtk-2.0/modules \
		--exclude=usr/lib/$(DEB_HOST_MULTIARCH)/gtk-3.0/modules \
		--exclude=usr/lib/$(DEB_HOST_MULTIARCH)/libcanberra-0.30 -- -c4

override_dh_strip:
	dh_strip -plibcanberra0 --dbgsym-migration='libcanberra0-dbg (<< 0.30-3~)'
	dh_strip -plibcanberra-pulse --dbgsym-migration='libcanberra-pulse-dbg (<< 0.30-3~)'
	dh_strip -plibcanberra-gstreamer --dbgsym-migration='libcanberra-gstreamer-dbg (<< 0.30-3~)'
	dh_strip -plibcanberra-gtk0 --dbgsym-migration='libcanberra-gtk0-dbg (<< 0.30-3~)'
	dh_strip -plibcanberra-gtk-module --dbgsym-migration='libcanberra-gtk-module-dbg (<< 0.30-3~)'
	dh_strip -plibcanberra-gtk3-0 --dbgsym-migration='libcanberra-gtk3-0-dbg (<< 0.30-3~)'
	dh_strip -plibcanberra-gtk3-module --dbgsym-migration='libcanberra-gtk3-module-dbg (<< 0.30-3~)'
	dh_strip --remaining-packages

override_dh_install:
	cp -a src/canberra-gtk-module.desktop \
	      debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/gnome-settings-daemon-3.0/gtk-modules/canberra-gtk3-module.desktop
	find debian/tmp -name '*.la' -print -delete
	dh_install

override_dh_missing:
	dh_missing --list-missing
