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