1 # Distributed under the terms of the GNU General Public License v2
5 VIRTUALX_REQUIRED
="pgo"
8 inherit check-reqs flag-o-matic toolchain-funcs eutils gnome2-utils mozconfig-3 multilib pax-utils fdo-mime autotools mozextension versionator python virtualx nsplugins
10 MAJ_FF_PV
="$(get_version_component_range 1-2)" # 3.5, 3.6, 4.0, etc.
11 FF_PV
="${PV/_alpha/a}" # Handle alpha for SRC_URI
12 FF_PV
="${FF_PV/_beta/b}" # Handle beta for SRC_URI
13 FF_PV
="${FF_PV/_rc/rc}" # Handle rc for SRC_URI
14 CHANGESET
="e56ecd8b3a68"
15 PATCH
="${PN}-9.0-patches-0.4"
17 DESCRIPTION
="Firefox Web Browser"
18 HOMEPAGE
="http://www.mozilla.com/firefox"
20 KEYWORDS
="~amd64 ~arm ~ppc ~x86 ~amd64-linux ~x86-linux"
22 LICENSE
="|| ( MPL-1.1 GPL-2 LGPL-2.1 )"
23 IUSE
="bindist +crashreporter +ipc pgo system-sqlite +webm"
25 FTP_URI
="ftp://ftp.mozilla.org/pub/firefox/releases/"
26 # More URIs appended below...
27 SRC_URI
="http://dev.gentoo.org/~anarchy/mozilla/patchsets/${PATCH}.tar.xz"
29 ASM_DEPEND
=">=dev-lang/yasm-1.1"
31 # Mesa 7.10 needed for WebGL + bugfixes
33 >=sys-devel/binutils-2.16.1
36 >=dev-libs/glib-2.26:2
37 >=media-libs/mesa-7.10
38 media-libs/libpng[apng]
40 system-sqlite? ( >=dev-db/sqlite-3.7.7.1[fts3,secure-delete,unlock-notify,debug=] )
41 webm? ( >=media-libs/libvpx-0.9.7
43 crashreporter? ( net-misc/curl )"
44 # We don't use PYTHON_DEPEND/PYTHON_USE_WITH for some silly reason
48 =dev-lang/python-2*[sqlite]
50 webm? ( x86? ( ${ASM_DEPEND} )
51 amd64? ( ${ASM_DEPEND} ) )"
53 # No source releases for alpha|beta
54 if [[ ${PV} =~ alpha
]]; then
56 http://dev.gentoo.org/~anarchy/mozilla/firefox/firefox-${FF_PV}_${CHANGESET}.source.tar.bz2"
57 S
="${WORKDIR}/mozilla-central"
58 elif [[ ${PV} =~ beta
]]; then
60 ${FTP_URI}/${FF_PV}/source/firefox-${FF_PV}.source.tar.bz2"
61 S
="${WORKDIR}/mozilla-beta"
64 ${FTP_URI}/${FF_PV}/source/firefox-${FF_PV}.source.tar.bz2"
65 S
="${WORKDIR}/mozilla-release"
68 # No language packs for alphas
69 if ! [[ ${PV} =~ alpha|beta
]]; then
70 # This list can be updated with scripts/get_langs.sh from mozilla overlay
71 LANGS
=(af ak
ar ast be
bg bn-BD bn-IN br bs ca cs cy da de el en en-GB en-US
72 en-ZA eo es-AR es-CL es-ES es-MX et eu fa
fi fr fy-NL ga-IE gd gl gu-IN he
73 hi-IN hr hu hy-AM id is it ja kk kn ko ku lg lt lv mai mk ml mr nb-NO
nl
74 nn-NO nso or pa-IN pl pt-BR pt-PT
rm ro ru si sk sl son
sq sr sv-SE ta ta-LK
75 te th
tr uk vi zh-CN zh-TW zu
)
77 for X
in "${LANGS[@]}" ; do
78 # en and en_US are handled internally
79 if [[ ${X} != en
]] && [[ ${X} != en-US
]]; then
81 linguas_${X/-/_}? ( ${FTP_URI}/${FF_PV}/linux-i686/xpi/${X}.xpi -> ${P}-${X}.xpi )"
83 IUSE
="${IUSE} linguas_${X/-/_}"
84 # Install all the specific locale xpis if there's no generic locale xpi
85 # Example: there's no pt.xpi, so install all pt-*.xpi
86 if ! has
${X%%-*} "${LANGS[@]}"; then
88 linguas_${X%%-*}? ( ${FTP_URI}/${FF_PV}/linux-i686/xpi/${X}.xpi -> ${P}-${X}.xpi )"
89 IUSE
="${IUSE} linguas_${X%%-*}"
94 QA_PRESTRIPPED
="usr/$(get_libdir)/${PN}/firefox"
96 # TODO: Move all the linguas crap to an eclass
98 # Generate the list of language packs called "linguas"
99 # This list is used to install the xpi language packs
101 for LINGUA
in ${LINGUAS}; do
102 if has
${LINGUA} en en_US
; then
103 # For mozilla products, en and en_US are handled internally
105 # If this language is supported by ${P},
106 elif has
${LINGUA} "${LANGS[@]//-/_}"; then
107 # Add the language to linguas, if it isn't already there
108 has
${LINGUA//_/-} "${linguas[@]}" || linguas+=(${LINGUA//_/-})
110 # For each short LINGUA that isn't in LANGS,
111 # add *all* long LANGS to the linguas list
112 elif ! has
${LINGUA%%-*} "${LANGS[@]}"; then
113 for LANG
in "${LANGS[@]}"; do
114 if [[ ${LANG} == ${LINGUA}-* ]]; then
115 has
${LANG} "${linguas[@]}" || linguas+=(${LANG})
120 ewarn
"Sorry, but ${P} does not support the ${LINGUA} locale"
127 # Avoid PGO profiling problems due to enviroment leakage
128 # These should *always* be cleaned up anyway
129 unset DBUS_SESSION_BUS_ADDRESS \
136 if ! use bindist
; then
138 elog
"You are enabling official branding. You may not redistribute this build"
139 elog
"to any users on your network or the internet. Doing so puts yourself into"
140 elog
"a legal problem with Mozilla Foundation"
141 elog
"You can disable it by emerging ${PN} _with_ the bindist USE-flag"
146 ewarn
"You will do a double build for profile guided optimization."
147 ewarn
"This will result in your build taking at least twice as long as before."
150 # Ensure we have enough disk space to compile
152 CHECKREQS_DISK_BUILD
="8G"
155 CHECKREQS_DISK_BUILD
="4G"
164 for X
in "${linguas[@]}"; do
165 # FIXME: Add support for unpacking xpis to portage
166 xpi_unpack
"${P}-${X}.xpi"
172 EPATCH_SUFFIX
="patch" \
174 EPATCH_EXCLUDE
="5009_revert_bug_708572.patch 2001-gentoo_no_app_updates.patch 2003_fix_system_hunspell_dict_detection.patch 5002_allow_locked_prefs.patch 5004_properly_launch_applications_set_in_home.patch 5007_fix_libpr0n_nsPNGDecoder.patch 5008_revert_bug_468730.patch 6000_add_mips_hppa_ia64_s390_and_sparc_defines_in_ipc.patch 6002_use_a_pool_size_of_16kB_on_ia64.patch 6003_revert_bug_164580.patch 6004_ldrh_strh_ldrsb_strsb_arc_supported_on_armv5.patch 6005_reimplement_NS_InvokeByIndex_in_C_on_S390.patch 6010_avoid_invalid_conversions.patch" \
175 epatch
"${WORKDIR}/firefox"
177 # Allow user to apply any additional patches without modifing ebuild
180 # Enable gnomebreakpad
182 sed -i -e "s:GNOME_DISABLE_CRASH_DIALOG=1:GNOME_DISABLE_CRASH_DIALOG=0:g" \
183 "${S}"/build
/unix
/run-mozilla.sh || die
"sed failed!"
186 # Disable gnomevfs extension
187 sed -i -e "s:gnomevfs::" "${S}/"browser
/confvars.sh \
188 -e "s:gnomevfs::" "${S}/"xulrunner
/confvars.sh \
189 || die
"Failed to remove gnomevfs extension"
191 # Ensure that are plugins dir is enabled as default
192 sed -i -e "s:/usr/lib/mozilla/plugins:/usr/$(get_libdir)/nsbrowser/plugins:" \
193 "${S}"/xpcom
/io
/nsAppFileLocationProvider.cpp || die
"sed failed to replace plugin path!"
195 # Fix sandbox violations during make clean, bug 372817
196 sed -e "s:\(/no-such-file\):${T}\1:g" \
197 -i "${S}"/config
/rules.mk \
198 -i "${S}"/js
/src
/config
/rules.mk \
199 -i "${S}"/nsprpub
/configure
{.
in,} \
202 #Fix compilation with curl-7.21.7 bug 376027
203 sed -e '/#include <curl\/types.h>/d' \
204 -i "${S}"/toolkit
/crashreporter
/google-breakpad
/src
/common
/linux
/http_upload.cc \
205 -i "${S}"/toolkit
/crashreporter
/google-breakpad
/src
/common
/linux
/libcurl_wrapper.cc \
206 -i "${S}"/config
/system-headers \
207 -i "${S}"/js
/src
/config
/system-headers || die
"Sed failed"
213 MOZILLA_FIVE_HOME
="/usr/$(get_libdir)/${PN}"
214 MEXTENSIONS
="default"
216 ####################################
218 # mozconfig, CFLAGS and CXXFLAGS setup
220 ####################################
225 # It doesn't compile on alpha without this LDFLAGS
226 use alpha
&& append-ldflags
"-Wl,--no-relax"
228 mozconfig_annotate
'' --prefix="${EPREFIX}"/usr
229 mozconfig_annotate
'' --libdir="${EPREFIX}"/usr
/$
(get_libdir
)
230 mozconfig_annotate
'' --enable-extensions="${MEXTENSIONS}"
231 mozconfig_annotate
'' --disable-gconf
232 mozconfig_annotate
'' --disable-mailnews
233 mozconfig_annotate
'' --enable-canvas
234 mozconfig_annotate
'' --enable-safe-browsing
235 mozconfig_annotate
'' --with-system-png
236 mozconfig_annotate
'' --enable-system-ffi
238 # Other ff-specific settings
239 mozconfig_annotate
'' --with-default-mozilla-five-home=${MOZILLA_FIVE_HOME}
240 mozconfig_annotate
'' --target="${CTARGET:-${CHOST}}"
242 mozconfig_use_enable system-sqlite
244 # Allow for a proper pgo build
246 echo "mk_add_options PROFILE_GEN_SCRIPT='\$(PYTHON) \$(OBJDIR)/_profile/pgo/profileserver.py'" >> "${S}"/.mozconfig
249 # Finalize and report settings
252 if [[ $
(gcc-major-version
) -lt 4 ]]; then
253 append-cxxflags
-fno-stack-protector
254 elif [[ $
(gcc-major-version
) -gt 4 || $
(gcc-minor-version
) -gt 3 ]]; then
255 if use amd64 || use x86
; then
256 append-flags
-mno-avx
264 addpredict
/etc
/gconf
265 # Firefox tries to dri stuff when it's run, see bug 380283
267 local cards
=$
(echo -n /dev
/{dri
,ati
}/card
* /dev
/nvidiactl
* |
sed 's/ /:/g')
269 test -n "${cards}" && addpredict
"${cards}"
271 CC
="$(tc-getCC)" CXX
="$(tc-getCXX)" LD
="$(tc-getLD)" \
272 MOZ_MAKE_FLAGS
="${MAKEOPTS}" \
273 Xemake
-f client.mk profiledbuild || die
"Xemake failed"
275 CC
="$(tc-getCC)" CXX
="$(tc-getCXX)" LD
="$(tc-getLD)" \
276 MOZ_MAKE_FLAGS
="${MAKEOPTS}" \
277 emake
-f client.mk || die
"emake failed"
283 MOZILLA_FIVE_HOME
="/usr/$(get_libdir)/${PN}"
285 # MOZ_BUILD_ROOT, and hence OBJ_DIR change depending on arch, compiler, pgo, etc.
286 local obj_dir
="$(echo */config.log)"
287 obj_dir
="${obj_dir%/*}"
290 # Pax mark xpcshell for hardened support, only used for startupcache creation.
291 pax-mark m
"${S}/${obj_dir}"/dist
/bin
/xpcshell
293 # Add our default prefs for firefox + xulrunner
294 cp "${FILESDIR}"/gentoo-default-prefs.js-1 \
295 "${S}/${obj_dir}/dist/bin/defaults/pref/all-gentoo.js" || die
297 MOZ_MAKE_FLAGS
="${MAKEOPTS}" \
298 emake DESTDIR
="${D}" install || die
"emake install failed"
301 for X
in "${linguas[@]}"; do
302 xpi_install
"${WORKDIR}/${P}-${X}"
305 local size sizes icon_path icon name
308 icon_path
="${S}/browser/branding/unofficial"
309 # Firefox's new rapid release cycle means no more codenames
310 # Let's just stick with this one...
314 sizes
="16 22 24 32 256"
315 icon_path
="${S}/browser/branding/official"
317 name
="Mozilla Firefox"
320 # Install icons and .desktop for menu entry
321 for size
in ${sizes}; do
322 insinto
"/usr/share/icons/hicolor/${size}x${size}/apps"
323 newins
"${icon_path}/default${size}.png" "${icon}.png" || die
325 # The 128x128 icon has a different name
326 insinto
"/usr/share/icons/hicolor/128x128/apps"
327 newins
"${icon_path}/mozicon128.png" "${icon}.png" || die
328 # Install a 48x48 icon into /usr/share/pixmaps for legacy DEs
329 newicon
"${icon_path}/content/icon48.png" "${icon}.png" || die
330 newmenu
"${FILESDIR}/icon/${PN}.desktop" "${PN}.desktop" || die
331 sed -i -e "s:@NAME@:${name}:" -e "s:@ICON@:${icon}:" \
332 "${ED}/usr/share/applications/${PN}.desktop" || die
334 # Add StartupNotify=true bug 237317
335 if use startup-notification
; then
336 echo "StartupNotify=true" >> "${ED}/usr/share/applications/${PN}.desktop"
339 # Required in order to use plugins and even run firefox on hardened.
340 pax-mark m
"${ED}"${MOZILLA_FIVE_HOME}/{firefox,firefox-bin,plugin-container}
345 # very ugly hack to make firefox not sigbus on sparc
346 # FIXME: is this still needed??
347 use sparc && { sed -e 's/Firefox/FirefoxGentoo/g' \
348 -i "${ED}/${MOZILLA_FIVE_HOME}/application.ini
" || \
349 die "sparc
sed failed
"; }
357 # Update mimedb for the new .desktop file
358 fdo-mime_desktop_database_update
359 gnome2_icon_cache_update
363 gnome2_icon_cache_update