*/*: Drop stable alpha keywords
[gentoo.git] / app-text / mupdf / mupdf-1.16.1.ebuild
1 # Copyright 1999-2020 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         "${FILESDIR}"/${PN}-1.16.1-freeglut-fg_gl2-gcc-10.patch
50 )
51
52 src_prepare() {
53         xdg_src_prepare
54         use hppa && append-cflags -ffunction-sections
55
56         use javascript || \
57                 sed -e '/* #define FZ_ENABLE_JS/ a\#define FZ_ENABLE_JS 0' \
58                         -i include/mupdf/fitz/config.h
59
60         # See bug #670832
61         use ssl && use libressl && eapply "${FILESDIR}"/${PN}-1.14-libressl.patch
62
63         sed -e "1iOS = Linux" \
64                 -e "1iCC = $(tc-getCC)" \
65                 -e "1iLD = $(tc-getLD)" \
66                 -e "1iAR = $(tc-getAR)" \
67                 -e "1iverbose = yes" \
68                 -e "1ibuild = debug" \
69                 -e "1iprefix = ${ED}/usr" \
70                 -e "1ilibdir = ${ED}/usr/$(get_libdir)" \
71                 -e "1idocdir = ${ED}/usr/share/doc/${PF}" \
72                 -i Makerules || die
73 }
74
75 _emake() {
76         # When HAVE_OBJCOPY is yes, we end up with a lot of QA warnings.
77
78         # We don't use system's freeglut because upstream has a special modified
79         # version of it that gives mupdf clipboard support. See bug #653298
80
81         # As of v1.15.0, mupdf started using symbols in mujs that were not part
82         # of any release. We thus go back to using the bundled version of it.
83         # Bug #685244
84         emake \
85                 GENTOO_PV=${PV} \
86                 HAVE_GLUT=$(usex opengl) \
87                 HAVE_LIBCRYPTO=$(usex ssl) \
88                 HAVE_X11=$(usex X) \
89                 USE_SYSTEM_LIBS=yes \
90                 USE_SYSTEM_MUJS=no \
91                 USE_SYSTEM_GLUT=no \
92                 HAVE_OBJCOPY=no \
93                 "$@"
94 }
95
96 src_compile() {
97         _emake XCFLAGS="-fpic"
98
99         use static-libs && \
100                 _emake build/debug/lib${PN}.a
101 }
102
103 src_install() {
104         if use X || use opengl ; then
105                 domenu platform/debian/${PN}.desktop
106                 doicon platform/debian/${PN}.xpm
107         else
108                 rm docs/man/${PN}.1
109         fi
110
111         _emake install
112
113         dosym libmupdf.so.${PV} /usr/$(get_libdir)/lib${PN}.so
114
115         use static-libs && \
116                 dolib.a build/debug/lib${PN}.a
117         if use opengl ; then
118                 einfo "mupdf symlink points to mupdf-gl (bug 616654)"
119                 dosym ${PN}-gl /usr/bin/${PN}
120         elif use X ; then
121                 einfo "mupdf symlink points to mupdf-x11 (bug 616654)"
122                 dosym ${PN}-x11 /usr/bin/${PN}
123         fi
124         insinto /usr/$(get_libdir)/pkgconfig
125         doins platform/debian/${PN}.pc
126
127         dodoc README CHANGES CONTRIBUTORS
128 }