#!/usr/bin/make -f
# -*- makefile -*-

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

EXO_LIBNAME=0.3
EXO_SOVERSION=0
EXO_SONAME=libexo-$(EXO_LIBNAME)-$(EXO_SOVERSION)

config.status: configure
	dh_testdir
	# Add here commands to configure the package.
	 ./configure --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) --prefix=/usr --mandir=\$${prefix}/share/man --infodir=\$${prefix}/share/info --sysconfdir=/etc --libexecdir=/usr/lib/$(EXO_SONAME) --enable-final --disable-gtk-doc --disable-python --enable-notifications

build: build-stamp
build-stamp:  config.status
	dh_testdir

	# Add here commands to compile the package.
	$(MAKE)

	touch build-stamp

clean:
	dh_testdir
	dh_testroot
	rm -f build-stamp 

	# Add here commands to clean up after the build process.
	[ ! -f Makefile ] || $(MAKE) distclean

	dh_clean 

install: build
	dh_testdir
	dh_testroot
	dh_clean -k 
	dh_installdirs

	# Add here commands to install the package into debian/tmp
	$(MAKE) install DESTDIR=$(CURDIR)/debian/tmp

	# delete the unneeded .a and .la files
	rm -f debian/tmp/usr/lib/libexo-hal-$(EXO_LIBNAME).la
	rm -f debian/tmp/usr/lib/libexo-$(EXO_LIBNAME).la

	# Debianise
	sed -i -e 's/^WebBrowser=.*/WebBrowser=debian-sensible-browser/' \
		-e 's/TerminalEmulator=.*/TerminalEmulator=debian-x-terminal-emulator/' \
		debian/tmp/etc/xdg/xfce4/helpers.rc

	chrpath -d -k debian/tmp/usr/bin/exo-csource \
		debian/tmp/usr/bin/exo-desktop-item-edit \
		debian/tmp/usr/bin/exo-open \
		debian/tmp/usr/bin/exo-mount \
		debian/tmp/usr/lib/$(EXO_SONAME)/exo-helper-$(EXO_LIBNAME) \
		debian/tmp/usr/lib/libexo-$(EXO_LIBNAME)*.so.* \
		debian/tmp/usr/lib/libexo-hal-$(EXO_LIBNAME)*.so.* \

	# Create a muttng helper from the mutt one
	sed -e 's/utt/uttng/;s/Icon=muttng/Icon=mutt/' \
		<debian/tmp/usr/share/xfce4/helpers/mutt.desktop \
		>debian/tmp/usr/share/xfce4/helpers/muttng.desktop

# Build architecture-independent files here.
binary-indep: build install

# Build architecture-dependent files here.
binary-arch: build install
	dh_testdir
	dh_testroot
	dh_installchangelogs ChangeLog
	dh_installdocs
	dh_installman -pexo-utils debian/exo-preferred-applications.1\
		debian/exo-desktop-item-edit.1 debian/exo-mount.1 \
		debian/exo-unmount.1 debian/exo-eject.1
	dh_installexamples
	dh_install --fail-missing --sourcedir=debian/tmp
	dh_link
	dh_strip -p $(EXO_SONAME) --dbg-package=$(EXO_SONAME)-dbg
	dh_strip -p exo-utils --dbg-package=exo-utils-dbg
	dh_strip --remaining-packages

	dh_compress
	dh_fixperms
	dh_makeshlibs
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb

binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary install 
