#!/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.
#export DH_VERBOSE=1
 
# This is the debhelper compatability version to use.
export DH_COMPAT=3

INSTALL_DIR = install -p -d -o root -g root -m 755
INSTALL_FILE = install -p -o root -g root -m 644

tmp = debian/tmp
overrides = $(tmp)/usr/share/lintian/overrides
pixmaps = $(tmp)/usr/share/pixmaps

ARCH = $(shell dpkg-architecture -qDEB_BUILD_ARCH)
ifeq ($(ARCH),alpha)
  COMPILER_FLAGS=CXX=g++-3.0 CC=gcc-3.0 CFLAGS=-mieee CXXFLAGS=-mieee
else
  COMPILER_FLAGS=CXX=g++ CC=gcc
endif

build: build-stamp

-include debian/debiandirs

debian/debiandirs: admin/debianrules
	perl -w admin/debianrules echodirs > debian/debiandirs

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

	$(MAKE)

	touch build-stamp


clean: debian-clean
	dh_clean

debian-clean:
	dh_testdir
	-rm -f debian/debiandirs build-stamp install-stamp
	if test -d CVS; then \
	  $(MAKE) -f admin/Makefile.common cvs-clean ;\
	fi
	-$(MAKE) distclean

install: install-stamp

install-stamp: build
	dh_testdir
	dh_testroot
	dh_clean -k
	dh_installdirs

	$(INSTALL_DIR) $(overrides)
	$(INSTALL_FILE) debian/*.override $(overrides)
	-for i in `ls $(overrides)/`; do \
	  mv $(overrides)/$$i \
	    $(overrides)/`echo $$i | sed -e 's#.override##'`; \
	done

	$(INSTALL_DIR) $(pixmaps)
	$(INSTALL_FILE) debian/*.xpm $(pixmaps)

	$(MAKE) install DESTDIR=`pwd`/$(tmp)

	# Link made from amor.links.
	-rm $(tmp)/usr/share/apps/amor/tips

	# Fallout from renaming of kworldwatch to kworldclock.
	-mv $(tmp)/usr/share/apps/kworldclock/* $(tmp)/usr/share/apps/kworldwatch

	for i in `find debian/ -type l -name "common"`; do \
		rm $$i; \
	done

	touch install-stamp

binary-indep: build install
	dh_testroot
	dh_testdir

binary-arch: build install
	dh_testroot
	dh_testdir
	dh_movefiles -a
	dh_installdocs -a
	dh_installmenu -a
	dh_installman -a
	# Move the .pl.* manpages to the correct place.
	$(INSTALL_DIR) debian/kscore/usr/share/man/man1
	-mv debian/kscore/usr/share/man/pl/man1/* \
		debian/kscore/usr/share/man/man1
	-rm -rf debian/kscore/usr/share/man/pl
	dh_installchangelogs -pamor
	dh_installchangelogs -peyesapplet
	dh_installchangelogs -pfifteenapplet
	dh_installchangelogs -pkmoon
	dh_installchangelogs -pkodo kodo/ChangeLog
	dh_installchangelogs -pkscore
	dh_installchangelogs -pkteatime
	dh_installchangelogs -pktux
	dh_installchangelogs -pkworldclock
	dh_link -a
	dh_strip -a
	dh_compress -a --exclude=.docbook
	dh_fixperms -a
	dh_makeshlibs -a
	dh_installdeb -a
	dh_perl -a
	dh_shlibdeps -a
	dh_gencontrol -a
	dh_md5sums -a
	dh_builddeb -a

# Below here is fairly generic really

binary:		binary-indep binary-arch

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