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

Contents of /eclass/multilib.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.95 - (hide annotations) (download)
Thu Oct 27 05:50:40 2011 UTC (2 years, 11 months ago) by vapier
Branch: MAIN
Changes since 1.94: +1 -2 lines
drop AS export since get_abi_ASFLAGS no longer exists

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

  ViewVC Help
Powered by ViewVC 1.1.20