1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
|
# Copyright 1999-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $
# @ECLASS: mozilla-scm.eclass
# @MAINTAINER:
# Sardem FF7 <sardemff7.pub@gmail.com>
# @BLURB: This eclass provides Mozilla specific SCM support
WANT_AUTOCONF="2.1"
EAPI="3"
inherit eutils multilib flag-o-matic toolchain-funcs autotools prefix makeedit pax-utils python
MAJ_XUL_PV="2.0"
LICENSE="|| ( MPL-1.1 GPL-2 LGPL-2.1 )"
SLOT="0"
SRC_URI=""
S="${WORKDIR}/mozilla-central"
#
# Some per-application stuff
#
IS_LIBXUL=false
MOZLIBDIR="/usr/$(get_libdir)/xulrunner-${MAJ_XUL_PV}"
MOZDEVELDIR="/usr/$(get_libdir)/xulrunner-devel-${MAJ_XUL_PV}"
SDKDIR="${MOZDEVELDIR}/sdk"
MOZILLA_FIVE_HOME="/usr/$(get_libdir)/${PN}"
case "${PN}" in
xulrunner)
IS_LIBXUL=true
MOZ_APPLICATION=xulrunner
MOZILLA_FIVE_HOME="${MOZLIBDIR}"
;;
firefox)
MOZ_APPLICATION=browser
;;
thunderbird)
MOZ_APPLICATION=mail
;;
esac
${IS_LIXBUL} || inherit fdo-mime
EXPORT_FUNCTIONS pkg_setup src_unpack src_compile src_install pkg_postinst
# @ECLASS-VARIABLE: EHG_REVISION
# @DESCRIPTION:
# Create working directory for specified revision, defaults to tip.
#
# EHG_REVISION is passed as a value for --rev parameter, so it can be more than
# just a revision, please consult `hg help revisions' for more details.
: ${EHG_REVISION:=tip}
# @ECLASS-VARIABLE: EHG_STORE_DIR
# @DESCRIPTION:
# Mercurial sources store directory. Users may override this in /etc/make.conf
: ${EHG_STORE_DIR:=${PORTAGE_ACTUAL_DISTDIR:-${DISTDIR}}/hg-src}
# @ECLASS-VARIABLE: EHG_QUIET
# @DESCRIPTION:
# Suppress some extra noise from mercurial, set it to be quiet.
# @ECLASS-VARIABLE: EHG_CLONE_CMD
# @DESCRIPTION:
# Command used to perform initial repository clone.
: ${EHG_CLONE_CMD:=hg clone ${EHG_QUIET:+--quiet} --pull --noupdate}
# @ECLASS-VARIABLE: EHG_PULL_CMD
# @DESCRIPTION:
# Command used to update repository.
: ${EHG_PULL_CMD:=hg pull ${EHG_QUIET:+--quiet}}
# @ECLASS-VARIABLE: EHG_OFFLINE
# @DESCRIPTION:
# Set this variable to a non-empty value to disable the automatic updating of
# a mercurial source tree. This is intended to be set outside the ebuild by
# users.
: ${EHG_OFFLINE:=${ESCM_OFFLINE}}
# @ECLASS-VARIABLE: MOZILLA_BONUS_REPOS_URIS
: ${MOZILLA_BONUS_REPOS_URIS:=}
##
## Base common stuff
##
RDEPEND="
x11-libs/libXrender
x11-libs/libXt
x11-libs/libXmu
virtual/jpeg
dev-libs/expat
app-arch/zip
app-arch/unzip
>=x11-libs/gtk+-2.8.6
>=dev-libs/glib-2.8.2
>=x11-libs/pango-1.10.1
>=dev-libs/libIDL-0.8.0
!<x11-base/xorg-x11-6.7.0-r2
>=sys-libs/zlib-1.1.4
>=sys-devel/binutils-2.16.1
>=dev-libs/nss-3.12.9
>=dev-libs/nspr-4.8.7
>=app-text/hunspell-1.2
>=x11-libs/cairo-1.10.2[X]
x11-libs/pixman
x11-libs/pango[X]
media-libs/libpng[apng]
alsa? ( media-libs/alsa-lib )
dbus? ( >=dev-libs/dbus-glib-0.72 )
gnome? ( >=dev-libs/glib-2.25 )
libnotify? ( >=x11-libs/libnotify-0.4 )
startup-notification? ( >=x11-libs/startup-notification-0.8 )
system-sqlite? ( >=dev-db/sqlite-3.7.4[fts3,secure-delete,unlock-notify] )
webm? ( media-libs/libvpx )
wifi? ( net-wireless/wireless-tools )
"
${IS_LIBXUL} || RDEPEND+="~net-libs/xulrunner-9999[libnotify=,mozdom=,ram=,system-sqlite=,webm=,wifi=]"
DEPEND="${RDEPEND}
dev-vcs/mercurial
dev-util/pkgconfig
webm? ( dev-lang/yasm )
"
IUSE="+alsa custom-optimization dbus +ipc gnome libnotify mozdom raw startup-notification +system-sqlite +webm wifi"
# Set by configure (plus USE_AUTOCONF=1), but useful for NSPR
export MOZILLA_CLIENT=1
export BUILD_OPT=1
export NO_STATIC_LIB=1
export USE_PTHREADS=1
mozconfig_annotate() {
declare reason=$1 x ; shift
[[ $# -gt 0 ]] || die "mozconfig_annotate missing flags for ${reason}\!"
for x in ${*}; do
echo "ac_add_options ${x} # ${reason}" >>.mozconfig
done
}
mozconfig_flag() {
mozconfig_annotate "USE-flag: $(useq $1 && echo +$1 || echo -$1)" "$2"
}
mozconfig_use_enable() {
mozconfig_flag "$1" "$(use_enable "$@")"
}
mozconfig_use_with() {
mozconfig_flag "$1" "$(use_with "$@")"
}
function mercurial_fetch {
debug-print-function ${FUNCNAME} ${*}
local repo=${1}
local module="$(basename "${repo}")"
# Should be set but blank to prevent using $HOME/.hgrc
export HGRCPATH=
# Check ${EHG_STORE_DIR} directory:
addwrite "$(dirname "${EHG_STORE_DIR}")" || die "addwrite failed"
if [[ ! -d "${EHG_STORE_DIR}" ]]; then
mkdir -p "${EHG_STORE_DIR}" || die "failed to create ${EHG_STORE_DIR}"
chmod -f g+rw "${EHG_STORE_DIR}" || \
die "failed to chown ${EHG_STORE_DIR}"
fi
# Create project directory:
mkdir -p "${EHG_STORE_DIR}/mozilla" || \
die "failed to create ${EHG_STORE_DIR}/mozilla"
chmod -f g+rw "${EHG_STORE_DIR}/mozilla" || \
echo "Warning: failed to chmod g+rw mozilla"
cd "${EHG_STORE_DIR}/mozilla" || \
die "failed to cd to ${EHG_STORE_DIR}/mozilla"
# Clone/update repository:
if [[ ! -d "${module}" ]]; then
einfo "Cloning ${repo} to ${EHG_STORE_DIR}/mozilla/${module}"
${EHG_CLONE_CMD} "${repo}" "${module}" || {
rm -rf "${module}"
die "failed to clone ${repo}"
}
cd "${module}"
elif [[ "${PN}" == "xulrunner" && -z "${EHG_OFFLINE}" ]]; then
einfo "Updating ${EHG_STORE_DIR}/mozilla/${module} from ${repo}"
cd "${module}" || die "failed to cd to ${module}"
${EHG_PULL_CMD} || die "update failed"
fi
# Checkout working copy:
einfo "Creating working directory for ${module} (target revision: ${EHG_REVISION})"
hg archive \
${EHG_QUIET_CMD_OPT} \
--rev="${EHG_REVISION}" \
-R "${EHG_STORE_DIR}/mozilla/${module}" \
"${WORKDIR}/${module}" || die "hg clone failed"
einfo "Work directory: ${WORKDIR}/${module}"
}
##
## eclass exported function
## src_unpack
##
function mozilla-scm_src_unpack {
mercurial_fetch "http://hg.mozilla.org/mozilla-central/"
for repo in ${MOZILLA_BONUS_REPOS_URIS}; do
mercurial_fetch "${repo}"
done
}
##
## eclass exported function
## pkg_setup
##
function mozilla-scm_pkg_setup {
# Ensure we always build with C locale.
export LANG="C"
export LC_ALL="C"
export LC_MESSAGES="C"
export LC_CTYPE="C"
if ! ${IS_LIBXUL}; then
elog "You are enabling official branding. You may not redistribute this build"
elog "to any users on your network or the internet. Doing so puts yourself into"
elog "a legal problem with Mozilla Foundation"
fi
python_set_active_version 2
}
##
## ozconfig_configure
##
function mozconfig_configure {
####################################
#
# Setup the initial .mozconfig
# See https://developer.mozilla.org/en/Configuring_Build_Options
#
####################################
cp ${MOZ_APPLICATION}/config/mozconfig .mozconfig \
|| die "cp mozconfig failed"
####################################
#
# CFLAGS setup and ARCH support
#
####################################
# Set optimization level
if [[ ${ARCH} == x86 ]]; then
mozconfig_annotate "less then -O2 causes a segfault on x86" --enable-optimize=-O2
elif use custom-optimization; then
# Set optimization level based on CFLAGS
if is-flag -O0; then
mozconfig_annotate 'CFLAGS optimization' --enable-optimize=-O0
elif is-flag -O1; then
mozconfig_annotate 'CFLAGS optimization' --enable-optimize=-O1
elif is-flag -Os; then
mozconfig_annotate 'CFLAGS optimization' --enable-optimize=-Os
else
mozconfig_annotate 'Default optimization: Gentoo' --enable-optimize=-O2
fi
else
# Enable Mozilla's default
mozconfig_annotate 'Default optimization: Mozilla' --enable-optimize
fi
# Now strip optimization from CFLAGS so it doesn't end up in the
# compile string
filter-flags '-O*'
# Strip over-aggressive CFLAGS - Mozilla supplies its own
# fine-tuned CFLAGS and shouldn't be interfered with.. Do this
# AFTER setting optimization above since strip-flags only allows
# -O -O1 and -O2
strip-flags
if [[ $(gcc-major-version) -eq 3 ]]; then
# Enable us to use flash, etc plugins compiled with gcc-2.95.3
mozconfig_annotate "building with >=gcc-3" --enable-old-abi-compat-wrappers
# Needed to build without warnings on gcc-3
CXXFLAGS="${CXXFLAGS} -Wno-deprecated"
if [[ "${ARCH}" == x86 &&
( $(gcc-minor-version) -lt 2 ||
( $(gcc-minor-version) -eq 2 && $(gcc-micro-version) -lt 3 )
) ]]
then
replace-flags -march=pentium4 -march=pentium3
filter-flags -msse2
fi
elif [[ $(gcc-major-version) -lt 4 ]]; then
append-flags -fno-stack-protector
fi
# Go a little faster; use less RAM
append-flags "$MAKEEDIT_FLAGS"
####################################
#
# mozconfig setup
#
####################################
mozconfig_annotate 'Gentoo system' \
--disable-installer \
--disable-pedantic \
--with-system-png \
--with-system-jpeg \
--with-system-bz2 \
--with-system-zlib \
--disable-updater \
--enable-system-cairo \
--enable-system-hunspell \
--disable-strip \
--enable-default-toolkit=cairo-gtk2 \
--disable-strip-libs \
--disable-install-strip \
--with-system-nspr \
--with-nspr-prefix="${EPREFIX}"/usr \
--with-system-nss \
--with-nss-prefix="${EPREFIX}"/usr \
--x-includes="${EPREFIX}"/usr/include \
--x-libraries="${EPREFIX}"/usr/$(get_libdir) \
--with-distribution-id=org.gentoo
mozconfig_annotate 'Gentoo defaults' \
--enable-single-profile \
--disable-profilesharing \
--disable-profilelocking
sed -i \
-e '/--enable-application=/d' \
-e '/--enable-extensions=/d'\
.mozconfig
local extensions="default"
use mozdom && extensions+=",inspector"
mozconfig_annotate 'Application defaults' \
--enable-application=${MOZ_APPLICATION} \
--with-default-mozilla-five-home="${MOZILLA_FIVE_HOME}" \
--enable-extensions="${extensions}"
mozconfig_annotate 'Basic features' \
--enable-crypto \
--enable-tracejit \
--enable-pango \
--enable-mathml \
--enable-safe-browsing \
--enable-storage
# jemalloc won't build with older glibc
! has_version ">=sys-libs/glibc-2.4" && mozconfig_annotate 'old glibc' --disable-jemalloc
if ${IS_LIBXUL}; then
mozconfig_annotate 'Provide libmozjs' --enable-shared-js
mozconfig_annotate 'Gentoo system' --with-system-libevent="${EPREFIX}"/usr
else
mozconfig_annotate 'libxul application' \
--enable-official-branding \
--with-system-libxul \
--with-libxul-sdk="${EPREFIX}"${MOZDEVELDIR}
fi
[[ $# -gt 0 ]] && \
mozconfig_annotate 'Ebuild specific option: '"${P}" \
${*}
# Use system libraries
mozconfig_use_enable alsa ogg
mozconfig_use_enable alsa wave
mozconfig_use_enable dbus
mozconfig_use_enable ipc # +ipc, upstream default
mozconfig_use_enable libnotify
mozconfig_use_enable raw
mozconfig_use_enable startup-notification
mozconfig_use_enable system-sqlite
mozconfig_use_enable webm
mozconfig_use_with webm system-libvpx
mozconfig_use_enable wifi necko-wifi
mozconfig_use_enable gnome gio
# NOTE: Uses internal copy of libvpx
if use webm && ! use alsa; then
ewarn "USE=webm needs USE=alsa, disabling WebM support."
mozconfig_annotate '+webm -alsa' --disable-webm
fi
# Debug
if use debug ; then
mozconfig_annotate 'Debug activated' \
--disable-optimize \
--enable-valgrind \
--enable-debug=-ggdb \
--enable-debug-modules=all \
--enable-debugger-info-modules
else
mozconfig_annotate 'Debug deactivated' \
--disable-debug \
--disable-tests
fi
# omni.jar breaks ff on xr
# Bug 60668: Galeon doesn't build without oji enabled, so enable it
# regardless of java setting.--enable-oji
mozconfig_annotate 'Broken' \
--disable-crashreporter \
--enable-chrome-format=jar \
--enable-oji
mozconfig_annotate 'Deprecated' \
--disable-gnomeui \
--disable-gnomevfs
# Currently --enable-elf-dynstr-gc only works for x86 and ppc,
# thanks to Jason Wever <weeve@gentoo.org> for the fix.
# -- This breaks now on ppc, no idea why
# if use x86 || use ppc && [[ ${enable_optimize} != -O0 ]]; then
if use x86 && [[ ${enable_optimize} != -O0 ]]; then
mozconfig_annotate "${ARCH} optimized build" --enable-elf-dynstr-gc
fi
# fi
echo
echo '=========================================================='
echo "Building ${PF} with the following configuration"
grep '^ac_add_options' .mozconfig | while read ac opt hash reason; do
[[ -z ${hash} || ${hash} == \# ]] \
|| die "error reading mozconfig: ${ac} ${opt} ${hash} ${reason}"
printf ' %-60s %s\n' "${opt}" "${reason:-mozilla.org default}"
done
echo '=========================================================='
echo
CC="$(tc-getCC)" CXX="$(tc-getCXX)" LD="$(tc-getLD)" PYTHON="$(PYTHON)" econf
}
##
## eclass exported function
## src_install
##
function mozilla-scm_src_install {
if ! ${IS_LIBXUL}; then
# Install icon and .desktop for menu entry
newicon "${S}"/other-licenses/branding/${PN}/content/icon48.png ${PN}-icon.png
newmenu "${FILESDIR}"/${PN}.desktop \
${PN}.desktop
# Add StartupNotify=true bug 237317
if use startup-notification ; then
echo "StartupNotify=true" >> "${ED}"/usr/share/applications/${PN}.desktop
fi
fi
emake DESTDIR="${ED}" install || die "emake install failed"
local prefdir="${ED}/${MOZILLA_FIVE_HOME}/defaults/pref"
[[ -d "${prefdir}erences" ]] && prefdir+="erences"
cp "${FILESDIR}"/default-prefs.js \
"${prefdir}/all-gentoo.js" || \
die "failed to cp -default-prefs.js"
}
##
## eclass exported function
## src_compile
##
function mozilla-scm_src_compile {
# Should the build use multiprocessing? Not enabled by default, as it tends to break
[ "${WANT_MP}" = "true" ] && jobs=${MAKEOPTS} || jobs="-j1"
emake ${jobs} || die
}
##
## eclass exported function
## pkg_postinst
##
function mozilla-scm_pkg_postinst {
ewarn "This is experimental DO NOT file a bug report unless you can"
ewarn "are willing to provide a patch. All bugs that are filled without a patch"
ewarn "will be closed INVALID!!"
if ${IS_LIBXUL}; then
einfo "Don't forget to rebuild firefox/thunderbird to update it to the same changeset"
else
ewarn "All the packages built against ${PN} won't compile,"
ewarn "any package that fails to build warrants a bug report."
einfo "You should build xulrunner first to update the mercurial repository"
# Update mimedb for the new .desktop file
fdo-mime_desktop_database_update
fi
}
|