#!/usr/bin/make -f
# Made with the aid of debmake, by Christoph Lameter,
# based on the sample debian/rules file for GNU hello by Ian Jackson.

BUILDDIR = ./build

build: $(BUILDDIR)/build-stamp

$(BUILDDIR)/build-stamp:
	dh_testdir
	if test ! -f configure; then \
	  $(MAKE) -f admin/Makefile.common ;\
	fi 
	test -d $(BUILDDIR) || mkdir $(BUILDDIR) ;\
	cp -R po $(BUILDDIR) ;\
	cd $(BUILDDIR) ;\
	CFLAGS="-O2 -g -Wall" \
	CXXFLAGS="-O2 -g -Wall" \
	../configure --with-install-root=`pwd`/../debian/tmp \
	--disable-rpath --prefix=/usr --with-qt-dir=/usr/lib/qt1g 

	make -C $(BUILDDIR)

	touch $(BUILDDIR)/build-stamp

clean: debian-clean
	-rm -rf $(BUILDDIR)
	-rm -f debian/files
	-rm -f debian/substvars
	-rm -f debian/menu
	-rm -f configure
	dh_clean -k

debian-clean:
	dh_testdir
	-rm -f $(BUILDDIR)/build-stamp

binary-indep:	build
	dh_testdir
# There are no architecture-independent files to be uploaded
# generated by this package.  If there were any they would be
# made here.

binary-arch:	build
	dh_testroot
	dh_testdir
	dh_clean -k
	make -C $(BUILDDIR) install 
	rm -rf debian/tmp/usr/share/apps/kscd/cddb/
	mkdir -p debian/tmp/etc/kde
	echo "[CDDB]" > debian/tmp/etc/kde/kscdrc
	echo "LocalBaseDir=/var/lib/cddb/" >> debian/tmp/etc/kde/kscdrc
	echo "[General]" >> debian/tmp/etc/kde/kscdrc
	echo "UnixMailCommand=/usr/bin/mail -s \"%s\"" >> debian/tmp/etc/kde/kscdrc 
	echo "DOCKING=1" >> debian/tmp/etc/kde/kscdrc
	perl -w admin/debianrules
	dh_movefiles
	dh_undocumented 
	dh_installdocs
	dh_installmenu
	dh_installchangelogs 
	dh_strip
	dh_compress
	dh_fixperms
	chown root.cdrom debian/tmp/usr/bin/kscd
	chmod 2755 debian/tmp/usr/bin/kscd
	dh_suidregister
	dh_makeshlibs
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	perl -w admin/debianrules update
	dh_builddeb

# Below here is fairly generic really

binary:		binary-indep binary-arch

.PHONY: binary binary-arch binary-indep clean
