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

Contents of /eclass/multilib.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.93 - (hide 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 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.93 # $Header: /var/cvsroot/gentoo-x86/eclass/multilib.eclass,v 1.92 2011/08/18 14:58:57 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 eradicator 1.1 local abi
77     if [ $# -gt 1 ]; then
78     abi=${2}
79 eradicator 1.26 elif [ -n "${ABI}" ]; then
80     abi=${ABI}
81 eradicator 1.1 elif [ -n "${DEFAULT_ABI}" ]; then
82     abi=${DEFAULT_ABI}
83     else
84 eradicator 1.19 abi="default"
85 eradicator 1.1 fi
86    
87     local var="${flag}_${abi}"
88     echo ${!var}
89     }
90    
91 vapier 1.65 # @FUNCTION: get_abi_CFLAGS
92     # @USAGE: [ABI]
93     # @DESCRIPTION:
94     # Alias for 'get_abi_var CFLAGS'
95 vapier 1.33 get_abi_CFLAGS() { get_abi_var CFLAGS "$@"; }
96 vapier 1.65
97     # @FUNCTION: get_abi_LDFLAGS
98     # @USAGE: [ABI]
99     # @DESCRIPTION:
100     # Alias for 'get_abi_var LDFLAGS'
101 vapier 1.33 get_abi_LDFLAGS() { get_abi_var LDFLAGS "$@"; }
102 vapier 1.65
103     # @FUNCTION: get_abi_CHOST
104     # @USAGE: [ABI]
105     # @DESCRIPTION:
106     # Alias for 'get_abi_var CHOST'
107 vapier 1.33 get_abi_CHOST() { get_abi_var CHOST "$@"; }
108 vapier 1.65
109     # @FUNCTION: get_abi_CTARGET
110     # @USAGE: [ABI]
111     # @DESCRIPTION:
112     # Alias for 'get_abi_var CTARGET'
113 vapier 1.52 get_abi_CTARGET() { get_abi_var CTARGET "$@"; }
114 vapier 1.65
115     # @FUNCTION: get_abi_FAKE_TARGETS
116     # @USAGE: [ABI]
117     # @DESCRIPTION:
118     # Alias for 'get_abi_var FAKE_TARGETS'
119 vapier 1.33 get_abi_FAKE_TARGETS() { get_abi_var FAKE_TARGETS "$@"; }
120 vapier 1.65
121     # @FUNCTION: get_abi_LIBDIR
122     # @USAGE: [ABI]
123     # @DESCRIPTION:
124     # Alias for 'get_abi_var LIBDIR'
125 vapier 1.33 get_abi_LIBDIR() { get_abi_var LIBDIR "$@"; }
126 eradicator 1.1
127 vapier 1.65 # @FUNCTION: get_install_abis
128     # @DESCRIPTION:
129 swegener 1.30 # Return a list of the ABIs we want to install for with
130 eradicator 1.2 # the last one in the list being the default.
131 eradicator 1.17 get_install_abis() {
132 eradicator 1.2 local order=""
133    
134 vapier 1.33 if [[ -z ${MULTILIB_ABIS} ]] ; then
135 eradicator 1.19 echo "default"
136     return 0
137 eradicator 1.2 fi
138    
139 peper 1.63 if [[ ${EMULTILIB_PKG} == "true" ]] ; then
140 vapier 1.33 for x in ${MULTILIB_ABIS} ; do
141     if [[ ${x} != "${DEFAULT_ABI}" ]] ; then
142 ssuominen 1.91 has ${x} ${ABI_DENY} || order="${order} ${x}"
143 eradicator 1.2 fi
144     done
145 ssuominen 1.91 has ${DEFAULT_ABI} ${ABI_DENY} || order="${order} ${DEFAULT_ABI}"
146 eradicator 1.2
147 vapier 1.33 if [[ -n ${ABI_ALLOW} ]] ; then
148 eradicator 1.2 local ordera=""
149 vapier 1.33 for x in ${order} ; do
150 ssuominen 1.91 if has ${x} ${ABI_ALLOW} ; then
151 eradicator 1.2 ordera="${ordera} ${x}"
152     fi
153     done
154 vapier 1.33 order=${ordera}
155 eradicator 1.2 fi
156     else
157 vapier 1.33 order=${DEFAULT_ABI}
158 eradicator 1.2 fi
159    
160 vapier 1.33 if [[ -z ${order} ]] ; then
161 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."
162     fi
163    
164     echo ${order}
165     return 0
166     }
167    
168 vapier 1.65 # @FUNCTION: get_all_abis
169 vapier 1.92 # @DESCRIPTION:
170 eradicator 1.17 # 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 eradicator 1.40 if [[ -z ${MULTILIB_ABIS} ]] ; then
176 eradicator 1.19 echo "default"
177     return 0
178 eradicator 1.17 fi
179    
180     for x in ${MULTILIB_ABIS}; do
181 eradicator 1.40 if [[ ${x} != ${DEFAULT_ABI} ]] ; then
182     order="${order:+${order} }${x}"
183 eradicator 1.17 fi
184     done
185     order="${order:+${order} }${DEFAULT_ABI}"
186    
187     echo ${order}
188     return 0
189     }
190    
191 vapier 1.65 # @FUNCTION: get_all_libdirs
192     # @DESCRIPTION:
193 eradicator 1.2 # Returns a list of all the libdirs used by this profile. This includes
194 vapier 1.65 # those that might not be touched by the current ebuild and always includes
195     # "lib".
196 eradicator 1.1 get_all_libdirs() {
197 vapier 1.85 local libdirs
198 eradicator 1.2 local abi
199     local dir
200    
201 blubb 1.56 for abi in ${MULTILIB_ABIS}; do
202 vapier 1.85 libdirs+=" $(get_abi_LIBDIR ${abi})"
203 blubb 1.56 done
204 vapier 1.85 [[ " ${libdirs} " != *" lib "* ]] && libdirs+=" lib"
205 eradicator 1.2
206     echo "${libdirs}"
207     }
208    
209 vapier 1.65 # @FUNCTION: is_final_abi
210     # @DESCRIPTION:
211 eradicator 1.2 # 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 eradicator 1.23 has_multilib_profile || return 0
216 vapier 1.83 set -- $(get_install_abis)
217     local LAST_ABI=$#
218     [[ ${!LAST_ABI} == ${ABI} ]]
219 eradicator 1.2 }
220    
221 vapier 1.65 # @FUNCTION: number_abis
222     # @DESCRIPTION:
223 eradicator 1.2 # echo the number of ABIs we will be installing for
224     number_abis() {
225 vapier 1.88 set -- `get_install_abis`
226     echo $#
227 eradicator 1.2 }
228    
229 vapier 1.65 # @FUNCTION: get_libname
230     # @USAGE: [version]
231     # @DESCRIPTION:
232 grobian 1.73 # Returns libname with proper suffix {.so,.dylib,.dll,etc} and optionally
233     # supplied version for the current platform identified by CHOST.
234 vapier 1.65 #
235     # Example:
236 grobian 1.74 # get_libname ${PV}
237     # Returns: .so.${PV} (ELF) || .${PV}.dylib (MACH) || ...
238 kito 1.31 get_libname() {
239 vapier 1.44 local libname
240 kito 1.31 local ver=$1
241 vapier 1.44 case ${CHOST} in
242 vapier 1.69 *-cygwin|mingw*|*-mingw*) libname="dll";;
243     *-darwin*) libname="dylib";;
244 grobian 1.73 *-mint*) libname="irrelevant";;
245 grobian 1.75 hppa*-hpux*) libname="sl";;
246 vapier 1.69 *) libname="so";;
247 vapier 1.44 esac
248    
249 vapier 1.64 if [[ -z $* ]] ; then
250 vapier 1.44 echo ".${libname}"
251 kito 1.31 else
252 vapier 1.44 for ver in "$@" ; do
253     case ${CHOST} in
254     *-darwin*) echo ".${ver}.${libname}";;
255 grobian 1.73 *-mint*) echo ".${libname}";;
256 vapier 1.44 *) echo ".${libname}.${ver}";;
257     esac
258     done
259 kito 1.31 fi
260     }
261 eradicator 1.34
262 grobian 1.76 # @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 eradicator 1.34 # 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 vapier 1.41 local CTARGET=${1:-${CTARGET}}
286 eradicator 1.34
287 eradicator 1.37 case ${CTARGET} in
288     x86_64*)
289 eradicator 1.34 export CFLAGS_x86=${CFLAGS_x86--m32}
290 vapier 1.42 export CHOST_x86=${CTARGET/x86_64/i686}
291     export CTARGET_x86=${CHOST_x86}
292 vapier 1.87 if [[ ${SYMLINK_LIB} == "yes" ]] ; then
293 vapier 1.86 export LIBDIR_x86="lib32"
294     else
295     export LIBDIR_x86="lib"
296     fi
297 eradicator 1.34
298     export CFLAGS_amd64=${CFLAGS_amd64--m64}
299 vapier 1.42 export CHOST_amd64=${CTARGET}
300 blubb 1.57 export CTARGET_amd64=${CHOST_amd64}
301 eradicator 1.34 export LIBDIR_amd64="lib64"
302    
303 vapier 1.82 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 eradicator 1.34 ;;
311 eradicator 1.37 mips64*)
312 eradicator 1.34 export CFLAGS_o32=${CFLAGS_o32--mabi=32}
313 vapier 1.42 export CHOST_o32=${CTARGET/mips64/mips}
314     export CTARGET_o32=${CHOST_o32}
315 eradicator 1.34 export LIBDIR_o32="lib"
316    
317     export CFLAGS_n32=${CFLAGS_n32--mabi=n32}
318 vapier 1.42 export CHOST_n32=${CTARGET}
319     export CTARGET_n32=${CHOST_n32}
320 eradicator 1.34 export LIBDIR_n32="lib32"
321    
322     export CFLAGS_n64=${CFLAGS_n64--mabi=64}
323 vapier 1.42 export CHOST_n64=${CTARGET}
324     export CTARGET_n64=${CHOST_n64}
325 eradicator 1.34 export LIBDIR_n64="lib64"
326    
327 vapier 1.82 : ${MULTILIB_ABIS=n64 n32 o32}
328     : ${DEFAULT_ABI=n32}
329 eradicator 1.34 ;;
330 eradicator 1.37 powerpc64*)
331 eradicator 1.34 export CFLAGS_ppc=${CFLAGS_ppc--m32}
332 vapier 1.42 export CHOST_ppc=${CTARGET/powerpc64/powerpc}
333     export CTARGET_ppc=${CHOST_ppc}
334 eradicator 1.34 export LIBDIR_ppc="lib"
335    
336     export CFLAGS_ppc64=${CFLAGS_ppc64--m64}
337 vapier 1.42 export CHOST_ppc64=${CTARGET}
338     export CTARGET_ppc64=${CHOST_ppc64}
339 eradicator 1.34 export LIBDIR_ppc64="lib64"
340    
341 vapier 1.82 : ${MULTILIB_ABIS=ppc64 ppc}
342     : ${DEFAULT_ABI=ppc64}
343 eradicator 1.34 ;;
344 vapier 1.43 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 vapier 1.82 : ${MULTILIB_ABIS=s390x s390}
356     : ${DEFAULT_ABI=s390x}
357 vapier 1.43 ;;
358 bluebird 1.67 sparc*)
359     export CFLAGS_sparc32=${CFLAGS_sparc32}
360 vapier 1.42 export CHOST_sparc32=${CTARGET/sparc64/sparc}
361     export CTARGET_sparc32=${CHOST_sparc32}
362 eradicator 1.34 export LIBDIR_sparc32="lib"
363    
364     export CFLAGS_sparc64=${CFLAGS_sparc64--m64}
365 vapier 1.42 export CHOST_sparc64=${CTARGET}
366     export CTARGET_sparc64=${CHOST_sparc64}
367 eradicator 1.34 export LIBDIR_sparc64="lib64"
368    
369 vapier 1.82 : ${MULTILIB_ABIS=sparc64 sparc32}
370     : ${DEFAULT_ABI=sparc64}
371 eradicator 1.34 ;;
372     *)
373 vapier 1.82 : ${MULTILIB_ABIS=default}
374     : ${DEFAULT_ABI=default}
375 eradicator 1.36 ;;
376 eradicator 1.34 esac
377 vapier 1.82
378 vapier 1.84 export MULTILIB_ABIS DEFAULT_ABI
379 eradicator 1.34 }
380 eradicator 1.50
381 vapier 1.65 # @FUNCTION: multilib_toolchain_setup
382     # @DESCRIPTION:
383 vapier 1.51 # 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 eradicator 1.50 multilib_toolchain_setup() {
386 vapier 1.72 local v vv
387    
388 eradicator 1.55 export ABI=$1
389    
390 vapier 1.81 # 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 vapier 1.72 # 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 vapier 1.70 if [[ ${ABI} != ${DEFAULT_ABI} ]] ; then
403 vapier 1.81 # 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 eradicator 1.50
409 vapier 1.72 # 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 kevquinn 1.54 export CHOST=$(get_abi_CHOST $1)
417     export CBUILD=$(get_abi_CHOST $1)
418 vapier 1.53 fi
419 eradicator 1.50 }

  ViewVC Help
Powered by ViewVC 1.1.20