| 1 | # Copyright 1999-2011 Gentoo Foundation |
1 | # Copyright 1999-2013 Gentoo Foundation |
| 2 | # Distributed under the terms of the GNU General Public License v2 |
2 | # Distributed under the terms of the GNU General Public License v2 |
| 3 | # $Header: /var/cvsroot/gentoo-x86/eclass/multilib.eclass,v 1.95 2011/10/27 05:50:40 vapier Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/multilib.eclass,v 1.102 2013/01/21 19:22:25 mgorny Exp $ |
| 4 | |
4 | |
| 5 | # @ECLASS: multilib.eclass |
5 | # @ECLASS: multilib.eclass |
| 6 | # @MAINTAINER: |
6 | # @MAINTAINER: |
| 7 | # amd64@gentoo.org |
7 | # amd64@gentoo.org |
| 8 | # toolchain@gentoo.org |
8 | # toolchain@gentoo.org |
| 9 | # @BLURB: This eclass is for all functions pertaining to handling multilib configurations. |
9 | # @BLURB: This eclass is for all functions pertaining to handling multilib configurations. |
| 10 | # @DESCRIPTION: |
10 | # @DESCRIPTION: |
| 11 | # This eclass is for all functions pertaining to handling multilib configurations. |
11 | # This eclass is for all functions pertaining to handling multilib configurations. |
| 12 | |
12 | |
| 13 | ___ECLASS_RECUR_MULTILIB="yes" |
13 | if [[ ${___ECLASS_ONCE_MULTILIB} != "recur -_+^+_- spank" ]] ; then |
| 14 | [[ -z ${___ECLASS_RECUR_TOOLCHAIN_FUNCS} ]] && inherit toolchain-funcs |
14 | ___ECLASS_ONCE_MULTILIB="recur -_+^+_- spank" |
|
|
15 | |
|
|
16 | inherit toolchain-funcs |
| 15 | |
17 | |
| 16 | # Defaults: |
18 | # Defaults: |
| 17 | export MULTILIB_ABIS=${MULTILIB_ABIS:-"default"} |
19 | export MULTILIB_ABIS=${MULTILIB_ABIS:-"default"} |
| 18 | export DEFAULT_ABI=${DEFAULT_ABI:-"default"} |
20 | export DEFAULT_ABI=${DEFAULT_ABI:-"default"} |
| 19 | export CFLAGS_default |
21 | export CFLAGS_default |
| … | |
… | |
| 117 | # @FUNCTION: get_install_abis |
119 | # @FUNCTION: get_install_abis |
| 118 | # @DESCRIPTION: |
120 | # @DESCRIPTION: |
| 119 | # Return a list of the ABIs we want to install for with |
121 | # Return a list of the ABIs we want to install for with |
| 120 | # the last one in the list being the default. |
122 | # the last one in the list being the default. |
| 121 | get_install_abis() { |
123 | get_install_abis() { |
| 122 | local order="" |
124 | local x order="" |
| 123 | |
125 | |
| 124 | if [[ -z ${MULTILIB_ABIS} ]] ; then |
126 | if [[ -z ${MULTILIB_ABIS} ]] ; then |
| 125 | echo "default" |
127 | echo "default" |
| 126 | return 0 |
128 | return 0 |
| 127 | fi |
129 | fi |
| … | |
… | |
| 158 | # @FUNCTION: get_all_abis |
160 | # @FUNCTION: get_all_abis |
| 159 | # @DESCRIPTION: |
161 | # @DESCRIPTION: |
| 160 | # Return a list of the ABIs supported by this profile. |
162 | # Return a list of the ABIs supported by this profile. |
| 161 | # the last one in the list being the default. |
163 | # the last one in the list being the default. |
| 162 | get_all_abis() { |
164 | get_all_abis() { |
| 163 | local order="" |
165 | local x order="" mvar dvar |
| 164 | |
166 | |
| 165 | if [[ -z ${MULTILIB_ABIS} ]] ; then |
167 | mvar="MULTILIB_ABIS" |
|
|
168 | dvar="DEFAULT_ABI" |
|
|
169 | if [[ -n $1 ]] ; then |
|
|
170 | mvar="$1_${mvar}" |
|
|
171 | dvar="$1_${dvar}" |
|
|
172 | fi |
|
|
173 | |
|
|
174 | if [[ -z ${!mvar} ]] ; then |
| 166 | echo "default" |
175 | echo "default" |
| 167 | return 0 |
176 | return 0 |
| 168 | fi |
177 | fi |
| 169 | |
178 | |
| 170 | for x in ${MULTILIB_ABIS}; do |
179 | for x in ${!mvar}; do |
| 171 | if [[ ${x} != ${DEFAULT_ABI} ]] ; then |
180 | if [[ ${x} != ${!dvar} ]] ; then |
| 172 | order="${order:+${order} }${x}" |
181 | order="${order:+${order} }${x}" |
| 173 | fi |
182 | fi |
| 174 | done |
183 | done |
| 175 | order="${order:+${order} }${DEFAULT_ABI}" |
184 | order="${order:+${order} }${!dvar}" |
| 176 | |
185 | |
| 177 | echo ${order} |
186 | echo ${order} |
| 178 | return 0 |
187 | return 0 |
| 179 | } |
188 | } |
| 180 | |
189 | |
| … | |
… | |
| 182 | # @DESCRIPTION: |
191 | # @DESCRIPTION: |
| 183 | # Returns a list of all the libdirs used by this profile. This includes |
192 | # Returns a list of all the libdirs used by this profile. This includes |
| 184 | # those that might not be touched by the current ebuild and always includes |
193 | # those that might not be touched by the current ebuild and always includes |
| 185 | # "lib". |
194 | # "lib". |
| 186 | get_all_libdirs() { |
195 | get_all_libdirs() { |
| 187 | local libdirs |
196 | local libdirs abi |
| 188 | local abi |
|
|
| 189 | local dir |
|
|
| 190 | |
197 | |
| 191 | for abi in ${MULTILIB_ABIS}; do |
198 | for abi in ${MULTILIB_ABIS}; do |
| 192 | libdirs+=" $(get_abi_LIBDIR ${abi})" |
199 | libdirs+=" $(get_abi_LIBDIR ${abi})" |
| 193 | done |
200 | done |
| 194 | [[ " ${libdirs} " != *" lib "* ]] && libdirs+=" lib" |
201 | [[ " ${libdirs} " != *" lib "* ]] && libdirs+=" lib" |
| … | |
… | |
| 276 | |
283 | |
| 277 | case ${CTARGET} in |
284 | case ${CTARGET} in |
| 278 | x86_64*) |
285 | x86_64*) |
| 279 | export CFLAGS_x86=${CFLAGS_x86--m32} |
286 | export CFLAGS_x86=${CFLAGS_x86--m32} |
| 280 | export CHOST_x86=${CTARGET/x86_64/i686} |
287 | export CHOST_x86=${CTARGET/x86_64/i686} |
|
|
288 | CHOST_x86=${CHOST_x86/%-gnux32/-gnu} |
| 281 | export CTARGET_x86=${CHOST_x86} |
289 | export CTARGET_x86=${CHOST_x86} |
| 282 | if [[ ${SYMLINK_LIB} == "yes" ]] ; then |
290 | if [[ ${SYMLINK_LIB} == "yes" ]] ; then |
| 283 | export LIBDIR_x86="lib32" |
291 | export LIBDIR_x86="lib32" |
| 284 | else |
292 | else |
| 285 | export LIBDIR_x86="lib" |
293 | export LIBDIR_x86="lib" |
| 286 | fi |
294 | fi |
| 287 | |
295 | |
| 288 | export CFLAGS_amd64=${CFLAGS_amd64--m64} |
296 | export CFLAGS_amd64=${CFLAGS_amd64--m64} |
| 289 | export CHOST_amd64=${CTARGET} |
297 | export CHOST_amd64=${CTARGET/%-gnux32/-gnu} |
| 290 | export CTARGET_amd64=${CHOST_amd64} |
298 | export CTARGET_amd64=${CHOST_amd64} |
| 291 | export LIBDIR_amd64="lib64" |
299 | export LIBDIR_amd64="lib64" |
| 292 | |
300 | |
| 293 | export CFLAGS_x32=${CFLAGS_x32--mx32} |
301 | export CFLAGS_x32=${CFLAGS_x32--mx32} |
| 294 | export CHOST_x32=${CTARGET} |
302 | export CHOST_x32=${CTARGET/%-gnu/-gnux32} |
| 295 | export CTARGET_x32=${CHOST_x32} |
303 | export CTARGET_x32=${CHOST_x32} |
| 296 | export LIBDIR_x32="libx32" |
304 | export LIBDIR_x32="libx32" |
| 297 | |
305 | |
|
|
306 | case ${CTARGET} in |
|
|
307 | *-gnux32) |
|
|
308 | : ${MULTILIB_ABIS=x32 amd64 x86} |
|
|
309 | : ${DEFAULT_ABI=x32} |
|
|
310 | ;; |
|
|
311 | *) |
| 298 | : ${MULTILIB_ABIS=amd64 x86} |
312 | : ${MULTILIB_ABIS=amd64 x86} |
| 299 | : ${DEFAULT_ABI=amd64} |
313 | : ${DEFAULT_ABI=amd64} |
|
|
314 | ;; |
|
|
315 | esac |
| 300 | ;; |
316 | ;; |
| 301 | mips64*) |
317 | mips64*) |
| 302 | export CFLAGS_o32=${CFLAGS_o32--mabi=32} |
318 | export CFLAGS_o32=${CFLAGS_o32--mabi=32} |
| 303 | export CHOST_o32=${CTARGET/mips64/mips} |
319 | export CHOST_o32=${CTARGET/mips64/mips} |
| 304 | export CTARGET_o32=${CHOST_o32} |
320 | export CTARGET_o32=${CHOST_o32} |
| … | |
… | |
| 343 | export LIBDIR_s390x="lib64" |
359 | export LIBDIR_s390x="lib64" |
| 344 | |
360 | |
| 345 | : ${MULTILIB_ABIS=s390x s390} |
361 | : ${MULTILIB_ABIS=s390x s390} |
| 346 | : ${DEFAULT_ABI=s390x} |
362 | : ${DEFAULT_ABI=s390x} |
| 347 | ;; |
363 | ;; |
| 348 | sparc*) |
364 | sparc64*) |
| 349 | export CFLAGS_sparc32=${CFLAGS_sparc32} |
365 | export CFLAGS_sparc32=${CFLAGS_sparc32--m32} |
| 350 | export CHOST_sparc32=${CTARGET/sparc64/sparc} |
366 | export CHOST_sparc32=${CTARGET/sparc64/sparc} |
| 351 | export CTARGET_sparc32=${CHOST_sparc32} |
367 | export CTARGET_sparc32=${CHOST_sparc32} |
| 352 | export LIBDIR_sparc32="lib" |
368 | export LIBDIR_sparc32="lib" |
| 353 | |
369 | |
| 354 | export CFLAGS_sparc64=${CFLAGS_sparc64--m64} |
370 | export CFLAGS_sparc64=${CFLAGS_sparc64--m64} |
| … | |
… | |
| 377 | |
393 | |
| 378 | export ABI=$1 |
394 | export ABI=$1 |
| 379 | |
395 | |
| 380 | # First restore any saved state we have laying around. |
396 | # First restore any saved state we have laying around. |
| 381 | if [[ ${__DEFAULT_ABI_SAVED} == "true" ]] ; then |
397 | if [[ ${__DEFAULT_ABI_SAVED} == "true" ]] ; then |
| 382 | for v in CHOST CBUILD AS CC CXX LD ; do |
398 | for v in CHOST CBUILD AS CC CXX LD PKG_CONFIG_{LIBDIR,PATH} ; do |
| 383 | vv="__abi_saved_${v}" |
399 | vv="__abi_saved_${v}" |
| 384 | export ${v}="${!vv}" |
400 | export ${v}="${!vv}" |
| 385 | unset ${vv} |
401 | unset ${vv} |
| 386 | done |
402 | done |
| 387 | unset __DEFAULT_ABI_SAVED |
403 | unset __DEFAULT_ABI_SAVED |
| … | |
… | |
| 389 | |
405 | |
| 390 | # We want to avoid the behind-the-back magic of gcc-config as it |
406 | # 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. |
407 | # screws up ccache and distcc. See #196243 for more info. |
| 392 | if [[ ${ABI} != ${DEFAULT_ABI} ]] ; then |
408 | if [[ ${ABI} != ${DEFAULT_ABI} ]] ; then |
| 393 | # Back that multilib-ass up so we can restore it later |
409 | # Back that multilib-ass up so we can restore it later |
| 394 | for v in CHOST CBUILD AS CC CXX LD ; do |
410 | for v in CHOST CBUILD AS CC CXX LD PKG_CONFIG_{LIBDIR,PATH} ; do |
| 395 | export __abi_saved_${v}="${!v}" |
411 | export __abi_saved_${v}="${!v}" |
| 396 | done |
412 | done |
| 397 | export __DEFAULT_ABI_SAVED="true" |
413 | export __DEFAULT_ABI_SAVED="true" |
| 398 | |
414 | |
| 399 | # Set the CHOST native first so that we pick up the native |
415 | # Set the CHOST native first so that we pick up the native |
| … | |
… | |
| 402 | export CC="$(tc-getCC) $(get_abi_CFLAGS)" |
418 | export CC="$(tc-getCC) $(get_abi_CFLAGS)" |
| 403 | export CXX="$(tc-getCXX) $(get_abi_CFLAGS)" |
419 | export CXX="$(tc-getCXX) $(get_abi_CFLAGS)" |
| 404 | export LD="$(tc-getLD) $(get_abi_LDFLAGS)" |
420 | export LD="$(tc-getLD) $(get_abi_LDFLAGS)" |
| 405 | export CHOST=$(get_abi_CHOST $1) |
421 | export CHOST=$(get_abi_CHOST $1) |
| 406 | export CBUILD=$(get_abi_CHOST $1) |
422 | export CBUILD=$(get_abi_CHOST $1) |
|
|
423 | export PKG_CONFIG_LIBDIR=${EPREFIX}/usr/$(get_libdir)/pkgconfig |
|
|
424 | export PKG_CONFIG_PATH=${EPREFIX}/usr/share/pkgconfig |
|
|
425 | fi |
|
|
426 | } |
|
|
427 | |
| 407 | fi |
428 | fi |
| 408 | } |
|
|