#!/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.
#export DH_VERBOSE=1
 
# This is the debhelper compatability version to use.
export DH_COMPAT=3
tmp = $(shell pwd)/debian/korganizer
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
	$(COMPILER_FLAGS) \
	./configure $(configkdepim)
	$(MAKE)
	touch build-stamp

clean: debian-clean
	dh_clean

debian-clean:
	dh_testdir
	-rm -f debian/libical* 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) install DESTDIR=$(tmp)/
	for i in `find debian/ -type l -name "common"`; do \
		rm $$i ;\
		ln -s ../common $$i ;\
	done
	dh_undocumented
	dh_installman -a
	dh_movefiles -pkpilot --sourcedir=debian/korganizer
	dh_movefiles -pkandy --sourcedir=debian/korganizer
	dh_movefiles -pkdepim-libs --sourcedir=debian/korganizer
	dh_movefiles -pkdepim-dev --sourcedir=debian/korganizer
	dh_installdocs -a
	dh_installmenu -a
	dh_installmime -a
	dh_installchangelogs -pkorganizer
	dh_installchangelogs -pkpilot kpilot/ChangeLog
	dh_installchangelogs -pkdepim-libs
	dh_installchangelogs -pkdepim-dev
	dh_installchangelogs -pkandy
	dh_strip -a
	dh_compress -a -X.docbook -X.css -X-license -X.dcl -X.bz2
	dh_fixperms -a
	dh_makeshlibs -a -V
	dh_perl -a
	dh_installdeb -a
	dh_shlibdeps -a -l`pwd`/debian/kdepim-libs/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
