| 1 | # Copyright 1999-2004 Gentoo Foundation |
1 | # Copyright 1999-2007 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.1.1.1 2005/11/30 09:59:17 chriswhite Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/multilib.eclass,v 1.60 2007/03/27 01:46:50 vapier Exp $ |
| 4 | # |
4 | # |
| 5 | # Author: Jeremy Huddleston <eradicator@gentoo.org> |
5 | # Maintainer: amd64@gentoo.org / toolchain@gentoo.org |
| 6 | # |
6 | # |
| 7 | # This eclass is for all functions pertaining to handling multilib. |
7 | # This eclass is for all functions pertaining to handling multilib. |
| 8 | # configurations. |
8 | # configurations. |
|
|
9 | |
|
|
10 | ___ECLASS_RECUR_MULTILIB="yes" |
|
|
11 | [[ -z ${___ECLASS_RECUR_TOOLCHAIN_FUNCS} ]] && inherit toolchain-funcs |
| 9 | |
12 | |
| 10 | DESCRIPTION="Based on the ${ECLASS} eclass" |
13 | DESCRIPTION="Based on the ${ECLASS} eclass" |
| 11 | |
14 | |
| 12 | # has_multilib_profile: |
15 | # has_multilib_profile: |
| 13 | # Return true if the current profile is a multilib profile and lists more than |
16 | # Return true if the current profile is a multilib profile and lists more than |
| … | |
… | |
| 100 | export LDFLAGS_default |
103 | export LDFLAGS_default |
| 101 | export CHOST_default=${CHOST_default:-${CHOST}} |
104 | export CHOST_default=${CHOST_default:-${CHOST}} |
| 102 | export CTARGET_default=${CTARGET_default:-${CTARGET:-${CHOST_default}}} |
105 | export CTARGET_default=${CTARGET_default:-${CTARGET:-${CHOST_default}}} |
| 103 | export LIBDIR_default=${CONF_LIBDIR:-"lib"} |
106 | export LIBDIR_default=${CONF_LIBDIR:-"lib"} |
| 104 | export CDEFINE_default="__unix__" |
107 | export CDEFINE_default="__unix__" |
|
|
108 | export KERNEL_ABI=${KERNEL_ABI:-${DEFAULT_ABI}} |
| 105 | |
109 | |
| 106 | # has_multilib_profile() |
110 | # has_multilib_profile() |
| 107 | has_multilib_profile() { |
111 | has_multilib_profile() { |
| 108 | [ -n "${MULTILIB_ABIS}" -a "${MULTILIB_ABIS}" != "${MULTILIB_ABIS/ /}" ] |
112 | [ -n "${MULTILIB_ABIS}" -a "${MULTILIB_ABIS}" != "${MULTILIB_ABIS/ /}" ] |
| 109 | } |
113 | } |
| … | |
… | |
| 190 | local var="${flag}_${abi}" |
194 | local var="${flag}_${abi}" |
| 191 | echo ${!var} |
195 | echo ${!var} |
| 192 | } |
196 | } |
| 193 | |
197 | |
| 194 | get_abi_CFLAGS() { get_abi_var CFLAGS "$@"; } |
198 | get_abi_CFLAGS() { get_abi_var CFLAGS "$@"; } |
|
|
199 | get_abi_ASFLAGS() { get_abi_var ASFLAGS "$@"; } |
| 195 | get_abi_LDFLAGS() { get_abi_var LDFLAGS "$@"; } |
200 | get_abi_LDFLAGS() { get_abi_var LDFLAGS "$@"; } |
| 196 | get_abi_CHOST() { get_abi_var CHOST "$@"; } |
201 | get_abi_CHOST() { get_abi_var CHOST "$@"; } |
| 197 | get_abi_CTARGET() { get_abi_var CTARGET "$@"; } |
202 | get_abi_CTARGET() { get_abi_var CTARGET "$@"; } |
| 198 | get_abi_FAKE_TARGETS() { get_abi_var FAKE_TARGETS "$@"; } |
203 | get_abi_FAKE_TARGETS() { get_abi_var FAKE_TARGETS "$@"; } |
| 199 | get_abi_CDEFINE() { get_abi_var CDEFINE "$@"; } |
204 | get_abi_CDEFINE() { get_abi_var CDEFINE "$@"; } |
| … | |
… | |
| 266 | get_all_libdirs() { |
271 | get_all_libdirs() { |
| 267 | local libdirs="lib" |
272 | local libdirs="lib" |
| 268 | local abi |
273 | local abi |
| 269 | local dir |
274 | local dir |
| 270 | |
275 | |
| 271 | if has_multilib_profile; then |
|
|
| 272 | for abi in ${MULTILIB_ABIS}; do |
276 | for abi in ${MULTILIB_ABIS}; do |
| 273 | [ "$(get_abi_LIBDIR ${abi})" != "lib" ] && libdirs="${libdirs} $(get_abi_LIBDIR ${abi})" |
277 | [ "$(get_abi_LIBDIR ${abi})" != "lib" ] && libdirs="${libdirs} $(get_abi_LIBDIR ${abi})" |
| 274 | done |
278 | done |
| 275 | elif [ -n "${CONF_LIBDIR}" ]; then |
|
|
| 276 | for dir in ${CONF_LIBDIR} ${CONF_MULTILIBDIR:-lib32}; do |
|
|
| 277 | [ "${dir}" != "lib" ] && libdirs="${libdirs} ${dir}" |
|
|
| 278 | done |
|
|
| 279 | fi |
|
|
| 280 | |
279 | |
| 281 | echo "${libdirs}" |
280 | echo "${libdirs}" |
| 282 | } |
281 | } |
| 283 | |
282 | |
| 284 | # Return true if ${ABI} is the last ABI on our list (or if we're not |
283 | # Return true if ${ABI} is the last ABI on our list (or if we're not |
| … | |
… | |
| 388 | # Ideas for this code came from debian's sparc-linux headers package. |
387 | # Ideas for this code came from debian's sparc-linux headers package. |
| 389 | # |
388 | # |
| 390 | # Example: |
389 | # Example: |
| 391 | # create_ml_includes /usr/include/asm __sparc__:/usr/include/asm-sparc __sparc64__:/usr/include/asm-sparc64 |
390 | # create_ml_includes /usr/include/asm __sparc__:/usr/include/asm-sparc __sparc64__:/usr/include/asm-sparc64 |
| 392 | # create_ml_includes /usr/include/asm __i386__:/usr/include/asm-i386 __x86_64__:/usr/include/asm-x86_64 |
391 | # create_ml_includes /usr/include/asm __i386__:/usr/include/asm-i386 __x86_64__:/usr/include/asm-x86_64 |
|
|
392 | # |
|
|
393 | # Warning: Be careful with the ordering here. The default ABI has to be the |
|
|
394 | # last, because it is always defined (by GCC) |
| 393 | create_ml_includes() { |
395 | create_ml_includes() { |
| 394 | local dest=$1 |
396 | local dest=$1 |
| 395 | shift |
397 | shift |
| 396 | local basedirs=$(create_ml_includes-listdirs "$@") |
398 | local basedirs=$(create_ml_includes-listdirs "$@") |
| 397 | |
399 | |
| … | |
… | |
| 565 | export CDEFINE_x86="__i386__" |
567 | export CDEFINE_x86="__i386__" |
| 566 | export LIBDIR_x86="lib" |
568 | export LIBDIR_x86="lib" |
| 567 | |
569 | |
| 568 | export CFLAGS_amd64=${CFLAGS_amd64--m64} |
570 | export CFLAGS_amd64=${CFLAGS_amd64--m64} |
| 569 | export CHOST_amd64=${CTARGET} |
571 | export CHOST_amd64=${CTARGET} |
| 570 | export CTARGET_amd64=${CTARGET_amd64} |
572 | export CTARGET_amd64=${CHOST_amd64} |
| 571 | export CDEFINE_amd64="__x86_64__" |
573 | export CDEFINE_amd64="__x86_64__" |
| 572 | export LIBDIR_amd64="lib64" |
574 | export LIBDIR_amd64="lib64" |
| 573 | |
575 | |
| 574 | export MULTILIB_ABIS="amd64 x86" |
576 | export MULTILIB_ABIS="amd64 x86" |
| 575 | export DEFAULT_ABI="amd64" |
577 | export DEFAULT_ABI="amd64" |
| … | |
… | |
| 648 | export MULTILIB_ABIS="default" |
650 | export MULTILIB_ABIS="default" |
| 649 | export DEFAULT_ABI="default" |
651 | export DEFAULT_ABI="default" |
| 650 | ;; |
652 | ;; |
| 651 | esac |
653 | esac |
| 652 | } |
654 | } |
|
|
655 | |
|
|
656 | # Hide multilib details here for packages which are forced to be compiled for a |
|
|
657 | # specific ABI when run on another ABI (like x86-specific packages on amd64) |
|
|
658 | multilib_toolchain_setup() { |
|
|
659 | export ABI=$1 |
|
|
660 | |
|
|
661 | if has_version app-admin/eselect-compiler ; then |
|
|
662 | # Binutils doesn't have wrappers for ld and as (yet). Eventually it |
|
|
663 | # will, and all this can just be handled with CHOST. |
|
|
664 | export LD="ld $(get_abi_LDFLAGS $1)" |
|
|
665 | export AS="as $(get_abi_ASFLAGS $1)" |
|
|
666 | |
|
|
667 | export CHOST=$(get_abi_CHOST $1) |
|
|
668 | export CBUILD=$(get_abi_CHOST $1) |
|
|
669 | else |
|
|
670 | tc-export CC |
|
|
671 | fi |
|
|
672 | } |