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