#!/bin/sh

# Build (and install) all KDE "extra" packages.
# Written for Slackware by volkerdi@slackware.com.
# Modified for KDE4 by Robby Workman <rworkman@slackware.com>
# Modified for KDE4 by Eric Hameleers <alien@slackware.com>
#
# Modified for Slackware ARM by Stuart Winter <mozes@slackware.com>

source /usr/share/slackdev/buildkit.sh

# Paths to skeleton port's source & real Slackware source tree:
# We just point to the root of the 'kde' directory since we're not
# using this script to build a package - just a launcher for the individual
# build scripts:
export CWD=$SLACKSOURCE/kde
export PORTCWD=$PWD
 
# Set the config option variables if they are not already set:
if [ -r ./KDE.options ]; then
   . ./KDE.options
fi

# Set the config option variables if they are not already set:
[ -r ./KDE.options ] && . ./KDE.options

# This avoids compiling a version number into KDE's .la files:
QTDIR=/usr/lib${LIBDIRSUFFIX}/qt ; export QTDIR

# Get the kde environment variables
. $CWD/kdebase/profile.d/kde.sh

# Get the kde environment variables
[ -d kdebase ] && eval $(sed -e "s#/lib#/lib${LIBDIRSUFFIX}#" .$CWD/kdebase/profile.d/kde.sh)

#KDEMODS=" \
#  kdevplatform \
KDEMODS=" \
  kdevelop \
  konq-plugins \
  guidance-power-manager \
  kopete-cryptography \
  ktorrent \
  skanlite \
  koffice \
  kaudiocreator \
  amarok \
  k3b"

# Allow for specification of individual packages to be built:
if [ -z "$1" ]; then
  MODQUEUE=$KDEMODS
else
  MODQUEUE=$*
fi

for module in \
  $MODQUEUE ;
do
  cd $module
    removepkg $module
    ~/armedslack/dbuild # runs the SlackBuild via distcc ( same as ./arm/build )
    if [ $? = 0 ]; then
      # Yes, I will build with the fresh packages installed:
      upgradepkg --install-new --reinstall $PKGSTORE/kde/${module}-*.t?z || exit 1
    else
      echo "${module} failed to build."
      exit 1
      break
  fi
  # Keep MIME database current:
  /usr/bin/update-mime-database /usr/share/mime 1> /dev/null 2> /dev/null &
  cd - ;
done

