# Template file for 'sam'
pkgname=sam
version=20200206
revision=1
_githash=4d35598ce980dc4056901a843c0a628fb348cc1a
makedepends="libXft-devel libXi-devel libXt-devel"
short_desc="Screen editor with structural regular expressions"
maintainer="Leah Neukirchen <leah@vuxu.org>"
license="custom:MIT-like"
homepage="http://www.deadpixi.com/an-updated-version-of-sam"
distfiles="https://github.com/deadpixi/${pkgname}/archive/${_githash}.tar.gz"
checksum=51c4bf2124ae0f51a4f484efa60acb6e8d746bec62482050396cd489baa00b02
disable_parallel_build=yes
CFLAGS="-std=c99"

post_extract() {
	sed -i 's/ -sf / -sfr /' doc/Makefile
	sed -i '/Straddc/s/int/wchar_t/g' sam/sam.h
}
do_build() {
	local use64bits=0
	if [ "$XBPS_TARGET_WORDSIZE" = "64" ]; then
		use64bits=1
	fi

	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
}
