app-text/mupdf: ppc stable wrt bug #699980
[gentoo.git] / app-text / mupdf / mupdf-1.16.1.ebuild
1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=7
5
6 inherit flag-o-matic toolchain-funcs xdg desktop
7
8 DESCRIPTION="a lightweight PDF viewer and toolkit written in portable C"
9 HOMEPAGE="https://mupdf.com/"
10 SRC_URI="https://mupdf.com/downloads/archive/${P}-source.tar.xz"
11
12 LICENSE="AGPL-3"
13 SLOT="0/${PV}"
14 KEYWORDS="~alpha amd64 ~arm ~arm64 ~hppa ~ia64 ppc ~ppc64 s390 x86 ~amd64-linux ~ppc-macos ~x64-macos ~x86-macos"
15 IUSE="X +javascript libressl opengl ssl static-libs"
16
17 # Although we use the bundled, patched version of freeglut in mupdf (because of
18 # bug #653298), the best way to ensure that its dependencies are present is to
19 # install system's freeglut.
20 RDEPEND="
21         media-libs/freetype:2=[static-libs?]
22         media-libs/harfbuzz:=[static-libs?,truetype]
23         media-libs/jbig2dec:=[static-libs?]
24         media-libs/libpng:0=[static-libs?]
25         >=media-libs/openjpeg-2.1:2=[static-libs?]
26         virtual/jpeg[static-libs?]
27         opengl? ( >=media-libs/freeglut-3.0.0:= )
28         ssl? (
29                 libressl? ( >=dev-libs/libressl-2.8:0=[static-libs?] )
30                 !libressl? ( >=dev-libs/openssl-1.1:0=[static-libs?] )
31         )
32         X? (
33                 x11-libs/libX11[static-libs?]
34                 x11-libs/libXext[static-libs?]
35         )"
36 DEPEND="${RDEPEND}
37         virtual/pkgconfig"
38
39 REQUIRED_USE="opengl? ( !static-libs )"
40
41 S=${WORKDIR}/${P}-source
42
43 PATCHES=(
44         "${FILESDIR}"/${PN}-1.15-CFLAGS.patch
45         "${FILESDIR}"/${PN}-1.15-Makefile.patch
46         "${FILESDIR}"/${PN}-1.10a-add-desktop-pc-xpm-files.patch
47         # See bugs #662352
48         "${FILESDIR}"/${PN}-1.15-openssl-x11.patch
49 )
50
51 src_prepare() {
52         xdg_src_prepare
53         use hppa && append-cflags -ffunction-sections
54
55         use javascript || \
56                 sed -e '/* #define FZ_ENABLE_JS/ a\#define FZ_ENABLE_JS 0' \
57                         -i include/mupdf/fitz/config.h
58
59         # See bug #670832
60         use ssl && use libressl && eapply "${FILESDIR}"/${PN}-1.14-libressl.patch
61
62         sed -e "1iOS = Linux" \
63                 -e "1iCC = $(tc-getCC)" \
64                 -e "1iLD = $(tc-getLD)" \
65                 -e "1iAR = $(tc-getAR)" \
66                 -e "1iverbose = yes" \
67                 -e "1ibuild = debug" \
68                 -e "1iprefix = ${ED}/usr" \
69                 -e "1ilibdir = ${ED}/usr/$(get_libdir)" \
70                 -e "1idocdir = ${ED}/usr/share/doc/${PF}" \
71                 -i Makerules || die
72 }
73
74 _emake() {
75         # When HAVE_OBJCOPY is yes, we end up with a lot of QA warnings.
76
77         # We don't use system's freeglut because upstream has a special modified
78         # version of it that gives mupdf clipboard support. See bug #653298
79
80         # As of v1.15.0, mupdf started using symbols in mujs that were not part
81         # of any release. We thus go back to using the bundled version of it.
82         # Bug #685244
83         emake \
84                 GENTOO_PV=${PV} \
85                 HAVE_GLUT=$(usex opengl) \
86                 HAVE_LIBCRYPTO=$(usex ssl) \
87                 HAVE_X11=$(usex X) \
88                 USE_SYSTEM_LIBS=yes \
89                 USE_SYSTEM_MUJS=no \
90                 USE_SYSTEM_GLUT=no \
91                 HAVE_OBJCOPY=no \
92                 "$@"
93 }
94
95 src_compile() {
96         _emake XCFLAGS="-fpic"
97
98         use static-libs && \
99                 _emake build/debug/lib${PN}.a
100 }
101
102 src_install() {
103         if use X || use opengl ; then
104                 domenu platform/debian/${PN}.desktop
105                 doicon platform/debian/${PN}.xpm
106         else
107                 rm docs/man/${PN}.1
108         fi
109
110         _emake install
111
112         dosym libmupdf.so.${PV} /usr/$(get_libdir)/lib${PN}.so
113
114         use static-libs && \
115                 dolib.a build/debug/lib${PN}.a
116         if use opengl ; then
117                 einfo "mupdf symlink points to mupdf-gl (bug 616654)"
118                 dosym ${PN}-gl /usr/bin/${PN}
119         elif use X ; then
120                 einfo "mupdf symlink points to mupdf-x11 (bug 616654)"
121                 dosym ${PN}-x11 /usr/bin/${PN}
122         fi
123         insinto /usr/$(get_libdir)/pkgconfig
124         doins platform/debian/${PN}.pc
125
126         dodoc README CHANGES CONTRIBUTORS
127 }