diff options
-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 |