LINUKS = Lidová Nacionálně Ultralevicová Komunistická Strana

#!/bin/sh
######################################################################
# Build script for Slackware Linux.

######################################################################
# Definition directory, program, diff and build character.

PWD=`pwd`
TMP="/tmp"

PROGRAM="bc"
VERSION="1.06"
ARCH="i486"
BUILD="1"

SRC="$TMP"/SRC-"$PROGRAM"-"$VERSION"
PKG="$TMP"/PKG-"$PROGRAM"-"$VERSION"
SLACK="$TMP"/"$PROGRAM"-"$VERSION"-"$ARCH"-"$BUILD".tgz

######################################################################
# Controls directory.

if [ ! -d "$TMP" ]; then
  mkdir -p "$TMP"
fi
if [ -d "$SRC" ]; then
  rm -rf "$SRC"
fi
if [ -d "$PKG" ]; then
  rm -rf "$PKG"
fi
if [ -e "$SLACK" ]; then
  rm "$SLACK"
fi

mkdir -p "$SRC"
mkdir -p "$PKG"

######################################################################
# Definition CPU.

if [ "$ARCH" = "i386" ]; then
  SLKCFLAGS="-O2 -march=i386 -mcpu=i686"
elif [ "$ARCH" = "i486" ]; then
  SLKCFLAGS="-O2 -march=i486 -mcpu=i686"
elif [ "$ARCH" = "i586" ]; then
  SLKCFLAGS="-O2 -march=i586 -mcpu=i686"
elif [ "$ARCH" = "i686" ]; then
  SLKCFLAGS="-O2 -march=i686 -mcpu=i686"
elif [ "$ARCH" = "s390" ]; then
  SLKCFLAGS="-O2"
elif [ "$ARCH" = "x86_64" ]; then
  SLKCFLAGS="-O2"
fi

######################################################################
# Unzip and copy source programs.

if [ -e "$PWD"/"$PROGRAM-$VERSION".tar.bz2 ]; then
  tar xfj "$PROGRAM-$VERSION".tar.bz2
fi
if [ -e "$PWD"/"$PROGRAM-$VERSION".tar.gz ]; then
  tar xfz "$PROGRAM-$VERSION".tar.gz
fi
if [ -e "$PWD"/"$PROGRAM-$VERSION".tar.Z ]; then
  tar xfZ "$PROGRAM-$VERSION".tar.Z
fi

mv "$PROGRAM"-"$VERSION"/* "$SRC"
rm -rf "$PROGRAM"-"$VERSION"

######################################################################
# Unzip and copy diff programs.


######################################################################
# Controls source probram.

cd $SRC

chown -R root.root .
find . -perm 664 -exec chmod 644 {} \;
find . -perm 600 -exec chmod 644 {} \;
find . -perm 444 -exec chmod 644 {} \;
find . -perm 400 -exec chmod 644 {} \;
find . -perm 440 -exec chmod 644 {} \;
find . -perm 777 -exec chmod 755 {} \;
find . -perm 775 -exec chmod 755 {} \;
find . -perm 511 -exec chmod 755 {} \;
find . -perm 711 -exec chmod 755 {} \;
find . -perm 555 -exec chmod 755 {} \;

######################################################################
# Config and compile program.

CFLAGS="$SLKCFLAGS"
CXXFLAGS="$SLKCFLAGS"

./configure \
  --prefix=/usr \
# --bindir=/usr/bin \
# --sbindir=/usr/sbin \
# --libexecdir=/usr/libexec \
# --datadir=/usr/share \
# --sysconfdir=/etc \
# --localstatedir=/usr/var \
# --libdir=/usr/lib \
# --includedir=/usr/include \
# --infodir=/usr/info \
# --mandir=/usr/man \
  $ARCH-slackware-linux

make
make check
make DESTDIR="$PKG" install

######################################################################
# Post compile work.

# Add directory /usr/doc and information files.

if [ ! -d "$PKG"/usr/doc/"$PROGRAM"-"$VERSION" ]; then
  mkdir -p "$PKG"/usr/doc/"$PROGRAM"-"$VERSION"
fi

cp -a AUTHORS COMPILE COPYING Changelog HISTORY INSTALL LICENSE NEWS README* TODO "$PKG"/usr/doc/"$PROGRAM"-"$VERSION"/

# Add /install for information packages.

cd $PKG

if [ ! -d $PKG/install ]; then
  mkdir $PKG/install
fi
if [ -e $PWD/slack-desk ]; then
  cat $PWD/slack-desk > $PKG/slack-desk
fi
if [ -e $SRC/config.log ]; then
  cat $SRC/config.log > $PKG/install/slack-config.log
fi

echo [ $PROGRAM-$VERSION ] > $PKG/install/slack-files
find | sed -e "s/.//" | cat >> $PKG/install/slack-files

echo [ $PROGRAM-$VERSION ] > $PKG/install/slack-required
ldd `find -type f -perm 755` | sed -e "s/.//" | cat >> $PKG/install/slack-required

######################################################################
# Building Salckware packages.

makepkg -l y -c n "$SLACK"

######################################################################
# Post building Slackware packages.
Autor: Jindřich Plešinger