#!/bin/sh
PKGNAM=nmap
VERSION=4.60
BUILD=${BUILD:-3}

. /etc/pkghelpers
pkghelpers_env

rm -rf $PKG
mkdir -p $PKG

cd $TMP
rm -rf nmap-$VERSION
tar xjvf $CWD/nmap-$VERSION.tar.bz2 || exit 1
cd nmap-$VERSION

pkghelpers_permissions

CFLAGS=$SLKCFLAGS \
./configure \
  --prefix=/usr \
  --libdir=/usr/lib$LIBSUFFIX \
  --mandir=/usr/man \
  --build=$ARCH-$DISTRO-linux

make -j5 || exit 1

make prefix=$PKG/usr install

# This thing also has its head up its ass with regards to DESTDIR.
# We will simply kill it.
rm -f $PKG/usr/bin/uninstall_zenmap

mkdir -p $PKG/usr/share/{applications,pixmaps}
zcat $CWD/zenmap.desktop.gz > $PKG/usr/share/applications/zenmap.desktop
cat $CWD/nmap.png > $PKG/usr/share/pixmaps/nmap.png
strip $PKG/usr/bin/*
mkdir -p $PKG/usr/doc/nmap-$VERSION
cp -a \
  COPYING COPYING.OpenSSL HACKING INSTALL \
  $PKG/usr/doc/nmap-$VERSION
mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc

# Build the package:
cd $PKG
pkghelpers_fixup
pkghelpers_makepkg
