/[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.92 Revision 1.98
1# Copyright 1999-2007 Gentoo Foundation 1# Copyright 1999-2007 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.92 2009/08/15 15:11:17 grobian Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/toolchain-funcs.eclass,v 1.98 2010/03/15 23:51:14 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
86tc-getFC() { tc-getPROG FC gfortran "$@"; } 86tc-getFC() { tc-getPROG FC gfortran "$@"; }
87# @FUNCTION: tc-getGCJ 87# @FUNCTION: tc-getGCJ
88# @USAGE: [toolchain prefix] 88# @USAGE: [toolchain prefix]
89# @RETURN: name of the java compiler 89# @RETURN: name of the java compiler
90tc-getGCJ() { tc-getPROG GCJ gcj "$@"; } 90tc-getGCJ() { tc-getPROG GCJ gcj "$@"; }
91# @FUNCTION: tc-getPKG_CONFIG
92# @USAGE: [toolchain prefix]
93# @RETURN: name of the pkg-config tool
94tc-getPKG_CONFIG() { tc-getPROG PKG_CONFIG pkg-config "$@"; }
95# @FUNCTION: tc-getRC
96# @USAGE: [toolchain prefix]
97# @RETURN: name of the Windows resource compiler
98tc-getRC() { tc-getPROG RC windres "$@"; }
99# @FUNCTION: tc-getDLLWRAP
100# @USAGE: [toolchain prefix]
101# @RETURN: name of the Windows dllwrap utility
102tc-getDLLWRAP() { tc-getPROG DLLWRAP dllwrap "$@"; }
91 103
92# @FUNCTION: tc-getBUILD_CC 104# @FUNCTION: tc-getBUILD_CC
93# @USAGE: [toolchain prefix] 105# @USAGE: [toolchain prefix]
94# @RETURN: name of the C compiler for building binaries to run on the build machine 106# @RETURN: name of the C compiler for building binaries to run on the build machine
95tc-getBUILD_CC() { 107tc-getBUILD_CC() {
162tc-is-static-only() { 174tc-is-static-only() {
163 local host=${CTARGET:-${CHOST}} 175 local host=${CTARGET:-${CHOST}}
164 176
165 # *MiNT doesn't have shared libraries, only platform so far 177 # *MiNT doesn't have shared libraries, only platform so far
166 return $([[ ${host} == *-mint* ]]) 178 return $([[ ${host} == *-mint* ]])
179}
180
181# @FUNCTION: tc-has-tls
182# @USAGE: [-s|-c|-l] [toolchain prefix]
183# @DESCRIPTION:
184# See if the toolchain supports thread local storage (TLS). Use -s to test the
185# compiler, -c to also test the assembler, and -l to also test the C library
186# (the default).
187tc-has-tls() {
188 local base="${T}/test-tc-tls"
189 cat <<-EOF > "${base}.c"
190 int foo(int *i) {
191 static __thread int j = 0;
192 return *i ? j : *i;
193 }
194 EOF
195 local flags
196 case $1 in
197 -s) flags="-S";;
198 -c) flags="-c";;
199 -l) ;;
200 -*) die "Usage: tc-has-tls [-c|-l] [toolchain prefix]";;
201 esac
202 : ${flags:=-fPIC -shared -Wl,-z,defs}
203 [[ $1 == -* ]] && shift
204 $(tc-getCC "$@") ${flags} "${base}.c" -o "${base}" >&/dev/null
205 local ret=$?
206 rm -f "${base}"*
207 return ${ret}
167} 208}
168 209
169 210
170# Parse information from CBUILD/CHOST/CTARGET rather than 211# Parse information from CBUILD/CHOST/CTARGET rather than
171# use external variables from the profile. 212# use external variables from the profile.
469 # Since we moved the lib from usr/lib into lib this reference is 510 # Since we moved the lib from usr/lib into lib this reference is
470 # wrong. Hence, we update it here. We don't configure with 511 # wrong. Hence, we update it here. We don't configure with
471 # libdir=/lib because that messes up libtool files. 512 # libdir=/lib because that messes up libtool files.
472 # Make sure we don't lose the specific version, so just modify the 513 # Make sure we don't lose the specific version, so just modify the
473 # existing install_name 514 # existing install_name
515 if [[ ! -w "${ED}/${libdir}/${tlib}" ]] ; then
516 chmod u+w "${ED}${libdir}/${tlib}" # needed to write to it
517 local nowrite=yes
518 fi
474 install_name_tool \ 519 install_name_tool \
475 -id "${EPREFIX}"/${libdir}/${tlib} \ 520 -id "${EPREFIX}"/${libdir}/${tlib} \
476 "${ED}"/${libdir}/${tlib} 521 "${ED}"/${libdir}/${tlib} || die "install_name_tool failed"
522 [[ -n ${nowrite} ]] && chmod u-w "${ED}${libdir}/${tlib}"
477 # Now as we don't use GNU binutils and our linker doesn't 523 # Now as we don't use GNU binutils and our linker doesn't
478 # understand linker scripts, just create a symlink. 524 # understand linker scripts, just create a symlink.
479 pushd "${ED}/usr/${libdir}" > /dev/null 525 pushd "${ED}/usr/${libdir}" > /dev/null
480 ln -snf "../../${libdir}/${tlib}" "${lib}" 526 ln -snf "../../${libdir}/${tlib}" "${lib}"
481 popd > /dev/null 527 popd > /dev/null
482 ;; 528 ;;
483 *-aix*|*-irix*|*-hpux*|*-interix*|*-winnt*) 529 *-aix*|*-irix*|*64*-hpux*|*-interix*|*-winnt*)
484 if ${auto} ; then 530 if ${auto} ; then
485 mv "${ED}"/usr/${libdir}/${lib}* "${ED}"/${libdir}/ || die 531 mv "${ED}"/usr/${libdir}/${lib}* "${ED}"/${libdir}/ || die
486 # no way to retrieve soname on these platforms (?) 532 # no way to retrieve soname on these platforms (?)
487 tlib=$(readlink "${ED}"/${libdir}/${lib}) 533 tlib=$(readlink "${ED}"/${libdir}/${lib})
488 tlib=${tlib##*/} 534 tlib=${tlib##*/}
512 # command line by itself). 558 # command line by itself).
513 pushd "${ED}/usr/${libdir}" > /dev/null 559 pushd "${ED}/usr/${libdir}" > /dev/null
514 ln -snf "../../${libdir}/${tlib}" "${lib}" 560 ln -snf "../../${libdir}/${tlib}" "${lib}"
515 popd > /dev/null 561 popd > /dev/null
516 ;; 562 ;;
563 hppa*-hpux*) # PA-RISC 32bit (SOM) only, others (ELF) match *64*-hpux* above.
564 if ${auto} ; then
565 tlib=$(chatr "${ED}"/usr/${libdir}/${lib} | sed -n '/internal name:/{n;s/^ *//;p;q}')
566 [[ -z ${tlib} ]] && tlib=${lib}
567 tlib=${tlib##*/} # 'internal name' can have a path component
568 mv "${ED}"/usr/${libdir}/${lib}* "${ED}"/${libdir}/ || die
569 # some SONAMEs are funky: they encode a version before the .so
570 if [[ ${tlib} != ${lib}* ]] ; then
571 mv "${ED}"/usr/${libdir}/${tlib}* "${ED}"/${libdir}/ || die
572 fi
573 [[ ${tlib} != ${lib} ]] &&
574 rm -f "${ED}"/${libdir}/${lib}
575 else
576 tlib=$(chatr "${ED}"/${libdir}/${lib} | sed -n '/internal name:/{n;s/^ *//;p;q}')
577 [[ -z ${tlib} ]] && tlib=${lib}
578 tlib=${tlib##*/} # 'internal name' can have a path component
579 fi
580 pushd "${ED}"/usr/${libdir} >/dev/null
581 ln -snf "../../${libdir}/${tlib}" "${lib}"
582 # need the internal name in usr/lib too, to be available at runtime
583 # when linked with /path/to/lib.sl (hardcode_direct_absolute=yes)
584 [[ ${tlib} != ${lib} ]] &&
585 ln -snf "../../${libdir}/${tlib}" "${tlib}"
586 popd >/dev/null
587 ;;
517 *) 588 *)
518 if ${auto} ; then 589 if ${auto} ; then
519 tlib=$(scanelf -qF'%S#F' "${ED}"/usr/${libdir}/${lib}) 590 tlib=$(scanelf -qF'%S#F' "${ED}"/usr/${libdir}/${lib})
520 [[ -z ${tlib} ]] && die "unable to read SONAME from ${lib}" 591 [[ -z ${tlib} ]] && die "unable to read SONAME from ${lib}"
521 mv "${ED}"/usr/${libdir}/${lib}* "${ED}"/${libdir}/ || die 592 mv "${ED}"/usr/${libdir}/${lib}* "${ED}"/${libdir}/ || die

Legend:
Removed from v.1.92  
changed lines
  Added in v.1.98

  ViewVC Help
Powered by ViewVC 1.1.20