#!/usr/bin/make -f

include /usr/share/cdbs/1/rules/autoreconf.mk
include /usr/share/cdbs/1/rules/debhelper.mk
include /usr/share/cdbs/1/rules/utils.mk
include /usr/share/cdbs/1/class/gnome.mk
include /usr/share/gnome-pkg-tools/1/rules/uploaders.mk
include /usr/share/gnome-pkg-tools/1/rules/gnome-version.mk
-include /usr/share/gnome-pkg-tools/1/rules/gnome-get-source.mk

DEB_DH_AUTORECONF_ARGS := --as-needed ./autogen.sh

DEB_CONFIGURE_EXTRA_FLAGS += --enable-lirc \
                             --enable-gtk-doc

ifeq ($(DEB_HOST_ARCH_OS),linux)
DEB_CONFIGURE_EXTRA_FLAGS += --without-hal --with-gudev
else
DEB_CONFIGURE_EXTRA_FLAGS += --without-hal --without-gudev
endif

ifneq ($(DEB_HOST_ARCH_OS),linux)
# Linux specific, needs hal/gudev
DEB_DH_INSTALL_ARGS_rhythmbox-plugins += -Xmtpdevice
endif

# exclude plugins from shlibs generation
DEB_DH_MAKESHLIBS_ARGS_rhythmbox += --no-act
DEB_DH_MAKESHLIBS_ARGS_rhythmbox-plugins += --no-act
DEB_DH_MAKESHLIBS_ARGS_rhythmbox-plugin-cdrecorder += --no-act
DEB_DH_MAKESHLIBS_ARGS_rhythmbox-plugin-magnatune += --no-act
DEB_DH_MAKESHLIBS_ARGS_rhythmbox-mozilla += --no-act
DEB_DH_MAKESHLIBS_ARGS_rhythmbox-plugin-visualizer += --no-act
DEB_DH_MAKESHLIBS_ARGS_rhythmbox-plugin-zeitgeist += --no-act
DEB_DH_MAKESHLIBS_ARGS_librhythmbox-core9 += -V -- -c4

# don't configure with --libdir, but move the files manually, because
# other locations in /usr/lib/ must not change.
common-install-impl::
	mkdir -p debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)
	mv debian/tmp/usr/lib/lib*a 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)

$(patsubst %,binary-post-install/%,$(DEB_PACKAGES)) ::
	find debian/$(cdbs_curpkg) -name '*.a' -delete
	find debian/$(cdbs_curpkg) -name '*.la' -delete
	dh_python3 --no-ext-rename -p$(cdbs_curpkg) /usr/lib/rhythmbox

# Fail if there are any files which are not installed
DEB_DH_INSTALL_ARGS += --fail-missing -X.la -Xsample-plugins -Xcontext
