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