1SUMMARY="Open source Portable Document Format (PDF) viewer"
2DESCRIPTION="Xpdf is a free PDF viewer and toolkit, including a text extractor, image \
3converter, HTML converter, and more. Most of the tools are available as \
4open source."
5HOMEPAGE="https://www.xpdfreader.com/"
6COPYRIGHT="1996-2024 Glyph & Cog, LLC."
7LICENSE="GNU GPL v2"
8REVISION="1"
9SOURCE_URI="http://dl.xpdfreader.com/xpdf-$portVersion.tar.gz"
10CHECKSUM_SHA256="92707ed5acb6584fbd73f34091fda91365654ded1f31ba72f0970022cf2a5cea"
11SOURCE_DIR="xpdf-$portVersion"
12PATCHES="xpdf-$portVersion.patchset"
13ADDITIONAL_FILES="xpdfreader.rdef.in"
14
15ARCHITECTURES="all !x86_gcc2"
16SECONDARY_ARCHITECTURES="x86"
17
18# On x86_gcc2 we don't want to install the commands in bin/<arch>/, but in bin/.
19commandSuffix=$secondaryArchSuffix
20commandBinDir=$binDir
21if [ "$targetArchitecture" = x86_gcc2 ]; then
22	commandSuffix=
23	commandBinDir=$prefix/bin
24fi
25
26PROVIDES="
27	xpdf$secondaryArchSuffix = $portVersion
28	app:XpdfViewer$commandSuffix = $portVersion
29	cmd:pdftopng$commandSuffix = $portVersion
30	cmd:xpdf$commandSuffix = $portVersion
31	"
32REQUIRES="
33	haiku$secondaryArchSuffix
34	urw_base35_fonts
35	lib:libfontconfig$secondaryArchSuffix
36	lib:libfreetype$secondaryArchSuffix
37	lib:libjpeg$secondaryArchSuffix
38	lib:libpaper$secondaryArchSuffix
39	lib:libpng16$secondaryArchSuffix
40	lib:libQt5Core$secondaryArchSuffix
41	lib:libQt5Gui$secondaryArchSuffix
42	lib:libQt5Widgets$secondaryArchSuffix
43	lib:libtiff$secondaryArchSuffix
44	lib:libz$secondaryArchSuffix
45	"
46
47BUILD_REQUIRES="
48	haiku${secondaryArchSuffix}_devel
49	devel:libfontconfig$secondaryArchSuffix
50	devel:libfreetype$secondaryArchSuffix
51	devel:libjpeg$secondaryArchSuffix
52	devel:libpaper$secondaryArchSuffix
53	devel:libpng16$secondaryArchSuffix
54	devel:libQt5Core$secondaryArchSuffix
55	devel:libQt5Gui$secondaryArchSuffix
56	devel:libQt5Widgets$secondaryArchSuffix
57	devel:libtiff$secondaryArchSuffix
58	devel:libz$secondaryArchSuffix
59	"
60BUILD_PREREQUIRES="
61	cmd:awk
62	cmd:cmake
63	cmd:gcc$secondaryArchSuffix
64	cmd:ld$secondaryArchSuffix
65	cmd:make
66	"
67
68BUILD()
69{
70	cmake -B build -S . -DCMAKE_BUILD_TYPE=Release \
71		-DCMAKE_INSTALL_PREFIX=$prefix \
72		-DCMAKE_INSTALL_MANDIR=$manDir \
73		-DSPLASH_CMYK=ON -L
74	make -C build $jobArgs
75}
76
77INSTALL()
78{
79	make -C build install
80
81	mkdir -p $appsDir
82	mv $prefix/bin/xpdf $appsDir/XpdfReader
83	ln -s $appsDir/XpdfReader $prefix/bin/xpdf
84
85	# remove stuff provided by poppler
86	for tool in pdfdetach pdffonts pdfimages pdfinfo pdftoppm pdftops pdftotext pdftohtml; do
87		rm "$commandBinDir/${tool}" "$manDir/man1/${tool}.1"
88	done
89
90	local APP_SIGNATURE="application/x-vnd.xpdf"
91	local MAJOR="`echo "$portVersion" | cut -d. -f1`"
92	local MIDDLE="`echo "$portVersion" | cut -d. -f2`"
93	local MINOR="`echo "$portVersion" | cut -d. -f3`"
94	local MINOR="01"
95	local LONG_INFO="$SUMMARY"
96	sed \
97		-e "s|@APP_SIGNATURE@|$APP_SIGNATURE|" \
98		-e "s|@MAJOR@|$MAJOR|" \
99		-e "s|@MIDDLE@|$MIDDLE|" \
100		-e "s|@MINOR@|$MINOR|" \
101		-e "s|@LONG_INFO@|$LONG_INFO|" \
102		$portDir/additional-files/xpdfreader.rdef.in > xpdfreader.rdef
103
104	addResourcesToBinaries xpdfreader.rdef $appsDir/XpdfReader
105	addAppDeskbarSymlink $appsDir/XpdfReader
106}
107