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

Diff of /eclass/multilib.eclass

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

Revision 1.72 Revision 1.82
1# Copyright 1999-2008 Gentoo Foundation 1# Copyright 1999-2008 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.72 2009/02/20 23:20:22 vapier Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/multilib.eclass,v 1.82 2011/03/10 04:26:38 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
475# Helper function for create_ml_includes 475# Helper function for create_ml_includes
476create_ml_includes-makedestdirs() { 476create_ml_includes-makedestdirs() {
477 local dest=$1 477 local dest=$1
478 shift 478 shift
479 local basedirs=$@ 479 local basedirs=$@
480 [[ -z ${ED} ]] && local ED=${D}
480 481
481 dodir ${dest} 482 dodir ${dest}
482 483
483 local basedir 484 local basedir
484 for basedir in ${basedirs}; do 485 for basedir in ${basedirs}; do
485 local dir 486 local dir
486 for dir in $(find "${D}"/${basedir} -type d); do 487 for dir in $(find "${ED}"/${basedir} -type d); do
487 dodir ${dest}/${dir/${D}\/${basedir}/} 488 dodir ${dest}/${dir/${ED}\/${basedir}/}
488 done 489 done
489 done 490 done
490} 491}
491 492
492# Helper function for create_ml_includes 493# Helper function for create_ml_includes
493create_ml_includes-allfiles() { 494create_ml_includes-allfiles() {
495 [[ -z ${ED} ]] && local ED=${D}
494 local basedir file 496 local basedir file
495 for basedir in "$@" ; do 497 for basedir in "$@" ; do
496 for file in $(find "${D}"/${basedir} -type f); do 498 for file in $(find "${ED}"/${basedir} -type f); do
497 echo ${file/${D}\/${basedir}\//} 499 echo ${file/${ED}\/${basedir}\//}
498 done 500 done
499 done | sort | uniq 501 done | sort | uniq
500} 502}
501 503
502# Helper function for create_ml_includes 504# Helper function for create_ml_includes
516} 518}
517 519
518# @FUNCTION: get_libname 520# @FUNCTION: get_libname
519# @USAGE: [version] 521# @USAGE: [version]
520# @DESCRIPTION: 522# @DESCRIPTION:
521# Returns libname with proper suffix {.so,.dylib} and optionally supplied version 523# Returns libname with proper suffix {.so,.dylib,.dll,etc} and optionally
522# for ELF/MACH-O shared objects 524# supplied version for the current platform identified by CHOST.
523# 525#
524# Example: 526# Example:
525# get_libname libfoo ${PV} 527# get_libname ${PV}
526# Returns: libfoo.so.${PV} (ELF) || libfoo.${PV}.dylib (MACH) 528# Returns: .so.${PV} (ELF) || .${PV}.dylib (MACH) || ...
527get_libname() { 529get_libname() {
528 local libname 530 local libname
529 local ver=$1 531 local ver=$1
530 case ${CHOST} in 532 case ${CHOST} in
531 *-cygwin|mingw*|*-mingw*) libname="dll";; 533 *-cygwin|mingw*|*-mingw*) libname="dll";;
532 *-darwin*) libname="dylib";; 534 *-darwin*) libname="dylib";;
535 *-mint*) libname="irrelevant";;
536 hppa*-hpux*) libname="sl";;
533 *) libname="so";; 537 *) libname="so";;
534 esac 538 esac
535 539
536 if [[ -z $* ]] ; then 540 if [[ -z $* ]] ; then
537 echo ".${libname}" 541 echo ".${libname}"
538 else 542 else
539 for ver in "$@" ; do 543 for ver in "$@" ; do
540 case ${CHOST} in 544 case ${CHOST} in
541 *-darwin*) echo ".${ver}.${libname}";; 545 *-darwin*) echo ".${ver}.${libname}";;
546 *-mint*) echo ".${libname}";;
542 *) echo ".${libname}.${ver}";; 547 *) echo ".${libname}.${ver}";;
543 esac 548 esac
544 done 549 done
545 fi 550 fi
551}
552
553# @FUNCTION: get_modname
554# @USAGE:
555# @DESCRIPTION:
556# Returns modulename with proper suffix {.so,.bundle,etc} for the current
557# platform identified by CHOST.
558#
559# Example:
560# libfoo$(get_modname)
561# Returns: libfoo.so (ELF) || libfoo.bundle (MACH) || ...
562get_modname() {
563 local modname
564 local ver=$1
565 case ${CHOST} in
566 *-darwin*) modname="bundle";;
567 *) modname="so";;
568 esac
569
570 echo ".${modname}"
546} 571}
547 572
548# This is for the toolchain to setup profile variables when pulling in 573# This is for the toolchain to setup profile variables when pulling in
549# a crosscompiler (and thus they aren't set in the profile) 574# a crosscompiler (and thus they aren't set in the profile)
550multilib_env() { 575multilib_env() {
554 x86_64*) 579 x86_64*)
555 export CFLAGS_x86=${CFLAGS_x86--m32} 580 export CFLAGS_x86=${CFLAGS_x86--m32}
556 export CHOST_x86=${CTARGET/x86_64/i686} 581 export CHOST_x86=${CTARGET/x86_64/i686}
557 export CTARGET_x86=${CHOST_x86} 582 export CTARGET_x86=${CHOST_x86}
558 export CDEFINE_x86="__i386__" 583 export CDEFINE_x86="__i386__"
559 export LIBDIR_x86="lib" 584 export LIBDIR_x86="lib32"
560 585
561 export CFLAGS_amd64=${CFLAGS_amd64--m64} 586 export CFLAGS_amd64=${CFLAGS_amd64--m64}
562 export CHOST_amd64=${CTARGET} 587 export CHOST_amd64=${CTARGET}
563 export CTARGET_amd64=${CHOST_amd64} 588 export CTARGET_amd64=${CHOST_amd64}
564 export CDEFINE_amd64="__x86_64__" 589 export CDEFINE_amd64="__x86_64__"
565 export LIBDIR_amd64="lib64" 590 export LIBDIR_amd64="lib64"
566 591
592 export CFLAGS_x32=${CFLAGS_x32--mx32}
593 export CHOST_x32=${CTARGET}
594 export CTARGET_x32=${CHOST_x32}
595 export CDEFINE_x32="__i386__"
596 export LIBDIR_x32="libx32"
597
567 export MULTILIB_ABIS="amd64 x86" 598 : ${MULTILIB_ABIS=amd64 x86}
568 export DEFAULT_ABI="amd64" 599 : ${DEFAULT_ABI=amd64}
569 ;; 600 ;;
570 mips64*) 601 mips64*)
571 export CFLAGS_o32=${CFLAGS_o32--mabi=32} 602 export CFLAGS_o32=${CFLAGS_o32--mabi=32}
572 export CHOST_o32=${CTARGET/mips64/mips} 603 export CHOST_o32=${CTARGET/mips64/mips}
573 export CTARGET_o32=${CHOST_o32} 604 export CTARGET_o32=${CHOST_o32}
584 export CHOST_n64=${CTARGET} 615 export CHOST_n64=${CTARGET}
585 export CTARGET_n64=${CHOST_n64} 616 export CTARGET_n64=${CHOST_n64}
586 export CDEFINE_n64="_MIPS_SIM == _ABI64" 617 export CDEFINE_n64="_MIPS_SIM == _ABI64"
587 export LIBDIR_n64="lib64" 618 export LIBDIR_n64="lib64"
588 619
589 export MULTILIB_ABIS="n64 n32 o32" 620 : ${MULTILIB_ABIS=n64 n32 o32}
590 export DEFAULT_ABI="n32" 621 : ${DEFAULT_ABI=n32}
591 ;; 622 ;;
592 powerpc64*) 623 powerpc64*)
593 export CFLAGS_ppc=${CFLAGS_ppc--m32} 624 export CFLAGS_ppc=${CFLAGS_ppc--m32}
594 export CHOST_ppc=${CTARGET/powerpc64/powerpc} 625 export CHOST_ppc=${CTARGET/powerpc64/powerpc}
595 export CTARGET_ppc=${CHOST_ppc} 626 export CTARGET_ppc=${CHOST_ppc}
600 export CHOST_ppc64=${CTARGET} 631 export CHOST_ppc64=${CTARGET}
601 export CTARGET_ppc64=${CHOST_ppc64} 632 export CTARGET_ppc64=${CHOST_ppc64}
602 export CDEFINE_ppc64="__powerpc64__" 633 export CDEFINE_ppc64="__powerpc64__"
603 export LIBDIR_ppc64="lib64" 634 export LIBDIR_ppc64="lib64"
604 635
605 export MULTILIB_ABIS="ppc64 ppc" 636 : ${MULTILIB_ABIS=ppc64 ppc}
606 export DEFAULT_ABI="ppc64" 637 : ${DEFAULT_ABI=ppc64}
607 ;; 638 ;;
608 s390x*) 639 s390x*)
609 export CFLAGS_s390=${CFLAGS_s390--m31} # the 31 is not a typo 640 export CFLAGS_s390=${CFLAGS_s390--m31} # the 31 is not a typo
610 export CHOST_s390=${CTARGET/s390x/s390} 641 export CHOST_s390=${CTARGET/s390x/s390}
611 export CTARGET_s390=${CHOST_s390} 642 export CTARGET_s390=${CHOST_s390}
616 export CHOST_s390x=${CTARGET} 647 export CHOST_s390x=${CTARGET}
617 export CTARGET_s390x=${CHOST_s390x} 648 export CTARGET_s390x=${CHOST_s390x}
618 export CDEFINE_s390x="__s390x__" 649 export CDEFINE_s390x="__s390x__"
619 export LIBDIR_s390x="lib64" 650 export LIBDIR_s390x="lib64"
620 651
621 export MULTILIB_ABIS="s390x s390" 652 : ${MULTILIB_ABIS=s390x s390}
622 export DEFAULT_ABI="s390x" 653 : ${DEFAULT_ABI=s390x}
623 ;; 654 ;;
624 sparc*) 655 sparc*)
625 export CFLAGS_sparc32=${CFLAGS_sparc32} 656 export CFLAGS_sparc32=${CFLAGS_sparc32}
626 export CHOST_sparc32=${CTARGET/sparc64/sparc} 657 export CHOST_sparc32=${CTARGET/sparc64/sparc}
627 export CTARGET_sparc32=${CHOST_sparc32} 658 export CTARGET_sparc32=${CHOST_sparc32}
632 export CHOST_sparc64=${CTARGET} 663 export CHOST_sparc64=${CTARGET}
633 export CTARGET_sparc64=${CHOST_sparc64} 664 export CTARGET_sparc64=${CHOST_sparc64}
634 export CDEFINE_sparc64="__arch64__" 665 export CDEFINE_sparc64="__arch64__"
635 export LIBDIR_sparc64="lib64" 666 export LIBDIR_sparc64="lib64"
636 667
637 export MULTILIB_ABIS="${MULTILIB_ABIS-sparc64 sparc32}" 668 : ${MULTILIB_ABIS=sparc64 sparc32}
638 export DEFAULT_ABI="${DEFAULT_ABI-sparc64}" 669 : ${DEFAULT_ABI=sparc64}
639 ;; 670 ;;
640 *) 671 *)
641 export MULTILIB_ABIS="default" 672 : ${MULTILIB_ABIS=default}
642 export DEFAULT_ABI="default" 673 : ${DEFAULT_ABI=default}
643 ;; 674 ;;
644 esac 675 esac
676
677 export MULTILIB_ABIS MULTILIB_ABI
645} 678}
646 679
647# @FUNCTION: multilib_toolchain_setup 680# @FUNCTION: multilib_toolchain_setup
648# @DESCRIPTION: 681# @DESCRIPTION:
649# Hide multilib details here for packages which are forced to be compiled for a 682# Hide multilib details here for packages which are forced to be compiled for a
651multilib_toolchain_setup() { 684multilib_toolchain_setup() {
652 local v vv 685 local v vv
653 686
654 export ABI=$1 687 export ABI=$1
655 688
689 # First restore any saved state we have laying around.
690 if [[ ${__DEFAULT_ABI_SAVED} == "true" ]] ; then
691 for v in CHOST CBUILD AS CC CXX LD ; do
692 vv="__abi_saved_${v}"
693 export ${v}="${!vv}"
694 unset ${vv}
695 done
696 unset __DEFAULT_ABI_SAVED
697 fi
698
656 # We want to avoid the behind-the-back magic of gcc-config as it 699 # We want to avoid the behind-the-back magic of gcc-config as it
657 # screws up ccache and distcc. See #196243 for more info. 700 # screws up ccache and distcc. See #196243 for more info.
658 if [[ ${ABI} != ${DEFAULT_ABI} ]] ; then 701 if [[ ${ABI} != ${DEFAULT_ABI} ]] ; then
659 if [[ ${DEFAULT_ABI_SAVED} != "true" ]] ; then 702 # Back that multilib-ass up so we can restore it later
660 for v in CHOST CBUILD AS CC CXX LD ; do 703 for v in CHOST CBUILD AS CC CXX LD ; do
661 export __abi_saved_${v}="${!v}" 704 export __abi_saved_${v}="${!v}"
662 done 705 done
663 export DEFAULT_ABI_SAVED="true" 706 export __DEFAULT_ABI_SAVED="true"
664 fi
665 707
666 # Set the CHOST native first so that we pick up the native 708 # Set the CHOST native first so that we pick up the native
667 # toolchain and not a cross-compiler by accident #202811. 709 # toolchain and not a cross-compiler by accident #202811.
668 export CHOST=$(get_abi_CHOST ${DEFAULT_ABI}) 710 export CHOST=$(get_abi_CHOST ${DEFAULT_ABI})
669 export AS="$(tc-getAS) $(get_abi_ASFLAGS)" 711 export AS="$(tc-getAS) $(get_abi_ASFLAGS)"
670 export CC="$(tc-getCC) $(get_abi_CFLAGS)" 712 export CC="$(tc-getCC) $(get_abi_CFLAGS)"
671 export CXX="$(tc-getCXX) $(get_abi_CFLAGS)" 713 export CXX="$(tc-getCXX) $(get_abi_CFLAGS)"
672 export LD="$(tc-getLD) $(get_abi_LDFLAGS)" 714 export LD="$(tc-getLD) $(get_abi_LDFLAGS)"
673 export CHOST=$(get_abi_CHOST $1) 715 export CHOST=$(get_abi_CHOST $1)
674 export CBUILD=$(get_abi_CHOST $1) 716 export CBUILD=$(get_abi_CHOST $1)
675
676 elif [[ ${DEFAULT_ABI_SAVED} == "true" ]] ; then
677 for v in CHOST CBUILD AS CC CXX LD ; do
678 vv="__abi_saved_${v}"
679 export ${v}=${!vv}
680 done
681 fi 717 fi
682} 718}

Legend:
Removed from v.1.72  
changed lines
  Added in v.1.82

  ViewVC Help
Powered by ViewVC 1.1.20