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