cantera/platform/posix/SConscript
2017-12-02 20:03:15 -05:00

118 lines
4.1 KiB
Python

import sys
from buildutils import *
Import('env', 'build', 'install')
localenv = env.Clone()
# Copy man pages
if env['INSTALL_MANPAGES']:
install('$inst_mandir', mglob(localenv, '#platform/posix/man', '*'))
### Generate customized scripts ###
# If any Python 3 package is built, prefer that one. If not,
# and if any Python 2 package is built, prefer that one.
# In all other cases, use the Python 3 location variables,
# which should all be empty strings
if env['python3_package'] in ['full', 'minimal']:
major = '3'
elif env['python2_package'] in ['full', 'minimal']:
major = '2'
else:
major = '3'
# 'setup_cantera'
if localenv['layout'] != 'debian' and env['OS'] != 'Windows':
def copy_var(target, source, env):
if env['python{}_prefix'.format(major)] == 'USER':
env['python_module_loc_sc'] = ''
else:
env['python_module_loc_sc'] = env['python{}_module_loc'.format(major)]
env['python_cmd'] = env['python{}_cmd'.format(major)]
env['python_array_home'] = env['python{}_array_home'.format(major)]
for script in ['setup_cantera', 'setup_cantera.csh']:
target = env.SubstFile(script, script + '.in')
localenv.AddPreAction(target, copy_var)
localenv.Depends(target, env['install_python{}_action'.format(major)])
install('$inst_bindir', target)
# Cantera.mak include file for Makefile projects
# cantera.pc for use with pkg-config
pc_libs = list(localenv['cantera_libs'])
pc_libdirs = []
pc_incdirs = []
pc_cflags = list(localenv['CXXFLAGS'])
localenv['mak_corelibs'] = '-lcantera'
localenv['mak_extra_includes'] = ' '.join('-I%s' % s for s in localenv['extra_inc_dirs'])
pc_incdirs.extend(localenv['extra_inc_dirs'])
localenv['mak_extra_libdirs'] = ' '.join('-L%s' % s for s in localenv['extra_lib_dirs'])
pc_libdirs.extend(localenv['extra_lib_dirs'])
if env['HAS_GLIBCXX']:
localenv['mak_stdlib'] = '-lstdc++'
elif env['HAS_LIBCPP']:
localenv['mak_stdlib'] = '-lc++'
else:
localenv['mak_stdlib'] = ''
if localenv['system_sundials']:
# Add links to the sundials environment
localenv['mak_sundials_libs'] = ' '.join('-l%s' % s
for s in localenv['sundials_libs'])
if localenv['sundials_libdir']:
localenv['mak_sundials_libdir'] = '-L' + localenv['sundials_libdir']
pc_libdirs.append(localenv['sundials_libdir'])
else:
localenv['mak_sundials_libdir'] = ''
if localenv['sundials_include']:
localenv['mak_sundials_include'] = '-I' + localenv['sundials_include']
pc_incdirs.append(localenv['sundials_include'])
else:
localenv['mak_sundials_include'] = ''
if localenv['boost_inc_dir']:
localenv['mak_boost_include'] = '-I' + localenv['boost_inc_dir']
pc_incdirs.append(localenv['boost_inc_dir'])
else:
localenv['mak_boost_include'] = ''
# Handle BLAS/LAPACK linkage
blas_lapack_libs = ' '.join('-l%s' % s for s in localenv['blas_lapack_libs'])
if localenv['blas_lapack_dir']:
localenv['mak_blas_lapack_libs'] = '-L{} {}'.format(localenv['blas_lapack_dir'],
blas_lapack_libs)
else:
localenv['mak_blas_lapack_libs'] = blas_lapack_libs
if 'Accelerate' in localenv['FRAMEWORKS']:
localenv['mak_blas_lapack_libs'] += ' -framework Accelerate'
pc_cflags.append('-framework Accelerate')
localenv['mak_threadflags'] = localenv['thread_flags']
if '-pthread' in localenv['thread_flags']:
localenv['mak_fort_threadflags'] = '-lpthread'
pc_cflags.append('-pthread')
pc_libs.append('pthread')
else:
localenv['mak_fort_threadflags'] = ''
mak = build(localenv.SubstFile('Cantera.mak', 'Cantera.mak.in'))
install('$inst_incdir', mak)
# Generate cantera.pc for use with pkg-config
localenv['pc_prefix'] = localenv['prefix']
localenv['pc_libdirs'] = ' '.join('-L' + d for d in pc_libdirs)
localenv['pc_libs'] = ' '.join('-l' + lib for lib in pc_libs)
localenv['pc_incdirs'] = ' '.join('-I' + d for d in pc_incdirs)
localenv['pc_cflags'] = ' '.join(pc_cflags)
pc = build(localenv.SubstFile('cantera.pc', 'cantera.pc.in'))
install('$inst_libdir/pkgconfig', pc)