1 # Copyright 1999-2014 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
5 # mozcoreconf.eclass : core options for mozilla
6 # inherit mozconfig-2 if you need USE flags
8 PYTHON_COMPAT=( python2_7 )
9 PYTHON_REQ_USE='threads,sqlite'
11 inherit multilib flag-o-matic python-any-r1 versionator
13 IUSE="${IUSE} custom-cflags custom-optimization"
15 RDEPEND="x11-libs/libXrender
17 >=sys-libs/zlib-1.1.4"
23 # mozconfig_annotate: add an annotated line to .mozconfig
26 # mozconfig_annotate "building on ultrasparc" --enable-js-ultrasparc
27 # => ac_add_options --enable-js-ultrasparc # building on ultrasparc
28 mozconfig_annotate() {
29 declare reason=$1 x ; shift
30 [[ $# -gt 0 ]] || die "mozconfig_annotate missing flags for ${reason}\!"
32 echo "ac_add_options ${x} # ${reason}" >>.mozconfig
36 # mozconfig_use_enable: add a line to .mozconfig based on a USE-flag
39 # mozconfig_use_enable truetype freetype2
40 # => ac_add_options --enable-freetype2 # +truetype
41 mozconfig_use_enable() {
42 declare flag=$(use_enable "$@")
43 mozconfig_annotate "$(use $1 && echo +$1 || echo -$1)" "${flag}"
46 # mozconfig_use_with: add a line to .mozconfig based on a USE-flag
49 # mozconfig_use_with kerberos gss-api /usr/$(get_libdir)
50 # => ac_add_options --with-gss-api=/usr/lib # +kerberos
51 mozconfig_use_with() {
52 declare flag=$(use_with "$@")
53 mozconfig_annotate "$(use $1 && echo +$1 || echo -$1)" "${flag}"
56 # mozconfig_use_extension: enable or disable an extension based on a USE-flag
59 # mozconfig_use_extension gnome gnomevfs
60 # => ac_add_options --enable-extensions=gnomevfs
61 mozconfig_use_extension() {
62 declare minus=$(use $1 || echo -)
63 mozconfig_annotate "${minus:-+}$1" --enable-extensions=${minus}${2}
66 mozversion_is_new_enough() {
69 if [[ $(get_version_component_range 1) -ge 17 ]] ; then
74 if [[ $(get_version_component_range 1) -eq 2 ]] && [[ $(get_version_component_range 2) -ge 14 ]] ; then
84 # Ensure we use C locale when building
87 export LC_MESSAGES="C"
90 # Ensure that we have a sane build enviroment
91 export MOZILLA_CLIENT=1
93 export NO_STATIC_LIB=1
95 export ALDFLAGS=${LDFLAGS}
96 # ensure MOZCONFIG is not defined
99 # nested configure scripts in mozilla products generate unrecognized options
100 # false positives when toplevel configure passes downwards.
101 export QA_CONFIGURE_OPTIONS=".*"
103 if [[ $(gcc-major-version) -eq 3 ]]; then
104 ewarn "Unsupported compiler detected, DO NOT file bugs for"
105 ewarn "outdated compilers. Bugs opened with gcc-3 will be closed"
109 python-any-r1_pkg_setup
113 declare enable_optimize pango_version myext x
114 declare XUL=$([[ ${PN} == xulrunner ]] && echo true || echo false)
115 declare FF=$([[ ${PN} == firefox ]] && echo true || echo false)
116 declare SM=$([[ ${PN} == seamonkey ]] && echo true || echo false)
117 declare TB=$([[ ${PN} == thunderbird ]] && echo true || echo false)
119 ####################################
121 # Setup the initial .mozconfig
122 # See http://www.mozilla.org/build/configure-build.html
124 ####################################
128 cp xulrunner/config/mozconfig .mozconfig \
129 || die "cp xulrunner/config/mozconfig failed" ;;
131 cp browser/config/mozconfig .mozconfig \
132 || die "cp browser/config/mozconfig failed" ;;
134 # Must create the initial mozconfig to enable application
135 : >.mozconfig || die "initial mozconfig creation failed"
136 mozconfig_annotate "" --enable-application=suite ;;
138 # Must create the initial mozconfig to enable application
139 : >.mozconfig || die "initial mozconfig creation failed"
140 mozconfig_annotate "" --enable-application=mail ;;
143 ####################################
145 # CFLAGS setup and ARCH support
147 ####################################
149 # Set optimization level
150 if [[ ${ARCH} == hppa ]]; then
151 mozconfig_annotate "more than -O0 causes a segfault on hppa" --enable-optimize=-O0
152 elif [[ ${ARCH} == x86 ]]; then
153 mozconfig_annotate "less then -O2 causes a segfault on x86" --enable-optimize=-O2
154 elif use custom-optimization || [[ ${ARCH} =~ (alpha|ia64) ]]; then
155 # Set optimization level based on CFLAGS
157 mozconfig_annotate "from CFLAGS" --enable-optimize=-O0
158 elif [[ ${ARCH} == ppc ]] && has_version '>=sys-libs/glibc-2.8'; then
159 mozconfig_annotate "more than -O1 segfaults on ppc with glibc-2.8" --enable-optimize=-O1
160 elif is-flag -O3; then
161 mozconfig_annotate "from CFLAGS" --enable-optimize=-O3
162 elif is-flag -O1; then
163 mozconfig_annotate "from CFLAGS" --enable-optimize=-O1
164 elif is-flag -Os; then
165 mozconfig_annotate "from CFLAGS" --enable-optimize=-Os
167 mozconfig_annotate "Gentoo's default optimization" --enable-optimize=-O2
170 # Enable Mozilla's default
171 mozconfig_annotate "mozilla default" --enable-optimize
174 # Strip optimization so it does not end up in compile string
177 # Strip over-aggressive CFLAGS
178 use custom-cflags || strip-flags
180 # Additional ARCH support
183 # Historically we have needed to add -fPIC manually for 64-bit.
184 # Additionally, alpha should *always* build with -mieee for correct math
186 append-flags -fPIC -mieee
190 # Historically we have needed to add this manually for 64-bit
195 append-flags -fPIC -mminimal-toc
199 # Go a little faster; use less RAM
200 append-flags "$MAKEEDIT_FLAGS"
202 ####################################
206 ####################################
208 mozconfig_annotate system_libs \
212 --enable-system-cairo
213 if ! $(mozversion_is_new_enough) ; then
214 mozconfig_annotate system-libs --enable-svg
217 mozconfig_annotate disable_update_strip \
221 --disable-install-strip
222 if ! $(mozversion_is_new_enough) ; then
223 mozconfig_annotate disable_update_strip \
224 --disable-installer \
228 if [[ ${PN} != seamonkey ]]; then
229 mozconfig_annotate basic_profile \
230 --disable-profilelocking
231 if ! $(mozversion_is_new_enough) ; then
232 mozconfig_annotate basic_profile \
233 --enable-single-profile \
234 --disable-profilesharing
238 # Here is a strange one...
239 if is-flag '-mcpu=ultrasparc*' || is-flag '-mtune=ultrasparc*'; then
240 mozconfig_annotate "building on ultrasparc" --enable-js-ultrasparc
243 # Currently --enable-elf-dynstr-gc only works for x86,
244 # thanks to Jason Wever <weeve@gentoo.org> for the fix.
245 if use x86 && [[ ${enable_optimize} != -O0 ]]; then
246 mozconfig_annotate "${ARCH} optimized build" --enable-elf-dynstr-gc
249 # jemalloc won't build with older glibc
250 ! has_version ">=sys-libs/glibc-2.4" && mozconfig_annotate "we have old glibc" --disable-jemalloc
253 # mozconfig_final: display a table describing all configuration options paired
254 # with reasons, then clean up extensions list
256 declare ac opt hash reason
258 echo "=========================================================="
259 echo "Building ${PF} with the following configuration"
260 grep ^ac_add_options .mozconfig | while read ac opt hash reason; do
261 [[ -z ${hash} || ${hash} == \# ]] \
262 || die "error reading mozconfig: ${ac} ${opt} ${hash} ${reason}"
263 printf " %-30s %s\n" "${opt}" "${reason:-mozilla.org default}"
265 echo "=========================================================="
268 # Resolve multiple --enable-extensions down to one
269 declare exts=$(sed -n 's/^ac_add_options --enable-extensions=\([^ ]*\).*/\1/p' \
271 sed -i '/^ac_add_options --enable-extensions/d' .mozconfig
272 echo "ac_add_options --enable-extensions=${exts// /,}" >> .mozconfig