diff options
author | Steven Knight <knight@baldmt.com> | 2010-06-27 19:37:31 (GMT) |
---|---|---|
committer | Steven Knight <knight@baldmt.com> | 2010-06-27 19:37:31 (GMT) |
commit | 8d8c099bade941250c795374297aa5dcd39e66e6 (patch) | |
tree | 248fc5aa168f675bad008c715e4b31ed09dfd144 /QMTest | |
parent | 9be7b07c0c453792c750e0842e81eb8cb9dbffc2 (diff) | |
download | SCons-8d8c099bade941250c795374297aa5dcd39e66e6.zip SCons-8d8c099bade941250c795374297aa5dcd39e66e6.tar.gz SCons-8d8c099bade941250c795374297aa5dcd39e66e6.tar.bz2 |
Generalize searching for the Fortran startup libraries (-lfrtbegin
vs. -lgfortranbegin) for gcc version 4.4 (and later).
Diffstat (limited to 'QMTest')
-rw-r--r-- | QMTest/TestSCons.py | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/QMTest/TestSCons.py b/QMTest/TestSCons.py index 9919920..039afe0 100644 --- a/QMTest/TestSCons.py +++ b/QMTest/TestSCons.py @@ -86,33 +86,31 @@ _dll = dll_suffix dll_ = dll_prefix def gccFortranLibs(): - """Test whether -lfrtbegin is required. This can probably be done in - a more reliable way, but using popen3 is relatively efficient.""" + """Test which gcc Fortran startup libraries are required. + This should probably move into SCons itself, but is kind of hacky. + """ libs = ['g2c'] - cmd = 'gcc -v' + cmd = ['gcc', '-v'] try: import subprocess except ImportError: try: import popen2 - stderr = popen2.popen3(cmd)[2] + stderr = popen2.popen3(cmd)[2].read() except OSError: return libs else: - p = subprocess.Popen(cmd, shell=True, stderr=subprocess.PIPE) - stderr = p.stderr - - for l in stderr.readlines(): - list = l.split() - if len(list) > 3 and list[:2] == ['gcc', 'version']: - if list[2][:3] in ('4.1','4.2','4.3'): - libs = ['gfortranbegin'] - break - if list[2][:2] in ('3.', '4.'): - libs = ['frtbegin'] + libs - break + stderr = subprocess.Popen(cmd, stderr=subprocess.PIPE).communicate()[1] + m = re.search('gcc version (\d\.\d)', stderr) + if m: + gcc_version = m.group(1) + if re.match('4.[^0]', gcc_version): + libs = ['gfortranbegin'] + elif gcc_version in ('3.1', '4.0'): + libs = ['frtbegin'] + libs + return libs |