1 # Copyright 1999-2018 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
4 # @ECLASS: mozcoreconf-v6.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 inherit multilib toolchain-funcs flag-o-matic python-any-r1 versionator
21 IUSE="${IUSE} custom-cflags custom-optimization"
23 DEPEND="virtual/pkgconfig
24 dev-lang/python:2.7[ncurses,sqlite,ssl,threads(+)]
27 # @FUNCTION: mozconfig_annotate
29 # add an annotated line to .mozconfig
32 # mozconfig_annotate "building on ultrasparc" --enable-js-ultrasparc
33 # => ac_add_options --enable-js-ultrasparc # building on ultrasparc
34 mozconfig_annotate() {
35 declare reason=$1 x ; shift
36 [[ $# -gt 0 ]] || die "mozconfig_annotate missing flags for ${reason}\!"
38 echo "ac_add_options ${x} # ${reason}" >>.mozconfig
42 # @FUNCTION: mozconfig_use_enable
44 # add a line to .mozconfig based on a USE-flag
47 # mozconfig_use_enable truetype freetype2
48 # => ac_add_options --enable-freetype2 # +truetype
49 mozconfig_use_enable() {
50 declare flag=$(use_enable "$@")
51 mozconfig_annotate "$(use $1 && echo +$1 || echo -$1)" "${flag}"
54 # @FUNCTION mozconfig_use_with
56 # add a line to .mozconfig based on a USE-flag
59 # mozconfig_use_with kerberos gss-api /usr/$(get_libdir)
60 # => ac_add_options --with-gss-api=/usr/lib # +kerberos
61 mozconfig_use_with() {
62 declare flag=$(use_with "$@")
63 mozconfig_annotate "$(use $1 && echo +$1 || echo -$1)" "${flag}"
66 # @FUNCTION mozconfig_use_extension
68 # enable or disable an extension based on a USE-flag
71 # mozconfig_use_extension gnome gnomevfs
72 # => ac_add_options --enable-extensions=gnomevfs
73 mozconfig_use_extension() {
74 declare minus=$(use $1 || echo -)
75 mozconfig_annotate "${minus:-+}$1" --enable-extensions=${minus}${2}
79 # Ensure we use C locale when building
82 export LC_MESSAGES="C"
85 # Ensure we use correct toolchain
86 export HOST_CC="$(tc-getBUILD_CC)"
87 export HOST_CXX="$(tc-getBUILD_CXX)"
88 tc-export CC CXX LD PKG_CONFIG AR RANLIB
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 # set MOZILLA_FIVE_HOME
100 export MOZILLA_FIVE_HOME="/usr/$(get_libdir)/${PN}"
102 # nested configure scripts in mozilla products generate unrecognized options
103 # false positives when toplevel configure passes downwards.
104 export QA_CONFIGURE_OPTIONS=".*"
106 python-any-r1_pkg_setup
107 # workaround to set python3 into PYTHON3 until mozilla doesn't need py2
108 if [[ "${PYTHON_COMPAT[@]}" != "${PYTHON_COMPAT[@]#python3*}" ]]; then
109 export PYTHON3=${PYTHON}
110 python_export python2_7 PYTHON EPYTHON
114 # @FUNCTION: mozconfig_init
116 # Initialize mozilla configuration and populate with core settings.
117 # This should be called in src_configure before any other mozconfig_* functions.
119 declare enable_optimize pango_version myext x
120 declare XUL=$([[ ${PN} == xulrunner ]] && echo true || echo false)
121 declare FF=$([[ ${PN} == firefox ]] && echo true || echo false)
122 declare SM=$([[ ${PN} == seamonkey ]] && echo true || echo false)
123 declare TB=$([[ ${PN} == thunderbird ]] && echo true || echo false)
124 declare TRB=$([[ ${PN} == torbrowser ]] && echo true || echo false)
126 ####################################
128 # Setup the initial .mozconfig
129 # See http://www.mozilla.org/build/configure-build.html
131 ####################################
135 cp xulrunner/config/mozconfig .mozconfig \
136 || die "cp xulrunner/config/mozconfig failed" ;;
138 cp browser/config/mozconfig .mozconfig \
139 || die "cp browser/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 # NOTE--this is not compatible with mozilla prior to v60
147 mozconfig_annotate "" --enable-application=comm/suite ;;
149 # Must create the initial mozconfig to enable application
150 : >.mozconfig || die "initial mozconfig creation failed"
151 # NOTE--this is not compatible with mozilla prior to v60
152 mozconfig_annotate "" --enable-application=comm/mail ;;
155 ####################################
157 # CFLAGS setup and ARCH support
159 ####################################
161 # Set optimization level
162 if [[ $(gcc-major-version) -eq 7 ]]; then
163 mozconfig_annotate "Workaround known breakage" --enable-optimize=-O2
164 elif [[ ${ARCH} == hppa ]]; then
165 mozconfig_annotate "more than -O0 causes a segfault on hppa" --enable-optimize=-O0
166 elif [[ ${ARCH} == x86 ]]; then
167 mozconfig_annotate "less than -O2 causes a segfault on x86" --enable-optimize=-O2
168 elif [[ ${ARCH} == arm ]] && [[ $(gcc-major-version) -ge 6 ]]; then
169 mozconfig_annotate "less than -O2 causes a breakage on arm with gcc-6" --enable-optimize=-O2
170 elif use custom-optimization || [[ ${ARCH} =~ (alpha|ia64) ]]; then
171 # Set optimization level based on CFLAGS
173 mozconfig_annotate "from CFLAGS" --enable-optimize=-O0
174 elif [[ ${ARCH} == ppc ]] && has_version '>=sys-libs/glibc-2.8'; then
175 mozconfig_annotate "more than -O1 segfaults on ppc with glibc-2.8" --enable-optimize=-O1
176 elif is-flag -O4; then
177 mozconfig_annotate "from CFLAGS" --enable-optimize=-O4
178 elif is-flag -O3; then
179 mozconfig_annotate "from CFLAGS" --enable-optimize=-O3
180 elif is-flag -O1; then
181 mozconfig_annotate "from CFLAGS" --enable-optimize=-O1
182 elif is-flag -Os; then
183 mozconfig_annotate "from CFLAGS" --enable-optimize=-Os
185 mozconfig_annotate "Gentoo's default optimization" --enable-optimize=-O2
188 # Enable Mozilla's default
189 mozconfig_annotate "mozilla default" --enable-optimize
192 # Strip optimization so it does not end up in compile string
195 if is-flagq '-g*' ; then
196 mozconfig_annotate 'elf-hack broken with -g* flags' --disable-elf-hack
199 # Strip over-aggressive CFLAGS
200 use custom-cflags || strip-flags
202 # Additional ARCH support
205 # Reduce the memory requirements for linking
209 elif tc-ld-is-gold; then
210 append-ldflags -Wl,--no-keep-memory
212 append-ldflags -Wl,--no-keep-memory -Wl,--reduce-memory-overheads
216 # Historically we have needed to add -fPIC manually for 64-bit.
217 # Additionally, alpha should *always* build with -mieee for correct math
219 append-flags -fPIC -mieee
222 # Historically we have needed to add this manually for 64-bit
227 # We need to append flags for gcc-6 support
228 if [[ $(gcc-major-version) -ge 6 ]]; then
229 append-cxxflags -flifetime-dse=1
232 # Use the MOZILLA_FIVE_HOME for the rpath
233 append-ldflags -Wl,-rpath="${MOZILLA_FIVE_HOME}",--enable-new-dtags
235 ####################################
239 ####################################
241 mozconfig_annotate disable_update_strip \
244 --disable-install-strip
246 # jemalloc won't build with older glibc
247 ! has_version ">=sys-libs/glibc-2.4" && mozconfig_annotate "we have old glibc" --disable-jemalloc
250 # @FUNCTION: mozconfig_final
252 # Apply EXTRA_ECONF values to .mozconfig
253 # Display a table describing all configuration options paired
254 # with reasons, then clean up extensions list.
255 # This should be called in src_configure at the end of all other mozconfig_* functions.
257 declare ac opt hash reason
259 # Apply EXTRA_ECONF entries to .mozconfig
260 if [[ -n ${EXTRA_ECONF} ]]; then
261 IFS=\! read -a ac <<<${EXTRA_ECONF// --/\!}
262 for opt in "${ac[@]}"; do
263 mozconfig_annotate "EXTRA_ECONF" --${opt#--}
268 echo "=========================================================="
269 echo "Building ${PF} with the following configuration"
270 grep ^ac_add_options .mozconfig | while read ac opt hash reason; do
271 [[ -z ${hash} || ${hash} == \# ]] \
272 || die "error reading mozconfig: ${ac} ${opt} ${hash} ${reason}"
273 printf " %-30s %s\n" "${opt}" "${reason:-mozilla.org default}"
275 echo "=========================================================="
278 # Resolve multiple --enable-extensions down to one
279 declare exts=$(sed -n 's/^ac_add_options --enable-extensions=\([^ ]*\).*/\1/p' \
281 sed -i '/^ac_add_options --enable-extensions/d' .mozconfig
282 echo "ac_add_options --enable-extensions=${exts// /,}" >> .mozconfig