#!/usr/bin/make -f

# Set LD_LIBRARY_PATH to the installed library directory to allow dh_shlibdeps to function
# Also include the main Trinity path
ifeq ("$(LD_LIBRARY_PATH)", "")
LD_LIBRARY_PATH=debian/tmp/usr/lib
else
LD_LIBRARY_PATH += :debian/tmp/usr/lib
endif
export LD_LIBRARY_PATH

include /usr/share/cdbs/1/rules/debhelper.mk
include /usr/share/cdbs/1/class/cmake.mk
include debian/cdbs/debian-tde.mk

DEB_CMAKE_EXTRA_FLAGS := \
 -DLIB_SUFFIX="" \
 -DCMAKE_INSTALL_PREFIX="/usr" \
 -DCONFIG_INSTALL_DIR="/etc/trinity" \
 -DSYSCONF_INSTALL_DIR="/etc/trinity" \
 -DXDG_MENU_INSTALL_DIR="/etc/xdg/menus" \
 -DCMAKE_LIBRARY_PATH="/usr/lib" \
 -DCMAKE_INCLUDE_PATH="/usr/include/" \
 -DCMAKE_VERBOSE_MAKEFILE="ON" \
 -DCMAKE_SKIP_RPATH="OFF" \
 -DCMAKE_BUILD_TYPE=RelWithDebInfo \
 -DBUILD_ALL="ON" \
 -DWITH_TIFF="ON" \
 -DWITH_OPENEXR="ON" \
 -DWITH_PDF="ON" \
 -DCMAKE_C_COMPILER=gcc \
 -DLIB_SUFFIX="/$(DEB_HOST_MULTIARCH)"

DEB_DH_STRIP_ARGS  := --dbg-package=tdegraphics-trinity-dbg \
-Xkcm_kgamma.so -Xxf86gammacfg -Xlibtext2path.so.0.0.0 \
-Xlibksvgrendererlibart.so

DEB_DH_BUILDDEB_ARGS += -- -Z$(shell dpkg-deb --help | grep -q ":.* xz[,.]" \
                               && echo xz || echo bzip2)

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

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

binary-post-install/kuickshow-trinity::
ifeq ($(DEB_HOST_ARCH), powerpc)
	chrpath -d -k debian/kuickshow-trinity/usr/lib/libtdeinit_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))'))

#binary-post-install/kpdf-trinity::
#	mv debian/kpdf-trinity/usr/share/man debian/kpdf-trinity/usr/share/

#binary-post-install/kghostview-trinity::
#	mv debian/kghostview-trinity/usr/share/man debian/kghostview-trinity/usr/share/

binary-post-install/kcolorchooser-trinity::
	mv debian/kcolorchooser-trinity/usr/share/man debian/kcolorchooser-trinity/usr/share/

#binary-post-install/kdvi-trinity::
#	mv debian/kdvi-trinity/usr/share/man debian/kdvi-trinity/usr/share/

#binary-post-install/kfaxview-trinity::
#	mv debian/kfaxview-trinity/usr/share/man debian/kfaxview-trinity/usr/share/

#binary-post-install/tdeiconedit-trinity::
#	mv debian/tdeiconedit-trinity/usr/share/man debian/tdeiconedit-trinity/usr/share/

#binary-post-install/kooka-trinity::
#	mv debian/kooka-trinity/usr/share/man debian/kooka-trinity/usr/share/

#binary-post-install/kpovmodeler-trinity::
#	mv debian/kpovmodeler-trinity/usr/share/man debian/kpovmodeler-trinity/usr/share/

#binary-post-install/ksnapshot-trinity::
#	mv debian/ksnapshot-trinity/usr/share/man debian/ksnapshot-trinity/usr/share/

#binary-post-install/kview-trinity::
#	mv debian/kview-trinity/usr/share/man debian/kview-trinity/usr/share/

#binary-post-install/kcoloredit-trinity::
#	mv debian/kcoloredit-trinity/usr/share/man debian/kcoloredit-trinity/usr/share/

#binary-post-install/kfax-trinity::
#	mv debian/kfax-trinity/usr/share/man debian/kfax-trinity/usr/share/

#binary-post-install/kolourpaint-trinity::
#	mv debian/kolourpaint-trinity/usr/share/man debian/kolourpaint-trinity/usr/share/

#binary-post-install/kruler-trinity::
#	mv debian/kruler-trinity/usr/share/man debian/kruler-trinity/usr/share/

#binary-post-install/kuickshow-trinity::
#	mv debian/kuickshow-trinity/usr/share/man debian/kuickshow-trinity/usr/share/

#binary-post-install/kviewshell-trinity::
#	mv debian/kviewshell-trinity/usr/share/man debian/kviewshell-trinity/usr/share/