#!/usr/bin/make -f
# -*- makefile -*-
# Sample debian/rules that uses debhelper.
# This file was originally written by Joey Hess and Craig Small.
# As a special exception, when this file is copied by dh-make into a
# dh-make output file, you may use that output file without restriction.
# This special exception was added by Craig Small in version 0.37 of dh-make.

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

%:
	dh $@ 

override_dh_auto_configure:
	cd daemon/libs/pjproject && ./configure --prefix=/usr --mandir=\$${prefix}/share/man --infodir=\$${prefix}/share/info --disable-ilbc-codec
	cd daemon && ./autogen.sh --prefix=/usr
	cd daemon && ./configure --prefix=/usr --mandir=\$${prefix}/share/man --infodir=\$${prefix}/share/info CFLAGS="$(CFLAGS)" LDFLAGS="-Wl,-z,defs" --disable-doxygen --without-ilbc
	cd gnome && ./autogen.sh --prefix=/usr
	cd gnome && ./configure --prefix=/usr --mandir=\$${prefix}/share/man --infodir=\$${prefix}/share/info CFLAGS="$(CFLAGS)" LDFLAGS="-Wl,-z,defs"

override_dh_auto_build:
	cd daemon/libs/pjproject && make V=1
	cd daemon && make V=1
	cd gnome && make V=1

override_dh_auto_clean:
	cd daemon/libs/pjproject && [ ! -f build.mak ] || $(MAKE) distclean
	cd daemon && [ ! -f Makefile ] || $(MAKE) distclean
	cd gnome && [ ! -f Makefile ] || $(MAKE) distclean
	dh_auto_clean

override_dh_auto_install:
	cd daemon && make DESTDIR=$(CURDIR)/debian/sflphone-daemon install
	cd gnome && make DESTDIR=$(CURDIR)/debian/sflphone-gnome install

	# Move gconf schemas to the right place
	mv $(CURDIR)/debian/sflphone-gnome/usr/etc/gconf/schemas/* $(CURDIR)/debian/sflphone-gnome/usr/share/gconf/schemas/
	cd $(CURDIR)/debian/sflphone-gnome/usr/ && rmdir -p etc/gconf/schemas

	# Move architecture-independent files to the data package
	if test -d "$(CURDIR)/debian/sflphone-data/usr/share/sflphone/" ; then \
	    mv $(CURDIR)/debian/sflphone-gnome/usr/share/sflphone/* $(CURDIR)/debian/sflphone-data/usr/share/sflphone/ ;\
	    mv $(CURDIR)/debian/sflphone-daemon/usr/share/sflphone/ringtones/ $(CURDIR)/debian/sflphone-data/usr/share/sflphone/ ;\
	fi
	rm -rf $(CURDIR)/debian/sflphone-gnome/usr/share/sflphone/
	rm -rf $(CURDIR)/debian/sflphone-daemon/usr/share/sflphone/

	dh_auto_install
