#!/bin/sh
#
# kTm port by Juzer
#
#       regards to hns & psych
#

# local config:
BUILD="1"
PACKAGE="gawk"

check() {
# Checking for configuration
# Downloading sources lists
INSTALLED="`ls -1 $PACKAGES/packages/|grep $PACKAGE-|cut -d "-" -f 1,2`"
$WGET -q ftp://ftp.gnu.org/gnu/gawk/
NEW=`grep $PACKAGE index.html|grep .tar|grep -v doc|grep -v ps|cut -d / -f 6|cut -d '"' -f 1|sed -e s/.tar.*//|tail -1`
#Checking for new version
    checkpkg
# clean
rm index.html
}

download() {
# Downloading version from "${VERFILE}"
$WGET -P $DOWNL http://ftp.gnu.org/pub/gnu/gawk/$SRC.tar.bz2
}

build() {
# Creating new
tar jxvf $DOWNL/$SRC.tar.bz2
cd $SRC
./configure \
    --prefix=/usr \
    --build=$TARGET --host=$TARGET || exit
make || exit
make install DESTDIR=$PKG || exit
( cd $PKG/usr/bin
  ln -sf $SRC gawk
  ln -sf p$SRC pgawk
)
mkdir -p $PKG/bin
mv $PKG/usr/bin/gawk* $PKG/bin
mv $PKG/usr/bin/awk $PKG/bin
( cd $PKG/usr/bin
  ln -sf ../../bin/awk .
  ln -sf ../../bin/gawk .
  ln -sf ../../bin/$SRC .
)

( cd $PKG/usr/info
  rm dir
)
strip $PKG/usr/libexec/awk/*
( cd $PKG/usr/man/man1
  rm -f pgawk.1
  ln -sf gawk.1.gz awk.1.gz
  ln -sf gawk.1.gz pgawk.1.gz
)
    postbuild
}

source "${DATA:-/usr/lib/ktm}/ktm.ports.sh"

