# Template file for 'sam'
pkgname=sam
version=20161021
revision=1
_githash=463c87a908760e0220276a0ef58295c246485414
wrksrc="${pkgname}-${_githash}"
disable_parallel_build=yes
makedepends="libXft-devel libXt-devel"
short_desc="Screen editor with structural regular expressions"
maintainer="Christian Neukirchen <chneukirchen@gmail.com>"
license="MIT-like"
homepage="http://www.deadpixi.com/an-updated-version-of-sam"
distfiles="https://github.com/deadpixi/${pkgname}/archive/${_githash}.tar.gz"
checksum=786b0ddff35cb61eabee7ac213cd68e88d0484c0f5f30725e41a40702853fa05
CFLAGS="-std=c99"

post_extract() {
	sed -i '/-o rsam/s/$/ $(LDFLAGS)/' rsam/Makefile
	sed -i '/LDFLAGS/d' rsam/Makefile
}
do_build() {
	case "$XBPS_TARGET_MACHINE" in
		i686*|armv*) USE64BITS=0;;
		x86_64*|aarch64*) USE64BITS=1;;
		*) msg_error "Unknown word length for $XBPS_TARGET_MACHINE";;
	esac

	make ${makejobs} CC="${CC} ${CFLAGS}" DESTDIR=/usr LDFLAGS="$LDFLAGS" \
		INCLUDES=-I${XBPS_CROSS_BASE}/usr/include/freetype2 \
		RXSAMNAME=rsam TERMNAME=/usr/bin/samterm USE64BITS=${USE64BITS}
}

do_install() {
	vmkdir usr/bin
	vmkdir usr/share/man/man1
	make install DESTDIR=${DESTDIR}/usr

	vlicense LICENSE
	vdoc doc/se.ps
	vdoc doc/sam.tut.ms
}
