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