#!/usr/bin/make -f

-include /usr/share/gnome-pkg-tools/1/rules/gnome-get-source.mk

export DEB_LDFLAGS_MAINT_APPEND = -Wl,-O1 -Wl,--as-needed

%:
	dh $@ --with autoreconf,gir,gnome,python3

override_dh_autoreconf:
	dh_autoreconf --as-needed ./autogen.sh

ifeq ($(DEB_HOST_ARCH_OS),linux)
CONFFLAGS = --with-gudev
else
CONFFLAGS = --without-gudev
endif

override_dh_auto_configure:
	dh_auto_configure -- \
		--libdir=\$${prefix}/lib \
		--libexecdir=\$${libdir}/rhythmbox \
		--enable-lirc \
		--enable-gtk-doc \
		--without-hal \
		$(CONFFLAGS)

override_dh_install:
# don't configure with --libdir, but move the files manually, because
# other locations in /usr/lib/ must not change.
	mkdir -p debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)
	mv debian/tmp/usr/lib/lib*.so* debian/tmp/usr/lib/girepository-1.0 \
		debian/tmp/usr/lib/pkgconfig \
		debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)

	find debian/tmp -name '*.a' -delete
	find debian/tmp -name '*.la' -delete
	dh_install --fail-missing -Xsample-plugins -Xcontext

override_dh_python3:
	dh_python3 --no-ext-rename /usr/lib/rhythmbox

override_dh_strip:
	dh_strip --dbgsym-migration='rhythmbox-dbg (<< 3.3.1-1~)'

override_dh_makeshlibs:
	dh_makeshlibs -prhythmbox-mozilla --no-act
	dh_makeshlibs -prhythmbox-plugins --no-act
	dh_makeshlibs -prhythmbox-plugin-cdrecorder --no-act
	dh_makeshlibs -prhythmbox-plugin-visualizer --no-act
	dh_makeshlibs -prhythmbox-plugin-zeitgeist --no-act
	dh_makeshlibs --remaining-packages -V -- -c4
