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