#!/usr/bin/make -f

include /usr/share/cdbs/1/rules/debhelper.mk
include /usr/share/cdbs/1/class/gnome.mk
include /usr/share/cdbs/1/rules/patchsys-quilt.mk
#not used with MUD... include /usr/share/gnome-pkg-tools/1/rules/uploaders.mk
include /usr/share/gnome-pkg-tools/1/rules/clean-la.mk
-include /usr/share/gnome-pkg-tools/1/rules/gnome-get-source.mk

DEB_BUILDDIR := $(CURDIR)/debian/build-oss
DEB_DESTDIR := $(CURDIR)/debian/tmp

DEB_CONFIGURE_EXTRA_FLAGS := --disable-ipv6 --without-libwrap
DEB_CONFIGURE_USER_FLAGS := --disable-oss --disable-alsa --disable-arts --disable-local-sound

ifeq ($(DEB_BUILD_ARCH),hurd-i386)
    DEB_CONFIGURE_EXTRA_FLAGS += --disable-local-sound
    DEB_DH_MAKESHLIBS_ARGS_ALL := -V "libesd0 (>= 0.2.35)"
else
    DEB_DH_MAKESHLIBS_ARGS_ALL := -V "libesd-alsa0 (>= 0.2.35) | libesd0 (>= 0.2.35)"
endif
DEB_DH_MAKESHLIBS_ARGS_esound-clients := --no-act

clean::
	sed -i "s/@ALSA_ARCHES@/$(shell type-handling any linux)/g" debian/control
	rm -fr $(DEB_BUILDDIR) $(DEB_BUILDDIR_libesd-alsa0) 
	rm -rf $(DEB_DESTDIR) $(DEB_DESTDIR_libesd-alsa0)

configure/libesd-alsa0:: $(DEB_BUILDDIR_libesd-alsa0)/config.status
$(DEB_BUILDDIR_libesd-alsa0)/config.status:
	cd $(DEB_BUILDDIR_libesd-alsa0) && \
		$(DEB_CONFIGURE_SCRIPT_ENV) $(DEB_CONFIGURE_SCRIPT) \
			$(DEB_CONFIGURE_NORMAL_ARGS) \
			$(cdbs_configure_flags) \
			$(DEB_CONFIGURE_EXTRA_FLAGS) \
			--enable-alsa --disable-oss

build/libesd-alsa0::
	$(MAKE) -C $(DEB_BUILDDIR_libesd-alsa0)

install/libesd-alsa0::
	$(MAKE) -C $(DEB_BUILDDIR_libesd-alsa0) install DESTDIR=$(DEB_DESTDIR_libesd-alsa0)

binary-post-install/%::
	if [ $* != esound-common ]; then \
		rm -rf debian/$(cdbs_curpkg)/usr/share/doc/$(cdbs_curpkg) ;\
		ln -s esound-common debian/$(cdbs_curpkg)/usr/share/doc/$(cdbs_curpkg) ;\
	fi
