/[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.107 Revision 1.118
1# Copyright 1999-2007 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.107 2011/09/12 21:42:08 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
227}
228
229# @FUNCTION: tc-env_build
230# @USAGE: <command> [command args]
231# @INTERNAL
232# @DESCRIPTION:
233# Setup the compile environment to the build tools and then execute the
234# specified command. We use tc-getBUILD_XX here so that we work with
235# all of the semi-[non-]standard env vars like $BUILD_CC which often
236# the target build system does not check.
237tc-env_build() {
238 tc-export_build_env
239 CFLAGS=${BUILD_CFLAGS} \
240 CXXFLAGS=${BUILD_CXXFLAGS} \
241 CPPFLAGS=${BUILD_CPPFLAGS} \
242 LDFLAGS=${BUILD_LDFLAGS} \
243 AR=$(tc-getBUILD_AR) \
244 AS=$(tc-getBUILD_AS) \
245 CC=$(tc-getBUILD_CC) \
246 CPP=$(tc-getBUILD_CPP) \
247 CXX=$(tc-getBUILD_CXX) \
248 LD=$(tc-getBUILD_LD) \
249 NM=$(tc-getBUILD_NM) \
250 PKG_CONFIG=$(tc-getBUILD_PKG_CONFIG) \
251 RANLIB=$(tc-getBUILD_RANLIB) \
252 "$@"
253}
254
255# @FUNCTION: econf_build
256# @USAGE: [econf flags]
257# @DESCRIPTION:
258# Sometimes we need to locally build up some tools to run on CBUILD because
259# the package has helper utils which are compiled+executed when compiling.
260# This won't work when cross-compiling as the CHOST is set to a target which
261# we cannot natively execute.
262#
263# For example, the python package will build up a local python binary using
264# a portable build system (configure+make), but then use that binary to run
265# local python scripts to build up other components of the overall python.
266# We cannot rely on the python binary in $PATH as that often times will be
267# a different version, or not even installed in the first place. Instead,
268# we compile the code in a different directory to run on CBUILD, and then
269# use that binary when compiling the main package to run on CHOST.
270#
271# For example, with newer EAPIs, you'd do something like:
272# @CODE
273# src_configure() {
274# ECONF_SOURCE=${S}
275# if tc-is-cross-compiler ; then
276# mkdir "${WORKDIR}"/${CBUILD}
277# pushd "${WORKDIR}"/${CBUILD} >/dev/null
278# econf_build --disable-some-unused-stuff
279# popd >/dev/null
280# fi
281# ... normal build paths ...
282# }
283# src_compile() {
284# if tc-is-cross-compiler ; then
285# pushd "${WORKDIR}"/${CBUILD} >/dev/null
286# emake one-or-two-build-tools
287# ln/mv build-tools to normal build paths in ${S}/
288# popd >/dev/null
289# fi
290# ... normal build paths ...
291# }
292# @CODE
293econf_build() {
294 tc-env_build econf --build=${CBUILD:-${CHOST}} "$@"
221} 295}
222 296
223# @FUNCTION: tc-has-openmp 297# @FUNCTION: tc-has-openmp
224# @USAGE: [toolchain prefix] 298# @USAGE: [toolchain prefix]
225# @DESCRIPTION: 299# @DESCRIPTION:
281 355
282 local type=$1 356 local type=$1
283 local host=$2 357 local host=$2
284 [[ -z ${host} ]] && host=${CTARGET:-${CHOST}} 358 [[ -z ${host} ]] && host=${CTARGET:-${CHOST}}
285 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
286 case ${host} in 363 case ${host} in
364 aarch64*) ninj aarch64 arm;;
287 alpha*) echo alpha;; 365 alpha*) echo alpha;;
288 arm*) echo arm;; 366 arm*) echo arm;;
289 avr*) ninj avr32 avr;; 367 avr*) ninj avr32 avr;;
290 bfin*) ninj blackfin bfin;; 368 bfin*) ninj blackfin bfin;;
291 cris*) echo cris;; 369 cris*) echo cris;;
368 local host=$1 446 local host=$1
369 [[ -z ${host} ]] && host=${CTARGET:-${CHOST}} 447 [[ -z ${host} ]] && host=${CTARGET:-${CHOST}}
370 host=${host%%-*} 448 host=${host%%-*}
371 449
372 case ${host} in 450 case ${host} in
451 aarch64*be) echo big;;
452 aarch64) echo little;;
373 alpha*) echo big;; 453 alpha*) echo big;;
374 arm*b*) echo big;; 454 arm*b*) echo big;;
375 arm*) echo little;; 455 arm*) echo little;;
376 cris*) echo little;; 456 cris*) echo little;;
377 hppa*) echo big;; 457 hppa*) echo big;;
534 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)
535 [[ -z ${ED+set} ]] && local ED=${D%/}${EPREFIX}/ 615 [[ -z ${ED+set} ]] && local ED=${D%/}${EPREFIX}/
536 616
537 tc-is-static-only && return 617 tc-is-static-only && return
538 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
539 # Just make sure it exists 627 # Just make sure it exists
540 dodir /usr/${libdir} 628 dodir /usr/${libdir}
541 629
542 if [[ $1 == "-a" ]] ; then 630 if [[ $1 == "-a" ]] ; then
543 auto=true 631 auto=true
600 # understand linker scripts, just create a symlink. 688 # understand linker scripts, just create a symlink.
601 pushd "${ED}/usr/${libdir}" > /dev/null 689 pushd "${ED}/usr/${libdir}" > /dev/null
602 ln -snf "../../${libdir}/${tlib}" "${lib}" 690 ln -snf "../../${libdir}/${tlib}" "${lib}"
603 popd > /dev/null 691 popd > /dev/null
604 ;; 692 ;;
605 *-aix*|*-irix*|*64*-hpux*|*-interix*|*-winnt*)
606 if ${auto} ; then
607 mv "${ED}"/usr/${libdir}/${lib}* "${ED}"/${libdir}/ || die
608 # no way to retrieve soname on these platforms (?)
609 tlib=$(readlink "${ED}"/${libdir}/${lib})
610 tlib=${tlib##*/}
611 if [[ -z ${tlib} ]] ; then
612 # ok, apparently was not a symlink, don't remove it and
613 # just link to it
614 tlib=${lib}
615 else
616 rm -f "${ED}"/${libdir}/${lib}
617 fi
618 else
619 tlib=${lib}
620 fi
621
622 # we don't have GNU binutils on these platforms, so we symlink
623 # instead, which seems to work fine. Keep it relative, otherwise
624 # we break some QA checks in Portage
625 # on interix, the linker scripts would work fine in _most_
626 # situations. if a library links to such a linker script the
627 # absolute path to the correct library is inserted into the binary,
628 # which is wrong, since anybody linking _without_ libtool will miss
629 # some dependencies, since the stupid linker cannot find libraries
630 # hardcoded with absolute paths (as opposed to the loader, which
631 # seems to be able to do this).
632 # this has been seen while building shared-mime-info which needs
633 # libxml2, but links without libtool (and does not add libz to the
634 # command line by itself).
635 pushd "${ED}/usr/${libdir}" > /dev/null
636 ln -snf "../../${libdir}/${tlib}" "${lib}"
637 popd > /dev/null
638 ;;
639 hppa*-hpux*) # PA-RISC 32bit (SOM) only, others (ELF) match *64*-hpux* above.
640 if ${auto} ; then
641 tlib=$(chatr "${ED}"/usr/${libdir}/${lib} | sed -n '/internal name:/{n;s/^ *//;p;q}')
642 [[ -z ${tlib} ]] && tlib=${lib}
643 tlib=${tlib##*/} # 'internal name' can have a path component
644 mv "${ED}"/usr/${libdir}/${lib}* "${ED}"/${libdir}/ || die
645 # some SONAMEs are funky: they encode a version before the .so
646 if [[ ${tlib} != ${lib}* ]] ; then
647 mv "${ED}"/usr/${libdir}/${tlib}* "${ED}"/${libdir}/ || die
648 fi
649 [[ ${tlib} != ${lib} ]] &&
650 rm -f "${ED}"/${libdir}/${lib}
651 else
652 tlib=$(chatr "${ED}"/${libdir}/${lib} | sed -n '/internal name:/{n;s/^ *//;p;q}')
653 [[ -z ${tlib} ]] && tlib=${lib}
654 tlib=${tlib##*/} # 'internal name' can have a path component
655 fi
656 pushd "${ED}"/usr/${libdir} >/dev/null
657 ln -snf "../../${libdir}/${tlib}" "${lib}"
658 # need the internal name in usr/lib too, to be available at runtime
659 # when linked with /path/to/lib.sl (hardcode_direct_absolute=yes)
660 [[ ${tlib} != ${lib} ]] &&
661 ln -snf "../../${libdir}/${tlib}" "${tlib}"
662 popd >/dev/null
663 ;;
664 *) 693 *)
665 if ${auto} ; then 694 if ${auto} ; then
666 tlib=$(scanelf -qF'%S#F' "${ED}"/usr/${libdir}/${lib}) 695 tlib=$(scanelf -qF'%S#F' "${ED}"/usr/${libdir}/${lib})
667 [[ -z ${tlib} ]] && die "unable to read SONAME from ${lib}" 696 [[ -z ${tlib} ]] && die "unable to read SONAME from ${lib}"
668 mv "${ED}"/usr/${libdir}/${lib}* "${ED}"/${libdir}/ || die 697 mv "${ED}"/usr/${libdir}/${lib}* "${ED}"/${libdir}/ || die
690 ;; 719 ;;
691 esac 720 esac
692 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}"
693 done 722 done
694} 723}
724
725fi

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

  ViewVC Help
Powered by ViewVC 1.1.20