1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
5 # @ECLASS: mozcoreconf-v4.eclass
7 # Mozilla team <mozilla@gentoo.org>
8 # @BLURB: core options and configuration functions for mozilla
11 # inherit mozconfig-v6.* or above for mozilla configuration support
13 # @ECLASS-VARIABLE: MOZILLA_FIVE_HOME
15 # This is an eclass-generated variable that defines the rpath that the mozilla
16 # product will be installed in. Read-only
18 if [[ ! ${_MOZCORECONF} ]]; then
20 PYTHON_COMPAT=( python2_7 )
21 PYTHON_REQ_USE='ncurses,sqlite,ssl,threads'
23 inherit multilib toolchain-funcs flag-o-matic python-any-r1 versionator
25 IUSE="${IUSE} custom-cflags custom-optimization"
27 DEPEND="virtual/pkgconfig
30 # @FUNCTION: mozconfig_annotate
32 # add an annotated line to .mozconfig
35 # mozconfig_annotate "building on ultrasparc" --enable-js-ultrasparc
36 # => ac_add_options --enable-js-ultrasparc # building on ultrasparc
37 mozconfig_annotate() {
38 declare reason=$1 x ; shift
39 [[ $# -gt 0 ]] || die "mozconfig_annotate missing flags for ${reason}\!"
41 echo "ac_add_options ${x} # ${reason}" >>.mozconfig
45 # @FUNCTION: mozconfig_use_enable
47 # add a line to .mozconfig based on a USE-flag
50 # mozconfig_use_enable truetype freetype2
51 # => ac_add_options --enable-freetype2 # +truetype
52 mozconfig_use_enable() {
53 declare flag=$(use_enable "$@")
54 mozconfig_annotate "$(use $1 && echo +$1 || echo -$1)" "${flag}"
57 # @FUNCTION mozconfig_use_with
59 # add a line to .mozconfig based on a USE-flag
62 # mozconfig_use_with kerberos gss-api /usr/$(get_libdir)
63 # => ac_add_options --with-gss-api=/usr/lib # +kerberos
64 mozconfig_use_with() {
65 declare flag=$(use_with "$@")
66 mozconfig_annotate "$(use $1 && echo +$1 || echo -$1)" "${flag}"
69 # @FUNCTION mozconfig_use_extension
71 # enable or disable an extension based on a USE-flag
74 # mozconfig_use_extension gnome gnomevfs
75 # => ac_add_options --enable-extensions=gnomevfs
76 mozconfig_use_extension() {
77 declare minus=$(use $1 || echo -)
78 mozconfig_annotate "${minus:-+}$1" --enable-extensions=${minus}${2}
82 # Ensure we use C locale when building
85 export LC_MESSAGES="C"
88 # Ensure we use correct toolchain
89 export HOST_CC="$(tc-getBUILD_CC)"
90 export HOST_CXX="$(tc-getBUILD_CXX)"
91 tc-export CC CXX LD PKG_CONFIG
93 # Ensure that we have a sane build enviroment
94 export MOZILLA_CLIENT=1
96 export NO_STATIC_LIB=1
98 export ALDFLAGS=${LDFLAGS}
99 # ensure MOZCONFIG is not defined
102 # set MOZILLA_FIVE_HOME
103 export MOZILLA_FIVE_HOME="/usr/$(get_libdir)/${PN}"
105 # nested configure scripts in mozilla products generate unrecognized options
106 # false positives when toplevel configure passes downwards.
107 export QA_CONFIGURE_OPTIONS=".*"
109 if [[ $(gcc-major-version) -eq 3 ]]; then
110 ewarn "Unsupported compiler detected, DO NOT file bugs for"
111 ewarn "outdated compilers. Bugs opened with gcc-3 will be closed"
115 python-any-r1_pkg_setup
118 # @FUNCTION: mozconfig_init
120 # Initialize mozilla configuration and populate with core settings.
121 # This should be called in src_configure before any other mozconfig_* functions.
123 declare enable_optimize pango_version myext x
124 declare XUL=$([[ ${PN} == xulrunner ]] && echo true || echo false)
125 declare FF=$([[ ${PN} == firefox ]] && echo true || echo false)
126 declare SM=$([[ ${PN} == seamonkey ]] && echo true || echo false)
127 declare TB=$([[ ${PN} == thunderbird ]] && echo true || echo false)
129 ####################################
131 # Setup the initial .mozconfig
132 # See http://www.mozilla.org/build/configure-build.html
134 ####################################
138 cp xulrunner/config/mozconfig .mozconfig \
139 || die "cp xulrunner/config/mozconfig failed" ;;
141 cp browser/config/mozconfig .mozconfig \
142 || die "cp browser/config/mozconfig failed" ;;
144 # Must create the initial mozconfig to enable application
145 : >.mozconfig || die "initial mozconfig creation failed"
146 mozconfig_annotate "" --enable-application=suite ;;
148 # Must create the initial mozconfig to enable application
149 : >.mozconfig || die "initial mozconfig creation failed"
150 mozconfig_annotate "" --enable-application=mail ;;
153 ####################################
155 # CFLAGS setup and ARCH support
157 ####################################
159 # Set optimization level
160 if [[ ${ARCH} == hppa ]]; then
161 mozconfig_annotate "more than -O0 causes a segfault on hppa" --enable-optimize=-O0
162 elif [[ ${ARCH} == x86 ]]; then
163 mozconfig_annotate "less then -O2 causes a segfault on x86" --enable-optimize=-O2
164 elif use custom-optimization || [[ ${ARCH} =~ (alpha|ia64) ]]; then
165 # Set optimization level based on CFLAGS
167 mozconfig_annotate "from CFLAGS" --enable-optimize=-O0
168 elif [[ ${ARCH} == ppc ]] && has_version '>=sys-libs/glibc-2.8'; then
169 mozconfig_annotate "more than -O1 segfaults on ppc with glibc-2.8" --enable-optimize=-O1
170 elif is-flag -O3; then
171 mozconfig_annotate "from CFLAGS" --enable-optimize=-O3
172 elif is-flag -O1; then
173 mozconfig_annotate "from CFLAGS" --enable-optimize=-O1
174 elif is-flag -Os; then
175 mozconfig_annotate "from CFLAGS" --enable-optimize=-Os
177 mozconfig_annotate "Gentoo's default optimization" --enable-optimize=-O2
180 # Enable Mozilla's default
181 mozconfig_annotate "mozilla default" --enable-optimize
184 # Strip optimization so it does not end up in compile string
187 # Strip over-aggressive CFLAGS
188 use custom-cflags || strip-flags
190 # Additional ARCH support
193 # Historically we have needed to add -fPIC manually for 64-bit.
194 # Additionally, alpha should *always* build with -mieee for correct math
196 append-flags -fPIC -mieee
200 # Historically we have needed to add this manually for 64-bit
205 append-flags -fPIC -mminimal-toc
209 # Go a little faster; use less RAM
210 append-flags "$MAKEEDIT_FLAGS"
212 # Use the MOZILLA_FIVE_HOME for the rpath
213 append-ldflags -Wl,-rpath="${MOZILLA_FIVE_HOME}",--enable-new-dtags
214 # Set MOZILLA_FIVE_HOME in mozconfig
215 mozconfig_annotate '' --with-default-mozilla-five-home=${MOZILLA_FIVE_HOME}
217 ####################################
221 ####################################
223 mozconfig_annotate disable_update_strip \
226 --disable-install-strip
228 # Here is a strange one...
229 if is-flag '-mcpu=ultrasparc*' || is-flag '-mtune=ultrasparc*'; then
230 mozconfig_annotate "building on ultrasparc" --enable-js-ultrasparc
233 # Currently --enable-elf-dynstr-gc only works for x86,
234 # thanks to Jason Wever <weeve@gentoo.org> for the fix.
235 if use x86 && [[ ${enable_optimize} != -O0 ]]; then
236 mozconfig_annotate "${ARCH} optimized build" --enable-elf-dynstr-gc
239 # jemalloc won't build with older glibc
240 ! has_version ">=sys-libs/glibc-2.4" && mozconfig_annotate "we have old glibc" --disable-jemalloc
243 # @FUNCTION: mozconfig_final
245 # Display a table describing all configuration options paired
246 # with reasons, then clean up extensions list.
247 # This should be called in src_configure at the end of all other mozconfig_* functions.
249 declare ac opt hash reason
251 echo "=========================================================="
252 echo "Building ${PF} with the following configuration"
253 grep ^ac_add_options .mozconfig | while read ac opt hash reason; do
254 [[ -z ${hash} || ${hash} == \# ]] \
255 || die "error reading mozconfig: ${ac} ${opt} ${hash} ${reason}"
256 printf " %-30s %s\n" "${opt}" "${reason:-mozilla.org default}"
258 echo "=========================================================="
261 # Resolve multiple --enable-extensions down to one
262 declare exts=$(sed -n 's/^ac_add_options --enable-extensions=\([^ ]*\).*/\1/p' \
264 sed -i '/^ac_add_options --enable-extensions/d' .mozconfig
265 echo "ac_add_options --enable-extensions=${exts// /,}" >> .mozconfig