diff --git a/Cantera/matlab/SConscript b/Cantera/matlab/SConscript new file mode 100644 index 000000000..8825730f8 --- /dev/null +++ b/Cantera/matlab/SConscript @@ -0,0 +1,50 @@ +from buildutils import * + +Import('env', 'build') + +class MatlabBuilder(object): + def __init__(self, libs): + self.libs = libs + + def __call__(self, target, source, env): + filenames = [os.path.split(node.path)[1] for node in source] + sourcestr = ' '.join(pjoin('private',name) for name in filenames) + includes = ' '.join('-I%s' % Dir(s).abspath for s in env['CPPPATH']) + libdir = ' '.join('-L%s' % Dir(s).abspath for s in env['LIBPATH']) + libs = ' '.join('-l'+s for s in self.libs) + text = """ +disp('building Cantera...'); +mex -cxx -v %(sourcestr)s %(include)s %(libdir)s %(libs)s +disp('done.'); +exit +""" % dict(sourcestr=sourcestr, + include=includes, + libdir=libdir, + libs=libs) + + with open(str(target[0]), 'w') as f: + f.write(text) + +localenv = env.Clone() + +linkLibs = ['clib','oneD','zeroD','equil','kinetics','transport', + 'thermo','ctnumerics','ctmath','tpx', + 'ctspectra','converters','ctbase'] + +if env['use_sundials']: + linkLibs.extend(('sundials_cvodes','sundials_nvecserial')) + +linkLibs.extend(localenv['blas_lapack_libs']) + +if env['build_with_f2c']: + linkLibs.append('ctf2c') +else: + linkLibs.append('gfortran') + +localenv.Command('cantera/build_cantera.m', mglob(localenv, 'cantera/private', 'cpp'), + MatlabBuilder(linkLibs)) + +localenv['ENV']['PATH'] = os.environ['PATH'] + +localenv.Command('cantera/ctfunctions.mexa64', 'cantera/build_cantera.m', + 'cd ${SOURCE.dir}; %(matlab_cmd)s -nojvm -nosplash -r build_cantera' % localenv) diff --git a/SConstruct b/SConstruct index 4d59f3456..15b1441ba 100644 --- a/SConstruct +++ b/SConstruct @@ -103,7 +103,7 @@ else: if env['matlab_toolbox'] != 'n': opts.AddVariables( PathVariable('matlab_cmd', 'Path to the matlab executable', - 'default', PathVariable.PathAccept) + 'matlab', PathVariable.PathAccept) ) # Options that apply only if building the Fortran interface @@ -271,3 +271,6 @@ VariantDir('build/interfaces/fortran/', 'Cantera/fortran', duplicate=1) SConscript('build/interfaces/fortran/SConscript') SConscript('Cantera/python/SConscript') + +if env['matlab_toolbox'] == 'y': + SConscript('Cantera/matlab/SConscript')