| 1 | # Copyright 1999-2004 Gentoo Foundation |
1 | # Copyright 1999-2004 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.10 2004/12/06 06:18:59 vapier Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/toolchain-funcs.eclass,v 1.13 2004/12/14 05:04:09 vapier Exp $ |
| 4 | # |
4 | # |
| 5 | # Author: Toolchain Ninjas <ninjas@gentoo.org> |
5 | # Author: Toolchain Ninjas <ninjas@gentoo.org> |
| 6 | # |
6 | # |
| 7 | # This eclass contains (or should) functions to get common info |
7 | # This eclass contains (or should) functions to get common info |
| 8 | # about the toolchain (libc/compiler/binutils/etc...) |
8 | # about the toolchain (libc/compiler/binutils/etc...) |
| … | |
… | |
| 57 | tc-getGCJ() { tc-getPROG GCJ gcj; } |
57 | tc-getGCJ() { tc-getPROG GCJ gcj; } |
| 58 | |
58 | |
| 59 | # Returns the name of the C compiler for build |
59 | # Returns the name of the C compiler for build |
| 60 | tc-getBUILD_CC() { |
60 | tc-getBUILD_CC() { |
| 61 | if [ -n "${CC_FOR_BUILD}" ] ; then |
61 | if [ -n "${CC_FOR_BUILD}" ] ; then |
|
|
62 | export BUILD_CC="${CC_FOR_BUILD}" |
| 62 | echo "${CC_FOR_BUILD}" |
63 | echo "${CC_FOR_BUILD}" |
| 63 | return 0 |
64 | return 0 |
| 64 | fi |
65 | fi |
| 65 | |
66 | |
| 66 | local search= |
67 | local search= |
| 67 | if [ -n "${CTARGET}" ] ; then |
68 | if [ -n "${CBUILD}" ] ; then |
| 68 | search="$(type -p "${CTARGET}-gcc")" |
|
|
| 69 | elif [ -n "${CHOST}" ] ; then |
|
|
| 70 | search="$(type -p "${CHOST}-gcc")" |
69 | search="$(type -p "${CBUILD}-gcc")" |
| 71 | fi |
70 | fi |
| 72 | |
71 | |
| 73 | if [ -n "${search}" ] ; then |
72 | if [ -n "${search}" ] ; then |
| 74 | echo "${search##*/}" |
73 | search="${search##*/}" |
| 75 | else |
74 | else |
| 76 | echo "gcc" |
75 | search="gcc" |
| 77 | fi |
76 | fi |
|
|
77 | |
|
|
78 | export BUILD_CC="${search}" |
|
|
79 | echo "${search}" |
| 78 | } |
80 | } |
| 79 | |
81 | |
| 80 | # Quick way to export a bunch of vars at once |
82 | # Quick way to export a bunch of vars at once |
| 81 | tc-export() { |
83 | tc-export() { |
| 82 | local var |
84 | local var |
| 83 | for var in "$@" ; do |
85 | for var in "$@" ; do |
| 84 | eval tc-get${var} |
86 | eval tc-get${var} |
| 85 | done |
87 | done |
|
|
88 | } |
|
|
89 | |
|
|
90 | # A simple way to see if we're using a cross-compiler ... |
|
|
91 | tc-is-cross-compiler() { |
|
|
92 | local ret tmpfile=$(emktemp).c |
|
|
93 | echo 'int main(){return 0;}' > "${tmpfile}" |
|
|
94 | $(tc-getCC) "${tmpfile}" -o "${tmpfile}".bin |
|
|
95 | "${tmpfile}".bin &>/dev/null |
|
|
96 | ret=$? |
|
|
97 | rm -f "${tmpfile}" "${tmpfile}".bin |
|
|
98 | return ${ret} |
| 86 | } |
99 | } |
| 87 | |
100 | |
| 88 | |
101 | |
| 89 | # Returns the version as by `$CC -dumpversion` |
102 | # Returns the version as by `$CC -dumpversion` |
| 90 | gcc-fullversion() { |
103 | gcc-fullversion() { |