1 # Copyright 1999-2017 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
4 # @ECLASS: mozcoreconf-v5.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 [[ $(gcc-major-version) -ge 7 ]]; then
160 mozconfig_annotate "Workaround known breakage" --enable-optimize=-O2
161 elif [[ ${ARCH} == hppa ]]; then
162 mozconfig_annotate "more than -O0 causes a segfault on hppa" --enable-optimize=-O0
163 elif [[ ${ARCH} == x86 ]]; then
164 mozconfig_annotate "less then -O2 causes a segfault on x86" --enable-optimize=-O2
165 elif use custom-optimization || [[ ${ARCH} =~ (alpha|ia64) ]]; then
166 # Set optimization level based on CFLAGS
168 mozconfig_annotate "from CFLAGS" --enable-optimize=-O0
169 elif [[ ${ARCH} == ppc ]] && has_version '>=sys-libs/glibc-2.8'; then
170 mozconfig_annotate "more than -O1 segfaults on ppc with glibc-2.8" --enable-optimize=-O1
171 elif is-flag -O4; then
172 mozconfig_annotate "from CFLAGS" --enable-optimize=-O4
173 elif is-flag -O3; then
174 mozconfig_annotate "from CFLAGS" --enable-optimize=-O3
175 elif is-flag -O1; then
176 mozconfig_annotate "from CFLAGS" --enable-optimize=-O1
177 elif is-flag -Os; then
178 mozconfig_annotate "from CFLAGS" --enable-optimize=-Os
180 mozconfig_annotate "Gentoo's default optimization" --enable-optimize=-O2
183 # Enable Mozilla's default
184 mozconfig_annotate "mozilla default" --enable-optimize
187 # Strip optimization so it does not end up in compile string
190 # Strip over-aggressive CFLAGS
191 use custom-cflags || strip-flags
193 # Additional ARCH support
196 # Reduce the memory requirements for linking
197 append-ldflags -Wl,--no-keep-memory -Wl,--reduce-memory-overheads
200 # Historically we have needed to add -fPIC manually for 64-bit.
201 # Additionally, alpha should *always* build with -mieee for correct math
203 append-flags -fPIC -mieee
206 # Historically we have needed to add this manually for 64-bit
210 append-flags -fPIC -mminimal-toc
211 # Reduce the memory requirements for linking
212 append-ldflags -Wl,--no-keep-memory -Wl,--reduce-memory-overheads
216 # We need to append flags for gcc-6 support
217 if [[ $(gcc-major-version) -ge 6 ]]; then
218 append-cxxflags -fno-delete-null-pointer-checks -fno-lifetime-dse -fno-schedule-insns2
221 # Go a little faster; use less RAM
222 append-flags "$MAKEEDIT_FLAGS"
224 # Use the MOZILLA_FIVE_HOME for the rpath
225 append-ldflags -Wl,-rpath="${MOZILLA_FIVE_HOME}",--enable-new-dtags
226 # Set MOZILLA_FIVE_HOME in mozconfig
227 mozconfig_annotate '' --with-default-mozilla-five-home=${MOZILLA_FIVE_HOME}
229 ####################################
233 ####################################
235 mozconfig_annotate disable_update_strip \
238 --disable-install-strip
240 # jemalloc won't build with older glibc
241 ! has_version ">=sys-libs/glibc-2.4" && mozconfig_annotate "we have old glibc" --disable-jemalloc
244 # @FUNCTION: mozconfig_final
246 # Apply EXTRA_ECONF values to .mozconfig
247 # Display a table describing all configuration options paired
248 # with reasons, then clean up extensions list.
249 # This should be called in src_configure at the end of all other mozconfig_* functions.
251 declare ac opt hash reason
253 # Apply EXTRA_ECONF entries to .mozconfig
254 if [[ -n ${EXTRA_ECONF} ]]; then
255 IFS=\! read -a ac <<<${EXTRA_ECONF// --/\!}
256 for opt in "${ac[@]}"; do
257 mozconfig_annotate "EXTRA_ECONF" --${opt#--}
262 echo "=========================================================="
263 echo "Building ${PF} with the following configuration"
264 grep ^ac_add_options .mozconfig | while read ac opt hash reason; do
265 [[ -z ${hash} || ${hash} == \# ]] \
266 || die "error reading mozconfig: ${ac} ${opt} ${hash} ${reason}"
267 printf " %-30s %s\n" "${opt}" "${reason:-mozilla.org default}"
269 echo "=========================================================="
272 # Resolve multiple --enable-extensions down to one
273 declare exts=$(sed -n 's/^ac_add_options --enable-extensions=\([^ ]*\).*/\1/p' \
275 sed -i '/^ac_add_options --enable-extensions/d' .mozconfig
276 echo "ac_add_options --enable-extensions=${exts// /,}" >> .mozconfig