#! /usr/bin/make -f

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

DEB_CONFIGURE_INCLUDEDIR := /opt/kde3/include/tde
DEB_CONFIGURE_MANDIR := /opt/kde3/share/man
DEB_CONFIGURE_PREFIX := /opt/kde3
DEB_CONFIGURE_INFODIR := /opt/kde3/share/info

cdbs_configure_flags := --with-qt-dir=/usr/share/qt3 --with-xinerama $(cdbs_kde_enable_final) $(cdbs_kde_enable_debug)

DEB_CONFIGURE_EXTRA_FLAGS := --prefix=/opt/kde3 --includedir="/opt/kde3/include/tde" --mandir="/opt/kde3/share/man" --infodir="/opt/kde3/share/info" --with-extra-libs="/usr/lib/mesa"

DEB_DH_STRIP_ARGS  := --dbg-package=kdegraphics-kde3-dbg

PACKAGES_WITH_LIBS := kfaxview-kde3 kghostview-kde3 kmrml-kde3 kpovmodeler-kde3 ksvg-kde3 \
			kuickshow-kde3 kview-kde3 kviewshell-kde3 libkscan1-kde3

DEB_DH_MAKESHLIBS_ARGS_kghostview-kde3	:= -V'kghostview-kde3 (>= 4:3.5.5-1)'
DEB_DH_MAKESHLIBS_ARGS_kpovmodeler-kde3	:= -V'kpovmodeler-kde3 (>= 4:3.5.5-1)'
DEB_DH_MAKESHLIBS_ARGS_ksvg-kde3	:= -V'ksvg-kde3 (>= 4:3.5.5-1)'
DEB_DH_MAKESHLIBS_ARGS_kview-kde3	:= -V'kview-kde3 (>= 4:3.5.5-1)'
DEB_DH_MAKESHLIBS_ARGS_kviewshell-kde3	:= -V'kviewshell-kde3 (>= 4:3.5.5-1)'
DEB_DH_MAKESHLIBS_ARGS_libkscan1-kde3	:= -V'libkscan1-kde3 (>= 4:3.5.5-1)'

binary-post-install/kuickshow-kde3::
ifeq ($(DEB_HOST_ARCH), powerpc)
	chrpath -d -k debian/kuickshow-kde3/opt/kde3/lib/libkdeinit_kuickshow.so
endif

#shlibs_ver = 4:3.5.0-1
#$(foreach p,$(PACKAGES_WITH_LIBS),$(eval DEB_DH_MAKESHLIBS_ARGS_$(p) := -V'$(p) (>= $(shlibs_ver))'))

kuickshow-kde3-tar:
	mkdir ../kuickshow-kde3-3.5.8
	cp -f * ../kuickshow-kde3-3.5.8 || true
	mkdir ../kuickshow-kde3-3.5.8/doc
	cp doc/Makefile.am ../kuickshow-kde3-3.5.8/doc
	cp -r doc/kuickshow ../kuickshow-kde3-3.5.8/doc
	cp -r kuickshow ../kuickshow-kde3-3.5.8
	cp -r admin ../kuickshow-kde3-3.5.8
	cd ../kuickshow-kde3-3.5.8; make -f admin/Makefile.common dist
	cd ..; tar zcf kuickshow-kde3_3.5.8.orig.tar.gz kuickshow-kde3-3.5.8

binary-post-install/kpdf-kde3::
	cp -Rp debian/kpdf-kde3/usr/* debian/kpdf-kde3/opt/kde3/
	rm -rf debian/kpdf-kde3/usr/

binary-post-install/kghostview-kde3::
	cp -Rp debian/kghostview-kde3/usr/* debian/kghostview-kde3/opt/kde3/
	rm -rf debian/kghostview-kde3/usr/

binary-post-install/kcolorchooser-kde3::
	cp -Rp debian/kcolorchooser-kde3/usr/* debian/kcolorchooser-kde3/opt/kde3/
	rm -rf debian/kcolorchooser-kde3/usr/

binary-post-install/kdvi-kde3::
	cp -Rp debian/kdvi-kde3/usr/* debian/kdvi-kde3/opt/kde3/
	rm -rf debian/kdvi-kde3/usr/

binary-post-install/kfaxview-kde3::
	cp -Rp debian/kfaxview-kde3/usr/* debian/kfaxview-kde3/opt/kde3/
	rm -rf debian/kfaxview-kde3/usr/	

binary-post-install/kiconedit-kde3::
	cp -Rp debian/kiconedit-kde3/usr/* debian/kiconedit-kde3/opt/kde3/
	rm -rf debian/kiconedit-kde3/usr/	

binary-post-install/kooka-kde3::
	cp -Rp debian/kooka-kde3/usr/* debian/kooka-kde3/opt/kde3/
	rm -rf debian/kooka-kde3/usr/

binary-post-install/kpovmodeler-kde3::
	cp -Rp debian/kpovmodeler-kde3/usr/* debian/kpovmodeler-kde3/opt/kde3/
	rm -rf debian/kpovmodeler-kde3/usr/

binary-post-install/ksnapshot-kde3::
	cp -Rp debian/ksnapshot-kde3/usr/* debian/ksnapshot-kde3/opt/kde3/
	rm -rf debian/ksnapshot-kde3/usr/

binary-post-install/kview-kde3::
	cp -Rp debian/kview-kde3/usr/* debian/kview-kde3/opt/kde3/
	rm -rf debian/kview-kde3/usr/

binary-post-install/kcoloredit-kde3::
	cp -Rp debian/kcoloredit-kde3/usr/* debian/kcoloredit-kde3/opt/kde3/
	rm -rf debian/kcoloredit-kde3/usr/

binary-post-install/kfax-kde3::
	cp -Rp debian/kfax-kde3/usr/* debian/kfax-kde3/opt/kde3/
	rm -rf debian/kfax-kde3/usr/

binary-post-install/kolourpaint-kde3::
	cp -Rp debian/kolourpaint-kde3/usr/* debian/kolourpaint-kde3/opt/kde3/
	rm -rf debian/kolourpaint-kde3/usr/

binary-post-install/kruler-kde3::
	cp -Rp debian/kruler-kde3/usr/* debian/kruler-kde3/opt/kde3/
	rm -rf debian/kruler-kde3/usr/

binary-post-install/kuickshow-kde3::
	cp -Rp debian/kuickshow-kde3/usr/* debian/kuickshow-kde3/opt/kde3/
	rm -rf debian/kuickshow-kde3/usr/

binary-post-install/kviewshell-kde3::
	cp -Rp debian/kviewshell-kde3/usr/* debian/kviewshell-kde3/opt/kde3/
	rm -rf debian/kviewshell-kde3/usr/