# Template file for 'plan9port'
pkgname=plan9port
version=20150410
revision=2
_githash=3aca22118d808597bc7451adc559d89460ed5a6e
wrksrc="${pkgname}-${_githash}"
hostmakedepends="which perl"
makedepends="libX11-devel libXt-devel libXext-devel freetype-devel fontconfig-devel"
short_desc="Port of many Plan 9 programs to Unix-like operating systems"
maintainer="Christian Neukirchen <chneukirchen@gmail.com>"
license="custom"
homepage="http://swtch.com/plan9port/"
distfiles="https://github.com/9fans/plan9port/archive/${_githash}.tar.gz"
checksum=6c00253ec08b3e5f8fdcfa5219998b3d71a7b135c85fc85d0451d7d0dee33da6
nocross=yes

do_build() {
	CFLAGS+=' -D_DEFAULT_SOURCE'
	echo "CFLAGS='$CFLAGS'" >LOCAL.config
	echo "LDFLAGS='$LDFLAGS'" >>LOCAL.config
	sed -i 's/-O2/$CFLAGS/' bin/9c

	./INSTALL
}
do_install() {
	xargs -a lib/moveplan9.files -d'\n' sed -i "s#$wrksrc#/opt/plan9#"

	vinstall $FILESDIR/plan9.sh 644 etc/profile.d
	vlicense LICENSE

	vmkdir opt
	cp -a $wrksrc $DESTDIR/opt/plan9
	cd $DESTDIR/opt/plan9
	rm -f install.{log,sum}
}
