#!/bin/bash

# autoconf264.SlackBuild
# by Stuart Winter <mozes@slackware.com>
# Please see changelog.txt for revisions to this package's build script history.

# Record toolchain & other info for the build log:
slackbuildinfo

# Paths to skeleton port's source & real Slackware source tree:
export CWD=$SLACKSOURCE/$PKGSERIES/source/$PKGNAM*
export PORTCWD=$PWD

# Temporary build locations:
export TMPBUILD=$TMP/build-$PKGNAM
export PKG=$TMP/package-$PKGNAM
mkpkgdirs # Delete & re-create temporary directories then cd into $TMPBUILD

# Extract source:
tar xvvf $PORTCWD/sources/autoconf*.tar.xz
cd autoconf* || exit 1
slackhousekeeping

# Apply debian patches:
xzcat $PORTCWD/sources/*diff* | patch -p1
for i in debian/patches/*.diff ; do
  auto_apply_patch $i || exit 1
done

# Configure:
./configure \
   --prefix=/usr \
   --infodir=/usr/info \
   --mandir=/usr/man \
   --build=$ARCH-slackware-linux-gnueabi || failconfig

# Build:
make $NUMJOBS || make || exit 1

# Install into package:
make install DESTDIR=$PKG || exit 1

# Add the versioned symlinks, as some scripts look for them:
( cd $PKG/usr/bin
  for i in autoconf autoheader autoreconf autoupdate ifnames autoscan; do
     ln -vfs ${i} ${i}2.64
  done )

# If necessary, start the fakeroot server so we can set file/dir ownerships:
start_fakeroot

# Apply generic Slackware packaging policies:
cd $PKG
slackstripall   # strip all .a archives and all ELFs
slackgzpages -i # compress man & info pages and delete usr/info/dir
slackslack      # chown -R root:root, chmod -R og-w, slackchown, slack644docs
slackdesc       # install slack-desc and doinst.sh

# /extra has packages in separate dirs:
export PKGSERIES=$PKGSERIES/$PKGNAM

slackmp         # run makepkg -l y -c n

# Perform any final checks on the package:
cd $PKG
slackhlinks     # search for any hard links
