#!/bin/bash

# KDE.SlackBuild
# Heavily based on the original Slackware build scripts by Patrick Volkerding;
# Modified by Stuart Winter <mozes@slackware.com>
# 13-Jul-2005

# 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/$PKGSERIES
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

KDEMODS=" \
  polkit-qt-1 \
  kdelibs \
  kdepimlibs \
  kdebase \
  kdebase-workspace \
  kdebase-runtime \
  kdesdk \
  kdegraphics \
  kdebindings \
  kdebase-workspace \
  kdeaccessibility \
  kdeutils \
  kdemultimedia \
  kdenetwork \
  kdepim \
  oxygen-icons \
  kdeadmin \
  kdeartwork \
  kdegames \
  kdetoys \
  kdepim \
  kdepim-runtime \
  kdeedu \
  kdewebdev \
  kdeplasma-addons \
  polkit-kde-1 "

# Non-core apps - these are built by KDE_extra.SlackBuild.
#  kdevplatform \
#  kopete-cryptography \
#  kdevelop \
#  konq-plugins \
#  guidance-power-manager \
#  ktorrent \
#  skanlite \
#  koffice \
#  kaudiocreator \
#  amarok \
#  k3b "
# and build kdepim before kopete-cryptography, and then again afterwards.
# For AS, I add k3b & mplayerthumbs to the build list.

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

# Yes, we know kdebase-workspace is built twice.  kdebase needs the
#   plasma bits from it, and then we build it again for good measure...
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/$PKGSERIES/${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

# Done!
