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