Revert "cuda.eclass: Attempt to fix unconditional dependency"
[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 #
4 # @ECLASS: mozconfig-v6.45.eclass
5 # @MAINTAINER:
6 # mozilla team <mozilla@gentoo.org>
7 # @SUPPORTED_EAPIS: 5 6 7
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 # @DEFAULT_UNSET
34 # @DESCRIPTION:
35 # Set this variable before the inherit line, when an ebuild needs to provide
36 # optional necko-wifi support via IUSE="wifi".  Currently this would include
37 # ebuilds for firefox, and potentially seamonkey.
38 #
39 # Leave the variable UNSET if necko-wifi support should not be available.
40 # Set the variable to "enabled" if the use flag should be enabled by default.
41 # Set the variable to any value if the use flag should exist but not be default-enabled.
42
43 # @ECLASS-VARIABLE: MOZCONFIG_OPTIONAL_JIT
44 # @DEFAULT_UNSET
45 # @DESCRIPTION:
46 # Set this variable before the inherit line, when an ebuild needs to provide
47 # optional necko-wifi support via IUSE="jit".  Currently this would include
48 # ebuilds for firefox, and potentially seamonkey.
49 #
50 # Leave the variable UNSET if optional jit support should not be available.
51 # Set the variable to "enabled" if the use flag should be enabled by default.
52 # Set the variable to any value if the use flag should exist but not be default-enabled.
53
54 # @ECLASS-VARIABLE: MOZCONFIG_OPTIONAL_GTK3
55 # @DEFAULT_UNSET
56 # @DESCRIPTION:
57 # Set this variable before the inherit line, when an ebuild can provide
58 # optional gtk3 support via IUSE="gtk3".  Currently this would include
59 # ebuilds for firefox, but thunderbird and seamonkey could follow in the future.
60 #
61 # Leave the variable UNSET if gtk3 support should not be available.
62 # Set the variable to "enabled" if the use flag should be enabled by default.
63 # Set the variable to any value if the use flag should exist but not be default-enabled.
64
65 # @ECLASS-VARIABLE: MOZCONFIG_OPTIONAL_QT5
66 # @DEFAULT_UNSET
67 # @DESCRIPTION:
68 # Set this variable before the inherit line, when an ebuild can provide
69 # optional qt5 support via IUSE="qt5".  Currently this would include
70 # ebuilds for firefox, but thunderbird and seamonkey could follow in the future.
71 #
72 # Leave the variable UNSET if qt5 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 # use-flags common among all mozilla ebuilds
77 IUSE="${IUSE} dbus debug ffmpeg +gstreamer +jemalloc3 neon pulseaudio selinux startup-notification system-cairo
78         system-harfbuzz system-icu system-jpeg system-libevent system-sqlite system-libvpx"
79
80 # some notes on deps:
81 # gtk:2 minimum is technically 2.10 but gio support (enabled by default) needs 2.14
82 # media-libs/mesa needs to be 10.2 or above due to a bug with flash+vdpau
83 # media-libs/libcanberra is dlopen'ed rather than linked
84
85 RDEPEND=">=app-text/hunspell-1.2:=
86         dev-libs/atk
87         dev-libs/expat
88         >=x11-libs/cairo-1.10[X]
89         >=x11-libs/gtk+-2.18:2
90         x11-libs/gdk-pixbuf
91         >=x11-libs/pango-1.22.0
92         >=media-libs/libpng-1.6.19:0=[apng]
93         >=media-libs/mesa-10.2:*
94         media-libs/fontconfig
95         >=media-libs/freetype-2.4.10
96         media-libs/libcanberra:*[pulseaudio?]
97         kernel_linux? ( media-libs/alsa-lib )
98         pulseaudio? ( media-sound/pulseaudio )
99         virtual/freedesktop-icon-theme
100         dbus? ( >=sys-apps/dbus-0.60
101                 >=dev-libs/dbus-glib-0.72 )
102         startup-notification? ( >=x11-libs/startup-notification-0.8 )
103         >=dev-libs/glib-2.26:2
104         >=sys-libs/zlib-1.2.3
105         >=virtual/libffi-3.0.10
106         ffmpeg? ( virtual/ffmpeg )
107         gstreamer? (
108                 >=media-libs/gstreamer-1.4.5:1.0
109                 >=media-libs/gst-plugins-base-1.4.5:1.0
110                 >=media-libs/gst-plugins-good-1.4.5:1.0
111                 >=media-plugins/gst-plugins-libav-1.4.5:1.0
112         )
113         x11-libs/libX11
114         x11-libs/libXcomposite
115         x11-libs/libXdamage
116         x11-libs/libXext
117         x11-libs/libXfixes
118         x11-libs/libXrender
119         x11-libs/libXt
120         system-cairo? ( >=x11-libs/cairo-1.12[X,xcb] >=x11-libs/pixman-0.19.2 )
121         system-icu? ( >=dev-libs/icu-51.1:= )
122         system-jpeg? ( >=media-libs/libjpeg-turbo-1.2.1 )
123         system-libevent? ( >=dev-libs/libevent-2.0:0= )
124         system-sqlite? ( >=dev-db/sqlite-3.9.1:3[secure-delete,debug=] )
125         system-harfbuzz? ( >=media-libs/harfbuzz-1.1.3:0=[graphite,icu] >=media-gfx/graphite2-1.3.8 )
126 "
127
128 if [[ ${PV/45.0*/} == "" ]]; then
129         RDEPEND+="
130         system-libvpx? ( >=media-libs/libvpx-1.3.0:0=[postproc] )"
131 else
132         # 45.1.0 and above bumped the libvpx requirement
133         RDEPEND+="
134         system-libvpx? ( >=media-libs/libvpx-1.5.0:0=[postproc] )"
135 fi
136
137 if [[ -n ${MOZCONFIG_OPTIONAL_GTK3} ]]; then
138         if [[ ${MOZCONFIG_OPTIONAL_GTK3} = "enabled" ]]; then
139                 IUSE+=" +gtk3"
140         else
141                 IUSE+=" gtk3"
142         fi
143         RDEPEND+="
144         gtk3? ( >=x11-libs/gtk+-3.4.0:3 )"
145 fi
146 if [[ -n ${MOZCONFIG_OPTIONAL_QT5} ]]; then
147         inherit qmake-utils
148         if [[ ${MOZCONFIG_OPTIONAL_QT5} = "enabled" ]]; then
149                 IUSE+=" +qt5"
150         else
151                 IUSE+=" qt5"
152         fi
153         RDEPEND+="
154         qt5? (
155                 dev-qt/qtcore:5
156                 dev-qt/qtgui:5
157                 dev-qt/qtnetwork:5
158                 dev-qt/qtprintsupport:5
159                 dev-qt/qtwidgets:5
160                 dev-qt/qtxml:5
161                 dev-qt/qtdeclarative:5
162         )"
163 fi
164 if [[ -n ${MOZCONFIG_OPTIONAL_WIFI} ]]; then
165         if [[ ${MOZCONFIG_OPTIONAL_WIFI} = "enabled" ]]; then
166                 IUSE+=" +wifi"
167         else
168                 IUSE+=" wifi"
169         fi
170         RDEPEND+="
171         wifi? (
172                 kernel_linux? ( >=sys-apps/dbus-0.60
173                         >=dev-libs/dbus-glib-0.72
174                         net-misc/networkmanager )
175         )"
176 fi
177 if [[ -n ${MOZCONFIG_OPTIONAL_JIT} ]]; then
178         if [[ ${MOZCONFIG_OPTIONAL_JIT} = "enabled" ]]; then
179                 IUSE+=" +jit"
180         else
181                 IUSE+=" jit"
182         fi
183 fi
184
185 DEPEND="app-arch/zip
186         app-arch/unzip
187         >=sys-devel/binutils-2.16.1
188         ${RDEPEND}"
189
190 RDEPEND+="
191         selinux? ( sec-policy/selinux-mozilla )"
192
193 # force system-icu if system-harfbuzz is set to avoid any potential ABI issues
194 REQUIRED_USE="
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         else
342                 mozconfig_annotate '' --disable-gstreamer
343         fi
344         mozconfig_use_enable pulseaudio
345
346         mozconfig_use_enable system-cairo
347         mozconfig_use_enable system-sqlite
348         mozconfig_use_with system-jpeg
349         mozconfig_use_with system-icu
350         mozconfig_use_with system-libvpx
351         mozconfig_use_with system-harfbuzz
352         mozconfig_use_with system-harfbuzz system-graphite2
353
354         # Modifications to better support ARM, bug 553364
355         if use neon ; then
356                 mozconfig_annotate '' --with-fpu=neon
357                 mozconfig_annotate '' --with-thumb=yes
358                 mozconfig_annotate '' --with-thumb-interwork=no
359         fi
360         if [[ ${CHOST} == armv* ]] ; then
361                 mozconfig_annotate '' --with-float-abi=hard
362                 mozconfig_annotate '' --enable-skia
363
364                 if ! use system-libvpx ; then
365                         sed -i -e "s|softfp|hard|" \
366                                 "${S}"/media/libvpx/moz.build
367                 fi
368         fi
369 }
370
371 # @FUNCTION: mozconfig_install_prefs
372 # @DESCRIPTION:
373 # Set preferences into the prefs.js file specified as a parameter to
374 # the function.  This sets both some common prefs to all mozilla
375 # packages, and any prefs that may relate to the use flags administered
376 # by mozconfig_config().
377 #
378 # Call this within src_install() phase, after copying the template
379 # prefs file (if any) from ${FILESDIR}
380 #
381 # Example:
382 #
383 # inherit mozconfig-v6.46
384 #
385 # src_install() {
386 #       cp "${FILESDIR}"/gentoo-default-prefs.js \
387 #       "${BUILD_OBJ_DIR}/dist/bin/browser/defaults/preferences/all-gentoo.js"  \
388 #       || die
389 #
390 #       mozconfig_install_prefs \
391 #       "${BUILD_OBJ_DIR}/dist/bin/browser/defaults/preferences/all-gentoo.js"
392 #
393 #       ...
394 # }
395
396 mozconfig_install_prefs() {
397         local prefs_file="${1}"
398
399         einfo "Adding prefs from mozconfig to ${prefs_file}"
400
401         # set dictionary path, to use system hunspell
402         echo "pref(\"spellchecker.dictionary_path\", \"${EPREFIX}/usr/share/myspell\");" \
403                 >>"${prefs_file}" || die
404
405         # force the graphite pref if system-harfbuzz is enabled, since the pref cant disable it
406         if use system-harfbuzz ; then
407                 echo "sticky_pref(\"gfx.font_rendering.graphite.enabled\",true);" \
408                         >>"${prefs_file}" || die
409         fi
410 }