Files
cantera/ext/SConscript

93 lines
3.1 KiB
Python

from buildutils import *
Import('env', 'buildDir', 'buildTargets', 'installTargets')
localenv = env.Clone()
def prep_default(env):
return env.Clone()
def prep_f2c(env):
localenv = env.Clone()
localenv.Append(CPPPATH=Dir('#ext/f2c_libs'))
if not localenv['HAS_TIMES_H']:
localenv.Append(CPPDEFINES=['USE_CLOCK'])
if not localenv['HAS_UNISTD_H']:
localenv.Append(CPPDEFINES=['MSDOS'])
# The F2C code generates a lot of warnings designed to catch
# programmer errors, but since this is autogenerated code, those
# warnings are irrelevant.
if '-Wall' in localenv['CCFLAGS']:
localenv['CCFLAGS'].remove('-Wall')
localenv['CCFLAGS'].append('-Wno-format-security')
return localenv
def prep_sundials(env):
localenv = env.Clone()
localenv.Append(CPPPATH=Dir('#ext/cvode/include'))
# Suppress warnings from external code
if '-Wall' in localenv['CCFLAGS']:
localenv['CCFLAGS'].append('-Wno-format')
return localenv
def prep_gtest(env):
localenv = env.Clone()
localenv.Append(CPPPATH=[Dir('#ext/gtest'),
Dir('#ext/gtest/include')],
CPPDEFINES={'GTEST_HAS_PTHREAD': 0})
return localenv
# (subdir, library name, (file extensions), prepfunction)
libs = [('gtest/src','gtest',['^gtest-all.cc'], prep_gtest)]
if env['build_with_f2c']:
libs.append(('f2c_math', 'ctmath', ['cpp','c'], prep_f2c))
# Create arith.h using the arithchk program
if not os.path.exists('arith.h'):
arithenv = prep_f2c(env)
# TODO: make link flag more general
arithenv.Append(CPPFLAGS='-DNO_FPINIT')
arithenv.Program('f2c_libs/arithchk/arithchk', source='f2c_libs/arithchk/arithchk.c',
LIBS=env['LIBM'])
arithenv.Command('#ext/f2c_libs/arith.h', 'f2c_libs/arithchk/arithchk$PROGSUFFIX',
'$SOURCE > $TARGET')
headerenv = prep_f2c(env)
# Possibly system-depenent headers
headerenv.Command('#ext/f2c_libs/signal1.h', 'f2c_libs/signal1.h0',
Copy('$TARGET', '$SOURCE'))
headerenv.Command('#ext/f2c_libs/sysdep1.h', 'f2c_libs/sysdep1.h0',
Copy('$TARGET', '$SOURCE'))
libs.append(('f2c_libs', 'ctf2c', 'c', prep_f2c))
if env['BUILD_BLAS_LAPACK']:
libs.append(('f2c_blas', 'ctblas', ['c'], prep_f2c))
libs.append(('f2c_lapack', 'ctlapack', ['c'], prep_f2c))
else:
libs.append(('math', 'ctmath', ['cpp','c','f'], prep_default))
if env['BUILD_BLAS_LAPACK']:
libs.append(('blas', 'ctblas', ['f'], prep_default))
libs.append(('lapack', 'ctlapack', ['f'], prep_default))
if env['use_sundials'] == 'n':
libs.append(('cvode/source', 'cvode', ['c'], prep_sundials))
for subdir, libname, extensions, prepFunction in libs:
localenv = prepFunction(env)
lib = localenv.Library(pjoin('../lib', libname),
source=mglob(localenv, subdir, *extensions))
inst = localenv.Install('$inst_libdir', lib)
buildTargets.extend(lib)
installTargets.extend(inst)