#!/bin/sh

# bash.build
# Compile & install bash.
# Based on the Slackware SlackBuild version.

CWD="$( pwd )"
VERSION=$1 # get version from the trackbuild script

TMP=${TMP}/bash
rm -rf $TMP
mkdir -p $TMP

cd $TMP
tar xzf $CWD/source/bash-$VERSION.tar.gz

cd bash-$VERSION

# Install patches.
for patch in $CWD/source/patches/bash* ; do
  zcat $patch | patch -p0 --verbose
done

echo $PATH

# chocky says we prolly shouldn't build with -static
#-static
CFLAGS="$ARMCFLAGS" $ARMCONFIGURE --prefix=/usr arm-slackware-linux
if [ $? -gt 0 ]; then
   echo "ERROR: failed to ./configure"
   exit 1
fi

make || { echo "Failed to make" ; exit 1 ; }

# Install into slacktrack/installwatch's pseudo root dir
make install 

# Fix up bash binary locations
( cd ${SLACKTRACKFAKEROOT}
  rm -f bin/bash* # this is the Intel version.
  # Move the ARM version into /bin/
  mv -f usr/bin/bash bin/bash2.new
  ln -fs bin/bash usr/bin/bash 

  # We don't include the "bashbug" script.
  rm -rf usr/bin usr/man/man1/bashbug.1
)

# Install docs
mkdir -p /usr/doc/bash-$VERSION
install -m644 -oroot -gbin AUTHORS CHANGES COMPAT COPYING INSTALL MANIFEST NEWS NOTES \
              README Y2K doc/FAQ doc/INTRO \
              /usr/doc/bash-$VERSION
( cd doc ; groff -ms -Tascii article.ms > /usr/doc/bash-$VERSION/article.txt )

# Install package description & install script
mkdir /install
zcat $CWD/doinst.sh.gz > /install/doinst.sh
install -m644 $CWD/slack-desc /install/

#EOF
