1 |
commit: 0c65bf3a8be23a1087252ab0b5c684360ac30d1b |
2 |
Author: Andreas K. Hüttel <dilfridge <AT> gentoo <DOT> org> |
3 |
AuthorDate: Fri Sep 11 15:02:28 2020 +0000 |
4 |
Commit: Andreas K. Hüttel <dilfridge <AT> gentoo <DOT> org> |
5 |
CommitDate: Fri Sep 11 15:02:28 2020 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/riscv.git/commit/?id=0c65bf3a |
7 |
|
8 |
eclass: Moved to main tree |
9 |
|
10 |
Signed-off-by: Andreas K. Hüttel <dilfridge <AT> gentoo.org> |
11 |
|
12 |
eclass/multilib-build.eclass | 694 ------------------------------------------- |
13 |
eclass/multilib.eclass | 554 ---------------------------------- |
14 |
2 files changed, 1248 deletions(-) |
15 |
|
16 |
diff --git a/eclass/multilib-build.eclass b/eclass/multilib-build.eclass |
17 |
deleted file mode 100644 |
18 |
index dc4f8a2..0000000 |
19 |
--- a/eclass/multilib-build.eclass |
20 |
+++ /dev/null |
21 |
@@ -1,694 +0,0 @@ |
22 |
-# Copyright 2013-2020 Gentoo Authors |
23 |
-# Distributed under the terms of the GNU General Public License v2 |
24 |
- |
25 |
-# @ECLASS: multilib-build.eclass |
26 |
-# @MAINTAINER: |
27 |
-# gx86-multilib team <multilib@g.o> |
28 |
-# @AUTHOR: |
29 |
-# Author: Michał Górny <mgorny@g.o> |
30 |
-# @SUPPORTED_EAPIS: 4 5 6 7 |
31 |
-# @BLURB: flags and utility functions for building multilib packages |
32 |
-# @DESCRIPTION: |
33 |
-# The multilib-build.eclass exports USE flags and utility functions |
34 |
-# necessary to build packages for multilib in a clean and uniform |
35 |
-# manner. |
36 |
-# |
37 |
-# Please note that dependency specifications for multilib-capable |
38 |
-# dependencies shall use the USE dependency string in ${MULTILIB_USEDEP} |
39 |
-# to properly request multilib enabled. |
40 |
- |
41 |
-if [[ ! ${_MULTILIB_BUILD} ]]; then |
42 |
- |
43 |
-# EAPI=4 is required for meaningful MULTILIB_USEDEP. |
44 |
-case ${EAPI:-0} in |
45 |
- 4|5|6|7) ;; |
46 |
- *) die "EAPI=${EAPI} is not supported" ;; |
47 |
-esac |
48 |
- |
49 |
-[[ ${EAPI} == [45] ]] && inherit eutils |
50 |
-inherit multibuild multilib |
51 |
- |
52 |
-# @ECLASS-VARIABLE: _MULTILIB_FLAGS |
53 |
-# @INTERNAL |
54 |
-# @DESCRIPTION: |
55 |
-# The list of multilib flags and corresponding ABI values. If the same |
56 |
-# flag is reused for multiple ABIs (e.g. x86 on Linux&FreeBSD), multiple |
57 |
-# ABIs may be separated by commas. |
58 |
-# |
59 |
-# Please contact multilib before modifying this list. This way we can |
60 |
-# ensure that every *preliminary* work is done and the multilib can be |
61 |
-# extended safely. |
62 |
-_MULTILIB_FLAGS=( |
63 |
- abi_x86_32:x86,x86_fbsd,x86_freebsd,x86_linux,x86_macos,x86_solaris |
64 |
- abi_x86_64:amd64,amd64_fbsd,x64_freebsd,amd64_linux,x64_macos,x64_solaris |
65 |
- abi_x86_x32:x32 |
66 |
- abi_mips_n32:n32 |
67 |
- abi_mips_n64:n64 |
68 |
- abi_mips_o32:o32 |
69 |
-# abi_ppc_32:ppc,ppc_aix,ppc_macos |
70 |
-# abi_ppc_64:ppc64 |
71 |
- abi_riscv_lp64d:lp64d |
72 |
- abi_riscv_lp64:lp64 |
73 |
- abi_riscv_ilp32d:ilp32d |
74 |
- abi_riscv_ilp32:ilp32 |
75 |
- abi_s390_32:s390 |
76 |
- abi_s390_64:s390x |
77 |
-) |
78 |
-readonly _MULTILIB_FLAGS |
79 |
- |
80 |
-# @ECLASS-VARIABLE: MULTILIB_COMPAT |
81 |
-# @DEFAULT_UNSET |
82 |
-# @DESCRIPTION: |
83 |
-# List of multilib ABIs supported by the ebuild. If unset, defaults to |
84 |
-# all ABIs supported by the eclass. |
85 |
-# |
86 |
-# This variable is intended for use in prebuilt multilib packages that |
87 |
-# can provide binaries only for a limited set of ABIs. If ABIs need to |
88 |
-# be limited due to a bug in source code, package.use.mask is to be used |
89 |
-# instead. Along with MULTILIB_COMPAT, KEYWORDS should contain '-*'. |
90 |
-# |
91 |
-# Note that setting this variable effectively disables support for all |
92 |
-# other ABIs, including other architectures. For example, specifying |
93 |
-# abi_x86_{32,64} disables support for MIPS as well. |
94 |
-# |
95 |
-# The value of MULTILIB_COMPAT determines the value of IUSE. If set, it |
96 |
-# also enables REQUIRED_USE constraints. |
97 |
-# |
98 |
-# Example use: |
99 |
-# @CODE |
100 |
-# # Upstream provides binaries for x86 & amd64 only |
101 |
-# MULTILIB_COMPAT=( abi_x86_{32,64} ) |
102 |
-# @CODE |
103 |
- |
104 |
-# @ECLASS-VARIABLE: MULTILIB_USEDEP |
105 |
-# @OUTPUT_VARIABLE |
106 |
-# @DESCRIPTION: |
107 |
-# The USE-dependency to be used on dependencies (libraries) needing |
108 |
-# to support multilib as well. |
109 |
-# |
110 |
-# Example use: |
111 |
-# @CODE |
112 |
-# RDEPEND="dev-libs/libfoo[${MULTILIB_USEDEP}] |
113 |
-# net-libs/libbar[ssl,${MULTILIB_USEDEP}]" |
114 |
-# @CODE |
115 |
- |
116 |
-# @ECLASS-VARIABLE: MULTILIB_ABI_FLAG |
117 |
-# @OUTPUT_VARIABLE |
118 |
-# @DESCRIPTION: |
119 |
-# The complete ABI name. Resembles the USE flag name. |
120 |
-# |
121 |
-# This is set within multilib_foreach_abi(), |
122 |
-# multilib_parallel_foreach_abi() and multilib-minimal sub-phase |
123 |
-# functions. |
124 |
-# |
125 |
-# It may be null (empty) when the build is done on ABI not controlled |
126 |
-# by a USE flag (e.g. on non-multilib arch or when using multilib |
127 |
-# portage). The build will always be done for a single ABI then. |
128 |
-# |
129 |
-# Example value: |
130 |
-# @CODE |
131 |
-# abi_x86_64 |
132 |
-# @CODE |
133 |
- |
134 |
-_multilib_build_set_globals() { |
135 |
- local flags=( "${_MULTILIB_FLAGS[@]%:*}" ) |
136 |
- |
137 |
- if [[ ${MULTILIB_COMPAT[@]} ]]; then |
138 |
- # Validate MULTILIB_COMPAT and filter out the flags. |
139 |
- local f |
140 |
- for f in "${MULTILIB_COMPAT[@]}"; do |
141 |
- if ! has "${f}" "${flags[@]}"; then |
142 |
- die "Invalid value in MULTILIB_COMPAT: ${f}" |
143 |
- fi |
144 |
- done |
145 |
- |
146 |
- flags=( "${MULTILIB_COMPAT[@]}" ) |
147 |
- |
148 |
- REQUIRED_USE="|| ( ${flags[*]} )" |
149 |
- fi |
150 |
- |
151 |
- local usedeps=${flags[@]/%/(-)?} |
152 |
- |
153 |
- IUSE=${flags[*]} |
154 |
- MULTILIB_USEDEP=${usedeps// /,} |
155 |
- readonly MULTILIB_USEDEP |
156 |
-} |
157 |
-_multilib_build_set_globals |
158 |
-unset -f _multilib_build_set_globals |
159 |
- |
160 |
-# @FUNCTION: multilib_get_enabled_abis |
161 |
-# @DESCRIPTION: |
162 |
-# Return the ordered list of enabled ABIs if multilib builds |
163 |
-# are enabled. The best (most preferred) ABI will come last. |
164 |
-# |
165 |
-# If multilib is disabled, the default ABI will be returned |
166 |
-# in order to enforce consistent testing with multilib code. |
167 |
-multilib_get_enabled_abis() { |
168 |
- debug-print-function ${FUNCNAME} "${@}" |
169 |
- |
170 |
- local pairs=( $(multilib_get_enabled_abi_pairs) ) |
171 |
- echo "${pairs[@]#*.}" |
172 |
-} |
173 |
- |
174 |
-# @FUNCTION: multilib_get_enabled_abi_pairs |
175 |
-# @DESCRIPTION: |
176 |
-# Return the ordered list of enabled <use-flag>.<ABI> pairs |
177 |
-# if multilib builds are enabled. The best (most preferred) |
178 |
-# ABI will come last. |
179 |
-# |
180 |
-# If multilib is disabled, the default ABI will be returned |
181 |
-# along with empty <use-flag>. |
182 |
-multilib_get_enabled_abi_pairs() { |
183 |
- debug-print-function ${FUNCNAME} "${@}" |
184 |
- |
185 |
- local abis=( $(get_all_abis) ) |
186 |
- |
187 |
- local abi i found |
188 |
- for abi in "${abis[@]}"; do |
189 |
- for i in "${_MULTILIB_FLAGS[@]}"; do |
190 |
- local m_abis=${i#*:} m_abi |
191 |
- local m_flag=${i%:*} |
192 |
- |
193 |
- # split on ,; we can't switch IFS for function scope because |
194 |
- # paludis is broken (bug #486592), and switching it locally |
195 |
- # for the split is more complex than cheating like this |
196 |
- for m_abi in ${m_abis//,/ }; do |
197 |
- if [[ ${m_abi} == ${abi} ]] \ |
198 |
- && { [[ ! "${MULTILIB_COMPAT[@]}" ]] || has "${m_flag}" "${MULTILIB_COMPAT[@]}"; } \ |
199 |
- && use "${m_flag}" |
200 |
- then |
201 |
- echo "${m_flag}.${abi}" |
202 |
- found=1 |
203 |
- break 2 |
204 |
- fi |
205 |
- done |
206 |
- done |
207 |
- done |
208 |
- |
209 |
- if [[ ! ${found} ]]; then |
210 |
- # ${ABI} can be used to override the fallback (multilib-portage), |
211 |
- # ${DEFAULT_ABI} is the safe fallback. |
212 |
- local abi=${ABI:-${DEFAULT_ABI}} |
213 |
- |
214 |
- debug-print "${FUNCNAME}: no ABIs enabled, fallback to ${abi}" |
215 |
- debug-print "${FUNCNAME}: ABI=${ABI}, DEFAULT_ABI=${DEFAULT_ABI}" |
216 |
- echo ".${abi}" |
217 |
- fi |
218 |
-} |
219 |
- |
220 |
-# @FUNCTION: _multilib_multibuild_wrapper |
221 |
-# @USAGE: <argv>... |
222 |
-# @INTERNAL |
223 |
-# @DESCRIPTION: |
224 |
-# Initialize the environment for ABI selected for multibuild. |
225 |
-_multilib_multibuild_wrapper() { |
226 |
- debug-print-function ${FUNCNAME} "${@}" |
227 |
- |
228 |
- local ABI=${MULTIBUILD_VARIANT#*.} |
229 |
- local -r MULTILIB_ABI_FLAG=${MULTIBUILD_VARIANT%.*} |
230 |
- |
231 |
- multilib_toolchain_setup "${ABI}" |
232 |
- readonly ABI |
233 |
- "${@}" |
234 |
-} |
235 |
- |
236 |
-# @FUNCTION: multilib_foreach_abi |
237 |
-# @USAGE: <argv>... |
238 |
-# @DESCRIPTION: |
239 |
-# If multilib support is enabled, sets the toolchain up for each |
240 |
-# supported ABI along with the ABI variable and correct BUILD_DIR, |
241 |
-# and runs the given commands with them. |
242 |
-# |
243 |
-# If multilib support is disabled, it just runs the commands. No setup |
244 |
-# is done. |
245 |
-multilib_foreach_abi() { |
246 |
- debug-print-function ${FUNCNAME} "${@}" |
247 |
- |
248 |
- local MULTIBUILD_VARIANTS=( $(multilib_get_enabled_abi_pairs) ) |
249 |
- multibuild_foreach_variant _multilib_multibuild_wrapper "${@}" |
250 |
-} |
251 |
- |
252 |
-# @FUNCTION: multilib_parallel_foreach_abi |
253 |
-# @USAGE: <argv>... |
254 |
-# @DESCRIPTION: |
255 |
-# If multilib support is enabled, sets the toolchain up for each |
256 |
-# supported ABI along with the ABI variable and correct BUILD_DIR, |
257 |
-# and runs the given commands with them. |
258 |
-# |
259 |
-# If multilib support is disabled, it just runs the commands. No setup |
260 |
-# is done. |
261 |
-# |
262 |
-# This function used to run multiple commands in parallel. Now it's just |
263 |
-# a deprecated alias to multilib_foreach_abi. |
264 |
-multilib_parallel_foreach_abi() { |
265 |
- debug-print-function ${FUNCNAME} "${@}" |
266 |
- |
267 |
- local MULTIBUILD_VARIANTS=( $(multilib_get_enabled_abi_pairs) ) |
268 |
- multibuild_foreach_variant _multilib_multibuild_wrapper "${@}" |
269 |
-} |
270 |
- |
271 |
-# @FUNCTION: multilib_for_best_abi |
272 |
-# @USAGE: <argv>... |
273 |
-# @DESCRIPTION: |
274 |
-# Runs the given command with setup for the 'best' (usually native) ABI. |
275 |
-multilib_for_best_abi() { |
276 |
- debug-print-function ${FUNCNAME} "${@}" |
277 |
- |
278 |
- [[ ${EAPI} == [45] ]] || die "${FUNCNAME} is banned in EAPI ${EAPI}, use multilib_is_native_abi() instead" |
279 |
- |
280 |
- eqawarn "QA warning: multilib_for_best_abi() function is deprecated and should" |
281 |
- eqawarn "not be used. The multilib_is_native_abi() check may be used instead." |
282 |
- |
283 |
- local MULTIBUILD_VARIANTS=( $(multilib_get_enabled_abi_pairs) ) |
284 |
- |
285 |
- multibuild_for_best_variant _multilib_multibuild_wrapper "${@}" |
286 |
-} |
287 |
- |
288 |
-# @FUNCTION: multilib_check_headers |
289 |
-# @DESCRIPTION: |
290 |
-# Check whether the header files are consistent between ABIs. |
291 |
-# |
292 |
-# This function needs to be called after each ABI's installation phase. |
293 |
-# It obtains the header file checksums and compares them with previous |
294 |
-# runs (if any). Dies if header files differ. |
295 |
-multilib_check_headers() { |
296 |
- _multilib_header_cksum() { |
297 |
- set -o pipefail |
298 |
- |
299 |
- if [[ -d ${ED%/}/usr/include ]]; then |
300 |
- find "${ED%/}"/usr/include -type f \ |
301 |
- -exec cksum {} + | sort -k2 |
302 |
- fi |
303 |
- } |
304 |
- |
305 |
- local cksum cksum_prev |
306 |
- local cksum_file=${T}/.multilib_header_cksum |
307 |
- cksum=$(_multilib_header_cksum) || die |
308 |
- unset -f _multilib_header_cksum |
309 |
- |
310 |
- if [[ -f ${cksum_file} ]]; then |
311 |
- cksum_prev=$(< "${cksum_file}") || die |
312 |
- |
313 |
- if [[ ${cksum} != ${cksum_prev} ]]; then |
314 |
- echo "${cksum}" > "${cksum_file}.new" || die |
315 |
- |
316 |
- eerror "Header files have changed between ABIs." |
317 |
- |
318 |
- if type -p diff &>/dev/null; then |
319 |
- eerror "$(diff -du "${cksum_file}" "${cksum_file}.new")" |
320 |
- else |
321 |
- eerror "Old checksums in: ${cksum_file}" |
322 |
- eerror "New checksums in: ${cksum_file}.new" |
323 |
- fi |
324 |
- |
325 |
- die "Header checksum mismatch, aborting." |
326 |
- fi |
327 |
- else |
328 |
- echo "${cksum}" > "${cksum_file}" || die |
329 |
- fi |
330 |
-} |
331 |
- |
332 |
-# @FUNCTION: multilib_copy_sources |
333 |
-# @DESCRIPTION: |
334 |
-# Create a single copy of the package sources for each enabled ABI. |
335 |
-# |
336 |
-# The sources are always copied from initial BUILD_DIR (or S if unset) |
337 |
-# to ABI-specific build directory matching BUILD_DIR used by |
338 |
-# multilib_foreach_abi(). |
339 |
-multilib_copy_sources() { |
340 |
- debug-print-function ${FUNCNAME} "${@}" |
341 |
- |
342 |
- local MULTIBUILD_VARIANTS=( $(multilib_get_enabled_abi_pairs) ) |
343 |
- multibuild_copy_sources |
344 |
-} |
345 |
- |
346 |
-# @ECLASS-VARIABLE: MULTILIB_WRAPPED_HEADERS |
347 |
-# @DEFAULT_UNSET |
348 |
-# @DESCRIPTION: |
349 |
-# A list of headers to wrap for multilib support. The listed headers |
350 |
-# will be moved to a non-standard location and replaced with a file |
351 |
-# including them conditionally to current ABI. |
352 |
-# |
353 |
-# This variable has to be a bash array. Paths shall be relative to |
354 |
-# installation root (${ED}), and name regular files. Recursive wrapping |
355 |
-# is not supported. |
356 |
-# |
357 |
-# Please note that header wrapping is *discouraged*. It is preferred to |
358 |
-# install all headers in a subdirectory of libdir and use pkg-config to |
359 |
-# locate the headers. Some C preprocessors will not work with wrapped |
360 |
-# headers. |
361 |
-# |
362 |
-# Example: |
363 |
-# @CODE |
364 |
-# MULTILIB_WRAPPED_HEADERS=( |
365 |
-# /usr/include/foobar/config.h |
366 |
-# ) |
367 |
-# @CODE |
368 |
- |
369 |
-# @ECLASS-VARIABLE: MULTILIB_CHOST_TOOLS |
370 |
-# @DEFAULT_UNSET |
371 |
-# @DESCRIPTION: |
372 |
-# A list of tool executables to preserve for each multilib ABI. |
373 |
-# The listed executables will be renamed to ${CHOST}-${basename}, |
374 |
-# and the native variant will be symlinked to the generic name. |
375 |
-# |
376 |
-# This variable has to be a bash array. Paths shall be relative to |
377 |
-# installation root (${ED}), and name regular files or symbolic |
378 |
-# links to regular files. Recursive wrapping is not supported. |
379 |
-# |
380 |
-# If symbolic link is passed, both symlink path and symlink target |
381 |
-# will be changed. As a result, the symlink target is expected |
382 |
-# to be wrapped as well (either by listing in MULTILIB_CHOST_TOOLS |
383 |
-# or externally). |
384 |
-# |
385 |
-# Please note that tool wrapping is *discouraged*. It is preferred to |
386 |
-# install pkg-config files for each ABI, and require reverse |
387 |
-# dependencies to use that. |
388 |
-# |
389 |
-# Packages that search for tools properly (e.g. using AC_PATH_TOOL |
390 |
-# macro) will find the wrapper executables automatically. Other packages |
391 |
-# will need explicit override of tool paths. |
392 |
-# |
393 |
-# Example: |
394 |
-# @CODE |
395 |
-# MULTILIB_CHOST_TOOLS=( |
396 |
-# /usr/bin/foo-config |
397 |
-# ) |
398 |
-# @CODE |
399 |
- |
400 |
-# @FUNCTION: multilib_prepare_wrappers |
401 |
-# @USAGE: [<install-root>] |
402 |
-# @DESCRIPTION: |
403 |
-# Perform the preparation of all kinds of wrappers for the current ABI. |
404 |
-# This function shall be called once per each ABI, after installing |
405 |
-# the files to be wrapped. |
406 |
-# |
407 |
-# Takes an optional custom <install-root> from which files will be |
408 |
-# used. If no root is specified, uses ${ED}. |
409 |
-# |
410 |
-# The files to be wrapped are specified using separate variables, |
411 |
-# e.g. MULTILIB_WRAPPED_HEADERS. Those variables shall not be changed |
412 |
-# between the successive calls to multilib_prepare_wrappers |
413 |
-# and multilib_install_wrappers. |
414 |
-# |
415 |
-# After all wrappers are prepared, multilib_install_wrappers shall |
416 |
-# be called to commit them to the installation tree. |
417 |
-multilib_prepare_wrappers() { |
418 |
- debug-print-function ${FUNCNAME} "${@}" |
419 |
- |
420 |
- [[ ${#} -le 1 ]] || die "${FUNCNAME}: too many arguments" |
421 |
- |
422 |
- local root=${1:-${ED%/}} |
423 |
- local f |
424 |
- |
425 |
- if [[ ${COMPLETE_MULTILIB} == yes ]]; then |
426 |
- # symlink '${CHOST}-foo -> foo' to support abi-wrapper while |
427 |
- # keeping ${CHOST}-foo calls correct. |
428 |
- |
429 |
- for f in "${MULTILIB_CHOST_TOOLS[@]}"; do |
430 |
- # drop leading slash if it's there |
431 |
- f=${f#/} |
432 |
- |
433 |
- local dir=${f%/*} |
434 |
- local fn=${f##*/} |
435 |
- |
436 |
- ln -s "${fn}" "${root}/${dir}/${CHOST}-${fn}" || die |
437 |
- done |
438 |
- |
439 |
- return |
440 |
- fi |
441 |
- |
442 |
- for f in "${MULTILIB_CHOST_TOOLS[@]}"; do |
443 |
- # drop leading slash if it's there |
444 |
- f=${f#/} |
445 |
- |
446 |
- local dir=${f%/*} |
447 |
- local fn=${f##*/} |
448 |
- |
449 |
- if [[ -L ${root}/${f} ]]; then |
450 |
- # rewrite the symlink target |
451 |
- local target |
452 |
- target=$(readlink "${root}/${f}") || die |
453 |
- local target_dir target_fn=${target##*/} |
454 |
- |
455 |
- [[ ${target} == */* ]] && target_dir=${target%/*} |
456 |
- |
457 |
- ln -f -s "${target_dir+${target_dir}/}${CHOST}-${target_fn}" \ |
458 |
- "${root}/${f}" || die |
459 |
- fi |
460 |
- |
461 |
- mv "${root}/${f}" "${root}/${dir}/${CHOST}-${fn}" || die |
462 |
- |
463 |
- # symlink the native one back |
464 |
- if multilib_is_native_abi; then |
465 |
- ln -s "${CHOST}-${fn}" "${root}/${f}" || die |
466 |
- fi |
467 |
- done |
468 |
- |
469 |
- if [[ ${MULTILIB_WRAPPED_HEADERS[@]} ]]; then |
470 |
- # If abi_flag is unset, then header wrapping is unsupported on |
471 |
- # this ABI. This means the arch doesn't support multilib at all |
472 |
- # -- in this case, the headers are not wrapped and everything |
473 |
- # works as expected. |
474 |
- |
475 |
- if [[ ${MULTILIB_ABI_FLAG} ]]; then |
476 |
- for f in "${MULTILIB_WRAPPED_HEADERS[@]}"; do |
477 |
- # drop leading slash if it's there |
478 |
- f=${f#/} |
479 |
- |
480 |
- if [[ ${f} != usr/include/* ]]; then |
481 |
- die "Wrapping headers outside of /usr/include is not supported at the moment." |
482 |
- fi |
483 |
- # and then usr/include |
484 |
- f=${f#usr/include} |
485 |
- |
486 |
- local dir=${f%/*} |
487 |
- |
488 |
- # Some ABIs may have install less files than others. |
489 |
- if [[ -f ${root}/usr/include${f} ]]; then |
490 |
- local wrapper=${ED%/}/tmp/multilib-include${f} |
491 |
- |
492 |
- if [[ ! -f ${ED%/}/tmp/multilib-include${f} ]]; then |
493 |
- dodir "/tmp/multilib-include${dir}" |
494 |
- # a generic template |
495 |
- cat > "${wrapper}" <<_EOF_ || die |
496 |
-/* This file is auto-generated by multilib-build.eclass |
497 |
- * as a multilib-friendly wrapper. For the original content, |
498 |
- * please see the files that are #included below. |
499 |
- */ |
500 |
- |
501 |
-#if defined(__x86_64__) /* amd64 */ |
502 |
-# if defined(__ILP32__) /* x32 ABI */ |
503 |
-# error "abi_x86_x32 not supported by the package." |
504 |
-# else /* 64-bit ABI */ |
505 |
-# error "abi_x86_64 not supported by the package." |
506 |
-# endif |
507 |
-#elif defined(__i386__) /* plain x86 */ |
508 |
-# error "abi_x86_32 not supported by the package." |
509 |
-#elif defined(__mips__) |
510 |
-# if(_MIPS_SIM == _ABIN32) /* n32 */ |
511 |
-# error "abi_mips_n32 not supported by the package." |
512 |
-# elif(_MIPS_SIM == _ABI64) /* n64 */ |
513 |
-# error "abi_mips_n64 not supported by the package." |
514 |
-# elif(_MIPS_SIM == _ABIO32) /* o32 */ |
515 |
-# error "abi_mips_o32 not supported by the package." |
516 |
-# endif |
517 |
-#elif defined(__riscv) |
518 |
-# if (__WORDSIZE == 64) && defined(__riscv_float_abi_double) |
519 |
-# error "abi_riscv_lp64d not supported by the package." |
520 |
-# elif (__WORDSIZE == 64) && defined(__riscv_float_abi_single) |
521 |
-# error "abi_riscv_lp64f not supported by the package." |
522 |
-# elif (__WORDSIZE == 64) |
523 |
-# error "abi_riscv_lp64 not supported by the package." |
524 |
-# elif (__WORDSIZE == 32) && defined(__riscv_float_abi_double) |
525 |
-# error "abi_riscv_ilp32d not supported by the package." |
526 |
-# elif (__WORDSIZE == 32) && defined(__riscv_float_abi_single) |
527 |
-# error "abi_riscv_ilp32f not supported by the package." |
528 |
-# else |
529 |
-# error "abi_riscv_ilp32 not supported by the package." |
530 |
-# endif |
531 |
-#elif defined(__sparc__) |
532 |
-# if defined(__arch64__) |
533 |
-# error "abi_sparc_64 not supported by the package." |
534 |
-# else |
535 |
-# error "abi_sparc_32 not supported by the package." |
536 |
-# endif |
537 |
-#elif defined(__s390__) |
538 |
-# if defined(__s390x__) |
539 |
-# error "abi_s390_64 not supported by the package." |
540 |
-# else |
541 |
-# error "abi_s390_32 not supported by the package." |
542 |
-# endif |
543 |
-#elif defined(__powerpc__) || defined(__ppc__) |
544 |
-# if defined(__powerpc64__) || defined(__ppc64__) |
545 |
-# error "abi_ppc_64 not supported by the package." |
546 |
-# else |
547 |
-# error "abi_ppc_32 not supported by the package." |
548 |
-# endif |
549 |
-#elif defined(SWIG) /* https://sourceforge.net/p/swig/bugs/799/ */ |
550 |
-# error "Native ABI not supported by the package." |
551 |
-#else |
552 |
-# error "No ABI matched, please report a bug to bugs.gentoo.org" |
553 |
-#endif |
554 |
-_EOF_ |
555 |
- fi |
556 |
- |
557 |
- if ! grep -q "${MULTILIB_ABI_FLAG} " "${wrapper}" |
558 |
- then |
559 |
- die "Flag ${MULTILIB_ABI_FLAG} not listed in wrapper template. Please report a bug to https://bugs.gentoo.org." |
560 |
- fi |
561 |
- |
562 |
- # $CHOST shall be set by multilib_toolchain_setup |
563 |
- dodir "/tmp/multilib-include/${CHOST}${dir}" |
564 |
- mv "${root}/usr/include${f}" "${ED%/}/tmp/multilib-include/${CHOST}${dir}/" || die |
565 |
- |
566 |
- # Note: match a space afterwards to avoid collision potential. |
567 |
- sed -e "/${MULTILIB_ABI_FLAG} /s&error.*&include <${CHOST}${f}>&" \ |
568 |
- -i "${wrapper}" || die |
569 |
- |
570 |
- # Needed for swig. |
571 |
- if multilib_is_native_abi; then |
572 |
- sed -e "/Native ABI/s&error.*&include <${CHOST}${f}>&" \ |
573 |
- -i "${wrapper}" || die |
574 |
- fi |
575 |
- fi |
576 |
- done |
577 |
- fi |
578 |
- fi |
579 |
-} |
580 |
- |
581 |
-# @FUNCTION: multilib_install_wrappers |
582 |
-# @USAGE: [<install-root>] |
583 |
-# @DESCRIPTION: |
584 |
-# Install the previously-prepared wrappers. This function shall |
585 |
-# be called once, after all wrappers were prepared. |
586 |
-# |
587 |
-# Takes an optional custom <install-root> to which the wrappers will be |
588 |
-# installed. If no root is specified, uses ${ED}. There is no need to |
589 |
-# use the same root as when preparing the wrappers. |
590 |
-# |
591 |
-# The files to be wrapped are specified using separate variables, |
592 |
-# e.g. MULTILIB_WRAPPED_HEADERS. Those variables shall not be changed |
593 |
-# between the calls to multilib_prepare_wrappers |
594 |
-# and multilib_install_wrappers. |
595 |
-multilib_install_wrappers() { |
596 |
- debug-print-function ${FUNCNAME} "${@}" |
597 |
- |
598 |
- [[ ${#} -le 1 ]] || die "${FUNCNAME}: too many arguments" |
599 |
- |
600 |
- [[ ${COMPLETE_MULTILIB} == yes ]] && return |
601 |
- |
602 |
- local root=${1:-${ED}} |
603 |
- |
604 |
- if [[ -d ${ED%/}/tmp/multilib-include ]]; then |
605 |
- multibuild_merge_root \ |
606 |
- "${ED%/}"/tmp/multilib-include "${root}"/usr/include |
607 |
- # it can fail if something else uses /tmp |
608 |
- rmdir "${ED%/}"/tmp &>/dev/null |
609 |
- fi |
610 |
-} |
611 |
- |
612 |
-# @FUNCTION: multilib_is_native_abi |
613 |
-# @DESCRIPTION: |
614 |
-# Determine whether the currently built ABI is the profile native. |
615 |
-# Return true status (0) if that is true, otherwise false (1). |
616 |
-multilib_is_native_abi() { |
617 |
- debug-print-function ${FUNCNAME} "${@}" |
618 |
- |
619 |
- [[ ${#} -eq 0 ]] || die "${FUNCNAME}: too many arguments" |
620 |
- |
621 |
- [[ ${COMPLETE_MULTILIB} == yes || ${ABI} == ${DEFAULT_ABI} ]] |
622 |
-} |
623 |
- |
624 |
-# @FUNCTION: multilib_build_binaries |
625 |
-# @DESCRIPTION: |
626 |
-# Deprecated synonym for multilib_is_native_abi |
627 |
-multilib_build_binaries() { |
628 |
- debug-print-function ${FUNCNAME} "${@}" |
629 |
- |
630 |
- [[ ${EAPI} == [45] ]] || die "${FUNCNAME} is banned in EAPI ${EAPI}, use multilib_is_native_abi() instead" |
631 |
- |
632 |
- eqawarn "QA warning: multilib_build_binaries is deprecated. Please use the equivalent" |
633 |
- eqawarn "multilib_is_native_abi function instead." |
634 |
- |
635 |
- multilib_is_native_abi "${@}" |
636 |
-} |
637 |
- |
638 |
-# @FUNCTION: multilib_native_use_with |
639 |
-# @USAGE: <flag> [<opt-name> [<opt-value>]] |
640 |
-# @DESCRIPTION: |
641 |
-# Output --with configure option alike use_with if USE <flag> is enabled |
642 |
-# and executables are being built (multilib_is_native_abi is true). |
643 |
-# Otherwise, outputs --without configure option. Arguments are the same |
644 |
-# as for use_with in the EAPI. |
645 |
-multilib_native_use_with() { |
646 |
- if multilib_is_native_abi; then |
647 |
- use_with "${@}" |
648 |
- else |
649 |
- echo "--without-${2:-${1}}" |
650 |
- fi |
651 |
-} |
652 |
- |
653 |
-# @FUNCTION: multilib_native_use_enable |
654 |
-# @USAGE: <flag> [<opt-name> [<opt-value>]] |
655 |
-# @DESCRIPTION: |
656 |
-# Output --enable configure option alike use_enable if USE <flag> |
657 |
-# is enabled and executables are being built (multilib_is_native_abi |
658 |
-# is true). Otherwise, outputs --disable configure option. Arguments are |
659 |
-# the same as for use_enable in the EAPI. |
660 |
-multilib_native_use_enable() { |
661 |
- if multilib_is_native_abi; then |
662 |
- use_enable "${@}" |
663 |
- else |
664 |
- echo "--disable-${2:-${1}}" |
665 |
- fi |
666 |
-} |
667 |
- |
668 |
-# @FUNCTION: multilib_native_enable |
669 |
-# @USAGE: <opt-name> [<opt-value>] |
670 |
-# @DESCRIPTION: |
671 |
-# Output --enable configure option if executables are being built |
672 |
-# (multilib_is_native_abi is true). Otherwise, output --disable configure |
673 |
-# option. |
674 |
-multilib_native_enable() { |
675 |
- if multilib_is_native_abi; then |
676 |
- echo "--enable-${1}${2+=${2}}" |
677 |
- else |
678 |
- echo "--disable-${1}" |
679 |
- fi |
680 |
-} |
681 |
- |
682 |
-# @FUNCTION: multilib_native_with |
683 |
-# @USAGE: <opt-name> [<opt-value>] |
684 |
-# @DESCRIPTION: |
685 |
-# Output --with configure option if executables are being built |
686 |
-# (multilib_is_native_abi is true). Otherwise, output --without configure |
687 |
-# option. |
688 |
-multilib_native_with() { |
689 |
- if multilib_is_native_abi; then |
690 |
- echo "--with-${1}${2+=${2}}" |
691 |
- else |
692 |
- echo "--without-${1}" |
693 |
- fi |
694 |
-} |
695 |
- |
696 |
-# @FUNCTION: multilib_native_usex |
697 |
-# @USAGE: <flag> [<true1> [<false1> [<true2> [<false2>]]]] |
698 |
-# @DESCRIPTION: |
699 |
-# Output the concatenation of <true1> (or 'yes' if unspecified) |
700 |
-# and <true2> if USE <flag> is enabled and executables are being built |
701 |
-# (multilib_is_native_abi is true). Otherwise, output the concatenation |
702 |
-# of <false1> (or 'no' if unspecified) and <false2>. Arguments |
703 |
-# are the same as for usex in the EAPI. |
704 |
-# |
705 |
-# Note: in EAPI 4 you need to inherit eutils to use this function. |
706 |
-multilib_native_usex() { |
707 |
- if multilib_is_native_abi; then |
708 |
- usex "${@}" |
709 |
- else |
710 |
- echo "${3-no}${5}" |
711 |
- fi |
712 |
-} |
713 |
- |
714 |
-_MULTILIB_BUILD=1 |
715 |
-fi |
716 |
|
717 |
diff --git a/eclass/multilib.eclass b/eclass/multilib.eclass |
718 |
deleted file mode 100644 |
719 |
index 9c7042f..0000000 |
720 |
--- a/eclass/multilib.eclass |
721 |
+++ /dev/null |
722 |
@@ -1,554 +0,0 @@ |
723 |
-# Copyright 1999-2020 Gentoo Authors |
724 |
-# Distributed under the terms of the GNU General Public License v2 |
725 |
- |
726 |
-# @ECLASS: multilib.eclass |
727 |
-# @MAINTAINER: |
728 |
-# amd64@g.o |
729 |
-# toolchain@g.o |
730 |
-# @BLURB: This eclass is for all functions pertaining to handling multilib configurations. |
731 |
-# @DESCRIPTION: |
732 |
-# This eclass is for all functions pertaining to handling multilib configurations. |
733 |
- |
734 |
-if [[ -z ${_MULTILIB_ECLASS} ]]; then |
735 |
-_MULTILIB_ECLASS=1 |
736 |
- |
737 |
-inherit toolchain-funcs |
738 |
- |
739 |
-# Defaults: |
740 |
-export MULTILIB_ABIS=${MULTILIB_ABIS:-"default"} |
741 |
-export DEFAULT_ABI=${DEFAULT_ABI:-"default"} |
742 |
-export CFLAGS_default |
743 |
-export LDFLAGS_default |
744 |
-export CHOST_default=${CHOST_default:-${CHOST}} |
745 |
-export CTARGET_default=${CTARGET_default:-${CTARGET:-${CHOST_default}}} |
746 |
-export LIBDIR_default=${CONF_LIBDIR:-"lib"} |
747 |
-export KERNEL_ABI=${KERNEL_ABI:-${DEFAULT_ABI}} |
748 |
- |
749 |
-# @FUNCTION: has_multilib_profile |
750 |
-# @DESCRIPTION: |
751 |
-# Return true if the current profile is a multilib profile and lists more than |
752 |
-# one abi in ${MULTILIB_ABIS}. When has_multilib_profile returns true, that |
753 |
-# profile should enable the 'multilib' use flag. This is so you can DEPEND on |
754 |
-# a package only for multilib or not multilib. |
755 |
-has_multilib_profile() { |
756 |
- [ -n "${MULTILIB_ABIS}" -a "${MULTILIB_ABIS}" != "${MULTILIB_ABIS/ /}" ] |
757 |
-} |
758 |
- |
759 |
-# @FUNCTION: get_libdir |
760 |
-# @RETURN: the libdir for the selected ABI |
761 |
-# @DESCRIPTION: |
762 |
-# This function simply returns the desired lib directory. With portage |
763 |
-# 2.0.51, we now have support for installing libraries to lib32/lib64 |
764 |
-# to accomidate the needs of multilib systems. It's no longer a good idea |
765 |
-# to assume all libraries will end up in lib. Replace any (sane) instances |
766 |
-# where lib is named directly with $(get_libdir) if possible. |
767 |
-# |
768 |
-# Jeremy Huddleston <eradicator@g.o> (23 Dec 2004): |
769 |
-# Added support for ${ABI} and ${DEFAULT_ABI}. If they're both not set, |
770 |
-# fall back on old behavior. Any profile that has these set should also |
771 |
-# depend on a newer version of portage (not yet released) which uses these |
772 |
-# over CONF_LIBDIR in econf, dolib, etc... |
773 |
-if has "${EAPI:-0}" 0 1 2 3 4 5; then |
774 |
- get_libdir() { |
775 |
- local CONF_LIBDIR |
776 |
- if [ -n "${CONF_LIBDIR_OVERRIDE}" ] ; then |
777 |
- # if there is an override, we want to use that... always. |
778 |
- echo ${CONF_LIBDIR_OVERRIDE} |
779 |
- else |
780 |
- get_abi_LIBDIR |
781 |
- fi |
782 |
- } |
783 |
-fi |
784 |
- |
785 |
-# @FUNCTION: get_abi_var |
786 |
-# @USAGE: <VAR> [ABI] |
787 |
-# @RETURN: returns the value of ${<VAR>_<ABI>} which should be set in make.defaults |
788 |
-# @INTERNAL |
789 |
-# @DESCRIPTION: |
790 |
-# ex: |
791 |
-# CFLAGS=$(get_abi_var CFLAGS sparc32) # CFLAGS=-m32 |
792 |
-# |
793 |
-# Note that the prefered method is to set CC="$(tc-getCC) $(get_abi_CFLAGS)" |
794 |
-# This will hopefully be added to portage soon... |
795 |
-# |
796 |
-# If <ABI> is not specified, ${ABI} is used. |
797 |
-# If <ABI> is not specified and ${ABI} is not defined, ${DEFAULT_ABI} is used. |
798 |
-# If <ABI> is not specified and ${ABI} and ${DEFAULT_ABI} are not defined, we return an empty string. |
799 |
-get_abi_var() { |
800 |
- local flag=$1 |
801 |
- local abi=${2:-${ABI:-${DEFAULT_ABI:-default}}} |
802 |
- local var="${flag}_${abi}" |
803 |
- echo ${!var} |
804 |
-} |
805 |
- |
806 |
-# @FUNCTION: get_abi_CFLAGS |
807 |
-# @USAGE: [ABI] |
808 |
-# @DESCRIPTION: |
809 |
-# Alias for 'get_abi_var CFLAGS' |
810 |
-get_abi_CFLAGS() { get_abi_var CFLAGS "$@"; } |
811 |
- |
812 |
-# @FUNCTION: get_abi_LDFLAGS |
813 |
-# @USAGE: [ABI] |
814 |
-# @DESCRIPTION: |
815 |
-# Alias for 'get_abi_var LDFLAGS' |
816 |
-get_abi_LDFLAGS() { get_abi_var LDFLAGS "$@"; } |
817 |
- |
818 |
-# @FUNCTION: get_abi_CHOST |
819 |
-# @USAGE: [ABI] |
820 |
-# @DESCRIPTION: |
821 |
-# Alias for 'get_abi_var CHOST' |
822 |
-get_abi_CHOST() { get_abi_var CHOST "$@"; } |
823 |
- |
824 |
-# @FUNCTION: get_abi_CTARGET |
825 |
-# @USAGE: [ABI] |
826 |
-# @DESCRIPTION: |
827 |
-# Alias for 'get_abi_var CTARGET' |
828 |
-get_abi_CTARGET() { get_abi_var CTARGET "$@"; } |
829 |
- |
830 |
-# @FUNCTION: get_abi_FAKE_TARGETS |
831 |
-# @USAGE: [ABI] |
832 |
-# @DESCRIPTION: |
833 |
-# Alias for 'get_abi_var FAKE_TARGETS' |
834 |
-get_abi_FAKE_TARGETS() { get_abi_var FAKE_TARGETS "$@"; } |
835 |
- |
836 |
-# @FUNCTION: get_abi_LIBDIR |
837 |
-# @USAGE: [ABI] |
838 |
-# @DESCRIPTION: |
839 |
-# Alias for 'get_abi_var LIBDIR' |
840 |
-get_abi_LIBDIR() { get_abi_var LIBDIR "$@"; } |
841 |
- |
842 |
-# @FUNCTION: get_install_abis |
843 |
-# @DESCRIPTION: |
844 |
-# Return a list of the ABIs we want to install for with |
845 |
-# the last one in the list being the default. |
846 |
-get_install_abis() { |
847 |
- local x order="" |
848 |
- |
849 |
- if [[ -z ${MULTILIB_ABIS} ]] ; then |
850 |
- echo "default" |
851 |
- return 0 |
852 |
- fi |
853 |
- |
854 |
- if [[ ${EMULTILIB_PKG} == "true" ]] ; then |
855 |
- for x in ${MULTILIB_ABIS} ; do |
856 |
- if [[ ${x} != "${DEFAULT_ABI}" ]] ; then |
857 |
- has ${x} ${ABI_DENY} || order="${order} ${x}" |
858 |
- fi |
859 |
- done |
860 |
- has ${DEFAULT_ABI} ${ABI_DENY} || order="${order} ${DEFAULT_ABI}" |
861 |
- |
862 |
- if [[ -n ${ABI_ALLOW} ]] ; then |
863 |
- local ordera="" |
864 |
- for x in ${order} ; do |
865 |
- if has ${x} ${ABI_ALLOW} ; then |
866 |
- ordera="${ordera} ${x}" |
867 |
- fi |
868 |
- done |
869 |
- order=${ordera} |
870 |
- fi |
871 |
- else |
872 |
- order=${DEFAULT_ABI} |
873 |
- fi |
874 |
- |
875 |
- if [[ -z ${order} ]] ; then |
876 |
- die "The ABI list is empty. Are you using a proper multilib profile? Perhaps your USE flags or MULTILIB_ABIS are too restrictive for this package." |
877 |
- fi |
878 |
- |
879 |
- echo ${order} |
880 |
- return 0 |
881 |
-} |
882 |
- |
883 |
-# @FUNCTION: get_all_abis |
884 |
-# @DESCRIPTION: |
885 |
-# Return a list of the ABIs supported by this profile. |
886 |
-# the last one in the list being the default. |
887 |
-get_all_abis() { |
888 |
- local x order="" mvar dvar |
889 |
- |
890 |
- mvar="MULTILIB_ABIS" |
891 |
- dvar="DEFAULT_ABI" |
892 |
- if [[ -n $1 ]] ; then |
893 |
- mvar="$1_${mvar}" |
894 |
- dvar="$1_${dvar}" |
895 |
- fi |
896 |
- |
897 |
- if [[ -z ${!mvar} ]] ; then |
898 |
- echo "default" |
899 |
- return 0 |
900 |
- fi |
901 |
- |
902 |
- for x in ${!mvar}; do |
903 |
- if [[ ${x} != ${!dvar} ]] ; then |
904 |
- order="${order:+${order} }${x}" |
905 |
- fi |
906 |
- done |
907 |
- order="${order:+${order} }${!dvar}" |
908 |
- |
909 |
- echo ${order} |
910 |
- return 0 |
911 |
-} |
912 |
- |
913 |
-# @FUNCTION: get_all_libdirs |
914 |
-# @DESCRIPTION: |
915 |
-# Returns a list of all the libdirs used by this profile. This includes |
916 |
-# those that might not be touched by the current ebuild and always includes |
917 |
-# "lib". |
918 |
-get_all_libdirs() { |
919 |
- local libdirs abi |
920 |
- |
921 |
- for abi in ${MULTILIB_ABIS}; do |
922 |
- libdirs+=" $(get_abi_LIBDIR ${abi})" |
923 |
- done |
924 |
- [[ " ${libdirs} " != *" lib "* ]] && libdirs+=" lib" |
925 |
- |
926 |
- echo "${libdirs}" |
927 |
-} |
928 |
- |
929 |
-# @FUNCTION: is_final_abi |
930 |
-# @DESCRIPTION: |
931 |
-# Return true if ${ABI} is the last ABI on our list (or if we're not |
932 |
-# using the new multilib configuration. This can be used to determine |
933 |
-# if we're in the last (or only) run through src_{unpack,compile,install} |
934 |
-is_final_abi() { |
935 |
- has_multilib_profile || return 0 |
936 |
- set -- $(get_install_abis) |
937 |
- local LAST_ABI=$# |
938 |
- [[ ${!LAST_ABI} == ${ABI} ]] |
939 |
-} |
940 |
- |
941 |
-# @FUNCTION: number_abis |
942 |
-# @DESCRIPTION: |
943 |
-# echo the number of ABIs we will be installing for |
944 |
-number_abis() { |
945 |
- set -- `get_install_abis` |
946 |
- echo $# |
947 |
-} |
948 |
- |
949 |
-# @FUNCTION: get_exeext |
950 |
-# @DESCRIPTION: |
951 |
-# Returns standard executable program suffix (null, .exe, etc.) |
952 |
-# for the current platform identified by CHOST. |
953 |
-# |
954 |
-# Example: |
955 |
-# get_exeext |
956 |
-# Returns: null string (almost everywhere) || .exe (mingw*) || ... |
957 |
-get_exeext() { |
958 |
- case ${CHOST} in |
959 |
- *-cygwin*|mingw*|*-mingw*) echo ".exe";; |
960 |
- esac |
961 |
-} |
962 |
- |
963 |
-# @FUNCTION: get_libname |
964 |
-# @USAGE: [version] |
965 |
-# @DESCRIPTION: |
966 |
-# Returns libname with proper suffix {.so,.dylib,.dll,etc} and optionally |
967 |
-# supplied version for the current platform identified by CHOST. |
968 |
-# |
969 |
-# Example: |
970 |
-# get_libname ${PV} |
971 |
-# Returns: .so.${PV} (ELF) || .${PV}.dylib (MACH) || ... |
972 |
-get_libname() { |
973 |
- local libname |
974 |
- local ver=$1 |
975 |
- case ${CHOST} in |
976 |
- *-cygwin*) libname="dll.a";; # import lib |
977 |
- mingw*|*-mingw*) libname="dll";; |
978 |
- *-darwin*) libname="dylib";; |
979 |
- *-mint*) libname="irrelevant";; |
980 |
- hppa*-hpux*) libname="sl";; |
981 |
- *) libname="so";; |
982 |
- esac |
983 |
- |
984 |
- if [[ -z $* ]] ; then |
985 |
- echo ".${libname}" |
986 |
- else |
987 |
- for ver in "$@" ; do |
988 |
- case ${CHOST} in |
989 |
- *-cygwin*) echo ".${ver}.${libname}";; |
990 |
- *-darwin*) echo ".${ver}.${libname}";; |
991 |
- *-mint*) echo ".${libname}";; |
992 |
- *) echo ".${libname}.${ver}";; |
993 |
- esac |
994 |
- done |
995 |
- fi |
996 |
-} |
997 |
- |
998 |
-# @FUNCTION: get_modname |
999 |
-# @USAGE: |
1000 |
-# @DESCRIPTION: |
1001 |
-# Returns modulename with proper suffix {.so,.bundle,etc} for the current |
1002 |
-# platform identified by CHOST. |
1003 |
-# |
1004 |
-# Example: |
1005 |
-# libfoo$(get_modname) |
1006 |
-# Returns: libfoo.so (ELF) || libfoo.bundle (MACH) || ... |
1007 |
-get_modname() { |
1008 |
- local modname |
1009 |
- local ver=$1 |
1010 |
- case ${CHOST} in |
1011 |
- *-darwin*) modname="bundle";; |
1012 |
- *) modname="so";; |
1013 |
- esac |
1014 |
- |
1015 |
- echo ".${modname}" |
1016 |
-} |
1017 |
- |
1018 |
-# This is for the toolchain to setup profile variables when pulling in |
1019 |
-# a crosscompiler (and thus they aren't set in the profile). |
1020 |
-multilib_env() { |
1021 |
- local CTARGET=${1:-${CTARGET}} |
1022 |
- local cpu=${CTARGET%%*-} |
1023 |
- |
1024 |
- if [[ ${CTARGET} = *-musl* ]]; then |
1025 |
- # musl has no multilib support and can run only in 'lib': |
1026 |
- # - https://bugs.gentoo.org/675954 |
1027 |
- # - https://gcc.gnu.org/PR90077 |
1028 |
- # - https://github.com/gentoo/musl/issues/245 |
1029 |
- : ${MULTILIB_ABIS=default} |
1030 |
- : ${DEFAULT_ABI=default} |
1031 |
- export MULTILIB_ABIS DEFAULT_ABI |
1032 |
- return |
1033 |
- fi |
1034 |
- |
1035 |
- case ${cpu} in |
1036 |
- aarch64*) |
1037 |
- # Not possible to do multilib with aarch64 and a single toolchain. |
1038 |
- export CFLAGS_arm=${CFLAGS_arm-} |
1039 |
- case ${cpu} in |
1040 |
- aarch64*be) export CHOST_arm="armv8b-${CTARGET#*-}";; |
1041 |
- *) export CHOST_arm="armv8l-${CTARGET#*-}";; |
1042 |
- esac |
1043 |
- CHOST_arm=${CHOST_arm/%-gnu/-gnueabi} |
1044 |
- export CTARGET_arm=${CHOST_arm} |
1045 |
- export LIBDIR_arm="lib" |
1046 |
- |
1047 |
- export CFLAGS_arm64=${CFLAGS_arm64-} |
1048 |
- export CHOST_arm64=${CTARGET} |
1049 |
- export CTARGET_arm64=${CHOST_arm64} |
1050 |
- export LIBDIR_arm64="lib64" |
1051 |
- |
1052 |
- : ${MULTILIB_ABIS=arm64} |
1053 |
- : ${DEFAULT_ABI=arm64} |
1054 |
- ;; |
1055 |
- x86_64*) |
1056 |
- export CFLAGS_x86=${CFLAGS_x86--m32} |
1057 |
- export CHOST_x86=${CTARGET/x86_64/i686} |
1058 |
- CHOST_x86=${CHOST_x86/%-gnux32/-gnu} |
1059 |
- export CTARGET_x86=${CHOST_x86} |
1060 |
- if [[ ${SYMLINK_LIB} == "yes" ]] ; then |
1061 |
- export LIBDIR_x86="lib32" |
1062 |
- else |
1063 |
- export LIBDIR_x86="lib" |
1064 |
- fi |
1065 |
- |
1066 |
- export CFLAGS_amd64=${CFLAGS_amd64--m64} |
1067 |
- export CHOST_amd64=${CTARGET/%-gnux32/-gnu} |
1068 |
- export CTARGET_amd64=${CHOST_amd64} |
1069 |
- export LIBDIR_amd64="lib64" |
1070 |
- |
1071 |
- export CFLAGS_x32=${CFLAGS_x32--mx32} |
1072 |
- export CHOST_x32=${CTARGET/%-gnu/-gnux32} |
1073 |
- export CTARGET_x32=${CHOST_x32} |
1074 |
- export LIBDIR_x32="libx32" |
1075 |
- |
1076 |
- case ${CTARGET} in |
1077 |
- *-gnux32) |
1078 |
- : ${MULTILIB_ABIS=x32 amd64 x86} |
1079 |
- : ${DEFAULT_ABI=x32} |
1080 |
- ;; |
1081 |
- *) |
1082 |
- : ${MULTILIB_ABIS=amd64 x86} |
1083 |
- : ${DEFAULT_ABI=amd64} |
1084 |
- ;; |
1085 |
- esac |
1086 |
- ;; |
1087 |
- mips64*|mipsisa64*) |
1088 |
- export CFLAGS_o32=${CFLAGS_o32--mabi=32} |
1089 |
- export CHOST_o32=${CTARGET/mips64/mips} |
1090 |
- export CHOST_o32=${CHOST_o32/mipsisa64/mipsisa32} |
1091 |
- export CTARGET_o32=${CHOST_o32} |
1092 |
- export LIBDIR_o32="lib" |
1093 |
- |
1094 |
- export CFLAGS_n32=${CFLAGS_n32--mabi=n32} |
1095 |
- export CHOST_n32=${CTARGET} |
1096 |
- export CTARGET_n32=${CHOST_n32} |
1097 |
- export LIBDIR_n32="lib32" |
1098 |
- |
1099 |
- export CFLAGS_n64=${CFLAGS_n64--mabi=64} |
1100 |
- export CHOST_n64=${CTARGET} |
1101 |
- export CTARGET_n64=${CHOST_n64} |
1102 |
- export LIBDIR_n64="lib64" |
1103 |
- |
1104 |
- : ${MULTILIB_ABIS=n64 n32 o32} |
1105 |
- : ${DEFAULT_ABI=n32} |
1106 |
- ;; |
1107 |
- powerpc64*) |
1108 |
- export CFLAGS_ppc=${CFLAGS_ppc--m32} |
1109 |
- export CHOST_ppc=${CTARGET/powerpc64/powerpc} |
1110 |
- export CTARGET_ppc=${CHOST_ppc} |
1111 |
- export LIBDIR_ppc="lib" |
1112 |
- |
1113 |
- export CFLAGS_ppc64=${CFLAGS_ppc64--m64} |
1114 |
- export CHOST_ppc64=${CTARGET} |
1115 |
- export CTARGET_ppc64=${CHOST_ppc64} |
1116 |
- export LIBDIR_ppc64="lib64" |
1117 |
- |
1118 |
- : ${MULTILIB_ABIS=ppc64 ppc} |
1119 |
- : ${DEFAULT_ABI=ppc64} |
1120 |
- ;; |
1121 |
- riscv64*) |
1122 |
- export CFLAGS_lp64d=${CFLAGS_lp64d--mabi=lp64d -march=rv64imafdc} |
1123 |
- export CHOST_lp64d=${CTARGET} |
1124 |
- export CTARGET_lp64d=${CTARGET} |
1125 |
- export LIBDIR_lp64d="lib64/lp64d" |
1126 |
- |
1127 |
- export CFLAGS_lp64=${CFLAGS_lp64--mabi=lp64 -march=rv64imac} |
1128 |
- export CHOST_lp64=${CTARGET} |
1129 |
- export CTARGET_lp64=${CTARGET} |
1130 |
- export LIBDIR_lp64="lib64/lp64" |
1131 |
- |
1132 |
- export CFLAGS_ilp32d=${CFLAGS_ilp32d--mabi=ilp32d -march=rv32imafdc} |
1133 |
- export CHOST_ilp32d=${CTARGET/riscv64/riscv32} |
1134 |
- export CTARGET_ilp32d=${CTARGET/riscv64/riscv32} |
1135 |
- export LIBDIR_ilp32d="lib32/ilp32d" |
1136 |
- |
1137 |
- export CFLAGS_ilp32=${CFLAGS_ilp32--mabi=ilp32 -march=rv32imac} |
1138 |
- export CHOST_ilp32=${CTARGET/riscv64/riscv32} |
1139 |
- export CTARGET_ilp32=${CTARGET/riscv64/riscv32} |
1140 |
- export LIBDIR_ilp32="lib32/ilp32" |
1141 |
- |
1142 |
- : ${MULTILIB_ABIS=lp64d lp64 ilp32d ilp32} |
1143 |
- : ${DEFAULT_ABI=lp64d} |
1144 |
- ;; |
1145 |
- riscv32*) |
1146 |
- export CFLAGS_ilp32d=${CFLAGS_ilp32d--mabi=ilp32d} |
1147 |
- export CHOST_ilp32d=${CTARGET} |
1148 |
- export CTARGET_ilp32d=${CTARGET} |
1149 |
- export LIBDIR_ilp32d="lib32/ilp32d" |
1150 |
- |
1151 |
- export CFLAGS_ilp32=${CFLAGS_ilp32--mabi=ilp32 -march=rv32imac} |
1152 |
- export CHOST_ilp32=${CTARGET} |
1153 |
- export CTARGET_ilp32=${CTARGET} |
1154 |
- export LIBDIR_ilp32="lib32/ilp32" |
1155 |
- |
1156 |
- : ${MULTILIB_ABIS=ilp32d ilp32} |
1157 |
- : ${DEFAULT_ABI=ilp32d} |
1158 |
- ;; |
1159 |
- s390x*) |
1160 |
- export CFLAGS_s390=${CFLAGS_s390--m31} # the 31 is not a typo |
1161 |
- export CHOST_s390=${CTARGET/s390x/s390} |
1162 |
- export CTARGET_s390=${CHOST_s390} |
1163 |
- export LIBDIR_s390="lib" |
1164 |
- |
1165 |
- export CFLAGS_s390x=${CFLAGS_s390x--m64} |
1166 |
- export CHOST_s390x=${CTARGET} |
1167 |
- export CTARGET_s390x=${CHOST_s390x} |
1168 |
- export LIBDIR_s390x="lib64" |
1169 |
- |
1170 |
- : ${MULTILIB_ABIS=s390x s390} |
1171 |
- : ${DEFAULT_ABI=s390x} |
1172 |
- ;; |
1173 |
- sparc64*) |
1174 |
- export CFLAGS_sparc32=${CFLAGS_sparc32--m32} |
1175 |
- export CHOST_sparc32=${CTARGET/sparc64/sparc} |
1176 |
- export CTARGET_sparc32=${CHOST_sparc32} |
1177 |
- export LIBDIR_sparc32="lib" |
1178 |
- |
1179 |
- export CFLAGS_sparc64=${CFLAGS_sparc64--m64} |
1180 |
- export CHOST_sparc64=${CTARGET} |
1181 |
- export CTARGET_sparc64=${CHOST_sparc64} |
1182 |
- export LIBDIR_sparc64="lib64" |
1183 |
- |
1184 |
- : ${MULTILIB_ABIS=sparc64 sparc32} |
1185 |
- : ${DEFAULT_ABI=sparc64} |
1186 |
- ;; |
1187 |
- *) |
1188 |
- : ${MULTILIB_ABIS=default} |
1189 |
- : ${DEFAULT_ABI=default} |
1190 |
- ;; |
1191 |
- esac |
1192 |
- |
1193 |
- export MULTILIB_ABIS DEFAULT_ABI |
1194 |
-} |
1195 |
- |
1196 |
-# @FUNCTION: multilib_toolchain_setup |
1197 |
-# @DESCRIPTION: |
1198 |
-# Hide multilib details here for packages which are forced to be compiled for a |
1199 |
-# specific ABI when run on another ABI (like x86-specific packages on amd64) |
1200 |
-multilib_toolchain_setup() { |
1201 |
- local v vv |
1202 |
- |
1203 |
- export ABI=$1 |
1204 |
- |
1205 |
- local save_restore_variables=( |
1206 |
- CBUILD |
1207 |
- CHOST |
1208 |
- AR |
1209 |
- CC |
1210 |
- CXX |
1211 |
- F77 |
1212 |
- FC |
1213 |
- LD |
1214 |
- NM |
1215 |
- OBJDUMP |
1216 |
- PKG_CONFIG |
1217 |
- RANLIB |
1218 |
- READELF |
1219 |
- STRINGS |
1220 |
- STRIP |
1221 |
- PKG_CONFIG_LIBDIR |
1222 |
- PKG_CONFIG_PATH |
1223 |
- PKG_CONFIG_SYSTEM_LIBRARY_PATH |
1224 |
- ) |
1225 |
- |
1226 |
- # First restore any saved state we have laying around. |
1227 |
- if [[ ${_DEFAULT_ABI_SAVED} == "true" ]] ; then |
1228 |
- for v in "${save_restore_variables[@]}" ; do |
1229 |
- vv="_abi_saved_${v}" |
1230 |
- [[ ${!vv+set} == "set" ]] && export ${v}="${!vv}" || unset ${v} |
1231 |
- unset ${vv} |
1232 |
- done |
1233 |
- unset _DEFAULT_ABI_SAVED |
1234 |
- fi |
1235 |
- |
1236 |
- if [[ ${ABI} != ${DEFAULT_ABI} ]] ; then |
1237 |
- # Back that multilib-ass up so we can restore it later |
1238 |
- for v in "${save_restore_variables[@]}" ; do |
1239 |
- vv="_abi_saved_${v}" |
1240 |
- [[ ${!v+set} == "set" ]] && export ${vv}="${!v}" || unset ${vv} |
1241 |
- done |
1242 |
- export _DEFAULT_ABI_SAVED="true" |
1243 |
- |
1244 |
- # Set CBUILD only if not cross-compiling. |
1245 |
- if [[ ${CBUILD} == "${CHOST}" ]]; then |
1246 |
- export CBUILD=$(get_abi_CHOST $1) |
1247 |
- fi |
1248 |
- |
1249 |
- # Set the CHOST native first so that we pick up the native |
1250 |
- # toolchain and not a cross-compiler by accident #202811. |
1251 |
- # |
1252 |
- # Make sure ${save_restore_variables[@]} list matches below. |
1253 |
- export CHOST=$(get_abi_CHOST ${DEFAULT_ABI}) |
1254 |
- |
1255 |
- export AR="$(tc-getAR)" # Avoid 'ar', use '${CHOST}-ar' |
1256 |
- export CC="$(tc-getCC) $(get_abi_CFLAGS)" |
1257 |
- export CXX="$(tc-getCXX) $(get_abi_CFLAGS)" |
1258 |
- export F77="$(tc-getF77) $(get_abi_CFLAGS)" |
1259 |
- export FC="$(tc-getFC) $(get_abi_CFLAGS)" |
1260 |
- export LD="$(tc-getLD) $(get_abi_LDFLAGS)" |
1261 |
- export NM="$(tc-getNM)" # Avoid 'nm', use '${CHOST}-nm' |
1262 |
- export OBJDUMP="$(tc-getOBJDUMP)" # Avoid 'objdump', use '${CHOST}-objdump' |
1263 |
- export PKG_CONFIG="$(tc-getPKG_CONFIG)" |
1264 |
- export RANLIB="$(tc-getRANLIB)" # Avoid 'ranlib', use '${CHOST}-ranlib' |
1265 |
- export READELF="$(tc-getREADELF)" # Avoid 'readelf', use '${CHOST}-readelf' |
1266 |
- export STRINGS="$(tc-getSTRINGS)" # Avoid 'strings', use '${CHOST}-strings' |
1267 |
- export STRIP="$(tc-getSTRIP)" # Avoid 'strip', use '${CHOST}-strip' |
1268 |
- |
1269 |
- export CHOST=$(get_abi_CHOST $1) |
1270 |
- export PKG_CONFIG_LIBDIR=${EPREFIX}/usr/$(get_libdir)/pkgconfig |
1271 |
- export PKG_CONFIG_PATH=${EPREFIX}/usr/share/pkgconfig |
1272 |
- export PKG_CONFIG_SYSTEM_LIBRARY_PATH=${EPREFIX}/usr/$(get_libdir) |
1273 |
- fi |
1274 |
-} |
1275 |
- |
1276 |
-fi |