# Template file for 'sam'
pkgname=sam
version=20150204
revision=2
wrksrc="${pkgname}"
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="http://www.deadpixi.com/an-updated-version-of-sam/sam.tar.gz?attredirects=0&d=1>sam.tar.gz"
checksum=65006c3a7bcd5f4431719c2504dbce40f3ffbb53eb8e7114f0ab093c377f6a02

post_extract() {
	rm -f */*.a
}

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} \$(SYSFLAGS)" DESTDIR=/usr \
		FREETYPEINC=${XBPS_CROSS_BASE}/usr/include/freetype2 \
		RXSAMNAME=rsam TERMNAME=/usr/bin/samterm USE64BITS=${USE64BITS}
}

do_install() {
	vbin sam/sam
	vbin sam/samsave
	vbin samterm/samterm
	vbin rsam/rsam
	vbin doc/B
	vman doc/sam.1
	ln -s sam.1 ${DESTDIR}/usr/share/man/man1/samterm.1
	ln -s sam.1 ${DESTDIR}/usr/share/man/man1/B.1
	ln -s sam.1 ${DESTDIR}/usr/share/man/man1/sam.save.1
	ln -s sam.1 ${DESTDIR}/usr/share/man/man1/samsave.1
	ln -s sam.1 ${DESTDIR}/usr/share/man/man1/rsam.1
	vlicense LICENSE
	vdoc README
	vdoc doc/se.ps
	vdoc doc/sam.tut.ms
}
