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

Diff of /eclass/multilib.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.71 Revision 1.86
1# Copyright 1999-2008 Gentoo Foundation 1# Copyright 1999-2011 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.71 2009/02/09 19:53:14 maekke Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/multilib.eclass,v 1.86 2011/03/18 19:12:08 vapier 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
235# @DESCRIPTION: 235# @DESCRIPTION:
236# Returns a list of all the libdirs used by this profile. This includes 236# Returns a list of all the libdirs used by this profile. This includes
237# those that might not be touched by the current ebuild and always includes 237# those that might not be touched by the current ebuild and always includes
238# "lib". 238# "lib".
239get_all_libdirs() { 239get_all_libdirs() {
240 local libdirs="lib" 240 local libdirs
241 local abi 241 local abi
242 local dir 242 local dir
243 243
244 for abi in ${MULTILIB_ABIS}; do 244 for abi in ${MULTILIB_ABIS}; do
245 [ "$(get_abi_LIBDIR ${abi})" != "lib" ] && libdirs="${libdirs} $(get_abi_LIBDIR ${abi})" 245 libdirs+=" $(get_abi_LIBDIR ${abi})"
246 done 246 done
247 [[ " ${libdirs} " != *" lib "* ]] && libdirs+=" lib"
247 248
248 echo "${libdirs}" 249 echo "${libdirs}"
249} 250}
250 251
251# @FUNCTION: is_final_abi 252# @FUNCTION: is_final_abi
253# Return true if ${ABI} is the last ABI on our list (or if we're not 254# Return true if ${ABI} is the last ABI on our list (or if we're not
254# using the new multilib configuration. This can be used to determine 255# using the new multilib configuration. This can be used to determine
255# if we're in the last (or only) run through src_{unpack,compile,install} 256# if we're in the last (or only) run through src_{unpack,compile,install}
256is_final_abi() { 257is_final_abi() {
257 has_multilib_profile || return 0 258 has_multilib_profile || return 0
258 local ALL_ABIS=$(get_install_abis) 259 set -- $(get_install_abis)
259 local LAST_ABI=${ALL_ABIS/* /} 260 local LAST_ABI=$#
260 [[ ${LAST_ABI} == ${ABI} ]] 261 [[ ${!LAST_ABI} == ${ABI} ]]
261} 262}
262 263
263# @FUNCTION: number_abis 264# @FUNCTION: number_abis
264# @DESCRIPTION: 265# @DESCRIPTION:
265# echo the number of ABIs we will be installing for 266# echo the number of ABIs we will be installing for
475# Helper function for create_ml_includes 476# Helper function for create_ml_includes
476create_ml_includes-makedestdirs() { 477create_ml_includes-makedestdirs() {
477 local dest=$1 478 local dest=$1
478 shift 479 shift
479 local basedirs=$@ 480 local basedirs=$@
481 [[ -z ${ED} ]] && local ED=${D}
480 482
481 dodir ${dest} 483 dodir ${dest}
482 484
483 local basedir 485 local basedir
484 for basedir in ${basedirs}; do 486 for basedir in ${basedirs}; do
485 local dir 487 local dir
486 for dir in $(find "${D}"/${basedir} -type d); do 488 for dir in $(find "${ED}"/${basedir} -type d); do
487 dodir ${dest}/${dir/${D}\/${basedir}/} 489 dodir ${dest}/${dir/${ED}\/${basedir}/}
488 done 490 done
489 done 491 done
490} 492}
491 493
492# Helper function for create_ml_includes 494# Helper function for create_ml_includes
493create_ml_includes-allfiles() { 495create_ml_includes-allfiles() {
496 [[ -z ${ED} ]] && local ED=${D}
494 local basedir file 497 local basedir file
495 for basedir in "$@" ; do 498 for basedir in "$@" ; do
496 for file in $(find "${D}"/${basedir} -type f); do 499 for file in $(find "${ED}"/${basedir} -type f); do
497 echo ${file/${D}\/${basedir}\//} 500 echo ${file/${ED}\/${basedir}\//}
498 done 501 done
499 done | sort | uniq 502 done | sort | uniq
500} 503}
501 504
502# Helper function for create_ml_includes 505# Helper function for create_ml_includes
516} 519}
517 520
518# @FUNCTION: get_libname 521# @FUNCTION: get_libname
519# @USAGE: [version] 522# @USAGE: [version]
520# @DESCRIPTION: 523# @DESCRIPTION:
521# Returns libname with proper suffix {.so,.dylib} and optionally supplied version 524# Returns libname with proper suffix {.so,.dylib,.dll,etc} and optionally
522# for ELF/MACH-O shared objects 525# supplied version for the current platform identified by CHOST.
523# 526#
524# Example: 527# Example:
525# get_libname libfoo ${PV} 528# get_libname ${PV}
526# Returns: libfoo.so.${PV} (ELF) || libfoo.${PV}.dylib (MACH) 529# Returns: .so.${PV} (ELF) || .${PV}.dylib (MACH) || ...
527get_libname() { 530get_libname() {
528 local libname 531 local libname
529 local ver=$1 532 local ver=$1
530 case ${CHOST} in 533 case ${CHOST} in
531 *-cygwin|mingw*|*-mingw*) libname="dll";; 534 *-cygwin|mingw*|*-mingw*) libname="dll";;
532 *-darwin*) libname="dylib";; 535 *-darwin*) libname="dylib";;
536 *-mint*) libname="irrelevant";;
537 hppa*-hpux*) libname="sl";;
533 *) libname="so";; 538 *) libname="so";;
534 esac 539 esac
535 540
536 if [[ -z $* ]] ; then 541 if [[ -z $* ]] ; then
537 echo ".${libname}" 542 echo ".${libname}"
538 else 543 else
539 for ver in "$@" ; do 544 for ver in "$@" ; do
540 case ${CHOST} in 545 case ${CHOST} in
541 *-darwin*) echo ".${ver}.${libname}";; 546 *-darwin*) echo ".${ver}.${libname}";;
547 *-mint*) echo ".${libname}";;
542 *) echo ".${libname}.${ver}";; 548 *) echo ".${libname}.${ver}";;
543 esac 549 esac
544 done 550 done
545 fi 551 fi
552}
553
554# @FUNCTION: get_modname
555# @USAGE:
556# @DESCRIPTION:
557# Returns modulename with proper suffix {.so,.bundle,etc} for the current
558# platform identified by CHOST.
559#
560# Example:
561# libfoo$(get_modname)
562# Returns: libfoo.so (ELF) || libfoo.bundle (MACH) || ...
563get_modname() {
564 local modname
565 local ver=$1
566 case ${CHOST} in
567 *-darwin*) modname="bundle";;
568 *) modname="so";;
569 esac
570
571 echo ".${modname}"
546} 572}
547 573
548# This is for the toolchain to setup profile variables when pulling in 574# This is for the toolchain to setup profile variables when pulling in
549# a crosscompiler (and thus they aren't set in the profile) 575# a crosscompiler (and thus they aren't set in the profile)
550multilib_env() { 576multilib_env() {
554 x86_64*) 580 x86_64*)
555 export CFLAGS_x86=${CFLAGS_x86--m32} 581 export CFLAGS_x86=${CFLAGS_x86--m32}
556 export CHOST_x86=${CTARGET/x86_64/i686} 582 export CHOST_x86=${CTARGET/x86_64/i686}
557 export CTARGET_x86=${CHOST_x86} 583 export CTARGET_x86=${CHOST_x86}
558 export CDEFINE_x86="__i386__" 584 export CDEFINE_x86="__i386__"
585 if [[ ${SYMLINK_LIBDIR} == "yes" ]] ; then
586 export LIBDIR_x86="lib32"
587 else
559 export LIBDIR_x86="lib" 588 export LIBDIR_x86="lib"
589 fi
560 590
561 export CFLAGS_amd64=${CFLAGS_amd64--m64} 591 export CFLAGS_amd64=${CFLAGS_amd64--m64}
562 export CHOST_amd64=${CTARGET} 592 export CHOST_amd64=${CTARGET}
563 export CTARGET_amd64=${CHOST_amd64} 593 export CTARGET_amd64=${CHOST_amd64}
564 export CDEFINE_amd64="__x86_64__" 594 export CDEFINE_amd64="__x86_64__"
565 export LIBDIR_amd64="lib64" 595 export LIBDIR_amd64="lib64"
566 596
597 export CFLAGS_x32=${CFLAGS_x32--mx32}
598 export CHOST_x32=${CTARGET}
599 export CTARGET_x32=${CHOST_x32}
600 export CDEFINE_x32="__i386__"
601 export LIBDIR_x32="libx32"
602
567 export MULTILIB_ABIS="amd64 x86" 603 : ${MULTILIB_ABIS=amd64 x86}
568 export DEFAULT_ABI="amd64" 604 : ${DEFAULT_ABI=amd64}
569 ;; 605 ;;
570 mips64*) 606 mips64*)
571 export CFLAGS_o32=${CFLAGS_o32--mabi=32} 607 export CFLAGS_o32=${CFLAGS_o32--mabi=32}
572 export CHOST_o32=${CTARGET/mips64/mips} 608 export CHOST_o32=${CTARGET/mips64/mips}
573 export CTARGET_o32=${CHOST_o32} 609 export CTARGET_o32=${CHOST_o32}
584 export CHOST_n64=${CTARGET} 620 export CHOST_n64=${CTARGET}
585 export CTARGET_n64=${CHOST_n64} 621 export CTARGET_n64=${CHOST_n64}
586 export CDEFINE_n64="_MIPS_SIM == _ABI64" 622 export CDEFINE_n64="_MIPS_SIM == _ABI64"
587 export LIBDIR_n64="lib64" 623 export LIBDIR_n64="lib64"
588 624
589 export MULTILIB_ABIS="n64 n32 o32" 625 : ${MULTILIB_ABIS=n64 n32 o32}
590 export DEFAULT_ABI="n32" 626 : ${DEFAULT_ABI=n32}
591 ;; 627 ;;
592 powerpc64*) 628 powerpc64*)
593 export CFLAGS_ppc=${CFLAGS_ppc--m32} 629 export CFLAGS_ppc=${CFLAGS_ppc--m32}
594 export CHOST_ppc=${CTARGET/powerpc64/powerpc} 630 export CHOST_ppc=${CTARGET/powerpc64/powerpc}
595 export CTARGET_ppc=${CHOST_ppc} 631 export CTARGET_ppc=${CHOST_ppc}
600 export CHOST_ppc64=${CTARGET} 636 export CHOST_ppc64=${CTARGET}
601 export CTARGET_ppc64=${CHOST_ppc64} 637 export CTARGET_ppc64=${CHOST_ppc64}
602 export CDEFINE_ppc64="__powerpc64__" 638 export CDEFINE_ppc64="__powerpc64__"
603 export LIBDIR_ppc64="lib64" 639 export LIBDIR_ppc64="lib64"
604 640
605 export MULTILIB_ABIS="ppc64 ppc" 641 : ${MULTILIB_ABIS=ppc64 ppc}
606 export DEFAULT_ABI="ppc64" 642 : ${DEFAULT_ABI=ppc64}
607 ;; 643 ;;
608 s390x*) 644 s390x*)
609 export CFLAGS_s390=${CFLAGS_s390--m31} # the 31 is not a typo 645 export CFLAGS_s390=${CFLAGS_s390--m31} # the 31 is not a typo
610 export CHOST_s390=${CTARGET/s390x/s390} 646 export CHOST_s390=${CTARGET/s390x/s390}
611 export CTARGET_s390=${CHOST_s390} 647 export CTARGET_s390=${CHOST_s390}
616 export CHOST_s390x=${CTARGET} 652 export CHOST_s390x=${CTARGET}
617 export CTARGET_s390x=${CHOST_s390x} 653 export CTARGET_s390x=${CHOST_s390x}
618 export CDEFINE_s390x="__s390x__" 654 export CDEFINE_s390x="__s390x__"
619 export LIBDIR_s390x="lib64" 655 export LIBDIR_s390x="lib64"
620 656
621 export MULTILIB_ABIS="s390x s390" 657 : ${MULTILIB_ABIS=s390x s390}
622 export DEFAULT_ABI="s390x" 658 : ${DEFAULT_ABI=s390x}
623 ;; 659 ;;
624 sparc*) 660 sparc*)
625 export CFLAGS_sparc32=${CFLAGS_sparc32} 661 export CFLAGS_sparc32=${CFLAGS_sparc32}
626 export CHOST_sparc32=${CTARGET/sparc64/sparc} 662 export CHOST_sparc32=${CTARGET/sparc64/sparc}
627 export CTARGET_sparc32=${CHOST_sparc32} 663 export CTARGET_sparc32=${CHOST_sparc32}
632 export CHOST_sparc64=${CTARGET} 668 export CHOST_sparc64=${CTARGET}
633 export CTARGET_sparc64=${CHOST_sparc64} 669 export CTARGET_sparc64=${CHOST_sparc64}
634 export CDEFINE_sparc64="__arch64__" 670 export CDEFINE_sparc64="__arch64__"
635 export LIBDIR_sparc64="lib64" 671 export LIBDIR_sparc64="lib64"
636 672
637 export MULTILIB_ABIS="${MULTILIB_ABIS-sparc64 sparc32}" 673 : ${MULTILIB_ABIS=sparc64 sparc32}
638 export DEFAULT_ABI="${DEFAULT_ABI-sparc64}" 674 : ${DEFAULT_ABI=sparc64}
639 ;; 675 ;;
640 *) 676 *)
641 export MULTILIB_ABIS="default" 677 : ${MULTILIB_ABIS=default}
642 export DEFAULT_ABI="default" 678 : ${DEFAULT_ABI=default}
643 ;; 679 ;;
644 esac 680 esac
681
682 export MULTILIB_ABIS DEFAULT_ABI
645} 683}
646 684
647# @FUNCTION: multilib_toolchain_setup 685# @FUNCTION: multilib_toolchain_setup
648# @DESCRIPTION: 686# @DESCRIPTION:
649# Hide multilib details here for packages which are forced to be compiled for a 687# Hide multilib details here for packages which are forced to be compiled for a
650# specific ABI when run on another ABI (like x86-specific packages on amd64) 688# specific ABI when run on another ABI (like x86-specific packages on amd64)
651multilib_toolchain_setup() { 689multilib_toolchain_setup() {
690 local v vv
691
652 export ABI=$1 692 export ABI=$1
653 693
654 # disable ccache for non-native builds #196243. this is because how 694 # First restore any saved state we have laying around.
655 # we cram ABI related CFLAGS behind the back of the gcc frontend with 695 if [[ ${__DEFAULT_ABI_SAVED} == "true" ]] ; then
656 # the gcc-config wrapper. 696 for v in CHOST CBUILD AS CC CXX LD ; do
697 vv="__abi_saved_${v}"
698 export ${v}="${!vv}"
699 unset ${vv}
700 done
701 unset __DEFAULT_ABI_SAVED
702 fi
703
704 # We want to avoid the behind-the-back magic of gcc-config as it
705 # screws up ccache and distcc. See #196243 for more info.
657 if [[ ${ABI} != ${DEFAULT_ABI} ]] ; then 706 if [[ ${ABI} != ${DEFAULT_ABI} ]] ; then
658 : ${CCACHE_DISABLE:=multilib-disable} 707 # Back that multilib-ass up so we can restore it later
659 else 708 for v in CHOST CBUILD AS CC CXX LD ; do
660 if [[ ${CCACHE_DISABLE} == "multilib-disable" ]] ; then 709 export __abi_saved_${v}="${!v}"
661 unset CCACHE_DISABLE 710 done
662 fi 711 export __DEFAULT_ABI_SAVED="true"
663 fi
664 export CCACHE_DISABLE
665 712
666 if has_version app-admin/eselect-compiler ; then 713 # Set the CHOST native first so that we pick up the native
667 # Binutils doesn't have wrappers for ld and as (yet). Eventually it 714 # toolchain and not a cross-compiler by accident #202811.
668 # will, and all this can just be handled with CHOST. 715 export CHOST=$(get_abi_CHOST ${DEFAULT_ABI})
669 export LD="ld $(get_abi_LDFLAGS $1)"
670 export AS="as $(get_abi_ASFLAGS $1)" 716 export AS="$(tc-getAS) $(get_abi_ASFLAGS)"
671 717 export CC="$(tc-getCC) $(get_abi_CFLAGS)"
718 export CXX="$(tc-getCXX) $(get_abi_CFLAGS)"
719 export LD="$(tc-getLD) $(get_abi_LDFLAGS)"
672 export CHOST=$(get_abi_CHOST $1) 720 export CHOST=$(get_abi_CHOST $1)
673 export CBUILD=$(get_abi_CHOST $1) 721 export CBUILD=$(get_abi_CHOST $1)
674 else
675 tc-export CC
676 fi 722 fi
677} 723}

Legend:
Removed from v.1.71  
changed lines
  Added in v.1.86

  ViewVC Help
Powered by ViewVC 1.1.20