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

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

  ViewVC Help
Powered by ViewVC 1.1.20