/[gentoo-x86]/eclass/multilib-build.eclass
Gentoo

Contents of /eclass/multilib-build.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations) (download)
Fri Feb 1 21:39:50 2013 UTC (20 months, 2 weeks ago) by mgorny
Branch: MAIN
Introduce a common multilib-build eclass to help building packages for multilib, and use the new ABI_X86 flags in it.

1 # Copyright 1999-2013 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-x86/eclass/autotools-multilib.eclass,v 1.7 2013/01/26 11:39:41 mgorny Exp $
4
5 # @ECLASS: multilib-build.eclass
6 # @MAINTAINER:
7 # Michał Górny <mgorny@gentoo.org>
8 # @BLURB: flags and utility functions for building multilib packages
9 # @DESCRIPTION:
10 # The multilib-build.eclass exports USE flags and utility functions
11 # necessary to build packages for multilib in a clean and uniform
12 # manner.
13 #
14 # Please note that dependency specifications for multilib-capable
15 # dependencies shall use the USE dependency string in ${MULTILIB_USEDEP}
16 # to properly request multilib enabled.
17
18 if [[ ! ${_MULTILIB_BUILD} ]]; then
19
20 # EAPI=5 is required for meaningful MULTILIB_USEDEP.
21 case ${EAPI:-0} in
22 5) ;;
23 *) die "EAPI=${EAPI} is not supported" ;;
24 esac
25
26 inherit multilib multiprocessing
27
28 # @ECLASS-VARIABLE: _MULTILIB_FLAGS
29 # @INTERNAL
30 # @DESCRIPTION:
31 # The list of multilib flags and corresponding ABI values.
32 _MULTILIB_FLAGS=(
33 abi_x86_32:x86
34 abi_x86_64:amd64
35 )
36
37 # @ECLASS-VARIABLE: MULTILIB_USEDEP
38 # @DESCRIPTION:
39 # The USE-dependency to be used on dependencies (libraries) needing
40 # to support multilib as well.
41 #
42 # Example use:
43 # @CODE
44 # RDEPEND="dev-libs/libfoo[${MULTILIB_USEDEP}]
45 # net-libs/libbar[ssl,${MULTILIB_USEDEP}]"
46 # @CODE
47
48 _multilib_build_set_globals() {
49 local flags=( "${_MULTILIB_FLAGS[@]%:*}" )
50 local usedeps=${flags[@]/%/(-)?}
51
52 IUSE=${flags[*]}
53 MULTILIB_USEDEP=${usedeps// /,}
54 }
55 _multilib_build_set_globals
56
57 # @FUNCTION: multilib_get_enabled_abis
58 # @DESCRIPTION:
59 # Return the ordered list of enabled ABIs if multilib builds
60 # are enabled. The best (most preferred) ABI will come last.
61 #
62 # If multilib is disabled, the default ABI will be returned
63 # in order to enforce consistent testing with multilib code.
64 multilib_get_enabled_abis() {
65 debug-print-function ${FUNCNAME} "${@}"
66
67 local abis=( $(get_all_abis) )
68
69 local abi i found
70 for abi in "${abis[@]}"; do
71 for i in "${_MULTILIB_FLAGS[@]}"; do
72 local m_abi=${i#*:}
73 local m_flag=${i%:*}
74
75 if [[ ${m_abi} == ${abi} ]] && use "${m_flag}"; then
76 echo "${abi}"
77 found=1
78 fi
79 done
80 done
81
82 if [[ ! ${found} ]]; then
83 debug-print "${FUNCNAME}: no ABIs enabled, fallback to ${DEFAULT_ABI}"
84 echo ${DEFAULT_ABI}
85 fi
86 }
87
88 # @FUNCTION: multilib_foreach_abi
89 # @USAGE: <argv>...
90 # @DESCRIPTION:
91 # If multilib support is enabled, sets the toolchain up for each
92 # supported ABI along with the ABI variable and correct BUILD_DIR,
93 # and runs the given commands with them.
94 #
95 # If multilib support is disabled, it just runs the commands. No setup
96 # is done.
97 multilib_foreach_abi() {
98 local initial_dir=${BUILD_DIR:-${S}}
99
100 local ABI
101 for ABI in $(multilib_get_enabled_abis); do
102 multilib_toolchain_setup "${ABI}"
103 BUILD_DIR=${initial_dir%%/}-${ABI} "${@}"
104 done
105 }
106
107 # @FUNCTION: multilib_parallel_foreach_abi
108 # @USAGE: <argv>...
109 # @DESCRIPTION:
110 # If multilib support is enabled, sets the toolchain up for each
111 # supported ABI along with the ABI variable and correct BUILD_DIR,
112 # and runs the given commands with them. The commands are run
113 # in parallel with number of jobs being determined from MAKEOPTS.
114 #
115 # If multilib support is disabled, it just runs the commands. No setup
116 # is done.
117 #
118 # Useful for running configure scripts.
119 multilib_parallel_foreach_abi() {
120 local initial_dir=${BUILD_DIR:-${S}}
121
122 multijob_init
123
124 local ABI
125 for ABI in $(multilib_get_enabled_abis); do
126 (
127 multijob_child_init
128
129 multilib_toolchain_setup "${ABI}"
130 BUILD_DIR=${initial_dir%%/}-${ABI}
131 "${@}"
132 ) &
133
134 multijob_post_fork
135 done
136
137 multijob_finish
138 }
139
140 _MULTILIB_BUILD=1
141 fi

  ViewVC Help
Powered by ViewVC 1.1.20