/[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.108 Revision 1.118
1# Copyright 1999-2011 Gentoo Foundation 1# Copyright 1999-2012 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.108 2011/10/17 19:11:49 vapier Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/toolchain-funcs.eclass,v 1.118 2012/09/27 19:34:28 axs 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
11# for gleaning useful information about the toolchain and to simplify 11# for gleaning useful information about the toolchain and to simplify
12# ugly things like cross-compiling and multilib. All of this is done 12# ugly things like cross-compiling and multilib. All of this is done
13# in such a way that you can rely on the function always returning 13# in such a way that you can rely on the function always returning
14# something sane. 14# something sane.
15 15
16___ECLASS_RECUR_TOOLCHAIN_FUNCS="yes" 16if [[ ${___ECLASS_ONCE_TOOLCHAIN_FUNCS} != "recur -_+^+_- spank" ]] ; then
17[[ -z ${___ECLASS_RECUR_MULTILIB} ]] && inherit multilib 17___ECLASS_ONCE_TOOLCHAIN_FUNCS="recur -_+^+_- spank"
18 18
19DESCRIPTION="Based on the ${ECLASS} eclass" 19inherit multilib
20 20
21# tc-getPROG <VAR [search vars]> <default> [tuple] 21# tc-getPROG <VAR [search vars]> <default> [tuple]
22_tc-getPROG() { 22_tc-getPROG() {
23 local tuple=$1 23 local tuple=$1
24 local v var vars=$2 24 local v var vars=$2
175# @FUNCTION: tc-is-softfloat 175# @FUNCTION: tc-is-softfloat
176# @DESCRIPTION: 176# @DESCRIPTION:
177# See if this toolchain is a softfloat based one. 177# See if this toolchain is a softfloat based one.
178# @CODE 178# @CODE
179# The possible return values: 179# The possible return values:
180# - only: the target is always softfloat (never had fpu) 180# - only: the target is always softfloat (never had fpu)
181# - yes: the target should support softfloat 181# - yes: the target should support softfloat
182# - softfp: (arm specific) the target should use hardfloat insns, but softfloat calling convention
182# - no: the target doesn't support softfloat 183# - no: the target doesn't support softfloat
183# @CODE 184# @CODE
184# This allows us to react differently where packages accept 185# This allows us to react differently where packages accept
185# softfloat flags in the case where support is optional, but 186# softfloat flags in the case where support is optional, but
186# rejects softfloat flags where the target always lacks an fpu. 187# rejects softfloat flags where the target always lacks an fpu.
187tc-is-softfloat() { 188tc-is-softfloat() {
189 local CTARGET=${CTARGET:-${CHOST}}
188 case ${CTARGET} in 190 case ${CTARGET} in
189 bfin*|h8300*) 191 bfin*|h8300*)
190 echo "only" ;; 192 echo "only" ;;
191 *) 193 *)
192 [[ ${CTARGET//_/-} == *-softfloat-* ]] \ 194 if [[ ${CTARGET//_/-} == *-softfloat-* ]] ; then
193 && echo "yes" \ 195 echo "yes"
196 elif [[ ${CTARGET//_/-} == *-softfp-* ]] ; then
197 echo "softfp"
198 else
194 || echo "no" 199 echo "no"
200 fi
195 ;; 201 ;;
196 esac 202 esac
197}
198
199# @FUNCTION: tc-is-hardfloat
200# @DESCRIPTION:
201# See if this toolchain is a hardfloat based one.
202# @CODE
203# The possible return values:
204# - yes: the target should support hardfloat
205# - no: the target doesn't support hardfloat
206tc-is-hardfloat() {
207 [[ ${CTARGET//_/-} == *-hardfloat-* ]] \
208 && echo "yes" \
209 || echo "no"
210} 203}
211 204
212# @FUNCTION: tc-is-static-only 205# @FUNCTION: tc-is-static-only
213# @DESCRIPTION: 206# @DESCRIPTION:
214# Return shell true if the target does not support shared libs, shell false 207# Return shell true if the target does not support shared libs, shell false
216tc-is-static-only() { 209tc-is-static-only() {
217 local host=${CTARGET:-${CHOST}} 210 local host=${CTARGET:-${CHOST}}
218 211
219 # *MiNT doesn't have shared libraries, only platform so far 212 # *MiNT doesn't have shared libraries, only platform so far
220 return $([[ ${host} == *-mint* ]]) 213 return $([[ ${host} == *-mint* ]])
214}
215
216# @FUNCTION: tc-export_build_env
217# @USAGE: [compiler variables]
218# @DESCRIPTION:
219# Export common build related compiler settings.
220tc-export_build_env() {
221 tc-export "$@"
222 : ${BUILD_CFLAGS:=-O1 -pipe}
223 : ${BUILD_CXXFLAGS:=-O1 -pipe}
224 : ${BUILD_CPPFLAGS:=}
225 : ${BUILD_LDFLAGS:=}
226 export BUILD_{C,CXX,CPP,LD}FLAGS
221} 227}
222 228
223# @FUNCTION: tc-env_build 229# @FUNCTION: tc-env_build
224# @USAGE: <command> [command args] 230# @USAGE: <command> [command args]
225# @INTERNAL 231# @INTERNAL
227# Setup the compile environment to the build tools and then execute the 233# Setup the compile environment to the build tools and then execute the
228# specified command. We use tc-getBUILD_XX here so that we work with 234# specified command. We use tc-getBUILD_XX here so that we work with
229# all of the semi-[non-]standard env vars like $BUILD_CC which often 235# all of the semi-[non-]standard env vars like $BUILD_CC which often
230# the target build system does not check. 236# the target build system does not check.
231tc-env_build() { 237tc-env_build() {
238 tc-export_build_env
232 CFLAGS=${BUILD_CFLAGS:--O1 -pipe} \ 239 CFLAGS=${BUILD_CFLAGS} \
233 CXXFLAGS=${BUILD_CXXFLAGS:--O1 -pipe} \ 240 CXXFLAGS=${BUILD_CXXFLAGS} \
234 CPPFLAGS=${BUILD_CPPFLAGS} \ 241 CPPFLAGS=${BUILD_CPPFLAGS} \
235 LDFLAGS=${BUILD_LDFLAGS} \ 242 LDFLAGS=${BUILD_LDFLAGS} \
236 AR=$(tc-getBUILD_AR) \ 243 AR=$(tc-getBUILD_AR) \
237 AS=$(tc-getBUILD_AS) \ 244 AS=$(tc-getBUILD_AS) \
238 CC=$(tc-getBUILD_CC) \ 245 CC=$(tc-getBUILD_CC) \
348 355
349 local type=$1 356 local type=$1
350 local host=$2 357 local host=$2
351 [[ -z ${host} ]] && host=${CTARGET:-${CHOST}} 358 [[ -z ${host} ]] && host=${CTARGET:-${CHOST}}
352 359
360 local KV=${KV:-${KV_FULL}}
361 [[ -z ${KV} ]] && die "toolchain-funcs.eclass: Kernel version could not be determined, please inherit kernel-2 or linux-info"
362
353 case ${host} in 363 case ${host} in
364 aarch64*) ninj aarch64 arm;;
354 alpha*) echo alpha;; 365 alpha*) echo alpha;;
355 arm*) echo arm;; 366 arm*) echo arm;;
356 avr*) ninj avr32 avr;; 367 avr*) ninj avr32 avr;;
357 bfin*) ninj blackfin bfin;; 368 bfin*) ninj blackfin bfin;;
358 cris*) echo cris;; 369 cris*) echo cris;;
435 local host=$1 446 local host=$1
436 [[ -z ${host} ]] && host=${CTARGET:-${CHOST}} 447 [[ -z ${host} ]] && host=${CTARGET:-${CHOST}}
437 host=${host%%-*} 448 host=${host%%-*}
438 449
439 case ${host} in 450 case ${host} in
451 aarch64*be) echo big;;
452 aarch64) echo little;;
440 alpha*) echo big;; 453 alpha*) echo big;;
441 arm*b*) echo big;; 454 arm*b*) echo big;;
442 arm*) echo little;; 455 arm*) echo little;;
443 cris*) echo little;; 456 cris*) echo little;;
444 hppa*) echo big;; 457 hppa*) echo big;;
601 local lib libdir=$(get_libdir) output_format="" auto=false suffix=$(get_libname) 614 local lib libdir=$(get_libdir) output_format="" auto=false suffix=$(get_libname)
602 [[ -z ${ED+set} ]] && local ED=${D%/}${EPREFIX}/ 615 [[ -z ${ED+set} ]] && local ED=${D%/}${EPREFIX}/
603 616
604 tc-is-static-only && return 617 tc-is-static-only && return
605 618
619 # Eventually we'd like to get rid of this func completely #417451
620 case ${CTARGET:-${CHOST}} in
621 *-darwin*) ;;
622 *linux*|*-freebsd*|*-openbsd*|*-netbsd*)
623 use prefix && return 0 ;;
624 *) return 0 ;;
625 esac
626
606 # Just make sure it exists 627 # Just make sure it exists
607 dodir /usr/${libdir} 628 dodir /usr/${libdir}
608 629
609 if [[ $1 == "-a" ]] ; then 630 if [[ $1 == "-a" ]] ; then
610 auto=true 631 auto=true
667 # understand linker scripts, just create a symlink. 688 # understand linker scripts, just create a symlink.
668 pushd "${ED}/usr/${libdir}" > /dev/null 689 pushd "${ED}/usr/${libdir}" > /dev/null
669 ln -snf "../../${libdir}/${tlib}" "${lib}" 690 ln -snf "../../${libdir}/${tlib}" "${lib}"
670 popd > /dev/null 691 popd > /dev/null
671 ;; 692 ;;
672 *-aix*|*-irix*|*64*-hpux*|*-interix*|*-winnt*)
673 if ${auto} ; then
674 mv "${ED}"/usr/${libdir}/${lib}* "${ED}"/${libdir}/ || die
675 # no way to retrieve soname on these platforms (?)
676 tlib=$(readlink "${ED}"/${libdir}/${lib})
677 tlib=${tlib##*/}
678 if [[ -z ${tlib} ]] ; then
679 # ok, apparently was not a symlink, don't remove it and
680 # just link to it
681 tlib=${lib}
682 else
683 rm -f "${ED}"/${libdir}/${lib}
684 fi
685 else
686 tlib=${lib}
687 fi
688
689 # we don't have GNU binutils on these platforms, so we symlink
690 # instead, which seems to work fine. Keep it relative, otherwise
691 # we break some QA checks in Portage
692 # on interix, the linker scripts would work fine in _most_
693 # situations. if a library links to such a linker script the
694 # absolute path to the correct library is inserted into the binary,
695 # which is wrong, since anybody linking _without_ libtool will miss
696 # some dependencies, since the stupid linker cannot find libraries
697 # hardcoded with absolute paths (as opposed to the loader, which
698 # seems to be able to do this).
699 # this has been seen while building shared-mime-info which needs
700 # libxml2, but links without libtool (and does not add libz to the
701 # command line by itself).
702 pushd "${ED}/usr/${libdir}" > /dev/null
703 ln -snf "../../${libdir}/${tlib}" "${lib}"
704 popd > /dev/null
705 ;;
706 hppa*-hpux*) # PA-RISC 32bit (SOM) only, others (ELF) match *64*-hpux* above.
707 if ${auto} ; then
708 tlib=$(chatr "${ED}"/usr/${libdir}/${lib} | sed -n '/internal name:/{n;s/^ *//;p;q}')
709 [[ -z ${tlib} ]] && tlib=${lib}
710 tlib=${tlib##*/} # 'internal name' can have a path component
711 mv "${ED}"/usr/${libdir}/${lib}* "${ED}"/${libdir}/ || die
712 # some SONAMEs are funky: they encode a version before the .so
713 if [[ ${tlib} != ${lib}* ]] ; then
714 mv "${ED}"/usr/${libdir}/${tlib}* "${ED}"/${libdir}/ || die
715 fi
716 [[ ${tlib} != ${lib} ]] &&
717 rm -f "${ED}"/${libdir}/${lib}
718 else
719 tlib=$(chatr "${ED}"/${libdir}/${lib} | sed -n '/internal name:/{n;s/^ *//;p;q}')
720 [[ -z ${tlib} ]] && tlib=${lib}
721 tlib=${tlib##*/} # 'internal name' can have a path component
722 fi
723 pushd "${ED}"/usr/${libdir} >/dev/null
724 ln -snf "../../${libdir}/${tlib}" "${lib}"
725 # need the internal name in usr/lib too, to be available at runtime
726 # when linked with /path/to/lib.sl (hardcode_direct_absolute=yes)
727 [[ ${tlib} != ${lib} ]] &&
728 ln -snf "../../${libdir}/${tlib}" "${tlib}"
729 popd >/dev/null
730 ;;
731 *) 693 *)
732 if ${auto} ; then 694 if ${auto} ; then
733 tlib=$(scanelf -qF'%S#F' "${ED}"/usr/${libdir}/${lib}) 695 tlib=$(scanelf -qF'%S#F' "${ED}"/usr/${libdir}/${lib})
734 [[ -z ${tlib} ]] && die "unable to read SONAME from ${lib}" 696 [[ -z ${tlib} ]] && die "unable to read SONAME from ${lib}"
735 mv "${ED}"/usr/${libdir}/${lib}* "${ED}"/${libdir}/ || die 697 mv "${ED}"/usr/${libdir}/${lib}* "${ED}"/${libdir}/ || die
757 ;; 719 ;;
758 esac 720 esac
759 fperms a+x "/usr/${libdir}/${lib}" || die "could not change perms on ${lib}" 721 fperms a+x "/usr/${libdir}/${lib}" || die "could not change perms on ${lib}"
760 done 722 done
761} 723}
724
725fi

Legend:
Removed from v.1.108  
changed lines
  Added in v.1.118

  ViewVC Help
Powered by ViewVC 1.1.20