1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
4 # @ECLASS: mozcoreconf-v4.eclass
6 # Mozilla team <mozilla@gentoo.org>
7 # @BLURB: core options and configuration functions for mozilla
10 # inherit mozconfig-v6.* or above for mozilla configuration support
12 # @ECLASS-VARIABLE: MOZILLA_FIVE_HOME
14 # This is an eclass-generated variable that defines the rpath that the mozilla
15 # product will be installed in. Read-only
17 if [[ ! ${_MOZCORECONF} ]]; then
19 PYTHON_COMPAT=( python2_7 )
20 PYTHON_REQ_USE='ncurses,sqlite,ssl,threads'
22 inherit multilib toolchain-funcs flag-o-matic python-any-r1 versionator
24 IUSE="${IUSE} custom-cflags custom-optimization"
26 DEPEND="virtual/pkgconfig
29 # @FUNCTION: mozconfig_annotate
31 # add an annotated line to .mozconfig
34 # mozconfig_annotate "building on ultrasparc" --enable-js-ultrasparc
35 # => ac_add_options --enable-js-ultrasparc # building on ultrasparc
36 mozconfig_annotate() {
37 declare reason=$1 x ; shift
38 [[ $# -gt 0 ]] || die "mozconfig_annotate missing flags for ${reason}\!"
40 echo "ac_add_options ${x} # ${reason}" >>.mozconfig
44 # @FUNCTION: mozconfig_use_enable
46 # add a line to .mozconfig based on a USE-flag
49 # mozconfig_use_enable truetype freetype2
50 # => ac_add_options --enable-freetype2 # +truetype
51 mozconfig_use_enable() {
52 declare flag=$(use_enable "$@")
53 mozconfig_annotate "$(use $1 && echo +$1 || echo -$1)" "${flag}"
56 # @FUNCTION mozconfig_use_with
58 # add a line to .mozconfig based on a USE-flag
61 # mozconfig_use_with kerberos gss-api /usr/$(get_libdir)
62 # => ac_add_options --with-gss-api=/usr/lib # +kerberos
63 mozconfig_use_with() {
64 declare flag=$(use_with "$@")
65 mozconfig_annotate "$(use $1 && echo +$1 || echo -$1)" "${flag}"
68 # @FUNCTION mozconfig_use_extension
70 # enable or disable an extension based on a USE-flag
73 # mozconfig_use_extension gnome gnomevfs
74 # => ac_add_options --enable-extensions=gnomevfs
75 mozconfig_use_extension() {
76 declare minus=$(use $1 || echo -)
77 mozconfig_annotate "${minus:-+}$1" --enable-extensions=${minus}${2}
81 # Ensure we use C locale when building
84 export LC_MESSAGES="C"
87 # Ensure we use correct toolchain
88 export HOST_CC="$(tc-getBUILD_CC)"
89 export HOST_CXX="$(tc-getBUILD_CXX)"
90 tc-export CC CXX LD PKG_CONFIG
92 # Ensure that we have a sane build enviroment
93 export MOZILLA_CLIENT=1
95 export NO_STATIC_LIB=1
97 export ALDFLAGS=${LDFLAGS}
98 # ensure MOZCONFIG is not defined
101 # set MOZILLA_FIVE_HOME
102 export MOZILLA_FIVE_HOME="/usr/$(get_libdir)/${PN}"
104 # nested configure scripts in mozilla products generate unrecognized options
105 # false positives when toplevel configure passes downwards.
106 export QA_CONFIGURE_OPTIONS=".*"
108 if [[ $(gcc-major-version) -eq 3 ]]; then
109 ewarn "Unsupported compiler detected, DO NOT file bugs for"
110 ewarn "outdated compilers. Bugs opened with gcc-3 will be closed"
114 python-any-r1_pkg_setup
117 # @FUNCTION: mozconfig_init
119 # Initialize mozilla configuration and populate with core settings.
120 # This should be called in src_configure before any other mozconfig_* functions.
122 declare enable_optimize pango_version myext x
123 declare XUL=$([[ ${PN} == xulrunner ]] && echo true || echo false)
124 declare FF=$([[ ${PN} == firefox ]] && echo true || echo false)
125 declare SM=$([[ ${PN} == seamonkey ]] && echo true || echo false)
126 declare TB=$([[ ${PN} == thunderbird ]] && echo true || echo false)
128 ####################################
130 # Setup the initial .mozconfig
131 # See http://www.mozilla.org/build/configure-build.html
133 ####################################
137 cp xulrunner/config/mozconfig .mozconfig \
138 || die "cp xulrunner/config/mozconfig failed" ;;
140 cp browser/config/mozconfig .mozconfig \
141 || die "cp browser/config/mozconfig failed" ;;
143 # Must create the initial mozconfig to enable application
144 : >.mozconfig || die "initial mozconfig creation failed"
145 mozconfig_annotate "" --enable-application=suite ;;
147 # Must create the initial mozconfig to enable application
148 : >.mozconfig || die "initial mozconfig creation failed"
149 mozconfig_annotate "" --enable-application=mail ;;
152 ####################################
154 # CFLAGS setup and ARCH support
156 ####################################
158 # Set optimization level
159 if [[ ${ARCH} == hppa ]]; then
160 mozconfig_annotate "more than -O0 causes a segfault on hppa" --enable-optimize=-O0
161 elif [[ ${ARCH} == x86 ]]; then
162 mozconfig_annotate "less then -O2 causes a segfault on x86" --enable-optimize=-O2
163 elif use custom-optimization || [[ ${ARCH} =~ (alpha|ia64) ]]; then
164 # Set optimization level based on CFLAGS
166 mozconfig_annotate "from CFLAGS" --enable-optimize=-O0
167 elif [[ ${ARCH} == ppc ]] && has_version '>=sys-libs/glibc-2.8'; then
168 mozconfig_annotate "more than -O1 segfaults on ppc with glibc-2.8" --enable-optimize=-O1
169 elif is-flag -O4; then
170 mozconfig_annotate "from CFLAGS" --enable-optimize=-O4
171 elif is-flag -O3; then
172 mozconfig_annotate "from CFLAGS" --enable-optimize=-O3
173 elif is-flag -O1; then
174 mozconfig_annotate "from CFLAGS" --enable-optimize=-O1
175 elif is-flag -Os; then
176 mozconfig_annotate "from CFLAGS" --enable-optimize=-Os
178 mozconfig_annotate "Gentoo's default optimization" --enable-optimize=-O2
181 # Enable Mozilla's default
182 mozconfig_annotate "mozilla default" --enable-optimize
185 # Strip optimization so it does not end up in compile string
188 # Strip over-aggressive CFLAGS
189 use custom-cflags || strip-flags
191 # Additional ARCH support
194 # Historically we have needed to add -fPIC manually for 64-bit.
195 # Additionally, alpha should *always* build with -mieee for correct math
197 append-flags -fPIC -mieee
201 # Historically we have needed to add this manually for 64-bit
206 append-flags -fPIC -mminimal-toc
210 # We need to append flags for gcc-6 support
211 if [[ $(gcc-major-version) -ge 6 ]]; then
212 append-cxxflags -fno-delete-null-pointer-checks -fno-lifetime-dse -fno-schedule-insns2
215 # Use the MOZILLA_FIVE_HOME for the rpath
216 append-ldflags -Wl,-rpath="${MOZILLA_FIVE_HOME}",--enable-new-dtags
217 # Set MOZILLA_FIVE_HOME in mozconfig
218 mozconfig_annotate '' --with-default-mozilla-five-home=${MOZILLA_FIVE_HOME}
220 ####################################
224 ####################################
226 mozconfig_annotate disable_update_strip \
229 --disable-install-strip
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