| 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.74 2007/08/17 10:14:13 vapier Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/toolchain-funcs.eclass,v 1.84 2009/01/08 11:06:10 gengor 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 |
| … | |
… | |
| 74 | tc-getRANLIB() { tc-getPROG RANLIB ranlib "$@"; } |
74 | tc-getRANLIB() { tc-getPROG RANLIB ranlib "$@"; } |
| 75 | # @FUNCTION: tc-getF77 |
75 | # @FUNCTION: tc-getF77 |
| 76 | # @USAGE: [toolchain prefix] |
76 | # @USAGE: [toolchain prefix] |
| 77 | # @RETURN: name of the Fortran 77 compiler |
77 | # @RETURN: name of the Fortran 77 compiler |
| 78 | tc-getF77() { tc-getPROG F77 f77 "$@"; } |
78 | tc-getF77() { tc-getPROG F77 f77 "$@"; } |
| 79 | # @FUNCTION: tc-getF90 |
79 | # @FUNCTION: tc-getFC |
| 80 | # @USAGE: [toolchain prefix] |
80 | # @USAGE: [toolchain prefix] |
| 81 | # @RETURN: name of the Fortran 90 compiler |
81 | # @RETURN: name of the Fortran 90 compiler |
| 82 | tc-getF90() { tc-getPROG F90 gfortran "$@"; } |
82 | tc-getFC() { tc-getPROG FC gfortran "$@"; } |
| 83 | # @FUNCTION: tc-getFORTRAN |
|
|
| 84 | # @USAGE: [toolchain prefix] |
|
|
| 85 | # @RETURN: name of the Fortran compiler |
|
|
| 86 | tc-getFORTRAN() { tc-getPROG FORTRAN gfortran "$@"; } |
|
|
| 87 | # @FUNCTION: tc-getGCJ |
83 | # @FUNCTION: tc-getGCJ |
| 88 | # @USAGE: [toolchain prefix] |
84 | # @USAGE: [toolchain prefix] |
| 89 | # @RETURN: name of the java compiler |
85 | # @RETURN: name of the java compiler |
| 90 | tc-getGCJ() { tc-getPROG GCJ gcj "$@"; } |
86 | tc-getGCJ() { tc-getPROG GCJ gcj "$@"; } |
| 91 | |
87 | |
| … | |
… | |
| 118 | # @DESCRIPTION: |
114 | # @DESCRIPTION: |
| 119 | # Quick way to export a bunch of compiler vars at once. |
115 | # Quick way to export a bunch of compiler vars at once. |
| 120 | tc-export() { |
116 | tc-export() { |
| 121 | local var |
117 | local var |
| 122 | for var in "$@" ; do |
118 | for var in "$@" ; do |
|
|
119 | [[ $(type -t tc-get${var}) != "function" ]] && die "tc-export: invalid export variable '${var}'" |
| 123 | eval tc-get${var} > /dev/null |
120 | eval tc-get${var} > /dev/null |
| 124 | done |
121 | done |
| 125 | } |
122 | } |
| 126 | |
123 | |
| 127 | # @FUNCTION: tc-is-cross-compiler |
124 | # @FUNCTION: tc-is-cross-compiler |
| … | |
… | |
| 168 | arm*) echo arm;; |
165 | arm*) echo arm;; |
| 169 | avr*) ninj avr32 avr;; |
166 | avr*) ninj avr32 avr;; |
| 170 | bfin*) ninj blackfin bfin;; |
167 | bfin*) ninj blackfin bfin;; |
| 171 | cris*) echo cris;; |
168 | cris*) echo cris;; |
| 172 | hppa*) ninj parisc hppa;; |
169 | hppa*) ninj parisc hppa;; |
| 173 | i?86*) ninj i386 x86;; |
170 | i?86*) |
|
|
171 | # Starting with linux-2.6.24, the 'x86_64' and 'i386' |
|
|
172 | # trees have been unified into 'x86'. |
|
|
173 | # FreeBSD still uses i386 |
|
|
174 | if [[ ${type} == "kern" ]] && [[ $(KV_to_int ${KV}) -lt $(KV_to_int 2.6.24) || ${host} == *freebsd* ]] ; then |
|
|
175 | echo i386 |
|
|
176 | else |
|
|
177 | echo x86 |
|
|
178 | fi |
|
|
179 | ;; |
| 174 | ia64*) echo ia64;; |
180 | ia64*) echo ia64;; |
| 175 | m68*) echo m68k;; |
181 | m68*) echo m68k;; |
| 176 | mips*) echo mips;; |
182 | mips*) echo mips;; |
| 177 | nios2*) echo nios2;; |
183 | nios2*) echo nios2;; |
| 178 | nios*) echo nios;; |
184 | nios*) echo nios;; |
| … | |
… | |
| 203 | sparc*) [[ ${PROFILE_ARCH} == "sparc64" ]] \ |
209 | sparc*) [[ ${PROFILE_ARCH} == "sparc64" ]] \ |
| 204 | && ninj sparc64 sparc \ |
210 | && ninj sparc64 sparc \ |
| 205 | || echo sparc |
211 | || echo sparc |
| 206 | ;; |
212 | ;; |
| 207 | vax*) echo vax;; |
213 | vax*) echo vax;; |
| 208 | x86_64*) ninj x86_64 amd64;; |
214 | x86_64*) |
|
|
215 | # Starting with linux-2.6.24, the 'x86_64' and 'i386' |
|
|
216 | # trees have been unified into 'x86'. |
|
|
217 | if [[ ${type} == "kern" ]] && [[ $(KV_to_int ${KV}) -ge $(KV_to_int 2.6.24) ]] ; then |
|
|
218 | echo x86 |
|
|
219 | else |
|
|
220 | ninj x86_64 amd64 |
|
|
221 | fi |
|
|
222 | ;; |
| 209 | |
223 | |
| 210 | # since our usage of tc-arch is largely concerned with |
224 | # since our usage of tc-arch is largely concerned with |
| 211 | # normalizing inputs for testing ${CTARGET}, let's filter |
225 | # normalizing inputs for testing ${CTARGET}, let's filter |
| 212 | # other cross targets (mingw and such) into the unknown. |
226 | # other cross targets (mingw and such) into the unknown. |
| 213 | *) echo unknown;; |
227 | *) echo unknown;; |
| … | |
… | |
| 279 | } |
293 | } |
| 280 | |
294 | |
| 281 | # Returns the installation directory - internal toolchain |
295 | # Returns the installation directory - internal toolchain |
| 282 | # function for use by _gcc-specs-exists (for flag-o-matic). |
296 | # function for use by _gcc-specs-exists (for flag-o-matic). |
| 283 | _gcc-install-dir() { |
297 | _gcc-install-dir() { |
| 284 | echo "$($(tc-getCC) -print-search-dirs 2> /dev/null |\ |
298 | echo "$(LC_ALL=C $(tc-getCC) -print-search-dirs 2> /dev/null |\ |
| 285 | awk '$1=="install:" {print $2}')" |
299 | awk '$1=="install:" {print $2}')" |
| 286 | } |
300 | } |
| 287 | # Returns true if the indicated specs file exists - internal toolchain |
301 | # Returns true if the indicated specs file exists - internal toolchain |
| 288 | # function for use by flag-o-matic. |
302 | # function for use by flag-o-matic. |
| 289 | _gcc-specs-exists() { |
303 | _gcc-specs-exists() { |
| … | |
… | |
| 333 | |
347 | |
| 334 | # Returns true if gcc sets relro |
348 | # Returns true if gcc sets relro |
| 335 | gcc-specs-relro() { |
349 | gcc-specs-relro() { |
| 336 | local directive |
350 | local directive |
| 337 | directive=$(gcc-specs-directive link_command) |
351 | directive=$(gcc-specs-directive link_command) |
| 338 | return $([[ ${directive/\{!norelro:} != ${directive} ]]) |
352 | return $([[ "${directive/\{!norelro:}" != "${directive}" ]]) |
| 339 | } |
353 | } |
| 340 | # Returns true if gcc sets now |
354 | # Returns true if gcc sets now |
| 341 | gcc-specs-now() { |
355 | gcc-specs-now() { |
| 342 | local directive |
356 | local directive |
| 343 | directive=$(gcc-specs-directive link_command) |
357 | directive=$(gcc-specs-directive link_command) |
| 344 | return $([[ ${directive/\{!nonow:} != ${directive} ]]) |
358 | return $([[ "${directive/\{!nonow:}" != "${directive}" ]]) |
| 345 | } |
359 | } |
| 346 | # Returns true if gcc builds PIEs |
360 | # Returns true if gcc builds PIEs |
| 347 | gcc-specs-pie() { |
361 | gcc-specs-pie() { |
| 348 | local directive |
362 | local directive |
| 349 | directive=$(gcc-specs-directive cc1) |
363 | directive=$(gcc-specs-directive cc1) |
| 350 | return $([[ ${directive/\{!nopie:} != ${directive} ]]) |
364 | return $([[ "${directive/\{!nopie:}" != "${directive}" ]]) |
| 351 | } |
365 | } |
| 352 | # Returns true if gcc builds with the stack protector |
366 | # Returns true if gcc builds with the stack protector |
| 353 | gcc-specs-ssp() { |
367 | gcc-specs-ssp() { |
| 354 | local directive |
368 | local directive |
| 355 | directive=$(gcc-specs-directive cc1) |
369 | directive=$(gcc-specs-directive cc1) |
| 356 | return $([[ ${directive/\{!fno-stack-protector:} != ${directive} ]]) |
370 | return $([[ "${directive/\{!fno-stack-protector:}" != "${directive}" ]]) |
| 357 | } |
371 | } |
| 358 | # Returns true if gcc upgrades fstack-protector to fstack-protector-all |
372 | # Returns true if gcc upgrades fstack-protector to fstack-protector-all |
| 359 | gcc-specs-ssp-to-all() { |
373 | gcc-specs-ssp-to-all() { |
| 360 | local directive |
374 | local directive |
| 361 | directive=$(gcc-specs-directive cc1) |
375 | directive=$(gcc-specs-directive cc1) |
| 362 | return $([[ ${directive/\{!fno-stack-protector-all:} != ${directive} ]]) |
376 | return $([[ "${directive/\{!fno-stack-protector-all:}" != "${directive}" ]]) |
|
|
377 | } |
|
|
378 | # Returns true if gcc builds with fno-strict-overflow |
|
|
379 | gcc-specs-nostrict() { |
|
|
380 | local directive |
|
|
381 | directive=$(gcc-specs-directive cc1) |
|
|
382 | return $([[ "${directive/\{!fstrict-overflow:}" != "${directive}" ]]) |
| 363 | } |
383 | } |
| 364 | |
384 | |
| 365 | |
385 | |
| 366 | # @FUNCTION: gen_usr_ldscript |
386 | # @FUNCTION: gen_usr_ldscript |
| 367 | # @USAGE: <list of libs to create linker scripts for> |
387 | # @USAGE: <list of libs to create linker scripts for> |