IGNOREPATH=/etc:/home:/dev:/boot:/root:/tmp:/usr/local:/bin:/sbin:/mnt:/var:/usr/src
STRIPLIB=y
STRIPBIN=y

VERSION=`grep VERSION= ../KDE.options | cut -f 2- -d =`
PROGNAME="KDE Base $VERSION"
DESC="\
kdebase (KDE base package)                                             \n\
                                                                       \n\
Core applications for the K Desktop Environment.  Included are: kdm    \n\
(replacement for xdm), kwin (window manager), konqueror (filemanager,  \n\
web browser, ftp client), konsole (xterm replacement), kicker          \n\
(application starter and desktop pager), kaudio (audio server),        \n\
kdehelp (viewer for kde help files, info and man pages), kthememgr     \n\
(system for managing alternate theme packages) plus other KDE          \n\
components like kcheckpass, kikbd, kscreensaver, kcontrol, kfind,      \n\
kfontmanager, kmenuedit, and kappfinder."

BUILD=2
MAINTAINER="Mark Post <mark.post@eds.com>"
SOURCE=ftp://ftp.kde.org/pub/kde/stable/latest/src/
PKGNAME=kdebase-$VERSION-s390-$BUILD
TAG=OPT

compile() {
   # Avoid a version number in .la files:
   if [ -d /usr/lib/qt ]; then
     QTDIR=/usr/lib/qt
   fi

   tar -yxvf $CWD/kdebase-$VERSION.tar.bz2
   cd kdebase-$VERSION/
   chown -R root.root .
   # Make Vera Sans (aka Helv) the default font:
   zcat $CWD/kdebase.kpersonalizer.verasans.diff.gz | patch -p1 --verbose --backup

   CFLAGS=-O2 CXXFLAGS=-O2 \
    ./configure --prefix=/opt/kde \
                --with-shadow \
                --with-xinerama \
                --disable-debug \
                --program-prefix="" \
                --program-suffix="" \
                --build=s390-slackware-linux \
                --host=s390-slackware-linux \
                --target=s390-slackware-linux

   PATH=$PATH:/opt/kde/bin make
}

install() {
   cd $TMP/kdebase-$VERSION/
   make install DESTDIR=/package-kdebase

   mkdir -p /package-kdebase/usr/doc/kdebase-$VERSION
   cp -a AUTHORS COPYING INSTALL README kdebase.lsm \
       /package-kdebase/usr/doc/kdebase-$VERSION

   mkdir -p /package-kdebase/etc/X11/xinit \
            /package-kdebase/etc/profile.d
   cp -a $CWD/xinit/xinitrc.kde /package-kdebase/etc/X11/xinit/xinitrc.kde
   cp -a $CWD/profile.d/kde.sh /package-kdebase/etc/profile.d/kde.sh
   cp -a $CWD/profile.d/kde.csh /package-kdebase/etc/profile.d/kde.csh

   # Change the konsole defaults to look like the real Linux console:
   cat $CWD/config/konsolerc > /package-kdebase/opt/kde/share/config/konsolerc

   # Make konsole a login shell by default:
   cp -a $CWD/config/konsole.desktop \
      /package-kdebase/opt/kde/share/applications/kde/konsole.desktop

   # Install our own special KDM Xsession file (better for non-bash users):
   ( cd /package-kdebase/opt/kde/share/config/kdm
     cp -a Xsession Xsession.orig
     cat $CWD/config/Xsession > Xsession
   )

   # Turn off KDE menu side image, because it triggers a bug where the menu arrows
   # do not appear:
   cat $CWD/config/kickerrc > /package-kdebase/opt/kde/share/config/kickerrc

   # Add default kdmrc:
   rm -f /package-kdebase/opt/kde/share/config/kdm/kdmrc
   cp -a $CWD/config/kdmrc /package-kdebase/opt/kde/share/config/kdm/kdmrc.new
}

attributes() {
   chown root.nogroup $PKG/package-kdebase/opt/kde/bin/kdesud
   chmod 2755 $PKG/package-kdebase/opt/kde/bin/kdesud
}

special() {
   cd $PKG
   mv package-kdebase/* ./
   rmdir package-kdebase/

   cd $CTL
   cat $CWD/slack-desc > slack-desc

   cat $CWD/config.sh >> doinst.sh
   echo config opt/kde/share/config/kdm/kdmrc.new >> doinst.sh

   sed -e 's%package-kdebase/%%g' doinst.sh > doinst.sh.new
   cat doinst.sh.new > doinst.sh
   rm doinst.sh.new
}

