#!/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
tmp = $(shell pwd)/debian/ark-cvs
ARCH = $(shell dpkg-architecture -qDEB_BUILD_ARCH)
ifeq ($(ARCH),alpha)
  COMPILER_FLAGS=CFLAGS="-O0 -mieee" CXXFLAGS="-O0 -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 
	-chmod 755 configure
	-mv subdirs subdirs.tmp
	-cat subdirs.tmp | grep -v kdessh > subdirs
	-rm -f subdirs.tmp
	$(COMPILER_FLAGS) \
	./configure $(configkde)

	$(MAKE)

	touch build-stamp

clean: debian-clean
	dh_clean

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

binary-indep:	build
	dh_testroot
	dh_testdir

binary-arch: build
	dh_testdir
	dh_testroot
	dh_clean -k
	dh_installdirs -a
	$(MAKE) DESTDIR=$(tmp)/ install
	dh_undocumented
	dh_installman -a
	dh_movefiles -a --sourcedir=debian/ark-cvs
	dh_installdocs -a
	dh_installmenu -a
	dh_installmime -a
	dh_installchangelogs -park-cvs ark/ChangeLog
	dh_installchangelogs -pkdf-cvs
	dh_installchangelogs -pktimer-cvs
	dh_installchangelogs -pkcalc-cvs kcalc/ChangeLog
	dh_installchangelogs -pkedit-cvs kedit/ChangeLog
	dh_installchangelogs -pkjots-cvs kjots/CHANGES
	dh_installchangelogs -pklpq-cvs klpq/CHANGES
	dh_installchangelogs -pklprfax-cvs klprfax/ChangeLog
	dh_installchangelogs -pkpm-cvs kpm/CHANGES
	dh_installchangelogs -pkab-cvs
	dh_installchangelogs -pkcharselect-cvs
	dh_installchangelogs -pkdepasswd-cvs
	dh_installchangelogs -pkfloppy-cvs
	dh_installchangelogs -pkhexedit-cvs
	dh_installchangelogs -pklaptopdaemon-cvs
	dh_installchangelogs -pkljettool-cvs
	dh_strip -a
	dh_compress -a -X.docbook -X.css -X-license -X.dcl -X.bz2
	dh_fixperms -a
	dh_perl -a
	dh_makeshlibs -a
	dh_installdeb -a
	dh_shlibdeps -a -l`pwd`/debian/ark-cvs/usr/lib
	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
