|
Lines 7-29
Link Here
|
| 7 |
# Julian Ospald <hasufell@gentoo.org> |
7 |
# Julian Ospald <hasufell@gentoo.org> |
| 8 |
# @BLURB: wrapper for multilib builds providing convenient multilib_src_* functions |
8 |
# @BLURB: wrapper for multilib builds providing convenient multilib_src_* functions |
| 9 |
# @DESCRIPTION: |
9 |
# @DESCRIPTION: |
|
|
10 |
# multilib-minimal implements src_configure, src_compile, src_test |
| 11 |
# and src_install, and invokes callbacks which may be used by multi-abi |
| 12 |
# ebuilds and eclasses to cleanly separate per-ABI and global logic |
| 13 |
# within their implementations. It also provides logic to ensure that |
| 14 |
# ABI's do not scribble over each other's header files during installation. |
| 10 |
# |
15 |
# |
| 11 |
# src_configure, src_compile, src_test and src_install are exported. |
16 |
# To use multilib-minimal.eclass, inherit from it normally and implement |
|
|
17 |
# functions named multilib_<phase> (i.e.: multilib_src_install) containing |
| 18 |
# code which must run once for each ABI. multilib-minimal will invoke your |
| 19 |
# callback repeatedly and automatically, once for each active ABI, |
| 20 |
# with essential abi-specific settings for variables such as CFLAGS |
| 21 |
# automatically exported. |
| 12 |
# |
22 |
# |
| 13 |
# Use multilib_src_* instead of src_* which runs this phase for |
23 |
# Be advised that, for now at least, some features of |
| 14 |
# all enabled ABIs. |
24 |
# toolchain-funcs.eclass, specifically, those that |
|
|
25 |
# retrieve those same variables, will not work as expected, as this |
| 26 |
# eclass knows nothing about multilib-minimal and will return values |
| 27 |
# suitable only for the native ABI. |
| 15 |
# |
28 |
# |
| 16 |
# multilib-minimal should _always_ go last in inherit order! |
29 |
# A simple workaround for this limitation is to check if a variable is |
|
|
30 |
# already defined before querying toolchain-funcs. For example: |
| 31 |
# |
| 32 |
# @CODE@ |
| 33 |
# local CC=${CC:-$(tc-getCC)} |
| 34 |
# @CODE |
| 35 |
# |
| 36 |
# It is also important to make sure that your ebuild or eclass's dependencies |
| 37 |
# correctly reflect build- and run-time dependencies of each active ABI. |
| 38 |
# This can be simplified by using the ${MULTILIB_USEDEP} variable during |
| 39 |
# construction of *DEPEND variables. Note that not all dependencies |
| 40 |
# will require this; a judgement call will need to be made for each |
| 41 |
# dependency when porting existing ebuilds. See: |
| 42 |
# @CODE@ |
| 43 |
# http://devmanual.gentoo.org/eclass-reference/multilib-build.eclass/index.html |
| 44 |
# @CODE@ |
| 45 |
# for more information. |
| 46 |
# |
| 47 |
# Another snag you may encounter is that, in many circumstances, it is possible |
| 48 |
# for variables to flow between multilib_<phase> functions. This is because |
| 49 |
# no subshell is utilized. |
| 50 |
# Extreme care must sometimes be taken to ensure that different ABI's don't |
| 51 |
# trample each other's variables. |
| 52 |
# |
| 53 |
# A reasonable precaution against this type of problem would be to localize |
| 54 |
# certian variables to the multilib_<phase> function, for example: |
| 55 |
# |
| 56 |
# @CODE@ |
| 57 |
# multilib_src_configure() { |
| 58 |
# local CFLAGS="${CFLAGS}" CXXFLAGS="${CXXFLAGS}" |
| 59 |
# local FFLAGS="${FFLAGS}" FCFLAGS="${FCFLAGS}" |
| 60 |
# if [[ ${CHOST} == *x86_64* ]] ; then |
| 61 |
# append-flags -foo_flag -bar_flag |
| 62 |
# fi |
| 63 |
# @CODE@ |
| 64 |
# |
| 65 |
# However, this approach can create subtly confusing behavior. When porting |
| 66 |
# traditional phase-function-based code to multilib minimal, keep an eye out |
| 67 |
# for code that assumes variables defined in a prior phase function will persist |
| 68 |
# in subsequent phases. Depending on a number of factors, this may not |
| 69 |
# be the case -- it certainly will not, if you have localized variables as above. |
| 70 |
# |
| 71 |
# Eventually, a feature allowing reliable automatic variable persistence across |
| 72 |
# multilib_<phase> functions may be added, so, for the moment, it is best to |
| 73 |
# avoid any assumption about variable persistence, for example, by isolating |
| 74 |
# variable setup code in a convenience function which is invoked at the outset |
| 75 |
# of each multilib_<phase> function, or, where possible, by refactoring code |
| 76 |
# to avoid the use of persistent variables entirely. |
| 17 |
# |
77 |
# |
| 18 |
# If you want to use in-source builds, then you must run |
78 |
# If you want to use in-source builds, then you must run |
| 19 |
# multilib_copy_sources at the end of src_prepare! |
79 |
# multilib_copy_sources at the end of src_prepare. |
| 20 |
# Also make sure to set correct variables such as |
80 |
# Also make sure to correctly set ECONF_SOURCE, i.e., |
|
|
81 |
# |
| 82 |
# @CODE@ |
| 21 |
# ECONF_SOURCE=${S} |
83 |
# ECONF_SOURCE=${S} |
|
|
84 |
# @CODE@ |
| 22 |
# |
85 |
# |
| 23 |
# If you need generic install rules, use multilib_src_install_all function. |
86 |
# as out-of-tree builds will not be building in the same directory as |
| 24 |
|
87 |
# the configure script. |
|
|
88 |
# |
| 89 |
# EAPI >= 4 is required by multilib minimial, as without it, |
| 90 |
# the ${MULTILIB_USEDEP} variable cannot be correctly implemented. |
| 91 |
# |
| 92 |
# Note: inheritance order matters when inheriting from multiple |
| 93 |
# eclasses. In particular, it is important to understand that the |
| 94 |
# first inherited eclass on the list is the one whose phase |
| 95 |
# functions get wired up to the defaults; if it does not provide |
| 96 |
# an implementation, then the next (in a depthwise-recursive manner) is |
| 97 |
# afforded the opportunity, and so-forth, down the line. Therefore, |
| 98 |
# if you inherit both from a framework eclass and multilib-minimal, |
| 99 |
# and multilib-minimal comes after the framework eclass on the |
| 100 |
# inheritance list, you will get the framework eclass phase-function |
| 101 |
# implementations, if present, possibly making your inheritance |
| 102 |
# from multilib-minimal, and any implementations of the |
| 103 |
# multilib_<phase> callbacks, into a noop. For this reason, |
| 104 |
# it is often best to put multilib-minimal first on the inherits list. |
| 25 |
|
105 |
|
| 26 |
# EAPI=4 is required for meaningful MULTILIB_USEDEP. |
|
|
| 27 |
case ${EAPI:-0} in |
106 |
case ${EAPI:-0} in |
| 28 |
4|5) ;; |
107 |
4|5) ;; |
| 29 |
*) die "EAPI=${EAPI} is not supported" ;; |
108 |
*) die "EAPI=${EAPI} is not supported" ;; |