/[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.99 Revision 1.102
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.99 2010/04/22 18:28:11 armin76 Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/toolchain-funcs.eclass,v 1.102 2010/09/11 17:12:20 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
77# @RETURN: name of the object copier 77# @RETURN: name of the object copier
78tc-getOBJCOPY() { tc-getPROG OBJCOPY objcopy "$@"; } 78tc-getOBJCOPY() { tc-getPROG OBJCOPY objcopy "$@"; }
79# @FUNCTION: tc-getF77 79# @FUNCTION: tc-getF77
80# @USAGE: [toolchain prefix] 80# @USAGE: [toolchain prefix]
81# @RETURN: name of the Fortran 77 compiler 81# @RETURN: name of the Fortran 77 compiler
82tc-getF77() { tc-getPROG F77 f77 "$@"; } 82tc-getF77() { tc-getPROG F77 gfortran "$@"; }
83# @FUNCTION: tc-getFC 83# @FUNCTION: tc-getFC
84# @USAGE: [toolchain prefix] 84# @USAGE: [toolchain prefix]
85# @RETURN: name of the Fortran 90 compiler 85# @RETURN: name of the Fortran 90 compiler
86tc-getFC() { tc-getPROG FC gfortran "$@"; } 86tc-getFC() { tc-getPROG FC gfortran "$@"; }
87# @FUNCTION: tc-getGCJ 87# @FUNCTION: tc-getGCJ
187tc-is-static-only() { 187tc-is-static-only() {
188 local host=${CTARGET:-${CHOST}} 188 local host=${CTARGET:-${CHOST}}
189 189
190 # *MiNT doesn't have shared libraries, only platform so far 190 # *MiNT doesn't have shared libraries, only platform so far
191 return $([[ ${host} == *-mint* ]]) 191 return $([[ ${host} == *-mint* ]])
192}
193
194# @FUNCTION: tc-has-openmp
195# @USAGE: [toolchain prefix]
196# @DESCRIPTION:
197# See if the toolchain supports OpenMP.
198tc-has-openmp() {
199 local base="${T}/test-tc-openmp"
200 cat <<-EOF > "${base}.c"
201 #include <omp.h>
202 int main() {
203 int nthreads, tid, ret = 0;
204 #pragma omp parallel private(nthreads, tid)
205 {
206 tid = omp_get_thread_num();
207 nthreads = omp_get_num_threads(); ret += tid + nthreads;
208 }
209 return ret;
210 }
211 EOF
212 $(tc-getCC "$@") -fopenmp "${base}.c" -o "${base}" >&/dev/null
213 local ret=$?
214 rm -f "${base}"*
215 return ${ret}
192} 216}
193 217
194# @FUNCTION: tc-has-tls 218# @FUNCTION: tc-has-tls
195# @USAGE: [-s|-c|-l] [toolchain prefix] 219# @USAGE: [-s|-c|-l] [toolchain prefix]
196# @DESCRIPTION: 220# @DESCRIPTION:
334 x86_64*) echo little;; 358 x86_64*) echo little;;
335 *) echo wtf;; 359 *) echo wtf;;
336 esac 360 esac
337} 361}
338 362
363# Internal func. The first argument is the version info to expand.
364# Query the preprocessor to improve compatibility across different
365# compilers rather than maintaining a --version flag matrix. #335943
366_gcc_fullversion() {
367 local ver="$1"; shift
368 set -- `$(tc-getCPP "$@") -E -P - <<<"__GNUC__ __GNUC_MINOR__ __GNUC_PATCHLEVEL__"`
369 eval echo "$ver"
370}
371
339# @FUNCTION: gcc-fullversion 372# @FUNCTION: gcc-fullversion
340# @RETURN: compiler version (major.minor.micro: [3.4.6]) 373# @RETURN: compiler version (major.minor.micro: [3.4.6])
341gcc-fullversion() { 374gcc-fullversion() {
342 $(tc-getCC "$@") -dumpversion 375 _gcc_fullversion '$1.$2.$3' "$@"
343} 376}
344# @FUNCTION: gcc-version 377# @FUNCTION: gcc-version
345# @RETURN: compiler version (major.minor: [3.4].6) 378# @RETURN: compiler version (major.minor: [3.4].6)
346gcc-version() { 379gcc-version() {
347 gcc-fullversion "$@" | cut -f1,2 -d. 380 _gcc_fullversion '$1.$2' "$@"
348} 381}
349# @FUNCTION: gcc-major-version 382# @FUNCTION: gcc-major-version
350# @RETURN: major compiler version (major: [3].4.6) 383# @RETURN: major compiler version (major: [3].4.6)
351gcc-major-version() { 384gcc-major-version() {
352 gcc-version "$@" | cut -f1 -d. 385 _gcc_fullversion '$1' "$@"
353} 386}
354# @FUNCTION: gcc-minor-version 387# @FUNCTION: gcc-minor-version
355# @RETURN: minor compiler version (minor: 3.[4].6) 388# @RETURN: minor compiler version (minor: 3.[4].6)
356gcc-minor-version() { 389gcc-minor-version() {
357 gcc-version "$@" | cut -f2 -d. 390 _gcc_fullversion '$2' "$@"
358} 391}
359# @FUNCTION: gcc-micro-version 392# @FUNCTION: gcc-micro-version
360# @RETURN: micro compiler version (micro: 3.4.[6]) 393# @RETURN: micro compiler version (micro: 3.4.[6])
361gcc-micro-version() { 394gcc-micro-version() {
362 gcc-fullversion "$@" | cut -f3 -d. | cut -f1 -d- 395 _gcc_fullversion '$3' "$@"
363} 396}
364 397
365# Returns the installation directory - internal toolchain 398# Returns the installation directory - internal toolchain
366# function for use by _gcc-specs-exists (for flag-o-matic). 399# function for use by _gcc-specs-exists (for flag-o-matic).
367_gcc-install-dir() { 400_gcc-install-dir() {

Legend:
Removed from v.1.99  
changed lines
  Added in v.1.102

  ViewVC Help
Powered by ViewVC 1.1.20