| 1 | # Copyright 1999-2011 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/toolchain-funcs.eclass,v 1.112 2012/06/14 03:38:51 vapier Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/toolchain-funcs.eclass,v 1.116 2012/09/13 05:06:34 vapier Exp $ |
| 4 | |
4 | |
| 5 | # @ECLASS: toolchain-funcs.eclass |
5 | # @ECLASS: toolchain-funcs.eclass |
| 6 | # @MAINTAINER: |
6 | # @MAINTAINER: |
| 7 | # Toolchain Ninjas <toolchain@gentoo.org> |
7 | # Toolchain Ninjas <toolchain@gentoo.org> |
| 8 | # @BLURB: functions to query common info about the toolchain |
8 | # @BLURB: functions to query common info about the toolchain |
| … | |
… | |
| 358 | local type=$1 |
358 | local type=$1 |
| 359 | local host=$2 |
359 | local host=$2 |
| 360 | [[ -z ${host} ]] && host=${CTARGET:-${CHOST}} |
360 | [[ -z ${host} ]] && host=${CTARGET:-${CHOST}} |
| 361 | |
361 | |
| 362 | case ${host} in |
362 | case ${host} in |
|
|
363 | aarch64*) ninj aarch64 arm;; |
| 363 | alpha*) echo alpha;; |
364 | alpha*) echo alpha;; |
| 364 | arm*) echo arm;; |
365 | arm*) echo arm;; |
| 365 | avr*) ninj avr32 avr;; |
366 | avr*) ninj avr32 avr;; |
| 366 | bfin*) ninj blackfin bfin;; |
367 | bfin*) ninj blackfin bfin;; |
| 367 | cris*) echo cris;; |
368 | cris*) echo cris;; |
| … | |
… | |
| 444 | local host=$1 |
445 | local host=$1 |
| 445 | [[ -z ${host} ]] && host=${CTARGET:-${CHOST}} |
446 | [[ -z ${host} ]] && host=${CTARGET:-${CHOST}} |
| 446 | host=${host%%-*} |
447 | host=${host%%-*} |
| 447 | |
448 | |
| 448 | case ${host} in |
449 | case ${host} in |
|
|
450 | aarch64*be) echo big;; |
|
|
451 | aarch64) echo little;; |
| 449 | alpha*) echo big;; |
452 | alpha*) echo big;; |
| 450 | arm*b*) echo big;; |
453 | arm*b*) echo big;; |
| 451 | arm*) echo little;; |
454 | arm*) echo little;; |
| 452 | cris*) echo little;; |
455 | cris*) echo little;; |
| 453 | hppa*) echo big;; |
456 | hppa*) echo big;; |
| … | |
… | |
| 610 | local lib libdir=$(get_libdir) output_format="" auto=false suffix=$(get_libname) |
613 | local lib libdir=$(get_libdir) output_format="" auto=false suffix=$(get_libname) |
| 611 | [[ -z ${ED+set} ]] && local ED=${D%/}${EPREFIX}/ |
614 | [[ -z ${ED+set} ]] && local ED=${D%/}${EPREFIX}/ |
| 612 | |
615 | |
| 613 | tc-is-static-only && return |
616 | tc-is-static-only && return |
| 614 | |
617 | |
|
|
618 | # Eventually we'd like to get rid of this func completely #417451 |
|
|
619 | case ${CTARGET:-${CHOST}} in |
|
|
620 | *-darwin*) ;; |
|
|
621 | *linux*|*-freebsd*|*-openbsd*|*-netbsd*) |
|
|
622 | use prefix && return 0 ;; |
|
|
623 | *) return 0 ;; |
|
|
624 | esac |
|
|
625 | |
| 615 | # Just make sure it exists |
626 | # Just make sure it exists |
| 616 | dodir /usr/${libdir} |
627 | dodir /usr/${libdir} |
| 617 | |
628 | |
| 618 | if [[ $1 == "-a" ]] ; then |
629 | if [[ $1 == "-a" ]] ; then |
| 619 | auto=true |
630 | auto=true |
| … | |
… | |
| 676 | # understand linker scripts, just create a symlink. |
687 | # understand linker scripts, just create a symlink. |
| 677 | pushd "${ED}/usr/${libdir}" > /dev/null |
688 | pushd "${ED}/usr/${libdir}" > /dev/null |
| 678 | ln -snf "../../${libdir}/${tlib}" "${lib}" |
689 | ln -snf "../../${libdir}/${tlib}" "${lib}" |
| 679 | popd > /dev/null |
690 | popd > /dev/null |
| 680 | ;; |
691 | ;; |
| 681 | *-aix*|*-irix*|*64*-hpux*|*-interix*|*-winnt*) |
|
|
| 682 | if ${auto} ; then |
|
|
| 683 | mv "${ED}"/usr/${libdir}/${lib}* "${ED}"/${libdir}/ || die |
|
|
| 684 | # no way to retrieve soname on these platforms (?) |
|
|
| 685 | tlib=$(readlink "${ED}"/${libdir}/${lib}) |
|
|
| 686 | tlib=${tlib##*/} |
|
|
| 687 | if [[ -z ${tlib} ]] ; then |
|
|
| 688 | # ok, apparently was not a symlink, don't remove it and |
|
|
| 689 | # just link to it |
|
|
| 690 | tlib=${lib} |
|
|
| 691 | else |
|
|
| 692 | rm -f "${ED}"/${libdir}/${lib} |
|
|
| 693 | fi |
|
|
| 694 | else |
|
|
| 695 | tlib=${lib} |
|
|
| 696 | fi |
|
|
| 697 | |
|
|
| 698 | # we don't have GNU binutils on these platforms, so we symlink |
|
|
| 699 | # instead, which seems to work fine. Keep it relative, otherwise |
|
|
| 700 | # we break some QA checks in Portage |
|
|
| 701 | # on interix, the linker scripts would work fine in _most_ |
|
|
| 702 | # situations. if a library links to such a linker script the |
|
|
| 703 | # absolute path to the correct library is inserted into the binary, |
|
|
| 704 | # which is wrong, since anybody linking _without_ libtool will miss |
|
|
| 705 | # some dependencies, since the stupid linker cannot find libraries |
|
|
| 706 | # hardcoded with absolute paths (as opposed to the loader, which |
|
|
| 707 | # seems to be able to do this). |
|
|
| 708 | # this has been seen while building shared-mime-info which needs |
|
|
| 709 | # libxml2, but links without libtool (and does not add libz to the |
|
|
| 710 | # command line by itself). |
|
|
| 711 | pushd "${ED}/usr/${libdir}" > /dev/null |
|
|
| 712 | ln -snf "../../${libdir}/${tlib}" "${lib}" |
|
|
| 713 | popd > /dev/null |
|
|
| 714 | ;; |
|
|
| 715 | hppa*-hpux*) # PA-RISC 32bit (SOM) only, others (ELF) match *64*-hpux* above. |
|
|
| 716 | if ${auto} ; then |
|
|
| 717 | tlib=$(chatr "${ED}"/usr/${libdir}/${lib} | sed -n '/internal name:/{n;s/^ *//;p;q}') |
|
|
| 718 | [[ -z ${tlib} ]] && tlib=${lib} |
|
|
| 719 | tlib=${tlib##*/} # 'internal name' can have a path component |
|
|
| 720 | mv "${ED}"/usr/${libdir}/${lib}* "${ED}"/${libdir}/ || die |
|
|
| 721 | # some SONAMEs are funky: they encode a version before the .so |
|
|
| 722 | if [[ ${tlib} != ${lib}* ]] ; then |
|
|
| 723 | mv "${ED}"/usr/${libdir}/${tlib}* "${ED}"/${libdir}/ || die |
|
|
| 724 | fi |
|
|
| 725 | [[ ${tlib} != ${lib} ]] && |
|
|
| 726 | rm -f "${ED}"/${libdir}/${lib} |
|
|
| 727 | else |
|
|
| 728 | tlib=$(chatr "${ED}"/${libdir}/${lib} | sed -n '/internal name:/{n;s/^ *//;p;q}') |
|
|
| 729 | [[ -z ${tlib} ]] && tlib=${lib} |
|
|
| 730 | tlib=${tlib##*/} # 'internal name' can have a path component |
|
|
| 731 | fi |
|
|
| 732 | pushd "${ED}"/usr/${libdir} >/dev/null |
|
|
| 733 | ln -snf "../../${libdir}/${tlib}" "${lib}" |
|
|
| 734 | # need the internal name in usr/lib too, to be available at runtime |
|
|
| 735 | # when linked with /path/to/lib.sl (hardcode_direct_absolute=yes) |
|
|
| 736 | [[ ${tlib} != ${lib} ]] && |
|
|
| 737 | ln -snf "../../${libdir}/${tlib}" "${tlib}" |
|
|
| 738 | popd >/dev/null |
|
|
| 739 | ;; |
|
|
| 740 | *) |
692 | *) |
| 741 | if ${auto} ; then |
693 | if ${auto} ; then |
| 742 | tlib=$(scanelf -qF'%S#F' "${ED}"/usr/${libdir}/${lib}) |
694 | tlib=$(scanelf -qF'%S#F' "${ED}"/usr/${libdir}/${lib}) |
| 743 | [[ -z ${tlib} ]] && die "unable to read SONAME from ${lib}" |
695 | [[ -z ${tlib} ]] && die "unable to read SONAME from ${lib}" |
| 744 | mv "${ED}"/usr/${libdir}/${lib}* "${ED}"/${libdir}/ || die |
696 | mv "${ED}"/usr/${libdir}/${lib}* "${ED}"/${libdir}/ || die |