1SUMMARY="A lightweight XPS and PDF rendering library"
2DESCRIPTION="The renderer in MuPDF is tailored for high quality anti-aliased \
3graphics. It renders text with metrics and spacing accurate to within \
4fractions of a pixel for the highest fidelity in reproducing the look of a \
5printed page on screen.
6
7MuPDF is also small, fast, and yet complete. It supports PDF 1.7 with \
8transparency, encryption, hyperlinks, annotations, searching and more. It also \
9reads XPS/OpenXPS documents and CBZ (Comic Book archive) files."
10HOMEPAGE="https://www.mupdf.com/"
11COPYRIGHT="2006-2022 Artifex Software, Inc"
12LICENSE="AGPL-3.0"
13REVISION="2"
14SOURCE_URI="https://mupdf.com/downloads/archive/mupdf-$portVersion-source.tar.gz"
15CHECKSUM_SHA256="6b60070f6eec20e8d87d2b5cd22cf49020311a3cf15ee10998e3e5f5f984b1eb"
16SOURCE_DIR="mupdf-$portVersion-source"
17PATCHES="mupdf-$portVersion.patchset"
18
19ARCHITECTURES="all !x86_gcc2"
20SECONDARY_ARCHITECTURES="x86"
21
22commandSuffix=$secondaryArchSuffix
23commandBinDir=$binDir
24if [ "$targetArchitecture" = x86_gcc2 ]; then
25	commandSuffix=
26	commandBinDir=$prefix/bin
27fi
28
29portVersionCompat="$portVersion compat >= ${portVersion%.**}"
30
31PROVIDES="
32	mupdf$secondaryArchSuffix = $portVersion
33	lib:libmupdf$secondaryArchSuffix = $portVersionCompat
34	"
35REQUIRES="
36	haiku$secondaryArchSuffix
37	lib:libcrypto$secondaryArchSuffix
38	lib:libcurl$secondaryArchSuffix
39	lib:libfreetype$secondaryArchSuffix
40	lib:libglib_2.0$secondaryArchSuffix
41	lib:libharfbuzz$secondaryArchSuffix
42	lib:libjbig2dec$secondaryArchSuffix
43	lib:libjpeg$secondaryArchSuffix
44	lib:libopenjp2$secondaryArchSuffix
45	lib:libz$secondaryArchSuffix
46	"
47
48PROVIDES_devel="
49	mupdf${secondaryArchSuffix}_devel = $portVersion
50	devel:libmupdf$secondaryArchSuffix = $portVersionCompat
51	"
52REQUIRES_devel="
53	mupdf$secondaryArchSuffix == $portVersion base
54	"
55
56SUMMARY_tools="Tools to convert, examine and rasterise PDF files"
57PROVIDES_tools="
58	mupdf${secondaryArchSuffix}_tools = $portVersion
59	cmd:muraster$commandSuffix
60	cmd:mutool$commandSuffix
61	"
62REQUIRES_tools="
63	haiku$secondaryArchSuffix
64	mupdf$secondaryArchSuffix == $portVersion base
65	lib:libcrypto$secondaryArchSuffix
66	lib:libfreetype$secondaryArchSuffix
67	lib:libharfbuzz$secondaryArchSuffix
68	lib:libjbig2dec$secondaryArchSuffix
69	lib:libjpeg$secondaryArchSuffix
70	lib:libopenjp2$secondaryArchSuffix
71	lib:libz$secondaryArchSuffix
72	"
73
74BUILD_REQUIRES="
75	haiku${secondaryArchSuffix}_devel
76	devel:libcrypto$secondaryArchSuffix
77	devel:libcurl$secondaryArchSuffix
78	devel:libfreetype$secondaryArchSuffix
79	devel:libglib_2.0$secondaryArchSuffix
80	devel:libharfbuzz$secondaryArchSuffix
81	devel:libjbig2dec$secondaryArchSuffix
82	devel:libjpeg$secondaryArchSuffix
83	devel:libopenjp2$secondaryArchSuffix
84	devel:libz$secondaryArchSuffix
85	"
86BUILD_PREREQUIRES="
87	cmd:find
88	cmd:gcc$secondaryArchSuffix
89	cmd:make
90	cmd:pkg_config$secondaryArchSuffix
91	"
92
93defineDebugInfoPackage mupdf$secondaryArchSuffix \
94	"$libDir"/libmupdf.so \
95	"$(getPackagePrefix tools)"/bin/mutool \
96	"$(getPackagePrefix tools)"/bin/muraster
97
98BUILD()
99{
100	# remove bundled and use system libaries where possible
101	rm -rf thirdparty/{curl,freetype,harfbuzz,jbig2dec,libjpeg,openjpeg,zlib}
102
103	# build shared library
104	make USE_SYSTEM_LIBS=yes USE_SYSTEM_GUMBO=no \
105		XCFLAGS=-fPIC shared=yes build=release $jobArgs
106}
107
108INSTALL()
109{
110	make USE_SYSTEM_LIBS=yes USE_SYSTEM_GUMBO=no \
111		shared=yes build=release install \
112		prefix=$prefix \
113		bindir=$commandBinDir \
114		docdir=$docDir \
115		libdir=$libDir \
116		incdir=$includeDir \
117		mandir=$manDir
118
119	prepareInstalledDevelLib libmupdf
120	fixPkgconfig
121
122	# devel package
123	packageEntries devel $developDir \
124		$docDir
125
126	# tools package
127	packageEntries tools $commandBinDir \
128		$manDir
129}
130