]> git.draconx.ca Git - gentoo-fixes.git/blob - eclass/mozcoreconf-v5.eclass
app-emulation/wine-vanilla-4.0.4: Adapt mpg123 dependency.
[gentoo-fixes.git] / eclass / mozcoreconf-v5.eclass
1 # This eclass is a modified version of the work originally distributed with
2 # Gentoo GNU/Linux, covered by the following copyright and permission notice:
3 #
4 #   Copyright 1999-2022 Gentoo Authors
5 #   Distributed under the terms of the GNU General Public License v2
6 #
7 # The modifications are:
8 #
9 #   * Avoid python eclasses which no longer support python2 (2022-12)
10 #   * Remove versionator inherit which seems unused (2023-04)
11 #   * Update to EAPI 8 (2023-04)
12 #
13 # @DEAD
14 # @ECLASS: mozcoreconf-v5.eclass
15 # @MAINTAINER:
16 # Mozilla team <mozilla@gentoo.org>
17 # @BLURB: core options and configuration functions for mozilla
18 # @DESCRIPTION:
19 #
20 # inherit mozconfig-v6.* or above for mozilla configuration support
21
22 # @ECLASS_VARIABLE: MOZILLA_FIVE_HOME
23 # @DESCRIPTION:
24 # This is an eclass-generated variable that defines the rpath that the mozilla
25 # product will be installed in.  Read-only
26
27 if [[ ! ${_MOZCORECONF} ]]; then
28
29 inherit multilib toolchain-funcs flag-o-matic
30
31 IUSE="${IUSE} custom-cflags custom-optimization"
32
33 BDEPEND="dev-lang/python:2.7[ncurses,sqlite,ssl,threads(+)]
34         virtual/pkgconfig"
35
36 # @FUNCTION: mozconfig_annotate
37 # @DESCRIPTION:
38 # add an annotated line to .mozconfig
39 #
40 # Example:
41 # mozconfig_annotate "building on ultrasparc" --enable-js-ultrasparc
42 # => ac_add_options --enable-js-ultrasparc # building on ultrasparc
43 mozconfig_annotate() {
44         declare reason=$1 x ; shift
45         [[ $# -gt 0 ]] || die "mozconfig_annotate missing flags for ${reason}\!"
46         for x in ${*}; do
47                 echo "ac_add_options ${x} # ${reason}" >>.mozconfig
48         done
49 }
50
51 # @FUNCTION: mozconfig_use_enable
52 # @DESCRIPTION:
53 # add a line to .mozconfig based on a USE-flag
54 #
55 # Example:
56 # mozconfig_use_enable truetype freetype2
57 # => ac_add_options --enable-freetype2 # +truetype
58 mozconfig_use_enable() {
59         declare flag=$(use_enable "$@")
60         mozconfig_annotate "$(use $1 && echo +$1 || echo -$1)" "${flag}"
61 }
62
63 # @FUNCTION: mozconfig_use_with
64 # @DESCRIPTION:
65 # add a line to .mozconfig based on a USE-flag
66 #
67 # Example:
68 # mozconfig_use_with kerberos gss-api /usr/$(get_libdir)
69 # => ac_add_options --with-gss-api=/usr/lib # +kerberos
70 mozconfig_use_with() {
71         declare flag=$(use_with "$@")
72         mozconfig_annotate "$(use $1 && echo +$1 || echo -$1)" "${flag}"
73 }
74
75 # @FUNCTION: mozconfig_use_extension
76 # @DESCRIPTION:
77 # enable or disable an extension based on a USE-flag
78 #
79 # Example:
80 # mozconfig_use_extension gnome gnomevfs
81 # => ac_add_options --enable-extensions=gnomevfs
82 mozconfig_use_extension() {
83         declare minus=$(use $1 || echo -)
84         mozconfig_annotate "${minus:-+}$1" --enable-extensions=${minus}${2}
85 }
86
87 moz_pkgsetup() {
88         # Ensure we use C locale when building
89         export LANG="C"
90         export LC_ALL="C"
91         export LC_MESSAGES="C"
92         export LC_CTYPE="C"
93
94         # Ensure we use correct toolchain
95         export HOST_CC="$(tc-getBUILD_CC)"
96         export HOST_CXX="$(tc-getBUILD_CXX)"
97         tc-export CC CXX LD PKG_CONFIG
98
99         # Ensure that we have a sane build enviroment
100         export MOZILLA_CLIENT=1
101         export BUILD_OPT=1
102         export NO_STATIC_LIB=1
103         export USE_PTHREADS=1
104         export ALDFLAGS=${LDFLAGS}
105         # ensure MOZCONFIG is not defined
106         unset MOZCONFIG
107
108         # set MOZILLA_FIVE_HOME
109         export MOZILLA_FIVE_HOME="/usr/$(get_libdir)/${PN}"
110
111         # nested configure scripts in mozilla products generate unrecognized options
112         # false positives when toplevel configure passes downwards.
113         export QA_CONFIGURE_OPTIONS=".*"
114
115         export PYTHON=python2.7
116 }
117
118 # @FUNCTION: mozconfig_init
119 # @DESCRIPTION:
120 # Initialize mozilla configuration and populate with core settings.
121 # This should be called in src_configure before any other mozconfig_* functions.
122 mozconfig_init() {
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)
128         declare WF=$([[ ${PN} == waterfox* ]] && echo true || echo false)
129
130         ####################################
131         #
132         # Setup the initial .mozconfig
133         # See http://www.mozilla.org/build/configure-build.html
134         #
135         ####################################
136
137         case ${PN} in
138                 *xulrunner)
139                         cp xulrunner/config/mozconfig .mozconfig \
140                                 || die "cp xulrunner/config/mozconfig failed" ;;
141                 *firefox|waterfox*)
142                         cp browser/config/mozconfig .mozconfig \
143                                 || die "cp browser/config/mozconfig failed" ;;
144                 seamonkey)
145                         # Must create the initial mozconfig to enable application
146                         : >.mozconfig || die "initial mozconfig creation failed"
147                         mozconfig_annotate "" --enable-application=suite ;;
148                 *thunderbird)
149                         # Must create the initial mozconfig to enable application
150                         : >.mozconfig || die "initial mozconfig creation failed"
151                         mozconfig_annotate "" --enable-application=mail ;;
152         esac
153
154         ####################################
155         #
156         # CFLAGS setup and ARCH support
157         #
158         ####################################
159
160         # Set optimization level
161         mozconfig_annotate "Workaround known breakage" --enable-optimize=-O2
162
163         if [[ ${ARCH} == hppa ]]; then
164                 mozconfig_annotate "more than -O0 causes a segfault on hppa" --enable-optimize=-O0
165         elif [[ ${ARCH} == x86 ]]; then
166                 mozconfig_annotate "less then -O2 causes a segfault on x86" --enable-optimize=-O2
167         elif use custom-optimization || [[ ${ARCH} =~ (alpha|ia64) ]]; then
168                 # Set optimization level based on CFLAGS
169                 if is-flag -O0; then
170                         mozconfig_annotate "from CFLAGS" --enable-optimize=-O0
171                 elif [[ ${ARCH} == ppc ]] && has_version '>=sys-libs/glibc-2.8'; then
172                         mozconfig_annotate "more than -O1 segfaults on ppc with glibc-2.8" --enable-optimize=-O1
173                 elif is-flag -O4; then
174                         mozconfig_annotate "from CFLAGS" --enable-optimize=-O4
175                 elif is-flag -O3; then
176                         mozconfig_annotate "from CFLAGS" --enable-optimize=-O3
177                 elif is-flag -O1; then
178                         mozconfig_annotate "from CFLAGS" --enable-optimize=-O1
179                 elif is-flag -Os; then
180                         mozconfig_annotate "from CFLAGS" --enable-optimize=-Os
181                 else
182                         mozconfig_annotate "Gentoo's default optimization" --enable-optimize=-O2
183                 fi
184         else
185                 # Enable Mozilla's default
186                 mozconfig_annotate "mozilla default" --enable-optimize
187         fi
188
189         # Strip optimization so it does not end up in compile string
190         filter-flags '-O*'
191
192         # Strip over-aggressive CFLAGS
193         use custom-cflags || strip-flags
194
195         # Additional ARCH support
196         case "${ARCH}" in
197         arm)
198                 # Reduce the memory requirements for linking
199                 append-ldflags -Wl,--no-keep-memory -Wl,--reduce-memory-overheads
200                 ;;
201         alpha)
202                 # Historically we have needed to add -fPIC manually for 64-bit.
203                 # Additionally, alpha should *always* build with -mieee for correct math
204                 # operation
205                 append-flags -fPIC -mieee
206                 ;;
207         ia64)
208                 # Historically we have needed to add this manually for 64-bit
209                 append-flags -fPIC
210                 ;;
211         ppc64)
212                 append-flags -fPIC -mminimal-toc
213                 # Reduce the memory requirements for linking
214                 append-ldflags -Wl,--no-keep-memory -Wl,--reduce-memory-overheads
215                 ;;
216         esac
217
218         # We need to append flags for >= gcc-6 support
219         append-cxxflags -fno-delete-null-pointer-checks -fno-lifetime-dse -fno-schedule-insns2
220
221         # Use the MOZILLA_FIVE_HOME for the rpath
222         append-ldflags -Wl,-rpath="${MOZILLA_FIVE_HOME}",--enable-new-dtags
223         # Set MOZILLA_FIVE_HOME in mozconfig
224         mozconfig_annotate '' --with-default-mozilla-five-home=${MOZILLA_FIVE_HOME}
225
226         ####################################
227         #
228         # mozconfig setup
229         #
230         ####################################
231
232         mozconfig_annotate disable_update_strip \
233                 --disable-updater \
234                 --disable-strip \
235                 --disable-install-strip
236
237         # jemalloc won't build with older glibc
238         ! has_version ">=sys-libs/glibc-2.4" && mozconfig_annotate "we have old glibc" --disable-jemalloc
239 }
240
241 # @FUNCTION: mozconfig_final
242 # @DESCRIPTION:
243 # Apply EXTRA_ECONF values to .mozconfig
244 # Display a table describing all configuration options paired
245 # with reasons, then clean up extensions list.
246 # This should be called in src_configure at the end of all other mozconfig_* functions.
247 mozconfig_final() {
248         declare ac opt hash reason
249
250         # Apply EXTRA_ECONF entries to .mozconfig
251         if [[ -n ${EXTRA_ECONF} ]]; then
252                 IFS=\! read -a ac <<<${EXTRA_ECONF// --/\!}
253                 for opt in "${ac[@]}"; do
254                         mozconfig_annotate "EXTRA_ECONF" --${opt#--}
255                 done
256         fi
257
258         echo
259         echo "=========================================================="
260         echo "Building ${PF} with the following configuration"
261         grep ^ac_add_options .mozconfig | while read ac opt hash reason; do
262                 [[ -z ${hash} || ${hash} == \# ]] \
263                         || die "error reading mozconfig: ${ac} ${opt} ${hash} ${reason}"
264                 printf "    %-30s  %s\n" "${opt}" "${reason:-mozilla.org default}"
265         done
266         echo "=========================================================="
267         echo
268
269         # Resolve multiple --enable-extensions down to one
270         declare exts=$(sed -n 's/^ac_add_options --enable-extensions=\([^ ]*\).*/\1/p' \
271                 .mozconfig | xargs)
272         sed -i '/^ac_add_options --enable-extensions/d' .mozconfig
273         echo "ac_add_options --enable-extensions=${exts// /,}" >> .mozconfig
274 }
275
276 _MOZCORECONF=1
277 fi