/[gentoo-x86]/eclass/toolchain-funcs.eclass
Gentoo

Diff of /eclass/toolchain-funcs.eclass

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

Revision 1.110 Revision 1.116
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.110 2012/05/10 03:31:22 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
177# @FUNCTION: tc-is-softfloat 177# @FUNCTION: tc-is-softfloat
178# @DESCRIPTION: 178# @DESCRIPTION:
179# See if this toolchain is a softfloat based one. 179# See if this toolchain is a softfloat based one.
180# @CODE 180# @CODE
181# The possible return values: 181# The possible return values:
182# - only: the target is always softfloat (never had fpu) 182# - only: the target is always softfloat (never had fpu)
183# - yes: the target should support softfloat 183# - yes: the target should support softfloat
184# - softfp: (arm specific) the target should use hardfloat insns, but softfloat calling convention
184# - no: the target doesn't support softfloat 185# - no: the target doesn't support softfloat
185# @CODE 186# @CODE
186# This allows us to react differently where packages accept 187# This allows us to react differently where packages accept
187# softfloat flags in the case where support is optional, but 188# softfloat flags in the case where support is optional, but
188# rejects softfloat flags where the target always lacks an fpu. 189# rejects softfloat flags where the target always lacks an fpu.
189tc-is-softfloat() { 190tc-is-softfloat() {
190 local CTARGET=${CTARGET:-${CHOST}} 191 local CTARGET=${CTARGET:-${CHOST}}
191 case ${CTARGET} in 192 case ${CTARGET} in
192 bfin*|h8300*) 193 bfin*|h8300*)
193 echo "only" ;; 194 echo "only" ;;
194 *) 195 *)
195 [[ ${CTARGET//_/-} == *-softfloat-* ]] \ 196 if [[ ${CTARGET//_/-} == *-softfloat-* ]] ; then
196 && echo "yes" \ 197 echo "yes"
198 elif [[ ${CTARGET//_/-} == *-softfp-* ]] ; then
199 echo "softfp"
200 else
197 || echo "no" 201 echo "no"
202 fi
198 ;; 203 ;;
199 esac 204 esac
200}
201
202# @FUNCTION: tc-is-hardfloat
203# @DESCRIPTION:
204# See if this toolchain is a hardfloat based one.
205# @CODE
206# The possible return values:
207# - yes: the target should support hardfloat
208# - no: the target doesn't support hardfloat
209tc-is-hardfloat() {
210 [[ ${CTARGET//_/-} == *-hardfloat-* ]] \
211 && echo "yes" \
212 || echo "no"
213} 205}
214 206
215# @FUNCTION: tc-is-static-only 207# @FUNCTION: tc-is-static-only
216# @DESCRIPTION: 208# @DESCRIPTION:
217# Return shell true if the target does not support shared libs, shell false 209# Return shell true if the target does not support shared libs, shell false
219tc-is-static-only() { 211tc-is-static-only() {
220 local host=${CTARGET:-${CHOST}} 212 local host=${CTARGET:-${CHOST}}
221 213
222 # *MiNT doesn't have shared libraries, only platform so far 214 # *MiNT doesn't have shared libraries, only platform so far
223 return $([[ ${host} == *-mint* ]]) 215 return $([[ ${host} == *-mint* ]])
216}
217
218# @FUNCTION: tc-export_build_env
219# @USAGE: [compiler variables]
220# @DESCRIPTION:
221# Export common build related compiler settings.
222tc-export_build_env() {
223 tc-export "$@"
224 : ${BUILD_CFLAGS:=-O1 -pipe}
225 : ${BUILD_CXXFLAGS:=-O1 -pipe}
226 : ${BUILD_CPPFLAGS:=}
227 : ${BUILD_LDFLAGS:=}
228 export BUILD_{C,CXX,CPP,LD}FLAGS
224} 229}
225 230
226# @FUNCTION: tc-env_build 231# @FUNCTION: tc-env_build
227# @USAGE: <command> [command args] 232# @USAGE: <command> [command args]
228# @INTERNAL 233# @INTERNAL
230# Setup the compile environment to the build tools and then execute the 235# Setup the compile environment to the build tools and then execute the
231# specified command. We use tc-getBUILD_XX here so that we work with 236# specified command. We use tc-getBUILD_XX here so that we work with
232# all of the semi-[non-]standard env vars like $BUILD_CC which often 237# all of the semi-[non-]standard env vars like $BUILD_CC which often
233# the target build system does not check. 238# the target build system does not check.
234tc-env_build() { 239tc-env_build() {
240 tc-export_build_env
235 CFLAGS=${BUILD_CFLAGS:--O1 -pipe} \ 241 CFLAGS=${BUILD_CFLAGS} \
236 CXXFLAGS=${BUILD_CXXFLAGS:--O1 -pipe} \ 242 CXXFLAGS=${BUILD_CXXFLAGS} \
237 CPPFLAGS=${BUILD_CPPFLAGS} \ 243 CPPFLAGS=${BUILD_CPPFLAGS} \
238 LDFLAGS=${BUILD_LDFLAGS} \ 244 LDFLAGS=${BUILD_LDFLAGS} \
239 AR=$(tc-getBUILD_AR) \ 245 AR=$(tc-getBUILD_AR) \
240 AS=$(tc-getBUILD_AS) \ 246 AS=$(tc-getBUILD_AS) \
241 CC=$(tc-getBUILD_CC) \ 247 CC=$(tc-getBUILD_CC) \
352 local type=$1 358 local type=$1
353 local host=$2 359 local host=$2
354 [[ -z ${host} ]] && host=${CTARGET:-${CHOST}} 360 [[ -z ${host} ]] && host=${CTARGET:-${CHOST}}
355 361
356 case ${host} in 362 case ${host} in
363 aarch64*) ninj aarch64 arm;;
357 alpha*) echo alpha;; 364 alpha*) echo alpha;;
358 arm*) echo arm;; 365 arm*) echo arm;;
359 avr*) ninj avr32 avr;; 366 avr*) ninj avr32 avr;;
360 bfin*) ninj blackfin bfin;; 367 bfin*) ninj blackfin bfin;;
361 cris*) echo cris;; 368 cris*) echo cris;;
438 local host=$1 445 local host=$1
439 [[ -z ${host} ]] && host=${CTARGET:-${CHOST}} 446 [[ -z ${host} ]] && host=${CTARGET:-${CHOST}}
440 host=${host%%-*} 447 host=${host%%-*}
441 448
442 case ${host} in 449 case ${host} in
450 aarch64*be) echo big;;
451 aarch64) echo little;;
443 alpha*) echo big;; 452 alpha*) echo big;;
444 arm*b*) echo big;; 453 arm*b*) echo big;;
445 arm*) echo little;; 454 arm*) echo little;;
446 cris*) echo little;; 455 cris*) echo little;;
447 hppa*) echo big;; 456 hppa*) echo big;;
604 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)
605 [[ -z ${ED+set} ]] && local ED=${D%/}${EPREFIX}/ 614 [[ -z ${ED+set} ]] && local ED=${D%/}${EPREFIX}/
606 615
607 tc-is-static-only && return 616 tc-is-static-only && return
608 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
609 # Just make sure it exists 626 # Just make sure it exists
610 dodir /usr/${libdir} 627 dodir /usr/${libdir}
611 628
612 if [[ $1 == "-a" ]] ; then 629 if [[ $1 == "-a" ]] ; then
613 auto=true 630 auto=true
670 # understand linker scripts, just create a symlink. 687 # understand linker scripts, just create a symlink.
671 pushd "${ED}/usr/${libdir}" > /dev/null 688 pushd "${ED}/usr/${libdir}" > /dev/null
672 ln -snf "../../${libdir}/${tlib}" "${lib}" 689 ln -snf "../../${libdir}/${tlib}" "${lib}"
673 popd > /dev/null 690 popd > /dev/null
674 ;; 691 ;;
675 *-aix*|*-irix*|*64*-hpux*|*-interix*|*-winnt*)
676 if ${auto} ; then
677 mv "${ED}"/usr/${libdir}/${lib}* "${ED}"/${libdir}/ || die
678 # no way to retrieve soname on these platforms (?)
679 tlib=$(readlink "${ED}"/${libdir}/${lib})
680 tlib=${tlib##*/}
681 if [[ -z ${tlib} ]] ; then
682 # ok, apparently was not a symlink, don't remove it and
683 # just link to it
684 tlib=${lib}
685 else
686 rm -f "${ED}"/${libdir}/${lib}
687 fi
688 else
689 tlib=${lib}
690 fi
691
692 # we don't have GNU binutils on these platforms, so we symlink
693 # instead, which seems to work fine. Keep it relative, otherwise
694 # we break some QA checks in Portage
695 # on interix, the linker scripts would work fine in _most_
696 # situations. if a library links to such a linker script the
697 # absolute path to the correct library is inserted into the binary,
698 # which is wrong, since anybody linking _without_ libtool will miss
699 # some dependencies, since the stupid linker cannot find libraries
700 # hardcoded with absolute paths (as opposed to the loader, which
701 # seems to be able to do this).
702 # this has been seen while building shared-mime-info which needs
703 # libxml2, but links without libtool (and does not add libz to the
704 # command line by itself).
705 pushd "${ED}/usr/${libdir}" > /dev/null
706 ln -snf "../../${libdir}/${tlib}" "${lib}"
707 popd > /dev/null
708 ;;
709 hppa*-hpux*) # PA-RISC 32bit (SOM) only, others (ELF) match *64*-hpux* above.
710 if ${auto} ; then
711 tlib=$(chatr "${ED}"/usr/${libdir}/${lib} | sed -n '/internal name:/{n;s/^ *//;p;q}')
712 [[ -z ${tlib} ]] && tlib=${lib}
713 tlib=${tlib##*/} # 'internal name' can have a path component
714 mv "${ED}"/usr/${libdir}/${lib}* "${ED}"/${libdir}/ || die
715 # some SONAMEs are funky: they encode a version before the .so
716 if [[ ${tlib} != ${lib}* ]] ; then
717 mv "${ED}"/usr/${libdir}/${tlib}* "${ED}"/${libdir}/ || die
718 fi
719 [[ ${tlib} != ${lib} ]] &&
720 rm -f "${ED}"/${libdir}/${lib}
721 else
722 tlib=$(chatr "${ED}"/${libdir}/${lib} | sed -n '/internal name:/{n;s/^ *//;p;q}')
723 [[ -z ${tlib} ]] && tlib=${lib}
724 tlib=${tlib##*/} # 'internal name' can have a path component
725 fi
726 pushd "${ED}"/usr/${libdir} >/dev/null
727 ln -snf "../../${libdir}/${tlib}" "${lib}"
728 # need the internal name in usr/lib too, to be available at runtime
729 # when linked with /path/to/lib.sl (hardcode_direct_absolute=yes)
730 [[ ${tlib} != ${lib} ]] &&
731 ln -snf "../../${libdir}/${tlib}" "${tlib}"
732 popd >/dev/null
733 ;;
734 *) 692 *)
735 if ${auto} ; then 693 if ${auto} ; then
736 tlib=$(scanelf -qF'%S#F' "${ED}"/usr/${libdir}/${lib}) 694 tlib=$(scanelf -qF'%S#F' "${ED}"/usr/${libdir}/${lib})
737 [[ -z ${tlib} ]] && die "unable to read SONAME from ${lib}" 695 [[ -z ${tlib} ]] && die "unable to read SONAME from ${lib}"
738 mv "${ED}"/usr/${libdir}/${lib}* "${ED}"/${libdir}/ || die 696 mv "${ED}"/usr/${libdir}/${lib}* "${ED}"/${libdir}/ || die

Legend:
Removed from v.1.110  
changed lines
  Added in v.1.116

  ViewVC Help
Powered by ViewVC 1.1.20