#!/bin/sh
# Heavily based on the Slackware 12.2 SlackBuild
# http://www.scintilla.org
# Packager Andrea Sciucca  ( gohanz at infinito.it)
# http://www.slacky.it

CWD=`pwd`
TMP=${TMP:-/tmp/tgz}
PKG=$TMP/package-scintilla
NAME=scintilla
VERSION=2.01
ARCH=${ARCH:-i686}
BUILD=1as

if [ ! -d $TMP ]; then
 mkdir -p $TMP
fi
if [ ! -d $PKG ]; then
 mkdir -p $PKG
fi

cd $TMP
tar xvzf $CWD/scintilla201.tgz

echo -e "\E[0;32m+--------------------------------+\E[0;0m"
echo -e "\E[0;32m| Start SlackBuild $NAME-$VERSION |\E[0;0m"
echo -e "\E[0;32m+--------------------------------+\E[0;0m"

cd $NAME

find . -perm 777 -exec chmod 755 {} \;
find . -perm 775 -exec chmod 755 {} \;
find . -perm 555 -exec chmod 755 {} \;
find . -perm 666 -exec chmod 644 {} \;
find . -perm 664 -exec chmod 644 {} \;
find . -perm 444 -exec chmod 644 {} \;

(cd gtk
 make
)

mkdir -p $PKG/usr/lib
mkdir -p $PKG/usr/include
mkdir -p $PKG/install

( cd bin
  cp -a *.a $PKG/usr/lib
)

( cd include
  cp * $PKG/usr/include
)

cat << EOF > $PKG/install/slack-desc
# HOW TO EDIT THIS FILE:
# The "handy ruler" below makes it easier to edit a package description.  Line
# up the first '|' above the ':' following the base package name, and the '|'
# on the right side marks the last column you can put a character in.  You must
# make exactly 11 lines for the formatting to be correct.  It's also
# customary to leave one space after the ':'.

         |-----handy-ruler----------------------------------------------------|
scintilla: Scintilla (Source code editing component)
scintilla:
scintilla: Scintilla  includes features  especially useful  when  editing  and
scintilla: debugging  source code. These  include  support  for syntax styling
scintilla: error  indicators, code  completion  and  call  tips. The selection
scintilla: margin can contain markers like those used in debuggers to indicate
scintilla: breakpoints and the current line.
scintilla:
scintilla:
scintilla:
scintilla:
EOF

strip --strip-unneeded $PKG/usr/lib/* 2> /dev/null

mkdir -p $PKG/usr/doc/$NAME-$VERSION
cp -a License.txt README version.txt $PKG/usr/doc/$NAME-$VERSION
cd $CWD
cp -a *.SlackBuild $PKG/usr/doc/$NAME-$VERSION

cd $PKG
chown -R root:root .
requiredbuilder -y -v $PKG
makepkg -l y -c n $CWD/$NAME-$VERSION-$ARCH-$BUILD.tgz

cd $CWD # Come back to build source directory

##############Start Second SlackBuild#################

CWD=`pwd`
if ["$TMP" = ""]; then
 TMP=/tmp
fi
PKG=$TMP/package-scite
NAME=scite
VERSION=2.01
ARCH=${ARCH:-i686}
BUILD=1as

if [ ! -d $TMP ]; then
 mkdir -p $TMP
fi
if [ ! -d $PKG ]; then
 mkdir -p $PKG
fi

cd $TMP
tar xvzf $CWD/scite201.tgz

echo -e "\E[0;32m+----------------------------+\E[0;0m"
echo -e "\E[0;32m| Start SlackBuild $NAME-$VERSION |\E[0;0m"
echo -e "\E[0;32m+----------------------------+\E[0;0m"

cd $NAME

find . -perm 777 -exec chmod 755 {} \;
find . -perm 775 -exec chmod 755 {} \;
find . -perm 555 -exec chmod 755 {} \;
find . -perm 666 -exec chmod 644 {} \;
find . -perm 664 -exec chmod 644 {} \;
find . -perm 444 -exec chmod 644 {} \;

(cd gtk
 make && make install prefix=$PKG/usr
)

mkdir -p $PKG/install

cat << EOF > $PKG/install/slack-desc
# HOW TO EDIT THIS FILE:
# The "handy ruler" below makes it easier to edit a package description.  Line
# up the first '|' above the ':' following the base package name, and the '|'
# on the right side marks the last column you can put a character in.  You must
# make exactly 11 lines for the formatting to be correct.  It's also
# customary to leave one space after the ':'.

     |-----handy-ruler----------------------------------------------------|
scite: SciTE (SCIntilla based Text Editor)
scite:
scite: Originally built to demonstrate Scintilla, it  has grown to be a
scite: generally useful editor with facilities for building and running
scite: programs. It is best used for jobs with simple configurations.
scite:
scite:
scite:
scite:
scite:
scite:
EOF

strip --strip-unneeded $PKG/usr/bin/* 2> /dev/null

mkdir -p $PKG/usr/doc/$NAME-$VERSION
cp -a License.txt README $PKG/usr/doc/$NAME-$VERSION
cd $CWD
cp -a *.SlackBuild $PKG/usr/doc/$NAME-$VERSION

( cd $PKG/usr/share/applications
  sed -i "s|Icon=Sci48M.png|Icon=/usr/share/pixmaps/Sci48M.png|g" SciTE.desktop
)

cd $PKG
chown -R root:root .
requiredbuilder -y -v $PKG
makepkg -l y -c n $CWD/$NAME-$VERSION-$ARCH-$BUILD.tgz

if [ "$1" = "--cleanup" ]; then
 rm -rf $TMP
fi