1 # Copyright 1999-2007 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-x86/eclass/mozcoreconf.eclass,v 1.12 2007/03/12 11:57:49 armin76 Exp $
5 # mozcoreconf.eclass : core options for mozilla
6 # inherit mozconfig-2 if you need USE flags
8 inherit multilib flag-o-matic
10 RDEPEND
="x11-libs/libXrender
13 >=sys-libs/zlib-1.1.4"
18 # Set by configure (plus USE_AUTOCONF=1), but useful for NSPR
19 export MOZILLA_CLIENT
=1
21 export NO_STATIC_LIB
=1
25 declare enable_optimize pango_version myext x
26 declare MOZ
=$
([[ ${PN} == mozilla ||
${PN} == gecko-sdk
]] && echo true ||
echo false
)
27 declare FF
=$
([[ ${PN} == *firefox
]] && echo true ||
echo false
)
28 declare TB
=$
([[ ${PN} == *thunderbird
]] && echo true ||
echo false
)
29 declare SB
=$
([[ ${PN} == *sunbird
]] && echo true ||
echo false
)
30 declare DP
=$
([[ ${PN} == *deerpark
]] && echo true ||
echo false
)
31 declare MN
=$
([[ ${PN} == minefield
]] && echo true ||
echo false
)
32 declare XUL
=$
([[ ${PN} == *xulrunner
]] && echo true ||
echo false
)
33 declare EM
=$
([[ ${PN} == enigmail
]] && echo true ||
echo false
)
34 declare SM
=$
([[ ${PN} == seamonkey
]] && echo true ||
echo false
)
36 ####################################
38 # Setup the initial .mozconfig
39 # See http://www.mozilla.org/build/configure-build.html
41 ####################################
45 # The other builds have an initial --enable-extensions in their
46 # .mozconfig. The "default" set in configure applies to mozilla
48 : >.mozconfig || die
"initial mozconfig creation failed"
49 mozconfig_annotate
"" --enable-extensions=default
;;
51 cp browser
/config
/mozconfig .mozconfig \
52 || die
"cp browser/config/mozconfig failed" ;;
54 cp mail
/config
/mozconfig .mozconfig \
55 || die
"cp mail/config/mozconfig failed" ;;
57 cp browser
/config
/mozconfig .mozconfig \
58 || die
"cp browser/config/mozconfig failed" ;;
60 cp browser
/config
/mozconfig .mozconfig \
61 || die
"cp browser/config/mozconfig failed" ;;
63 cp browser
/config
/mozconfig .mozconfig \
64 || die
"cp browser/config/mozconfig failed" ;;
66 cp xulrunner
/config
/mozconfig .mozconfig \
67 || die
"cp xulrunner/config/mozconfig failed" ;;
69 cp calendar
/sunbird
/config
/mozconfig .mozconfig \
70 || die
"cp calendar/sunbird/config/mozconfig failed" ;;
72 cp mail
/config
/mozconfig .mozconfig \
73 || die
"cp mail/config/mozconfig failed" ;;
75 # The other builds have an initial --enable-extensions in their
76 # .mozconfig. The "default" set in configure applies to mozilla
78 : >.mozconfig || die
"initial mozconfig creation failed"
79 mozconfig_annotate
"" --enable-application=suite
80 mozconfig_annotate
"" --enable-extensions=default
;;
83 ####################################
85 # CFLAGS setup and ARCH support
87 ####################################
89 # Set optimization level based on CFLAGS
91 mozconfig_annotate
"from CFLAGS" --enable-optimize=-O0
92 elif [[ ${ARCH} == hppa
]]; then
93 mozconfig_annotate
"more than -O0 causes segfaults on hppa" --enable-optimize=-O0
94 elif is-flag
-O1; then
95 mozconfig_annotate
"from CFLAGS" --enable-optimize=-O1
96 elif is-flag
-Os; then
97 mozconfig_annotate
"from CFLAGS" --enable-optimize=-Os
99 mozconfig_annotate
"mozilla fallback" --enable-optimize=-O2
102 # Now strip optimization from CFLAGS so it doesn't end up in the
106 # Strip over-aggressive CFLAGS - Mozilla supplies its own
107 # fine-tuned CFLAGS and shouldn't be interfered with.. Do this
108 # AFTER setting optimization above since strip-flags only allows
112 # Additional ARCH support
115 # Historically we have needed to add -fPIC manually for 64-bit.
116 # Additionally, alpha should *always* build with -mieee for correct math
118 append-flags
-fPIC -mieee
122 # Historically we have needed to add this manually for 64-bit
127 append-flags
-fPIC -mminimal-toc
131 # Fix to avoid gcc-3.3.x micompilation issues.
132 if [[ $
(gcc-major-version
).$
(gcc-minor-version
) == 3.3 ]]; then
133 append-flags
-fno-strict-aliasing
139 replace-sparc64-flags
143 if [[ $
(gcc-major-version
) -eq 3 ]]; then
144 # gcc-3 prior to 3.2.3 doesn't work well for pentium4
146 if [[ $
(gcc-minor-version
) -lt 2 ||
147 ( $
(gcc-minor-version
) -eq 2 && $
(gcc-micro-version
) -lt 3 ) ]]
149 replace-flags
-march=pentium4
-march=pentium3
156 if [[ $
(gcc-major-version
) -eq 3 ]]; then
157 # Enable us to use flash, etc plugins compiled with gcc-2.95.3
158 mozconfig_annotate
"building with >=gcc-3" --enable-old-abi-compat-wrappers
160 # Needed to build without warnings on gcc-3
161 CXXFLAGS
="${CXXFLAGS} -Wno-deprecated"
164 # Go a little faster; use less RAM
165 append-flags
"$MAKEEDIT_FLAGS"
167 ####################################
171 ####################################
173 mozconfig_annotate gentoo \
174 --disable-installer \
179 --without-system-png \
183 --enable-svg-renderer=cairo \
184 --without-system-cairo \
188 if [[ ${PN} != seamonkey
]]; then
189 mozconfig_annotate gentoo \
190 --enable-single-profile \
191 --disable-profilesharing \
192 --disable-profilelocking
195 # Here is a strange one...
196 if is-flag
'-mcpu=ultrasparc*' || is-flag
'-mtune=ultrasparc*'; then
197 mozconfig_annotate
"building on ultrasparc" --enable-js-ultrasparc
201 # Simulate the silly csh makemake script
204 for m
in $
(find .
-name Makefile.
in); do
205 topdir
=$
(echo "$m" |
sed -r 's:[^/]+:..:g')
206 sed -e "s:@srcdir@:.:g" -e "s:@top_srcdir@:${topdir}:g" \
207 < ${m} > ${m%.in} || die "sed ${m} failed
"
212 for m in $(find ../ -name Makefile.in); do
213 topdir=$(echo "$m" | sed -r 's:[^/]+:..:g')
214 sed -e "s
:@srcdir@
:.
:g
" -e "s
:@top_srcdir@
:${topdir}:g
" \
215 < ${m} > ${m%.in} || die "sed ${m} failed"
219 # mozconfig_annotate: add an annotated line to .mozconfig
222 # mozconfig_annotate "building on ultrasparc" --enable-js-ultrasparc
223 # => ac_add_options --enable-js-ultrasparc # building on ultrasparc
224 mozconfig_annotate
() {
225 declare reason
=$1 x
; shift
226 [[ $# -gt 0 ]] || die
"mozconfig_annotate missing flags for ${reason}\!"
228 echo "ac_add_options ${x} # ${reason}" >>.mozconfig
232 # mozconfig_use_enable: add a line to .mozconfig based on a USE-flag
235 # mozconfig_use_enable truetype freetype2
236 # => ac_add_options --enable-freetype2 # +truetype
237 mozconfig_use_enable
() {
238 declare flag
=$
(use_enable
"$@")
239 mozconfig_annotate
"$(useq $1 && echo +$1 || echo -$1)" "${flag}"
242 # mozconfig_use_with: add a line to .mozconfig based on a USE-flag
245 # mozconfig_use_with kerberos gss-api /usr/$(get_libdir)
246 # => ac_add_options --with-gss-api=/usr/lib # +kerberos
247 mozconfig_use_with
() {
248 declare flag
=$
(use_with
"$@")
249 mozconfig_annotate
"$(useq $1 && echo +$1 || echo -$1)" "${flag}"
252 # mozconfig_use_extension: enable or disable an extension based on a USE-flag
255 # mozconfig_use_extension gnome gnomevfs
256 # => ac_add_options --enable-extensions=gnomevfs
257 mozconfig_use_extension
() {
258 declare minus
=$
(useq
$1 ||
echo -)
259 mozconfig_annotate
"${minus:-+}$1" --enable-extensions=${minus}${2}
262 # mozconfig_final: display a table describing all configuration options paired
263 # with reasons, then clean up extensions list
265 declare ac opt hash reason
267 echo "=========================================================="
268 echo "Building
${PF} with the following configuration
"
269 grep ^ac_add_options .mozconfig | while read ac opt hash reason; do
270 [[ -z ${hash} || ${hash} == \# ]] \
271 || die "error reading mozconfig
: ${ac} ${opt} ${hash} ${reason}"
272 printf " %-30s %s
\n" "${opt}" "${reason:-mozilla.org default}"
274 echo "=========================================================="
277 # Resolve multiple --enable-extensions down to one
278 declare exts=$(sed -n 's/^ac_add_options --enable-extensions=\([^ ]*\).*/\1/p' \
280 sed -i '/^ac_add_options --enable-extensions/d' .mozconfig
281 echo "ac_add_options
--enable-extensions=${exts// /,}" >> .mozconfig