# Template file for 'nawk'
pkgname=nawk
version=20121220
revision=5
create_wrksrc=yes
hostmakedepends="bison"
short_desc="The one, true implementation of AWK"
maintainer="Juan RP <xtraeme@voidlinux.eu>"
license="BSD"
homepage="http://cm.bell-labs.com/who/bwk/"
distfiles="http://www.cs.princeton.edu/~bwk/btl.mirror/awk.tar.gz"
checksum=8dc092165c5a4e1449f964286483d06d0dbfba4b0bd003cb5dab30de8f6d9b83

provides="awk-0_1"
alternatives="
 awk:awk:/usr/bin/nawk
 awk:awk.1:/usr/share/man/man1/nawk.1"

do_configure() {
	sed -i '/maketab/{s/CC/BUILD_CC/;s/CFLAGS/BUILD_CFLAGS/}' makefile
	sed -i '/YACC = yacc -d -S/ s|^|#|' makefile
	sed -n '/Copyright/,/THIS SOFTWARE\./p' README > LICENSE
	sed -i 's/-lm/$(LDFLAGS) &/' makefile
}
do_build() {
	make CC=$CC CFLAGS="$CFLAGS" CPPFLAGS="$CPPFLAGS -DHAS_ISBLANK" LDFLAGS="$LDFLAGS"
}
do_install() {
	vbin a.out nawk
	vman awk.1 nawk.1
	vlicense LICENSE
}
