NAME=kdelibs
VERSION=${VERSION:-3.5.6}
SOURCE=$MIRROR_KDE/stable/$VERSION/src/kdelibs-$VERSION.tar.bz2
PATCH=( kdelibs.do_no_slow_spell_checking.patch
	kdelibs-3.5.6.khtml.patch
	post-3.5.6-kdelibs.diff
	CVE-2007-1564-kdelibs-3.5.6.diff
	kdelibs.kjs.diff )
BUILD=${BUILD:-3}
OPTIMIZE=${OPTIMIZE:-"-Os -pipe"}
ROOT_REQUIRED=1
PREFIXTYPE=kde

build() {
	_explode 0
	cd kdelibs*
	[ ! -e configure ] && sh admin/cvs.sh dist
	
	# Disable automatic spell checking by default, because it often
	# makes text areas very slow. You can turn it back on by adding
	# KSpell_DoSpellChecking=1 to ~/.kde/share/config/kdeglobals
	# section [KSpell].
	_patch 0 -p1

	# Last-minute bug fix to KHTML:
	_patch 1 -p4

	# CVE-2007-0537 khtml/konqueror title XSS vulnerability
	_patch 2 -p0

	# CVE-2007-1564
	_patch 3 -p0

	# UTF-8 bug in kjs
	_patch 4 -p0

	_configure \
		--with-xinerama \
		--disable-debug \
		--enable-gcc-hidden-visibility \
		--enable-sendfile \
		--enable-mitshm \
		--disable-dnssd \
		--disable-libfam \
		--without-acl \
		--with-rgbfile=/usr/share/X11/rgb.txt \
		--without-lua \
		--with-libidn \
		--with-libart \
		--with-ssl-dir=/usr \
		--with-tiff \
		--without-jasper \
		--without-openexr \
		--without-gssapi \
		--without-aspell \
		--without-hspell \
		--with-alsa
	make -j$MAKEJOBS
	make install DESTDIR=$PKG

	_doc 0 kdelibs-$VERSION  AUTHORS COMPILING \
			COPYING COPYING.BSD COPYING.LIB COPYING-DOCS \
			DEBUG KDE2PORTING.html KDE3PORTING.html \
			NAMING README TODO kdelibs.lsm

	cat << EOF > $PKG/install/doinst.sh
#!/bin/sh
# Add KDE library directory to /etc/ld.so.conf:
if fgrep $LIBDIR etc/ld.so.conf 1> /dev/null 2> /dev/null ; then
  true
else
  echo $LIBDIR >> etc/ld.so.conf
fi
EOF

	# This is a Perl-script with setuid bit:
	chmod 0755 $PKG$PREFIX/bin/fileshareset

	# Small security improvements:
	chown root:users $PKG$PREFIX/bin/kgrantpty $PKG$PREFIX/bin/kpac_dhcp_helper
	chmod 4710 $PKG$PREFIX/bin/kgrantpty $PKG$PREFIX/bin/kpac_dhcp_helper
}
