# Template file for 'mg'
pkgname=mg
version=20210314
revision=1
hostmakedepends="pkg-config"
makedepends="libbsd-devel ncurses-devel"
short_desc="Micro GNU/emacs"
maintainer="Orphaned <orphan@voidlinux.org>"
license="Public Domain"
homepage="https://github.com/hboetes/mg"
distfiles="https://github.com/hboetes/mg/archive/${version}.tar.gz"
checksum=6820e76a0e27d9a744624d421b3b30b0030140c2a817df1310b25c3abe397106

CFLAGS="-DTCSASOFT=0"

case "$XBPS_TARGET_MACHINE" in
	*-musl) CFLAGS+=" -DREG_STARTEND=0";;
esac

do_configure() {
	sed -i "s,\(BSD_CPPFLAGS:=\).*,\1 -isystem ${XBPS_CROSS_BASE}/usr/include/bsd -DLIBBSD_OVERLAY,g" GNUmakefile
	sed -i "s,\(BSD_LIBS:=\).*,\1 -lbsd,g" GNUmakefile
}
do_build() {
	make CC="$CC" CFLAGS="$CFLAGS" prefix=/usr ${makejobs}
}
do_install() {
	vmkdir usr/bin
	make install prefix=/usr bindir=/usr/bin mandir=/usr/share/man DESTDIR=${DESTDIR}
}