# Template file for 'groff'
pkgname=groff
version=1.22.4
revision=3
build_style=gnu-configure
configure_args="--without-x --disable-rpath"
hostmakedepends="texinfo perl bison ghostscript"
makedepends="zlib-devel"
short_desc="GNU troff text-formatting system"
maintainer="Enno Boland <gottox@voidlinux.org>"
license="GPL-3.0-or-later"
homepage="https://www.gnu.org/software/groff/groff.html"
distfiles="${GNU_SITE}/${pkgname}/${pkgname}-${version}.tar.gz"
checksum=e78e7b4cb7dec310849004fa88847c44701e8d133b5d4c13057d876c1bad0293

subpackages="libgroff"

if [ "$CROSS_BUILD" ]; then
	hostmakedepends+=" groff"
	configure_args+=" --with-doc=no"
else
	subpackages+=" groff-doc"
fi

pre_configure() {
	case "$XBPS_TARGET_MACHINE" in
		*musl)
			patch -p0 -i ${FILESDIR}/musl.patch
		;;
	esac
}

post_install() {
	# From Arch:
	#
	# Fix some issues when encoding to utf8 man pages
	# The output chars don't match keyboard chars...
	for f in man mdoc; do
		cat ${FILESDIR}/site.tmac >> \
			${DESTDIR}/usr/share/groff/site-tmac/${f}.local
	done
}

libgroff_package() {
	short_desc+=" - libraries"
	pkg_install() {
		vmove usr/lib
	}
}

groff-doc_package() {
	short_desc+=" - documentation"
	pkg_install() {
		vmove usr/share/doc
	}
}
