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