#! /usr/bin/make -f

include /usr/share/cdbs/1/rules/debhelper.mk
include debian/kde.mk
include /usr/share/cdbs/1/rules/simple-patchsys.mk
include /usr/share/cdbs/1/rules/utils.mk

DEB_KDE_CVS_MAKE := yes
DEB_KDE_ENABLE_FINAL := yes
DEB_KDE_APIDOX := yes

DEB_CONFIGURE_EXTRA_FLAGS := --enable-shared --disable-static

post-patches:: debian/stamp-libtool-update

debian/stamp-libtool-update:
	cp -f /usr/share/libtool/libtool.m4 admin/libtool.m4.in
	cp -f /usr/share/libtool/ltmain.sh admin/ltmain.sh
	touch debian/stamp-libtool-update

common-build-arch:: debian/stamp-man-pages
debian/stamp-man-pages:
# Generate man pages for the programs
	for f in debian/man/*.man; do \
		soelim -Idebian/man $$f \
		 >debian/man/`basename $$f .man`.1; \
	done
	touch debian/stamp-man-pages

clean::
	rm -f debian/man/*.1
	rm -f debian/stamp-libtool-update debian/stamp-man-pages
	rm -f admin/libtool.m4.in admin/ltmain.sh
	rm -f Makefile.cvs
	rm -f debian/patches/04_korganizer_makefile.diff \
		debian/patches/05_lib_link.diff

DEB_INSTALL_DOCS_ALL :=

DEB_INSTALL_CHANGELOGS_ALL = $(shell for f in ChangeLog CHANGELOG CHANGES; do if test -s $(cdbs_curpkg)/$$f; then echo $(cdbs_curpkg)/$$f; break; fi; done)

shlibs_ver=4:3.3.1
DEB_DH_MAKESHLIBS_ARGS_libkcal2a := -V'libkcal2a (>= 4:3.3.2)'
DEB_DH_MAKESHLIBS_ARGS_libkdenetwork2 := -V'libkdenetwork2 (>= $(shlibs_ver))'
DEB_DH_MAKESHLIBS_ARGS_libkdepim1 := -V'libkdepim1 (>= 4:3.3.2)'
DEB_DH_MAKESHLIBS_ARGS_libkgantt0 := -V'libkgantt0 (>= $(shlibs_ver))'
DEB_DH_MAKESHLIBS_ARGS_libkleopatra0 := -V'libkleopatra0 (>= $(shlibs_ver))'
DEB_DH_MAKESHLIBS_ARGS_libkpimexchange1 := -V'libkpimexchange1 (>= $(shlibs_ver))'
DEB_DH_MAKESHLIBS_ARGS_libkpimidentities1 := -V'libkpimidentities1 (>= $(shlibs_ver))'
DEB_DH_MAKESHLIBS_ARGS_libksieve0 := -V'libksieve0 (>= $(shlibs_ver))'
DEB_DH_MAKESHLIBS_ARGS_libmimelib1 := -V'libmimelib1 (>= $(shlibs_ver))'
DEB_DH_MAKESHLIBS_ARGS_kaddressbook := -V
DEB_DH_MAKESHLIBS_ARGS_kalarm := -V
DEB_DH_MAKESHLIBS_ARGS_kdepim-wizards := -V
DEB_DH_MAKESHLIBS_ARGS_kitchensync := -V
DEB_DH_MAKESHLIBS_ARGS_kleopatra := -V
DEB_DH_MAKESHLIBS_ARGS_kmail := -V
DEB_DH_MAKESHLIBS_ARGS_knode := -V
DEB_DH_MAKESHLIBS_ARGS_knotes := -V
DEB_DH_MAKESHLIBS_ARGS_kontact := -V
DEB_DH_MAKESHLIBS_ARGS_korganizer := -V
DEB_DH_MAKESHLIBS_ARGS_kpilot := -V
DEB_DH_MAKESHLIBS_ARGS_ksync := -V
DEB_DH_MAKESHLIBS_ARGS_ktnef := -V

DEB_SHLIBDEPS_INCLUDE := \
	debian/kaddressbook/usr/lib \
	debian/kalarm/usr/lib \
	debian/kdepim-wizards/usr/lib \
	debian/kitchensync/usr/lib \
	debian/kleopatra/usr/lib \
	debian/kmail/usr/lib \
	debian/knode/usr/lib \
	debian/knotes/usr/lib \
	debian/kontact/usr/lib \
	debian/korganizer/usr/lib \
	debian/kpilot/usr/lib \
	debian/ksync/usr/lib \
	debian/ktnef/usr/lib \
	debian/libkcal2a/usr/lib \
	debian/libkdenetwork2/usr/lib \
	debian/libkdepim1/usr/lib \
	debian/libkgantt0/usr/lib \
	debian/libkleopatra0/usr/lib \
	debian/libkpimexchange1/usr/lib \
	debian/libkpimidentities1/usr/lib \
	debian/libksieve0/usr/lib \
	debian/libmimelib1/usr/lib

# kontact starts fine without korganizer or kpilot dependencies
DEB_DH_SHLIBDEPS_ARGS += $(DEB_DH_SHLIBDEPS_ARGS_$(cdbs_curpkg))
DEB_DH_SHLIBDEPS_ARGS_kontact := \
	-Xusr/lib/kde3/libkontact_korganizerplugin.so \
	-Xusr/lib/kde3/libkontact_kpilotplugin.so \
	-Xusr/lib/kde3/libkontact_todoplugin.so -- \
	-dRecommends \
	debian/kontact/usr/lib/kde3/libkontact_korganizerplugin.so \
	debian/kontact/usr/lib/kde3/libkontact_todoplugin.so \
	-dSuggests \
	debian/kontact/usr/lib/kde3/libkontact_kpilotplugin.so \
	-dDepends	# Since -u args go first in dpkg-shlibdeps call
