# Copyright 2003  Slackware Linux, Inc., Concord, CA, USA
# All rights reserved.
#
# Copyright (C) 2005 Lasse Collin (conversion to TukBuild)
#
# Redistribution and use of this script, with or without modification, is
# permitted provided that the following conditions are met:
#
# 1. Redistributions of this script must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
#
#  THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
#  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
#  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO
#  EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
#  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
#  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
#  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
#  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
#  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
#  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

# Building notes:
#   * First remove old: removepkg xfce
#   * You should have: gtk+2 librsvg libxml2 cups startup-notification

NAME=xfce
VERSION=4.2.3.2
SOURCE=http://www.xfce.org/archive/xfce-$VERSION/fat_tarballs/xfce-$VERSION-src.tar.bz2
PATCH=xfce-utils-xinitrc.diff.gz
BUILD=1
ROOT_REQUIRED=1
OPTIMIZE=${OPTIMIZE:-"-Os -pipe"} # -Os made KDE faster, does it do it with XFce?

build() {
	_explode 0
	cd xfce-$VERSION/src
	md5sum -c xfce-$VERSION.md5
	for I in \
			dbh-*.tar.* \
			libxfce4util-*.tar.* \
			libxfcegui4-*.tar.* \
			libxfce4mcs-*.tar.* \
			xfce-mcs-manager-*.tar.* \
			xfce4-panel-*.tar.* \
			*.tar.*
		do
		cd $TMP/xfce-$VERSION/src
		[ -d ${I%.tar.*} ] && continue
		_explode $I .
		cd ${I%.tar.*}
		# Security fix:
		[[ $I == xfce-utils-* ]] && _patch 0 -p1
		
		# configure tips:
		#   * Set --enable-letter if prefer letter to A4.
		#   * Composite is somewhat experimental. You can enable it by
		#     adding --enable-compositor. See xfwm4-4.2.3.1/COMPOSITOR
		#     for more information.
		#   * To view a full list of configure options, try:
		#     for I in *; do $I/configure --help=short | less ; done
		./configure \
			--prefix=$PREFIX \
			--libdir=$LIBDIR \
			--sysconfdir=$SYSCONFDIR/X11 \
			--disable-static \
			--disable-debug \
			--enable-final \
			--enable-xinerama \
			--enable-xf86misc \
			--enable-xkb \
			--enable-randr \
			--enable-xf86vm \
			--enable-all \
			--enable-cups \
			--disable-letter \
			--disable-gtkhtml \
			--disable-gconf \
			--program-prefix= \
			--program-suffix= \
			$CONFIGURE_TRIPET
		make -j$MAKEJOBS
		make DESTDIR=$PKG install
		_doc_except 0 xfce-$VERSION/${I%.tar.*}  INSTALL
		_chfix
		_chgrp_bin
		_tmp_pkg 0
	done
	(
		cd $PKG$BINDIR
		ln -sf xffm xffstab4
		ln -sf xffm xfapps
		ln -sf xffm xfbook
		ln -sf xffm xfsamba4
		ln -sf xffm xftrash4
		ln -sf xffm xfapps4
		ln -sf xffm xfbook4
		ln -sf xffm xffstab
		ln -sf xffm xfglob4
		ln -sf xffm xftree4
	)
	mkdir -p $PKG/etc/X11/xinit
	ln -sf ../xdg/xfce4/xinitrc $PKG/etc/X11/xinit/xinitrc.xfce
	chmod 0755 $PKG/etc/X11/xdg/xfce4/xinitrc
	_chfix
	_chgrp_bin
}
