#!/bin/sh
# Set initial variables:
CWD=`pwd`
if [ "$TMP" = "" ]; then
  TMP=/tmp
fi
PKG=$TMP/package-autoconf
SRC=/devel/manpagesrc
INFO=/devel/info-pages/usr/info
TEX=/devel/texinfo-docs

if [ ! -d $TMP ]; then
  mkdir -p $TMP # location to build the source
fi
if [ ! -d $PKG ]; then
  mkdir -p $PKG # place for the package to be built
fi

# Explode the package framework:
cd $PKG
explodepkg $CWD/_autoconf.tar.gz

# Find the size of a file:
filesize() {
 SIZE=`ls -l -d -G $1 | cut -b23-32`
 echo -n $SIZE
}

echo "+===============+"
echo "| autoconf-2.13 |"
echo "+===============+"
cd $TMP
tar xzvf $CWD/autoconf-2.13.tar.gz
cd autoconf-2.13
./configure --prefix=/usr
make
for n in *.info* ; do
  gzip -9c $n > $PKG/usr/info/$n.gz
done
for n in autoconf autoheader autoreconf autoupdate ifnames autoscan ; do
  cp $n $PKG/usr/bin
done
for n in autoconf.m4f autoheader.m4f autoconf.m4 acgeneral.m4 acoldnames.m4 \
acspecific.m4 autoheader.m4 acconfig.h acfunctions acheaders acidentifiers \
acprograms acmakevars; do
  cp $n $PKG/usr/share/autoconf
done
cp AUTHORS COPYING INSTALL NEWS README TODO $PKG/usr/doc/autoconf-2.13

# Build the package:
cd $PKG
tar czvf $TMP/autoconf.tgz .

# Warn of zero-length files:
for file in `find . -type f -print` ; do
 if [ "`filesize $file`" = "0" ]; then
  echo "WARNING: zero length file $file"
 fi
 if [ "`filesize $file`" = "20" ]; then
  echo "WARNING: possible empty gzipped file $file"
 fi
done

# Clean up the extra stuff:
if [ "$1" = "--cleanup" ]; then
  rm -rf $TMP/autoconf-2.13
  rm -rf $PKG
fi
