python = TestCmd.python_executable
+
+def gccFortranLibs():
+ """Test whether -lfrtbegin is required. This can probably be done in
+ a more reliable way, but using popen3 is relatively efficient."""
+
+ libs = ['g2c']
+
+ try:
+ import popen2
+ stderr = popen2.popen3('gcc -v')[2]
+ except OSError:
+ return libs
+
+ for l in stderr.readlines():
+ list = string.split(l)
+ if len(list) > 3 and list[:2] == ['gcc', 'version']:
+ if list[2][:2] == '3.':
+ libs = ['frtbegin'] + libs
+ break
+ return libs
+
+
if sys.platform == 'win32':
_exe = '.exe'
_obj = '.obj'
_shobj = '.obj'
_dll = '.dll'
lib_ = ''
- fortran_lib = 'g2c'
+ fortran_lib = gccFortranLibs()
elif sys.platform == 'cygwin':
_exe = '.exe'
_obj = '.o'
_shobj = '.os'
_dll = '.dll'
lib_ = ''
- fortran_lib = 'g2c'
+ fortran_lib = gccFortranLibs()
elif string.find(sys.platform, 'irix') != -1:
_exe = ''
_obj = '.o'
_shobj = '.o'
_dll = '.so'
lib_ = 'lib'
- fortran_lib = 'ftn'
+ fortran_lib = ['ftn']
else:
_exe = ''
_obj = '.o'
_shobj = '.os'
_dll = '.so'
lib_ = 'lib'
- fortran_lib = 'g2c'
+ fortran_lib = gccFortranLibs()
+
class TestFailed(Exception):
def __init__(self, args=None):
import time
import TestSCons
-if sys.platform == 'win32':
- _exe = '.exe'
-else:
- _exe = ''
+_exe = TestSCons._exe
+fortran_runtime = TestSCons.fortran_lib
test = TestSCons.TestSCons()
SConscript('../build/var6/SConscript', "env")
""")
-if string.find(sys.platform, 'irix') != -1:
- fortran_runtime = 'ftn'
-
- # f77 does NOT work on cruncher
- test.no_result()
-else:
- fortran_runtime = 'g2c'
-
test.subdir(['work1', 'src'])
test.write(['work1', 'src', 'SConscript'], """
import os
if f77 and env.Detect(env['F77']):
env.Command(target='b2.f', source='b2.in', action=buildIt)
- env.Copy(LIBS = [r'%s']).Program(target='bar2', source='b2.f')
- env.Copy(LIBS = [r'%s']).Program(target='bar1', source='b1.f')
+ env.Copy(LIBS = %s).Program(target='bar2', source='b2.f')
+ env.Copy(LIBS = %s).Program(target='bar1', source='b1.f')
""" % (fortran_runtime, fortran_runtime))
test.write(['work1', 'src', 'f1.c'], r"""
test.write(['work3', 'SConstruct'], """\
import os
env = Environment(ENV = { 'PATH' : os.environ['PATH'] })
-env.SourceCode('.', env.CVS(':pserver:anonymous:@cvs.sourceforge.net:/cvsroot/scons'))
+env.SourceCode('.', env.CVS(':pserver:anonymous@cvs.sourceforge.net:/cvsroot/scons'))
env.Install('install', 'scons/SConstruct')
""")
""" % string.replace(test.workpath('wrapper.out'), '\\', '\\\\'))
test.write('SConstruct', """
-foo = Environment(LIBS = r'%s')
+foo = Environment(LIBS = %s)
f77 = foo.Dictionary('F77')
bar = foo.Copy(F77 = r'%s wrapper.py ' + f77)
foo.Program(target = 'foo', source = 'foo.f')
""" % string.replace(test.workpath('wrapper.out'), '\\', '\\\\'))
test.write('SConstruct', """
-foo = Environment(LIBS = r'%s')
+foo = Environment(LIBS = %s)
f77 = foo.Dictionary('F77')
bar = foo.Copy(F77 = r'%s wrapper.py ' + f77, F77FLAGS = '-Ix')
foo.Program(target = 'foo', source = 'foo.f')
import sys
import TestSCons
-if sys.platform == 'win32':
- _exe = '.exe'
-else:
- _exe = ''
-
+_exe = TestSCons._exe
FTN_LIB = TestSCons.fortran_lib
prog = 'prog' + _exe
test.subdir('include', 'subdir', ['subdir', 'include'], 'inc2')
test.write('SConstruct', """
-env = Environment(F77PATH = ['$FOO'], LIBS = r'%s', FOO='include')
+env = Environment(F77PATH = ['$FOO'], LIBS = %s, FOO='include')
obj = env.Object(target='foobar/prog', source='subdir/prog.f')
env.Program(target='prog', source=obj)
SConscript('subdir/SConscript', "env")
BuildDir('variant', 'subdir', 0)
include = Dir('include')
-env = Environment(F77PATH=[include], LIBS = r'%s')
+env = Environment(F77PATH=[include], LIBS = %s)
SConscript('variant/SConscript', "env")
""" % (FTN_LIB, FTN_LIB))
# Change F77PATH and make sure we don't rebuild because of it.
test.write('SConstruct', """
-env = Environment(F77PATH = Split('inc2 include'), LIBS = r'%s')
+env = Environment(F77PATH = Split('inc2 include'), LIBS = %s)
obj = env.Object(target='foobar/prog', source='subdir/prog.f')
env.Program(target='prog', source=obj)
SConscript('subdir/SConscript', "env")
BuildDir('variant', 'subdir', 0)
include = Dir('include')
-env = Environment(F77PATH=['inc2', include], LIBS = r'%s')
+env = Environment(F77PATH=['inc2', include], LIBS = %s)
SConscript('variant/SConscript', "env")
""" % (FTN_LIB, FTN_LIB))
# Check that a null-string F77PATH doesn't blow up.
test.write('SConstruct', """
-env = Environment(F77PATH = '', LIBS = r'%s')
+env = Environment(F77PATH = '', LIBS = %s)
env.Library('foo', source = 'empty.f')
""" % FTN_LIB)
""" % string.replace(test.workpath('wrapper.out'), '\\', '\\\\'))
test.write('SConstruct', """
-foo = Environment(LIBS = r'%s')
+foo = Environment(LIBS = %s)
shf77 = foo.Dictionary('SHF77')
bar = foo.Copy(SHF77 = r'%s wrapper.py ' + shf77, SHF77FLAGS = '-Ix')
foo.SharedLibrary(target = 'foo/foo', source = 'foo.f')
for k in fromdict.keys():
if k != "ENV" and k != "SCANNERS" and k != "CFLAGS" and k != "CXXFLAGS" \
and not SCons.Util.is_Dict(fromdict[k]):
+ # the next line fails in Cygwin because it tries to do env.subst on
+ # $RMIC $RMICFLAGS -d ${TARGET.attributes.java_lookupdir} ...
+ # when $TARGET is None, so $TARGET.attributes throws an exception
todict[k] = env.subst(str(fromdict[k]))
todict["CFLAGS"] = fromdict["CPPFLAGS"] + " " + \
string.join(map(lambda x: "-I" + x, env["CPPPATH"])) + " " + \