# $Id: Portfile,v 1.12 2006/08/06 04:22:54 takanori Exp $

#Synced with Fink, Version 3.5.1-1024

PortSystem 1.0
name		kdelibs3
version		3.5.1
revision	3
set kdeadmin	kde-admindir-3.5.1
categories	kde
maintainers	ben@opendarwin.org takanori@opendarwin.org
description	Essential libraries for KDE applications. \
		NB No KDE sound support.
platforms	darwin
master_sites	opendarwin::kde351 \
		opendarwin::admin
#		kde:stable/${version}/src
#		http://ranger.befunk.com/fink/:admin
extract.suffix	.tar.bz2
use_bzip2	yes
distname	kdelibs-${version}
distfiles	${distname}.tar.bz2:kde351 \
		${kdeadmin}.tar.bz2:admin
depends_build	port:autoconf \
		port:automake
depends_lib	lib:libpoll:poll-emulator \
		lib:libX11.6:XFree86 \
		port:aspell \
		port:cups-headers \
		port:bzip2 \
		port:expat \
		port:flex \
		port:fontconfig \
		port:freetype \
		port:gettext \
		port:hicolor-icon-theme \
		port:jasper \
		port:jpeg \
		port:libart_lgpl \
		port:libidn \
		port:libiconv \
		port:libpng \
		port:libxml2 \
		port:libxslt \
		port:lua \
		port:pcre \
		port:tiff \
		port:OpenEXR \
		port:openssl \
		port:perl5.8 \
		port:pkgconfig \
		port:qt3 \
		port:Xft2 \
		port:xrender \
		port:zlib

checksums	${distname}.tar.bz2 md5 2a22193ae7c23f3759b02723dab02d30 \
		${kdeadmin}.tar.bz2 md5 b6115a7310f8e8533af91be02e225d0e

extract.only ${distname}.tar.bz2
post-extract { system "cd ${worksrcpath} && bzcat -dc ${distpath}/${kdeadmin}.tar.bz2 | tar xf -" }

patchfiles	kdelibs3-unified.patch
patch		{
		cd ${worksrcpath}
		foreach file $patchfiles {
		    system "sed -e 's,@FINKPREFIX@,${prefix},g' ${portpath}/${filesdir}/${file} | patch -p1"
		}
}
post-patch      {
		reinplace "s|lib/freetype219/||g" ${worksrcpath}/environment-helper.sh
		reinplace "s|include/qt|include/qt3|g" ${worksrcpath}/environment-helper.sh
		reinplace "s|--with-ssl-dir=/usr|--with-ssl-dir=\$PREFIX|g" ${worksrcpath}/environment-helper.sh
		foreach file [glob ${worksrcpath}/admin/*] {
		    reinplace "s|-O2|-Os|g" $file
		    reinplace "s|doc/HTML|doc/kde|g" $file
		    reinplace "s|/usr/share/doc/packages/qt3/html|${prefix}/share/doc/qt3/html|g" $file
		}
		foreach file {CompileScript.sh InstallScript.sh} {
		    file copy ${portpath}/${filesdir}/${file} ${worksrcpath}
		    reinplace "s|%p|${prefix}|g" ${worksrcpath}/${file}
		    reinplace "s|%N|${name}|g" ${worksrcpath}/${file}
		    reinplace "s|%v|${version}|g" ${worksrcpath}/${file}
		    reinplace "s|%r|${revision}|g" ${worksrcpath}/${file}
		    reinplace "s|%c|${configure.args}|g" ${worksrcpath}/${file}
		    reinplace "s|%d|${destroot}|g" ${worksrcpath}/${file}
		    reinplace "s|%i|${destroot}${prefix}|g" ${worksrcpath}/${file}
		    file attributes ${worksrcpath}/${file} -permissions 0755
		}
}

configure.args --enable-cups --with-ldap=framework --with-gssapi=framework --with-distribution='DarwinPorts/Mac OS X' --without-arts

configure	{}
build		{ system "cd ${worksrcpath} && ./CompileScript.sh" }
destroot	{ system "cd ${worksrcpath} && ./InstallScript.sh" }

post-destroot   {
		xinstall -m 755 -d ${destroot}${prefix}/share/doc/${name}
		xinstall -m 644 -W ${worksrcpath} COPYING COPYING.LIB INSTALL ${destroot}${prefix}/share/doc/${name}
}

platform darwin 6 {
	depends_lib-append	lib:libdl:dlcompat
}

platform darwin 8 {
	# NOP. Just for backward compatibility.
}

variant apidox {
	depends_lib-append port:doxygen
	post-patch { foreach f {CompileScript.sh InstallScript.sh} { reinplace "s|#apidox#||g" ${worksrcpath}/${f} }}
}
