1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
5 # @ECLASS: mozcoreconf.eclass
7 # Mozilla team <mozilla@gentoo.org>
8 # @BLURB: core options and configuration functions for mozilla
11 # inherit mozconfig-v5.* or above for mozilla configuration support
13 if [[ ! ${_MOZCORECONF_V3} ]]; then
15 PYTHON_COMPAT=( python2_7 )
16 PYTHON_REQ_USE='threads,sqlite'
18 inherit multilib flag-o-matic python-any-r1 versionator
20 IUSE="${IUSE} custom-cflags custom-optimization"
22 DEPEND="virtual/pkgconfig
25 # @FUNCTION: mozconfig_annotate
27 # add an annotated line to .mozconfig
30 # mozconfig_annotate "building on ultrasparc" --enable-js-ultrasparc
31 # => ac_add_options --enable-js-ultrasparc # building on ultrasparc
32 mozconfig_annotate() {
33 declare reason=$1 x ; shift
34 [[ $# -gt 0 ]] || die "mozconfig_annotate missing flags for ${reason}\!"
36 echo "ac_add_options ${x} # ${reason}" >>.mozconfig
40 # @FUNCTION: mozconfig_use_enable
42 # add a line to .mozconfig based on a USE-flag
45 # mozconfig_use_enable truetype freetype2
46 # => ac_add_options --enable-freetype2 # +truetype
47 mozconfig_use_enable() {
48 declare flag=$(use_enable "$@")
49 mozconfig_annotate "$(use $1 && echo +$1 || echo -$1)" "${flag}"
52 # @FUNCTION mozconfig_use_with
54 # add a line to .mozconfig based on a USE-flag
57 # mozconfig_use_with kerberos gss-api /usr/$(get_libdir)
58 # => ac_add_options --with-gss-api=/usr/lib # +kerberos
59 mozconfig_use_with() {
60 declare flag=$(use_with "$@")
61 mozconfig_annotate "$(use $1 && echo +$1 || echo -$1)" "${flag}"
64 # @FUNCTION mozconfig_use_extension
66 # enable or disable an extension based on a USE-flag
69 # mozconfig_use_extension gnome gnomevfs
70 # => ac_add_options --enable-extensions=gnomevfs
71 mozconfig_use_extension() {
72 declare minus=$(use $1 || echo -)
73 mozconfig_annotate "${minus:-+}$1" --enable-extensions=${minus}${2}
77 # Ensure we use C locale when building
80 export LC_MESSAGES="C"
83 # Ensure that we have a sane build enviroment
84 export MOZILLA_CLIENT=1
86 export NO_STATIC_LIB=1
88 export ALDFLAGS=${LDFLAGS}
89 # ensure MOZCONFIG is not defined
92 # nested configure scripts in mozilla products generate unrecognized options
93 # false positives when toplevel configure passes downwards.
94 export QA_CONFIGURE_OPTIONS=".*"
96 if [[ $(gcc-major-version) -eq 3 ]]; then
97 ewarn "Unsupported compiler detected, DO NOT file bugs for"
98 ewarn "outdated compilers. Bugs opened with gcc-3 will be closed"
102 python-any-r1_pkg_setup
105 # @FUNCTION: mozconfig_init
107 # Initialize mozilla configuration and populate with core settings.
108 # This should be called in src_configure before any other mozconfig_* functions.
110 declare enable_optimize pango_version myext x
111 declare XUL=$([[ ${PN} == xulrunner ]] && echo true || echo false)
112 declare FF=$([[ ${PN} == firefox ]] && echo true || echo false)
113 declare SM=$([[ ${PN} == seamonkey ]] && echo true || echo false)
114 declare TB=$([[ ${PN} == thunderbird ]] && echo true || echo false)
116 ####################################
118 # Setup the initial .mozconfig
119 # See http://www.mozilla.org/build/configure-build.html
121 ####################################
125 cp xulrunner/config/mozconfig .mozconfig \
126 || die "cp xulrunner/config/mozconfig failed" ;;
128 cp browser/config/mozconfig .mozconfig \
129 || die "cp browser/config/mozconfig failed" ;;
131 # Must create the initial mozconfig to enable application
132 : >.mozconfig || die "initial mozconfig creation failed"
133 mozconfig_annotate "" --enable-application=suite ;;
135 # Must create the initial mozconfig to enable application
136 : >.mozconfig || die "initial mozconfig creation failed"
137 mozconfig_annotate "" --enable-application=mail ;;
140 ####################################
142 # CFLAGS setup and ARCH support
144 ####################################
146 # Set optimization level
147 if [[ ${ARCH} == hppa ]]; then
148 mozconfig_annotate "more than -O0 causes a segfault on hppa" --enable-optimize=-O0
149 elif [[ ${ARCH} == x86 ]]; then
150 mozconfig_annotate "less then -O2 causes a segfault on x86" --enable-optimize=-O2
151 elif use custom-optimization || [[ ${ARCH} =~ (alpha|ia64) ]]; then
152 # Set optimization level based on CFLAGS
154 mozconfig_annotate "from CFLAGS" --enable-optimize=-O0
155 elif [[ ${ARCH} == ppc ]] && has_version '>=sys-libs/glibc-2.8'; then
156 mozconfig_annotate "more than -O1 segfaults on ppc with glibc-2.8" --enable-optimize=-O1
157 elif is-flag -O3; then
158 mozconfig_annotate "from CFLAGS" --enable-optimize=-O3
159 elif is-flag -O1; then
160 mozconfig_annotate "from CFLAGS" --enable-optimize=-O1
161 elif is-flag -Os; then
162 mozconfig_annotate "from CFLAGS" --enable-optimize=-Os
164 mozconfig_annotate "Gentoo's default optimization" --enable-optimize=-O2
167 # Enable Mozilla's default
168 mozconfig_annotate "mozilla default" --enable-optimize
171 # Strip optimization so it does not end up in compile string
174 # Strip over-aggressive CFLAGS
175 use custom-cflags || strip-flags
177 # Additional ARCH support
180 # Historically we have needed to add -fPIC manually for 64-bit.
181 # Additionally, alpha should *always* build with -mieee for correct math
183 append-flags -fPIC -mieee
187 # Historically we have needed to add this manually for 64-bit
192 append-flags -fPIC -mminimal-toc
196 # Go a little faster; use less RAM
197 append-flags "$MAKEEDIT_FLAGS"
199 ####################################
203 ####################################
205 mozconfig_annotate disable_update_strip \
209 --disable-install-strip \
210 --disable-installer \
213 if [[ ${PN} != seamonkey ]]; then
214 mozconfig_annotate basic_profile \
215 --disable-profilelocking \
216 --enable-single-profile \
217 --disable-profilesharing
220 # Here is a strange one...
221 if is-flag '-mcpu=ultrasparc*' || is-flag '-mtune=ultrasparc*'; then
222 mozconfig_annotate "building on ultrasparc" --enable-js-ultrasparc
225 # Currently --enable-elf-dynstr-gc only works for x86,
226 # thanks to Jason Wever <weeve@gentoo.org> for the fix.
227 if use x86 && [[ ${enable_optimize} != -O0 ]]; then
228 mozconfig_annotate "${ARCH} optimized build" --enable-elf-dynstr-gc
231 # jemalloc won't build with older glibc
232 ! has_version ">=sys-libs/glibc-2.4" && mozconfig_annotate "we have old glibc" --disable-jemalloc
235 # @FUNCTION: mozconfig_final
237 # Display a table describing all configuration options paired
238 # with reasons, then clean up extensions list.
239 # This should be called in src_configure at the end of all other mozconfig_* functions.
241 declare ac opt hash reason
243 echo "=========================================================="
244 echo "Building ${PF} with the following configuration"
245 grep ^ac_add_options .mozconfig | while read ac opt hash reason; do
246 [[ -z ${hash} || ${hash} == \# ]] \
247 || die "error reading mozconfig: ${ac} ${opt} ${hash} ${reason}"
248 printf " %-30s %s\n" "${opt}" "${reason:-mozilla.org default}"
250 echo "=========================================================="
253 # Resolve multiple --enable-extensions down to one
254 declare exts=$(sed -n 's/^ac_add_options --enable-extensions=\([^ ]*\).*/\1/p' \
256 sed -i '/^ac_add_options --enable-extensions/d' .mozconfig
257 echo "ac_add_options --enable-extensions=${exts// /,}" >> .mozconfig