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

# This is the debhelper compatability version to use.
export DH_COMPAT=3

-include debian/debiandirs

ARCH=$(shell dpkg-architecture -qDEB_BUILD_ARCH)
ifeq ($(ARCH),alpha)
  COMPILER_FLAGS=CFLAGS="-O0 -mieee" CXXFLAGS="-O0 -mieee -ftemplate-depth-99"
else
  COMPILER_FLAGS=CXXFLAGS="-ftemplate-depth-99"
endif

build: build-stamp
 
-include debian/debiandirs
 
debian/debiandirs: debian/debianrules
	perl -w debian/debianrules echodirs > debian/debiandirs

configure: configure-stamp
configure-stamp:
	dh_testdir
	if test ! -f configure; then \
	  $(MAKE) -f admin/Makefile.common ;\
	fi
	$(COMPILER_FLAGS) \
	./configure $(configkdevelop)

	touch configure-stamp

build: build-stamp 
build-stamp: configure
	$(MAKE)

	touch build-stamp

debian-clean:
	dh_testdir
	-rm -f build-stamp configure-stamp
	-rm -f debian/debiandirs
	-rm -f debian/files
	dh_clean -k
	
clean: debian-clean
	-make distclean

install: build
	dh_testroot
	dh_testdir
	dh_clean -a
	install -d debian/tmp/etc/kde3
	$(MAKE) prefix=/usr DESTDIR=`pwd`/debian/tmp/ install
	-rm -rf debian/tmp/home debian/tmp/blah \
		debian/tmp/usr/share/applnk/Development/designer.desktop \
		debian/tmp/usr/share/applnk/Development/linguist.desktop \
		debian/tmp/usr/share/mimelnk/application/x-designer.desktop \
		debian/tmp/usr/share/mimelnk/application/x-linguist.desktop \
		debian/tmp/usr/bin/extractrc
	cp kdevelop/kdeveloprc debian/tmp/etc/kde3/
	perl -w debian/debianrules cleanup
	perl -w debian/debianrules docbase
	perl -w debian/debianrules kdevelop_postinst
	install -d debian/tmp/usr/share/doc/kdevelop/examples
	install -g root -m 644 debian/htdig.conf \
		debian/tmp/usr/share/doc/kdevelop/examples
	install -g root -m 644 debian/README-htdig.Debian \
		debian/tmp/usr/share/doc/kdevelop
	install -d debian/tmp/usr/share/doc/kdevelop/updates
	install -g root -m 644 admin/conf.change.pl \
		debian/tmp/usr/share/doc/kdevelop/updates
	install -g root -m 644 admin/config.pl \
		debian/tmp/usr/share/doc/kdevelop/updates
	install -g root -m 644 debian/README-automake1.5.Debian \
		debian/tmp/usr/share/doc/kdevelop
	
build-indep: install
	chmod 755 debian/tmp/usr/share/apps/kdevelop/tools/*
	dh_movefiles -i
	dh_undocumented -i
	dh_installmenu -i
	dh_installdocs -i
	dh_installchangelogs -i
	dh_compress -X.database -i
	dh_perl -i
	dh_fixperms -i

binary-indep: build-indep
	-rm -f debian/files
#	dpkg-distaddfile kdevelop-doc doc optional
#	dpkg-distaddfile kdevelop-data devel optional
	dh_installdeb -i
	dh_gencontrol -i
	dh_md5sums -i
	dh_builddeb -i

build-arch:	install
	dh_movefiles -a
	dh_undocumented -a
	dh_installmenu -a
	dh_installdocs -a
	dh_installchangelogs -a
	dh_strip -a
	dh_compress -X.database -a
	dh_fixperms -a
	dh_makeshlibs -a
	dh_fixperms -a

binary-arch: build-arch
	-rm -f debian/files
#	dpkg-distaddfile kdevelop devel optional
	dh_installdeb -a
	dh_shlibdeps -a
	dh_gencontrol -a
	dh_md5sums -a
	dh_builddeb -a
	
# Below here is fairly generic really

binary: install build-indep build-arch
	dh_fixperms
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums 
	dh_builddeb

# Install local without making a package

install-local:
	$(MAKE) prefix=/usr
	sudo $(MAKE) prefix=/usr install

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