new amuleadu snapshot with bug fixes
[dottout.git] / eclass / mozcoreconf-minefield.eclass
blob82affcbdec9deb839fe49d960ea6ebaeb6368322
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
11 x11-libs/libXt
12 x11-libs/libXmu
13 >=sys-libs/zlib-1.1.4"
15 DEPEND="${RDEPEND}
16 dev-util/pkgconfig"
18 # Set by configure (plus USE_AUTOCONF=1), but useful for NSPR
19 export MOZILLA_CLIENT=1
20 export BUILD_OPT=1
21 export NO_STATIC_LIB=1
22 export USE_PTHREADS=1
24 mozconfig_init() {
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 ####################################
43 case ${PN} in
44 mozilla|gecko-sdk)
45 # The other builds have an initial --enable-extensions in their
46 # .mozconfig. The "default" set in configure applies to mozilla
47 # specifically.
48 : >.mozconfig || die "initial mozconfig creation failed"
49 mozconfig_annotate "" --enable-extensions=default ;;
50 *firefox)
51 cp browser/config/mozconfig .mozconfig \
52 || die "cp browser/config/mozconfig failed" ;;
53 enigmail)
54 cp mail/config/mozconfig .mozconfig \
55 || die "cp mail/config/mozconfig failed" ;;
56 *firefox-cvs)
57 cp browser/config/mozconfig .mozconfig \
58 || die "cp browser/config/mozconfig failed" ;;
59 minefield)
60 cp browser/config/mozconfig .mozconfig \
61 || die "cp browser/config/mozconfig failed" ;;
62 *deerpark)
63 cp browser/config/mozconfig .mozconfig \
64 || die "cp browser/config/mozconfig failed" ;;
65 *xulrunner)
66 cp xulrunner/config/mozconfig .mozconfig \
67 || die "cp xulrunner/config/mozconfig failed" ;;
68 *sunbird)
69 cp calendar/sunbird/config/mozconfig .mozconfig \
70 || die "cp calendar/sunbird/config/mozconfig failed" ;;
71 *thunderbird)
72 cp mail/config/mozconfig .mozconfig \
73 || die "cp mail/config/mozconfig failed" ;;
74 seamonkey)
75 # The other builds have an initial --enable-extensions in their
76 # .mozconfig. The "default" set in configure applies to mozilla
77 # specifically.
78 : >.mozconfig || die "initial mozconfig creation failed"
79 mozconfig_annotate "" --enable-application=suite
80 mozconfig_annotate "" --enable-extensions=default ;;
81 esac
83 ####################################
85 # CFLAGS setup and ARCH support
87 ####################################
89 # Set optimization level based on CFLAGS
90 if is-flag -O0; then
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
98 else
99 mozconfig_annotate "mozilla fallback" --enable-optimize=-O2
102 # Now strip optimization from CFLAGS so it doesn't end up in the
103 # compile string
104 filter-flags '-O*'
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
109 # -O -O1 and -O2
110 strip-flags
112 # Additional ARCH support
113 case "${ARCH}" in
114 alpha)
115 # Historically we have needed to add -fPIC manually for 64-bit.
116 # Additionally, alpha should *always* build with -mieee for correct math
117 # operation
118 append-flags -fPIC -mieee
121 amd64|ia64)
122 # Historically we have needed to add this manually for 64-bit
123 append-flags -fPIC
126 ppc64)
127 append-flags -fPIC -mminimal-toc
130 ppc)
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
137 sparc)
138 # Sparc support ...
139 replace-sparc64-flags
142 x86)
143 if [[ $(gcc-major-version) -eq 3 ]]; then
144 # gcc-3 prior to 3.2.3 doesn't work well for pentium4
145 # see bug 25332
146 if [[ $(gcc-minor-version) -lt 2 ||
147 ( $(gcc-minor-version) -eq 2 && $(gcc-micro-version) -lt 3 ) ]]
148 then
149 replace-flags -march=pentium4 -march=pentium3
150 filter-flags -msse2
154 esac
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 ####################################
169 # mozconfig setup
171 ####################################
173 mozconfig_annotate gentoo \
174 --disable-installer \
175 --disable-pedantic \
176 --enable-crypto \
177 --with-system-jpeg \
178 --with-system-zlib \
179 --without-system-png \
180 --disable-updater \
181 --enable-pango \
182 --enable-svg \
183 --enable-svg-renderer=cairo \
184 --without-system-cairo \
185 --disable-strip \
186 --disable-strip-libs
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
202 makemake() {
203 typeset m topdir
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"
208 done
211 makemake2() {
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"
216 done
219 # mozconfig_annotate: add an annotated line to .mozconfig
221 # Example:
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}\!"
227 for x in ${*}; do
228 echo "ac_add_options ${x} # ${reason}" >>.mozconfig
229 done
232 # mozconfig_use_enable: add a line to .mozconfig based on a USE-flag
234 # Example:
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
244 # Example:
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
254 # Example:
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
264 mozconfig_final() {
265 declare ac opt hash reason
266 echo
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}"
273 done
274 echo "=========================================================="
275 echo
277 # Resolve multiple --enable-extensions down to one
278 declare exts=$(sed -n 's/^ac_add_options --enable-extensions=\([^ ]*\).*/\1/p' \
279 .mozconfig | xargs)
280 sed -i '/^ac_add_options --enable-extensions/d' .mozconfig
281 echo "ac_add_options --enable-extensions=${exts// /,}" >> .mozconfig