# Description: Netcat from OpenBSD rewritten by Debian
# URL:         https://packages.debian.org/sid/netcat-openbsd
# Maintainer:  Wawrzek Niewodniczanski, main at wawrzek dot name
# Depends on:  libbsd gnutls

name=netcat-openbsd
version=1.234
release=1
source=(
http://deb.debian.org/debian/pool/main/n/netcat-openbsd/netcat-openbsd_${version}.orig.tar.gz
http://deb.debian.org/debian/pool/main/n/netcat-openbsd/netcat-openbsd_${version}-2.debian.tar.xz
)

build(){
        CFLAGS="${CFLAGS} -I/usr/opt/libbsd/include"
        LDFLAGS="${LDFLAGS} -L/usr/opt/libbsd/lib"
        LD_LIBRARY_PATH="/usr/oprt/libbsd/lib"
        PKG_CONFIG_PATH="/usr/opt/libbsd/lib/pkgconfig"

	cd $name-$version

	# apply debian patches
	for i in `cat $SRC/debian/patches/series`; do
		patch -p1 -i $SRC/debian/patches/$i
	done

	gcc -o nc $CFLAGS -I. ${LDFLAGS} -lgnutls -lssl -lcrypto -lbsd -lresolv *.c
	install -D -m755 nc $PKG/usr/bin/nc
	install -D -m644 nc.1 $PKG/usr/share/man1/nc.1
}
