dev-python/hypothesis: Bump to 5.8.3
[gentoo.git] / eclass / mozconfig-v6.52.eclass
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3 #
4 # @ECLASS: mozconfig-v6.52.eclass
5 # @MAINTAINER:
6 # mozilla team <mozilla@gentoo.org>
7 # @SUPPORTED_EAPIS: 5 6 7
8 # @BLURB: the new mozilla common configuration eclass for FF33 and newer, v6
9 # @DESCRIPTION:
10 # This eclass is used in mozilla ebuilds (firefox, thunderbird, seamonkey)
11 # to provide a single common place for the common mozilla engine compoments.
12 #
13 # The eclass provides all common dependencies as well as common use flags.
14 #
15 # Some use flags which may be optional in particular mozilla packages can be
16 # supported through setting eclass variables.
17 #
18 # This eclass inherits mozconfig helper functions as defined in mozcoreconf-v3,
19 # and so ebuilds inheriting this eclass do not need to inherit that.
20
21 case ${EAPI} in
22         0|1|2|3|4)
23                 die "EAPI=${EAPI} not supported"
24                 ;;
25         5)
26                 inherit multilib
27                 ;;
28 esac
29
30 inherit flag-o-matic toolchain-funcs mozcoreconf-v5
31
32 # @ECLASS-VARIABLE: MOZCONFIG_OPTIONAL_WIFI
33 # @DEFAULT_UNSET
34 # @DESCRIPTION:
35 # Set this variable before the inherit line, when an ebuild needs to provide
36 # optional necko-wifi support via IUSE="wifi".  Currently this would include
37 # ebuilds for firefox, and potentially seamonkey.
38 #
39 # Leave the variable UNSET if necko-wifi support should not be available.
40 # Set the variable to "enabled" if the use flag should be enabled by default.
41 # Set the variable to any value if the use flag should exist but not be default-enabled.
42
43 # @ECLASS-VARIABLE: MOZCONFIG_OPTIONAL_JIT
44 # @DEFAULT_UNSET
45 # @DESCRIPTION:
46 # Set this variable before the inherit line, when an ebuild needs to provide
47 # deterministic jit support via IUSE="jit".  The upstream default will be used
48 # otherwise, which is generally to enable jit unless support for the platform
49 # is missing.
50 #
51 # Set the variable to "enabled" if the use flag should be enabled by default.
52 # Set the variable to any value if the use flag should exist but not be default-enabled.
53
54 # @ECLASS-VARIABLE: MOZCONFIG_OPTIONAL_GTK3
55 # @DEFAULT_UNSET
56 # @DESCRIPTION:
57 # Set this variable before the inherit line, when an ebuild can provide
58 # optional gtk3 support via IUSE="force-gtk3".  Currently this would include
59 # thunderbird and seamonkey in the future, once support is ready for testing.
60 #
61 # Leave the variable UNSET if gtk3 support should not be optionally available.
62 # Set the variable to "enabled" if the use flag should be enabled by default.
63 # Set the variable to any value if the use flag should exist but not be default-enabled.
64 # If gtk+:3 is to be the standard toolkit, do not use this and instead use
65 # MOZCONFIG_OPTIONAL_GTK2ONLY.
66
67 # @ECLASS-VARIABLE: MOZCONFIG_OPTIONAL_GTK2ONLY
68 # @DEFAULT_UNSET
69 # @DESCRIPTION:
70 # Set this variable before the inherit line, when an ebuild can provide
71 # optional gtk2-only support via IUSE="gtk2".
72 #
73 # Note that this option conflicts directly with MOZCONFIG_OPTIONAL_GTK3, both
74 # variables cannot be set at the same time and this variable will be ignored if
75 # MOZCONFIG_OPTIONAL_GTK3 is set.
76 #
77 # Leave the variable UNSET if gtk2-only support should not be available.
78 # Set the variable to "enabled" if the use flag should be enabled by default.
79 # Set the variable to any value if the use flag should exist but not be default-enabled.
80
81 # @ECLASS-VARIABLE: MOZCONFIG_OPTIONAL_QT5
82 # @DEFAULT_UNSET
83 # @DESCRIPTION:
84 # Set this variable before the inherit line, when an ebuild can provide
85 # optional qt5 support via IUSE="qt5".  Currently this would include
86 # ebuilds for firefox, but thunderbird and seamonkey could follow in the future.
87 #
88 # Leave the variable UNSET if qt5 support should not be available.
89 # Set the variable to "enabled" if the use flag should be enabled by default.
90 # Set the variable to any value if the use flag should exist but not be default-enabled.
91
92 # use-flags common among all mozilla ebuilds
93 IUSE="${IUSE} dbus debug +jemalloc neon pulseaudio selinux startup-notification system-cairo
94         system-harfbuzz system-icu system-jpeg system-libevent system-sqlite system-libvpx"
95
96 # some notes on deps:
97 # gtk:2 minimum is technically 2.10 but gio support (enabled by default) needs 2.14
98 # media-libs/mesa needs to be 10.2 or above due to a bug with flash+vdpau
99
100 RDEPEND=">=app-text/hunspell-1.2:=
101         dev-libs/atk
102         dev-libs/expat
103         >=x11-libs/cairo-1.10[X]
104         >=x11-libs/gtk+-2.18:2
105         x11-libs/gdk-pixbuf
106         >=x11-libs/pango-1.22.0
107         >=media-libs/libpng-1.6.25:0=[apng]
108         >=media-libs/mesa-10.2:*
109         media-libs/fontconfig
110         >=media-libs/freetype-2.4.10
111         kernel_linux? ( !pulseaudio? ( media-libs/alsa-lib ) )
112         pulseaudio? ( || ( media-sound/pulseaudio
113                 >=media-sound/apulse-0.1.9 ) )
114         virtual/freedesktop-icon-theme
115         dbus? ( >=sys-apps/dbus-0.60
116                 >=dev-libs/dbus-glib-0.72 )
117         startup-notification? ( >=x11-libs/startup-notification-0.8 )
118         >=dev-libs/glib-2.26:2
119         >=sys-libs/zlib-1.2.3
120         >=virtual/libffi-3.0.10
121         virtual/ffmpeg
122         x11-libs/libX11
123         x11-libs/libXcomposite
124         x11-libs/libXdamage
125         x11-libs/libXext
126         x11-libs/libXfixes
127         x11-libs/libXrender
128         x11-libs/libXt
129         system-cairo? ( >=x11-libs/cairo-1.12[X,xcb(+)] >=x11-libs/pixman-0.19.2 )
130         system-icu? ( >=dev-libs/icu-58.1:= )
131         system-jpeg? ( >=media-libs/libjpeg-turbo-1.2.1 )
132         system-libevent? ( >=dev-libs/libevent-2.0:0=[threads] )
133         system-sqlite? ( >=dev-db/sqlite-3.17.0:3[secure-delete,debug=] )
134         system-libvpx? ( >=media-libs/libvpx-1.5.0:0=[postproc] )
135         system-harfbuzz? ( >=media-libs/harfbuzz-1.3.3:0= >=media-gfx/graphite2-1.3.8 )
136 "
137
138 if [[ -n ${MOZCONFIG_OPTIONAL_GTK3} ]]; then
139         MOZCONFIG_OPTIONAL_GTK2ONLY=
140         if [[ ${MOZCONFIG_OPTIONAL_GTK3} = "enabled" ]]; then
141                 IUSE+=" +force-gtk3"
142         else
143                 IUSE+=" force-gtk3"
144         fi
145         RDEPEND+=" force-gtk3? ( >=x11-libs/gtk+-3.4.0:3 )"
146 elif [[ -n ${MOZCONFIG_OPTIONAL_GTK2ONLY} ]]; then
147         if [[ ${MOZCONFIG_OPTIONAL_GTK2ONLY} = "enabled" ]]; then
148                 IUSE+=" +gtk2"
149         else
150                 IUSE+=" gtk2"
151         fi
152         RDEPEND+=" !gtk2? ( >=x11-libs/gtk+-3.4.0:3 )"
153 fi
154 if [[ -n ${MOZCONFIG_OPTIONAL_WIFI} ]]; then
155         if [[ ${MOZCONFIG_OPTIONAL_WIFI} = "enabled" ]]; then
156                 IUSE+=" +wifi"
157         else
158                 IUSE+=" wifi"
159         fi
160         RDEPEND+="
161         wifi? (
162                 kernel_linux? ( >=sys-apps/dbus-0.60
163                         >=dev-libs/dbus-glib-0.72
164                         net-misc/networkmanager )
165         )"
166 fi
167
168 DEPEND="app-arch/zip
169         app-arch/unzip
170         >=sys-devel/binutils-2.16.1
171         sys-apps/findutils
172         pulseaudio? ( media-sound/pulseaudio )
173         ${RDEPEND}"
174
175 RDEPEND+="
176         pulseaudio? ( || ( media-sound/pulseaudio
177                 >=media-sound/apulse-0.1.9 ) )
178         selinux? ( sec-policy/selinux-mozilla )"
179
180 # @FUNCTION: mozconfig_config
181 # @DESCRIPTION:
182 # Set common configure options for mozilla packages.
183 # Call this within src_configure() phase, after mozconfig_init
184 #
185 # Example:
186 #
187 # inherit mozconfig-v6.46
188 #
189 # src_configure() {
190 #       mozconfig_init
191 #       mozconfig_config
192 #       # ... misc ebuild-unique settings via calls to
193 #       # ... mozconfig_{annotate,use_with,use_enable}
194 #       mozconfig_final
195 # }
196
197 mozconfig_config() {
198         # Migrated from mozcoreconf-2
199         mozconfig_annotate 'system_libs' \
200                 --with-system-zlib \
201                 --with-system-bz2
202
203         if has bindist ${IUSE}; then
204                 mozconfig_use_enable !bindist official-branding
205                 if [[ ${PN} == firefox ]] && use bindist ; then
206                         mozconfig_annotate '' --with-branding=browser/branding/aurora
207                 fi
208         fi
209
210         # Enable position independent executables
211         mozconfig_annotate 'enabled by Gentoo' --enable-pie
212         mozconfig_use_enable debug
213         mozconfig_use_enable debug tests
214
215         if ! use debug ; then
216                 mozconfig_annotate 'disabled by Gentoo' --disable-debug-symbols
217         else
218                 mozconfig_annotate 'enabled by Gentoo' --enable-debug-symbols
219         fi
220
221         mozconfig_use_enable startup-notification
222
223         if [[ -n ${MOZCONFIG_OPTIONAL_WIFI} ]] ; then
224                 # wifi pulls in dbus so manage both here
225                 mozconfig_use_enable wifi necko-wifi
226                 if use kernel_linux && use wifi && ! use dbus; then
227                         echo "Enabling dbus support due to wifi request"
228                         mozconfig_annotate 'dbus required by necko-wifi on linux' --enable-dbus
229                 else
230                         mozconfig_use_enable dbus
231                 fi
232         else
233                 mozconfig_use_enable dbus
234                 mozconfig_annotate 'disabled' --disable-necko-wifi
235         fi
236
237         if [[ -n ${MOZCONFIG_OPTIONAL_JIT} ]]; then
238                 mozconfig_use_enable jit ion
239         fi
240
241         # These are enabled by default in all mozilla applications
242         mozconfig_annotate '' --with-system-nspr --with-nspr-prefix="${SYSROOT}${EPREFIX}"/usr
243         mozconfig_annotate '' --with-system-nss --with-nss-prefix="${SYSROOT}${EPREFIX}"/usr
244         mozconfig_annotate '' --x-includes="${SYSROOT}${EPREFIX}"/usr/include --x-libraries="${SYSROOT}${EPREFIX}"/usr/$(get_libdir)
245         if use system-libevent; then
246                 mozconfig_annotate '' --with-system-libevent="${SYSROOT}${EPREFIX}"/usr
247         fi
248         mozconfig_annotate '' --prefix="${EPREFIX}"/usr
249         mozconfig_annotate '' --libdir="${EPREFIX}"/usr/$(get_libdir)
250         mozconfig_annotate 'Gentoo default' --enable-system-hunspell
251         mozconfig_annotate '' --disable-gnomeui
252         mozconfig_annotate '' --enable-gio
253         mozconfig_annotate '' --disable-crashreporter
254         mozconfig_annotate 'Gentoo default' --with-system-png
255         mozconfig_annotate '' --enable-system-ffi
256         mozconfig_annotate 'Gentoo default to honor system linker' --disable-gold
257         mozconfig_annotate '' --disable-gconf
258         mozconfig_annotate '' --with-intl-api
259
260         # skia has no support for big-endian platforms
261         if [[ $(tc-endian) == "big" ]]; then
262                 mozconfig_annotate 'big endian target' --disable-skia
263         else
264                 mozconfig_annotate '' --enable-skia
265         fi
266
267         # default toolkit is cairo-gtk2, optional use flags can change this
268         local toolkit="cairo-gtk2"
269         local toolkit_comment=""
270         if [[ -n ${MOZCONFIG_OPTIONAL_GTK3} ]]; then
271                 if use force-gtk3; then
272                         toolkit="cairo-gtk3"
273                         toolkit_comment="force-gtk3 use flag"
274                 fi
275         fi
276         if [[ -n ${MOZCONFIG_OPTIONAL_GTK2ONLY} ]]; then
277                 if ! use gtk2 ; then
278                         toolkit="cairo-gtk3"
279                 else
280                         toolkit_comment="gtk2 use flag"
281                 fi
282         fi
283         if [[ -n ${MOZCONFIG_OPTIONAL_QT5} ]]; then
284                 if use qt5; then
285                         toolkit="cairo-qt"
286                         toolkit_comment="qt5 use flag"
287                         # need to specify these vars because the qt5 versions are not found otherwise,
288                         # and setting --with-qtdir overrides the pkg-config include dirs
289                         local i
290                         for i in qmake moc rcc; do
291                                 echo "export HOST_${i^^}=\"$(qt5_get_bindir)/${i}\"" \
292                                         >> "${S}"/.mozconfig || die
293                         done
294                         echo 'unset QTDIR' >> "${S}"/.mozconfig || die
295                         mozconfig_annotate '+qt5' --disable-gio
296                 fi
297         fi
298         mozconfig_annotate "${toolkit_comment}" --enable-default-toolkit=${toolkit}
299
300         # Use jemalloc unless libc is not glibc >= 2.4
301         # at this time the minimum glibc in the tree is 2.9 so we should be safe.
302         if use elibc_glibc && use jemalloc; then
303                 # We must force-enable jemalloc 4 via .mozconfig
304                 echo "export MOZ_JEMALLOC4=1" >> "${S}"/.mozconfig || die
305                 mozconfig_annotate '' --enable-replace-malloc
306         fi
307
308         # Instead of the standard --build= and --host=, mozilla uses --host instead
309         # of --build, and --target intstead of --host.
310         # Note, mozilla also has --build but it does not do what you think it does.
311         # Set both --target and --host as mozilla uses python to guess values otherwise
312         mozconfig_annotate '' --target="${CHOST}"
313         mozconfig_annotate '' --host="${CBUILD:-${CHOST}}"
314
315         mozconfig_use_enable pulseaudio
316         # force the deprecated alsa sound code if pulseaudio is disabled
317         if use kernel_linux && ! use pulseaudio ; then
318                 mozconfig_annotate '-pulseaudio' --enable-alsa
319         fi
320
321         mozconfig_use_enable system-cairo
322         mozconfig_use_enable system-sqlite
323         mozconfig_use_with system-jpeg
324         mozconfig_use_with system-icu
325         mozconfig_use_with system-libvpx
326         mozconfig_use_with system-harfbuzz
327         mozconfig_use_with system-harfbuzz system-graphite2
328
329         # Modifications to better support ARM, bug 553364
330         if use neon ; then
331                 mozconfig_annotate '' --with-fpu=neon
332                 mozconfig_annotate '' --with-thumb=yes
333                 mozconfig_annotate '' --with-thumb-interwork=no
334         fi
335         if [[ ${CHOST} == armv* ]] ; then
336                 mozconfig_annotate '' --with-float-abi=hard
337                 if ! use system-libvpx ; then
338                         sed -i -e "s|softfp|hard|" \
339                                 "${S}"/media/libvpx/moz.build
340                 fi
341         fi
342 }
343
344 # @FUNCTION: mozconfig_install_prefs
345 # @DESCRIPTION:
346 # Set preferences into the prefs.js file specified as a parameter to
347 # the function.  This sets both some common prefs to all mozilla
348 # packages, and any prefs that may relate to the use flags administered
349 # by mozconfig_config().
350 #
351 # Call this within src_install() phase, after copying the template
352 # prefs file (if any) from ${FILESDIR}
353 #
354 # Example:
355 #
356 # inherit mozconfig-v6.46
357 #
358 # src_install() {
359 #       cp "${FILESDIR}"/gentoo-default-prefs.js \
360 #       "${BUILD_OBJ_DIR}/dist/bin/browser/defaults/preferences/all-gentoo.js"  \
361 #       || die
362 #
363 #       mozconfig_install_prefs \
364 #       "${BUILD_OBJ_DIR}/dist/bin/browser/defaults/preferences/all-gentoo.js"
365 #
366 #       ...
367 # }
368
369 mozconfig_install_prefs() {
370         local prefs_file="${1}"
371
372         einfo "Adding prefs from mozconfig to ${prefs_file}"
373
374         # set dictionary path, to use system hunspell
375         echo "pref(\"spellchecker.dictionary_path\", \"${EPREFIX}/usr/share/myspell\");" \
376                 >>"${prefs_file}" || die
377
378         # force the graphite pref if system-harfbuzz is enabled, since the pref cant disable it
379         if use system-harfbuzz ; then
380                 echo "sticky_pref(\"gfx.font_rendering.graphite.enabled\",true);" \
381                         >>"${prefs_file}" || die
382         fi
383
384         # force cairo as the canvas renderer on platforms without skia support
385         if [[ $(tc-endian) == "big" ]] ; then
386                 echo "sticky_pref(\"gfx.canvas.azure.backends\",\"cairo\");" \
387                         >>"${prefs_file}" || die
388                 echo "sticky_pref(\"gfx.content.azure.backends\",\"cairo\");" \
389                         >>"${prefs_file}" || die
390         fi
391 }