# Description: Lightweight PDF and XPS viewer
# URL: https://www.mupdf.com/
# Maintainer: Juergen Daubert, jue at crux dot nu
# Depends on: glu harfbuzz libjpeg-turbo xorg-libxi
# Optional: freeglut openjpeg2 jbig2dec gumbo-parser

name=mupdf
version=1.24.1
release=1
source=(https://mupdf.com/downloads/archive/$name-$version-source.tar.lz)

build() {
	cd $name-$version-source

	PKGMK_MUPDF="USE_SYSTEM_LIBS=yes"

	prt-get isinst freeglut || PKGMK_MUPDF+=" USE_SYSTEM_GLUT=no"
	prt-get isinst openjpeg2 || PKGMK_MUPDF+=" USE_SYSTEM_OPENJPEG=no"
	prt-get isinst jbig2dec || PKGMK_MUPDF+=" USE_SYSTEM_JBIG2DEC=no"
	prt-get isinst gumbo-parser || PKGMK_MUPDF+=" USE_SYSTEM_GUMBO=no"

	make install $PKGMK_MUPDF\
		prefix=$PKG/usr \
		mandir=$PKG/usr/share/man \
		XCFLAGS="-fpic -fcommon"

	ln -s mupdf-gl $PKG/usr/bin/mupdf
	rm -r $PKG/usr/share/doc
}
