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