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

Contents of /eclass/multilib.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.93 - (show annotations) (download)
Fri Oct 14 22:54:35 2011 UTC (2 years, 10 months ago) by vapier
Branch: MAIN
Changes since 1.92: +2 -38 lines
delete unused functions

1 # Copyright 1999-2011 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-x86/eclass/multilib.eclass,v 1.92 2011/08/18 14:58:57 vapier Exp $
4
5 # @ECLASS: multilib.eclass
6 # @MAINTAINER:
7 # amd64@gentoo.org
8 # toolchain@gentoo.org
9 # @BLURB: This eclass is for all functions pertaining to handling multilib configurations.
10 # @DESCRIPTION:
11 # This eclass is for all functions pertaining to handling multilib configurations.
12
13 ___ECLASS_RECUR_MULTILIB="yes"
14 [[ -z ${___ECLASS_RECUR_TOOLCHAIN_FUNCS} ]] && inherit toolchain-funcs
15
16 # Defaults:
17 export MULTILIB_ABIS=${MULTILIB_ABIS:-"default"}
18 export DEFAULT_ABI=${DEFAULT_ABI:-"default"}
19 export CFLAGS_default
20 export LDFLAGS_default
21 export CHOST_default=${CHOST_default:-${CHOST}}
22 export CTARGET_default=${CTARGET_default:-${CTARGET:-${CHOST_default}}}
23 export LIBDIR_default=${CONF_LIBDIR:-"lib"}
24 export KERNEL_ABI=${KERNEL_ABI:-${DEFAULT_ABI}}
25
26 # @FUNCTION: has_multilib_profile
27 # @DESCRIPTION:
28 # Return true if the current profile is a multilib profile and lists more than
29 # one abi in ${MULTILIB_ABIS}. When has_multilib_profile returns true, that
30 # profile should enable the 'multilib' use flag. This is so you can DEPEND on
31 # a package only for multilib or not multilib.
32 has_multilib_profile() {
33 [ -n "${MULTILIB_ABIS}" -a "${MULTILIB_ABIS}" != "${MULTILIB_ABIS/ /}" ]
34 }
35
36 # @FUNCTION: get_libdir
37 # @RETURN: the libdir for the selected ABI
38 # @DESCRIPTION:
39 # This function simply returns the desired lib directory. With portage
40 # 2.0.51, we now have support for installing libraries to lib32/lib64
41 # to accomidate the needs of multilib systems. It's no longer a good idea
42 # to assume all libraries will end up in lib. Replace any (sane) instances
43 # where lib is named directly with $(get_libdir) if possible.
44 #
45 # Jeremy Huddleston <eradicator@gentoo.org> (23 Dec 2004):
46 # Added support for ${ABI} and ${DEFAULT_ABI}. If they're both not set,
47 # fall back on old behavior. Any profile that has these set should also
48 # depend on a newer version of portage (not yet released) which uses these
49 # over CONF_LIBDIR in econf, dolib, etc...
50 get_libdir() {
51 local CONF_LIBDIR
52 if [ -n "${CONF_LIBDIR_OVERRIDE}" ] ; then
53 # if there is an override, we want to use that... always.
54 echo ${CONF_LIBDIR_OVERRIDE}
55 else
56 get_abi_LIBDIR
57 fi
58 }
59
60 # @FUNCTION: get_abi_var
61 # @USAGE: <VAR> [ABI]
62 # @RETURN: returns the value of ${<VAR>_<ABI>} which should be set in make.defaults
63 # @INTERNAL
64 # @DESCRIPTION:
65 # ex:
66 # CFLAGS=$(get_abi_var CFLAGS sparc32) # CFLAGS=-m32
67 #
68 # Note that the prefered method is to set CC="$(tc-getCC) $(get_abi_CFLAGS)"
69 # This will hopefully be added to portage soon...
70 #
71 # If <ABI> is not specified, ${ABI} is used.
72 # If <ABI> is not specified and ${ABI} is not defined, ${DEFAULT_ABI} is used.
73 # If <ABI> is not specified and ${ABI} and ${DEFAULT_ABI} are not defined, we return an empty string.
74 get_abi_var() {
75 local flag=$1
76 local abi
77 if [ $# -gt 1 ]; then
78 abi=${2}
79 elif [ -n "${ABI}" ]; then
80 abi=${ABI}
81 elif [ -n "${DEFAULT_ABI}" ]; then
82 abi=${DEFAULT_ABI}
83 else
84 abi="default"
85 fi
86
87 local var="${flag}_${abi}"
88 echo ${!var}
89 }
90
91 # @FUNCTION: get_abi_CFLAGS
92 # @USAGE: [ABI]
93 # @DESCRIPTION:
94 # Alias for 'get_abi_var CFLAGS'
95 get_abi_CFLAGS() { get_abi_var CFLAGS "$@"; }
96
97 # @FUNCTION: get_abi_LDFLAGS
98 # @USAGE: [ABI]
99 # @DESCRIPTION:
100 # Alias for 'get_abi_var LDFLAGS'
101 get_abi_LDFLAGS() { get_abi_var LDFLAGS "$@"; }
102
103 # @FUNCTION: get_abi_CHOST
104 # @USAGE: [ABI]
105 # @DESCRIPTION:
106 # Alias for 'get_abi_var CHOST'
107 get_abi_CHOST() { get_abi_var CHOST "$@"; }
108
109 # @FUNCTION: get_abi_CTARGET
110 # @USAGE: [ABI]
111 # @DESCRIPTION:
112 # Alias for 'get_abi_var CTARGET'
113 get_abi_CTARGET() { get_abi_var CTARGET "$@"; }
114
115 # @FUNCTION: get_abi_FAKE_TARGETS
116 # @USAGE: [ABI]
117 # @DESCRIPTION:
118 # Alias for 'get_abi_var FAKE_TARGETS'
119 get_abi_FAKE_TARGETS() { get_abi_var FAKE_TARGETS "$@"; }
120
121 # @FUNCTION: get_abi_LIBDIR
122 # @USAGE: [ABI]
123 # @DESCRIPTION:
124 # Alias for 'get_abi_var LIBDIR'
125 get_abi_LIBDIR() { get_abi_var LIBDIR "$@"; }
126
127 # @FUNCTION: get_install_abis
128 # @DESCRIPTION:
129 # Return a list of the ABIs we want to install for with
130 # the last one in the list being the default.
131 get_install_abis() {
132 local order=""
133
134 if [[ -z ${MULTILIB_ABIS} ]] ; then
135 echo "default"
136 return 0
137 fi
138
139 if [[ ${EMULTILIB_PKG} == "true" ]] ; then
140 for x in ${MULTILIB_ABIS} ; do
141 if [[ ${x} != "${DEFAULT_ABI}" ]] ; then
142 has ${x} ${ABI_DENY} || order="${order} ${x}"
143 fi
144 done
145 has ${DEFAULT_ABI} ${ABI_DENY} || order="${order} ${DEFAULT_ABI}"
146
147 if [[ -n ${ABI_ALLOW} ]] ; then
148 local ordera=""
149 for x in ${order} ; do
150 if has ${x} ${ABI_ALLOW} ; then
151 ordera="${ordera} ${x}"
152 fi
153 done
154 order=${ordera}
155 fi
156 else
157 order=${DEFAULT_ABI}
158 fi
159
160 if [[ -z ${order} ]] ; then
161 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."
162 fi
163
164 echo ${order}
165 return 0
166 }
167
168 # @FUNCTION: get_all_abis
169 # @DESCRIPTION:
170 # Return a list of the ABIs supported by this profile.
171 # the last one in the list being the default.
172 get_all_abis() {
173 local order=""
174
175 if [[ -z ${MULTILIB_ABIS} ]] ; then
176 echo "default"
177 return 0
178 fi
179
180 for x in ${MULTILIB_ABIS}; do
181 if [[ ${x} != ${DEFAULT_ABI} ]] ; then
182 order="${order:+${order} }${x}"
183 fi
184 done
185 order="${order:+${order} }${DEFAULT_ABI}"
186
187 echo ${order}
188 return 0
189 }
190
191 # @FUNCTION: get_all_libdirs
192 # @DESCRIPTION:
193 # Returns a list of all the libdirs used by this profile. This includes
194 # those that might not be touched by the current ebuild and always includes
195 # "lib".
196 get_all_libdirs() {
197 local libdirs
198 local abi
199 local dir
200
201 for abi in ${MULTILIB_ABIS}; do
202 libdirs+=" $(get_abi_LIBDIR ${abi})"
203 done
204 [[ " ${libdirs} " != *" lib "* ]] && libdirs+=" lib"
205
206 echo "${libdirs}"
207 }
208
209 # @FUNCTION: is_final_abi
210 # @DESCRIPTION:
211 # Return true if ${ABI} is the last ABI on our list (or if we're not
212 # using the new multilib configuration. This can be used to determine
213 # if we're in the last (or only) run through src_{unpack,compile,install}
214 is_final_abi() {
215 has_multilib_profile || return 0
216 set -- $(get_install_abis)
217 local LAST_ABI=$#
218 [[ ${!LAST_ABI} == ${ABI} ]]
219 }
220
221 # @FUNCTION: number_abis
222 # @DESCRIPTION:
223 # echo the number of ABIs we will be installing for
224 number_abis() {
225 set -- `get_install_abis`
226 echo $#
227 }
228
229 # @FUNCTION: get_libname
230 # @USAGE: [version]
231 # @DESCRIPTION:
232 # Returns libname with proper suffix {.so,.dylib,.dll,etc} and optionally
233 # supplied version for the current platform identified by CHOST.
234 #
235 # Example:
236 # get_libname ${PV}
237 # Returns: .so.${PV} (ELF) || .${PV}.dylib (MACH) || ...
238 get_libname() {
239 local libname
240 local ver=$1
241 case ${CHOST} in
242 *-cygwin|mingw*|*-mingw*) libname="dll";;
243 *-darwin*) libname="dylib";;
244 *-mint*) libname="irrelevant";;
245 hppa*-hpux*) libname="sl";;
246 *) libname="so";;
247 esac
248
249 if [[ -z $* ]] ; then
250 echo ".${libname}"
251 else
252 for ver in "$@" ; do
253 case ${CHOST} in
254 *-darwin*) echo ".${ver}.${libname}";;
255 *-mint*) echo ".${libname}";;
256 *) echo ".${libname}.${ver}";;
257 esac
258 done
259 fi
260 }
261
262 # @FUNCTION: get_modname
263 # @USAGE:
264 # @DESCRIPTION:
265 # Returns modulename with proper suffix {.so,.bundle,etc} for the current
266 # platform identified by CHOST.
267 #
268 # Example:
269 # libfoo$(get_modname)
270 # Returns: libfoo.so (ELF) || libfoo.bundle (MACH) || ...
271 get_modname() {
272 local modname
273 local ver=$1
274 case ${CHOST} in
275 *-darwin*) modname="bundle";;
276 *) modname="so";;
277 esac
278
279 echo ".${modname}"
280 }
281
282 # This is for the toolchain to setup profile variables when pulling in
283 # a crosscompiler (and thus they aren't set in the profile)
284 multilib_env() {
285 local CTARGET=${1:-${CTARGET}}
286
287 case ${CTARGET} in
288 x86_64*)
289 export CFLAGS_x86=${CFLAGS_x86--m32}
290 export CHOST_x86=${CTARGET/x86_64/i686}
291 export CTARGET_x86=${CHOST_x86}
292 if [[ ${SYMLINK_LIB} == "yes" ]] ; then
293 export LIBDIR_x86="lib32"
294 else
295 export LIBDIR_x86="lib"
296 fi
297
298 export CFLAGS_amd64=${CFLAGS_amd64--m64}
299 export CHOST_amd64=${CTARGET}
300 export CTARGET_amd64=${CHOST_amd64}
301 export LIBDIR_amd64="lib64"
302
303 export CFLAGS_x32=${CFLAGS_x32--mx32}
304 export CHOST_x32=${CTARGET}
305 export CTARGET_x32=${CHOST_x32}
306 export LIBDIR_x32="libx32"
307
308 : ${MULTILIB_ABIS=amd64 x86}
309 : ${DEFAULT_ABI=amd64}
310 ;;
311 mips64*)
312 export CFLAGS_o32=${CFLAGS_o32--mabi=32}
313 export CHOST_o32=${CTARGET/mips64/mips}
314 export CTARGET_o32=${CHOST_o32}
315 export LIBDIR_o32="lib"
316
317 export CFLAGS_n32=${CFLAGS_n32--mabi=n32}
318 export CHOST_n32=${CTARGET}
319 export CTARGET_n32=${CHOST_n32}
320 export LIBDIR_n32="lib32"
321
322 export CFLAGS_n64=${CFLAGS_n64--mabi=64}
323 export CHOST_n64=${CTARGET}
324 export CTARGET_n64=${CHOST_n64}
325 export LIBDIR_n64="lib64"
326
327 : ${MULTILIB_ABIS=n64 n32 o32}
328 : ${DEFAULT_ABI=n32}
329 ;;
330 powerpc64*)
331 export CFLAGS_ppc=${CFLAGS_ppc--m32}
332 export CHOST_ppc=${CTARGET/powerpc64/powerpc}
333 export CTARGET_ppc=${CHOST_ppc}
334 export LIBDIR_ppc="lib"
335
336 export CFLAGS_ppc64=${CFLAGS_ppc64--m64}
337 export CHOST_ppc64=${CTARGET}
338 export CTARGET_ppc64=${CHOST_ppc64}
339 export LIBDIR_ppc64="lib64"
340
341 : ${MULTILIB_ABIS=ppc64 ppc}
342 : ${DEFAULT_ABI=ppc64}
343 ;;
344 s390x*)
345 export CFLAGS_s390=${CFLAGS_s390--m31} # the 31 is not a typo
346 export CHOST_s390=${CTARGET/s390x/s390}
347 export CTARGET_s390=${CHOST_s390}
348 export LIBDIR_s390="lib"
349
350 export CFLAGS_s390x=${CFLAGS_s390x--m64}
351 export CHOST_s390x=${CTARGET}
352 export CTARGET_s390x=${CHOST_s390x}
353 export LIBDIR_s390x="lib64"
354
355 : ${MULTILIB_ABIS=s390x s390}
356 : ${DEFAULT_ABI=s390x}
357 ;;
358 sparc*)
359 export CFLAGS_sparc32=${CFLAGS_sparc32}
360 export CHOST_sparc32=${CTARGET/sparc64/sparc}
361 export CTARGET_sparc32=${CHOST_sparc32}
362 export LIBDIR_sparc32="lib"
363
364 export CFLAGS_sparc64=${CFLAGS_sparc64--m64}
365 export CHOST_sparc64=${CTARGET}
366 export CTARGET_sparc64=${CHOST_sparc64}
367 export LIBDIR_sparc64="lib64"
368
369 : ${MULTILIB_ABIS=sparc64 sparc32}
370 : ${DEFAULT_ABI=sparc64}
371 ;;
372 *)
373 : ${MULTILIB_ABIS=default}
374 : ${DEFAULT_ABI=default}
375 ;;
376 esac
377
378 export MULTILIB_ABIS DEFAULT_ABI
379 }
380
381 # @FUNCTION: multilib_toolchain_setup
382 # @DESCRIPTION:
383 # Hide multilib details here for packages which are forced to be compiled for a
384 # specific ABI when run on another ABI (like x86-specific packages on amd64)
385 multilib_toolchain_setup() {
386 local v vv
387
388 export ABI=$1
389
390 # First restore any saved state we have laying around.
391 if [[ ${__DEFAULT_ABI_SAVED} == "true" ]] ; then
392 for v in CHOST CBUILD AS CC CXX LD ; do
393 vv="__abi_saved_${v}"
394 export ${v}="${!vv}"
395 unset ${vv}
396 done
397 unset __DEFAULT_ABI_SAVED
398 fi
399
400 # We want to avoid the behind-the-back magic of gcc-config as it
401 # screws up ccache and distcc. See #196243 for more info.
402 if [[ ${ABI} != ${DEFAULT_ABI} ]] ; then
403 # Back that multilib-ass up so we can restore it later
404 for v in CHOST CBUILD AS CC CXX LD ; do
405 export __abi_saved_${v}="${!v}"
406 done
407 export __DEFAULT_ABI_SAVED="true"
408
409 # Set the CHOST native first so that we pick up the native
410 # toolchain and not a cross-compiler by accident #202811.
411 export CHOST=$(get_abi_CHOST ${DEFAULT_ABI})
412 export AS="$(tc-getAS) $(get_abi_ASFLAGS)"
413 export CC="$(tc-getCC) $(get_abi_CFLAGS)"
414 export CXX="$(tc-getCXX) $(get_abi_CFLAGS)"
415 export LD="$(tc-getLD) $(get_abi_LDFLAGS)"
416 export CHOST=$(get_abi_CHOST $1)
417 export CBUILD=$(get_abi_CHOST $1)
418 fi
419 }

  ViewVC Help
Powered by ViewVC 1.1.20