5 |
# Licensed under the Open Software License version 3.0 |
# Licensed under the Open Software License version 3.0 |
6 |
# http://www.opensource.org/licenses/osl-3.0.php |
# http://www.opensource.org/licenses/osl-3.0.php |
7 |
|
|
|
# TODO use AppendUnique instead of seen_dirs for simplicity |
|
8 |
# TODO How to modify CCFLAGS for only one file? Look for example with Program(...) |
# TODO How to modify CCFLAGS for only one file? Look for example with Program(...) |
9 |
|
|
10 |
EnsureSConsVersion(0,96,91) |
EnsureSConsVersion(0,96,91) |
57 |
('ar_flags', 'Static library archiver flags to use', ''), |
('ar_flags', 'Static library archiver flags to use', ''), |
58 |
BoolOption('useopenmp', 'Compile parallel version using OpenMP', 'yes'), |
BoolOption('useopenmp', 'Compile parallel version using OpenMP', 'yes'), |
59 |
# Python |
# Python |
60 |
PathOption('python_path', 'Path to Python includes', '/usr/include/'+python_version), |
('python_path', 'Path to Python includes', '/usr/include/'+python_version), |
61 |
PathOption('python_lib_path', 'Path to Python libs', '/usr/lib'), |
('python_lib_path', 'Path to Python libs', '/usr/lib'), |
62 |
('python_libs', 'Python libraries to link with', [python_version]), |
('python_libs', 'Python libraries to link with', [python_version]), |
63 |
('python_cmd', 'Python command', 'python'), |
('python_cmd', 'Python command', 'python'), |
64 |
# Boost |
# Boost |
65 |
PathOption('boost_path', 'Path to Boost includes', "/usr/include"), |
('boost_path', 'Path to Boost includes', "/usr/include"), |
66 |
PathOption('boost_lib_path', 'Path to Boost libs', '/usr/lib'), |
('boost_lib_path', 'Path to Boost libs', '/usr/lib'), |
67 |
('boost_libs', 'Boost libraries to link with', ['boost_python']), |
('boost_libs', 'Boost libraries to link with', ['boost_python']), |
68 |
# NetCDF |
# NetCDF |
69 |
BoolOption('usenetcdf', 'switch on/off the usage of netCDF', 'yes'), |
BoolOption('usenetcdf', 'switch on/off the usage of netCDF', 'yes'), |
70 |
PathOption('netCDF_path', 'Path to netCDF includes', '/usr/include'), |
('netCDF_path', 'Path to netCDF includes', '/usr/include'), |
71 |
PathOption('netCDF_lib_path', 'Path to netCDF libs', '/usr/lib'), |
('netCDF_lib_path', 'Path to netCDF libs', '/usr/lib'), |
72 |
('netCDF_libs', 'netCDF C++ libraries to link with', ['netcdf_c++', 'netcdf']), |
('netCDF_libs', 'netCDF C++ libraries to link with', ['netcdf_c++', 'netcdf']), |
73 |
# MPI |
# MPI |
74 |
BoolOption('useMPI', 'For backwards compatibility', 'no'), |
BoolOption('useMPI', 'For backwards compatibility', 'no'), |
75 |
BoolOption('usempi', 'Compile parallel version using MPI', 'no'), |
BoolOption('usempi', 'Compile parallel version using MPI', 'no'), |
76 |
('MPICH_IGNORE_CXX_SEEK', 'name of macro to ignore MPI settings of C++ SEEK macro (for MPICH)' , 'MPICH_IGNORE_CXX_SEEK'), |
('MPICH_IGNORE_CXX_SEEK', 'name of macro to ignore MPI settings of C++ SEEK macro (for MPICH)' , 'MPICH_IGNORE_CXX_SEEK'), |
77 |
PathOption('mpi_path', 'Path to MPI includes', '/usr/include'), |
('mpi_path', 'Path to MPI includes', '/usr/include'), |
78 |
('mpi_run', 'mpirun name' , 'mpiexec -np 1'), |
('mpi_run', 'mpirun name' , 'mpiexec -np 1'), |
79 |
PathOption('mpi_lib_path', 'Path to MPI libs (needs to be added to the LD_LIBRARY_PATH)', '/usr/lib'), |
('mpi_lib_path', 'Path to MPI libs (needs to be added to the LD_LIBRARY_PATH)', '/usr/lib'), |
80 |
('mpi_libs', 'MPI libraries to link with (needs to be shared!)', ['mpich' , 'pthread', 'rt']), |
('mpi_libs', 'MPI libraries to link with (needs to be shared!)', ['mpich' , 'pthread', 'rt']), |
81 |
# ParMETIS |
# ParMETIS |
82 |
BoolOption('useparmetis', 'Compile parallel version using ParMETIS', 'yes'), |
BoolOption('useparmetis', 'Compile parallel version using ParMETIS', 'yes'), |
84 |
('parmetis_lib_path', 'Path to ParMETIS library', '/usr/lib'), |
('parmetis_lib_path', 'Path to ParMETIS library', '/usr/lib'), |
85 |
('parmetis_libs', 'ParMETIS library to link with', []), |
('parmetis_libs', 'ParMETIS library to link with', []), |
86 |
# PAPI |
# PAPI |
87 |
PathOption('papi_path', 'Path to PAPI includes', None), |
('papi_path', 'Path to PAPI includes', None), |
88 |
PathOption('papi_lib_path', 'Path to PAPI libs', None), |
('papi_lib_path', 'Path to PAPI libs', None), |
89 |
('papi_libs', 'PAPI libraries to link with', []), |
('papi_libs', 'PAPI libraries to link with', []), |
90 |
BoolOption('papi_instrument_solver', 'use PAPI in Solver.c to instrument each iteration of the solver', False), |
BoolOption('papi_instrument_solver', 'use PAPI in Solver.c to instrument each iteration of the solver', False), |
91 |
# MKL |
# MKL |
92 |
PathOption('mkl_path', 'Path to MKL includes', None), |
('mkl_path', 'Path to MKL includes', None), |
93 |
PathOption('mkl_lib_path', 'Path to MKL libs', None), |
('mkl_lib_path', 'Path to MKL libs', None), |
94 |
('mkl_libs', 'MKL libraries to link with', []), |
('mkl_libs', 'MKL libraries to link with', []), |
95 |
# UMFPACK |
# UMFPACK |
96 |
BoolOption('useumfpack', 'switch on/off the usage of UMFPACK', 'no'), |
BoolOption('useumfpack', 'switch on/off the usage of UMFPACK', 'no'), |
97 |
PathOption('ufc_path', 'Path to UFconfig includes', '/usr/include/suitesparse'), |
('ufc_path', 'Path to UFconfig includes', '/usr/include/suitesparse'), |
98 |
PathOption('umf_path', 'Path to UMFPACK includes', '/usr/include'), |
('umf_path', 'Path to UMFPACK includes', '/usr/include/suitesparse'), |
99 |
PathOption('umf_lib_path', 'Path to UMFPACK libs', '/usr/lib'), |
('umf_lib_path', 'Path to UMFPACK libs', '/usr/lib'), |
100 |
('umf_libs', 'UMFPACK libraries to link with', ['umfpack']), |
('umf_libs', 'UMFPACK libraries to link with', ['umfpack']), |
101 |
# AMD (used by UMFPACK) |
# AMD (used by UMFPACK) |
102 |
PathOption('amd_path', 'Path to AMD includes', '/usr/include/suitesparse'), |
('amd_path', 'Path to AMD includes', '/usr/include/suitesparse'), |
103 |
PathOption('amd_lib_path', 'Path to AMD libs', '/usr/lib'), |
('amd_lib_path', 'Path to AMD libs', '/usr/lib'), |
104 |
('amd_libs', 'AMD libraries to link with', ['amd']), |
('amd_libs', 'AMD libraries to link with', ['amd']), |
105 |
# BLAS (used by UMFPACK) |
# BLAS (used by UMFPACK) |
106 |
PathOption('blas_path', 'Path to BLAS includes', '/usr/include/suitesparse'), |
('blas_path', 'Path to BLAS includes', '/usr/include/suitesparse'), |
107 |
PathOption('blas_lib_path', 'Path to BLAS libs', '/usr/lib'), |
('blas_lib_path', 'Path to BLAS libs', '/usr/lib'), |
108 |
('blas_libs', 'BLAS libraries to link with', ['blas']) |
('blas_libs', 'BLAS libraries to link with', ['blas']) |
109 |
) |
) |
110 |
|
|
203 |
|
|
204 |
############ Set up paths for Configure() ###################### |
############ Set up paths for Configure() ###################### |
205 |
|
|
206 |
# Don't allow -I/path to appear multiple times (use a dictionary to remember what we've already added) |
# Make a copy of an environment |
|
seen_dirs_inc = {'/usr/include':1} # Don't need -I/usr/include because it's a default location |
|
|
seen_dirs_lib = {'/usr/lib':1, '/usr/lib64':1} # Don't need -L/usr/lib because it's a default location |
|
|
def seen_dir(dict, dir): |
|
|
status = dir in dict |
|
|
dict[dir] = 1 |
|
|
return status |
|
|
|
|
207 |
# Use env.Clone if available, but fall back on env.Copy for older version of scons |
# Use env.Clone if available, but fall back on env.Copy for older version of scons |
208 |
def clone_env(env): |
def clone_env(env): |
209 |
if 'Clone' in dir(env): return env.Clone() # scons-0.98 |
if 'Clone' in dir(env): return env.Clone() # scons-0.98 |
210 |
else: return env.Copy() # scons-0.96 |
else: return env.Copy() # scons-0.96 |
211 |
|
|
212 |
# Add gcc option -I<Escript>/trunk/include |
# Add cc option -I<Escript>/trunk/include |
213 |
env.Append(CPPPATH = [Dir('include')]) |
env.Append(CPPPATH = [Dir('include')]) |
214 |
|
|
215 |
# Add gcc option -L<Escript>/trunk/lib |
# Add cc option -L<Escript>/trunk/lib |
216 |
env.Append(LIBPATH = [Dir('lib')]) |
env.Append(LIBPATH = [Dir('lib')]) |
217 |
|
|
218 |
# Get the global Subversion revision number for getVersion() method |
# Get the global Subversion revision number for getVersion() method |
244 |
if not conf.CheckCHeader('Python.h'): sys.exit(1) |
if not conf.CheckCHeader('Python.h'): sys.exit(1) |
245 |
if not conf.CheckFunc('Py_Main'): sys.exit(1) |
if not conf.CheckFunc('Py_Main'): sys.exit(1) |
246 |
|
|
247 |
# Add python libraries to environment |
# Add python libraries to environment env |
248 |
if not seen_dir(seen_dirs_inc, env['python_path']): env.Append(CPPPATH = [env['python_path']]) |
env.AppendUnique(CPPPATH = [env['python_path']]) |
249 |
if not seen_dir(seen_dirs_lib, env['python_path']): env.Append(LIBPATH = [env['python_lib_path']]) |
env.AppendUnique(LIBPATH = [env['python_lib_path']]) |
250 |
env.Append(LIBS = [env['python_libs']]) |
env.Append(LIBS = [env['python_libs']]) |
251 |
|
|
252 |
############ boost (required) ################################## |
############ boost (required) ################################## |
258 |
if not conf.CheckCXXHeader('boost/python.hpp'): sys.exit(1) |
if not conf.CheckCXXHeader('boost/python.hpp'): sys.exit(1) |
259 |
if not conf.CheckFunc('PyObject_SetAttr'): sys.exit(1) |
if not conf.CheckFunc('PyObject_SetAttr'): sys.exit(1) |
260 |
|
|
261 |
# Add boost to environment |
# Add boost to environment env |
262 |
if not seen_dir(seen_dirs_inc, env['boost_path']): env.Append(CPPPATH = [env['boost_path']]) |
env.AppendUnique(CPPPATH = [env['boost_path']]) |
263 |
if not seen_dir(seen_dirs_lib, env['boost_lib_path']): env.Append(LIBPATH = [env['boost_lib_path']]) |
env.AppendUnique(LIBPATH = [env['boost_lib_path']]) |
264 |
env.Append(LIBS = [env['boost_libs']]) |
env.Append(LIBS = [env['boost_libs']]) |
265 |
|
|
266 |
############ VTK (optional) #################################### |
############ VTK (optional) #################################### |
272 |
except ImportError: |
except ImportError: |
273 |
env['usevtk'] = 0 |
env['usevtk'] = 0 |
274 |
|
|
275 |
# Add VTK to environment |
# Add VTK to environment env |
276 |
if env['usevtk']: |
if env['usevtk']: |
277 |
env.Append(CPPDEFINES = ['USE_VTK']) |
env.Append(CPPDEFINES = ['USE_VTK']) |
278 |
|
|
286 |
if env['usenetcdf'] and not conf.CheckCHeader('netcdf.h'): env['usenetcdf'] = 0 |
if env['usenetcdf'] and not conf.CheckCHeader('netcdf.h'): env['usenetcdf'] = 0 |
287 |
if env['usenetcdf'] and not conf.CheckFunc('nc_open'): env['usenetcdf'] = 0 |
if env['usenetcdf'] and not conf.CheckFunc('nc_open'): env['usenetcdf'] = 0 |
288 |
|
|
289 |
# Add NetCDF to environment |
# Add NetCDF to environment env |
290 |
if env['usenetcdf']: |
if env['usenetcdf']: |
291 |
if not seen_dir(seen_dirs_inc, env['netCDF_path']): env.Append(CPPPATH = [env['netCDF_path']]) |
env.AppendUnique(CPPPATH = [env['netCDF_path']]) |
292 |
if not seen_dir(seen_dirs_lib, env['netCDF_lib_path']): env.Append(LIBPATH = [env['netCDF_lib_path']]) |
env.AppendUnique(LIBPATH = [env['netCDF_lib_path']]) |
293 |
env.Append(LIBS = [env['netCDF_libs']]) |
env.Append(LIBS = [env['netCDF_libs']]) |
294 |
env.Append(CPPDEFINES = ['USE_NETCDF']) |
env.Append(CPPDEFINES = ['USE_NETCDF']) |
295 |
|
|
314 |
if env['useumfpack'] and not conf.CheckCHeader('umfpack.h'): env['useumfpack'] = 0 |
if env['useumfpack'] and not conf.CheckCHeader('umfpack.h'): env['useumfpack'] = 0 |
315 |
if env['useumfpack'] and not conf.CheckFunc('umfpack_di_symbolic'): env['useumfpack'] = 0 |
if env['useumfpack'] and not conf.CheckFunc('umfpack_di_symbolic'): env['useumfpack'] = 0 |
316 |
|
|
317 |
# Add UMFPACK to environment |
# Add UMFPACK to environment env |
318 |
if env['useumfpack']: |
if env['useumfpack']: |
319 |
if not seen_dir(seen_dirs_inc, env['ufc_path']): env.Append(CPPPATH = [env['ufc_path']]) |
env.AppendUnique(CPPPATH = [env['ufc_path']]) |
320 |
if not seen_dir(seen_dirs_inc, env['umf_path']): env.Append(CPPPATH = [env['umf_path']]) |
env.AppendUnique(CPPPATH = [env['umf_path']]) |
321 |
if not seen_dir(seen_dirs_lib, env['umf_lib_path']): env.Append(LIBPATH = [env['umf_lib_path']]) |
env.AppendUnique(LIBPATH = [env['umf_lib_path']]) |
322 |
env.Append(LIBS = [env['umf_libs']]) |
env.Append(LIBS = [env['umf_libs']]) |
323 |
env.Append(CPPDEFINES = ['UMFPACK']) |
env.Append(CPPDEFINES = ['UMFPACK']) |
324 |
|
|
325 |
if not seen_dir(seen_dirs_inc, env['amd_path']): env.Append(CPPPATH = [env['amd_path']]) |
env.AppendUnique(CPPPATH = [env['amd_path']]) |
326 |
if not seen_dir(seen_dirs_lib, env['amd_lib_path']): env.Append(LIBPATH = [env['amd_lib_path']]) |
env.AppendUnique(LIBPATH = [env['amd_lib_path']]) |
327 |
env.Append(LIBS = [env['amd_libs']]) |
env.Append(LIBS = [env['amd_libs']]) |
328 |
|
|
329 |
if not seen_dir(seen_dirs_inc, env['blas_path']): env.Append(CPPPATH = [env['blas_path']]) |
env.AppendUnique(CPPPATH = [env['blas_path']]) |
330 |
if not seen_dir(seen_dirs_lib, env['blas_lib_path']): env.Append(LIBPATH = [env['blas_lib_path']]) |
env.AppendUnique(LIBPATH = [env['blas_lib_path']]) |
331 |
env.Append(LIBS = [env['blas_libs']]) |
env.Append(LIBS = [env['blas_libs']]) |
332 |
|
|
333 |
############ MPI (optional) #################################### |
############ MPI (optional) #################################### |
347 |
# Create a modified environment for MPI programs |
# Create a modified environment for MPI programs |
348 |
env_mpi = clone_env(env) |
env_mpi = clone_env(env) |
349 |
|
|
350 |
# Add NetCDF to environment copy |
# Add MPI to environment env_mpi |
351 |
if env_mpi['usempi']: |
if env_mpi['usempi']: |
352 |
if not seen_dir(seen_dirs_inc, env['mpi_path']): env_mpi.Append(CPPPATH = [env['mpi_path']]) |
env_mpi.AppendUnique(CPPPATH = [env['mpi_path']]) |
353 |
if not seen_dir(seen_dirs_lib, env['mpi_lib_path']): env_mpi.Append(LIBPATH = [env['mpi_lib_path']]) |
env_mpi.AppendUnique(LIBPATH = [env['mpi_lib_path']]) |
354 |
env_mpi.Append(LIBS = [env['mpi_libs']]) |
env_mpi.Append(LIBS = [env['mpi_libs']]) |
355 |
env_mpi.Append(CPPDEFINES = ['PASO_MPI', 'MPI_NO_CPPBIND', env_mpi['MPICH_IGNORE_CXX_SEEK']]) |
env_mpi.Append(CPPDEFINES = ['PASO_MPI', 'MPI_NO_CPPBIND', env_mpi['MPICH_IGNORE_CXX_SEEK']]) |
356 |
|
|
370 |
if env['useparmetis'] and not conf.CheckCHeader('parmetis.h'): env['useparmetis'] = 0 |
if env['useparmetis'] and not conf.CheckCHeader('parmetis.h'): env['useparmetis'] = 0 |
371 |
if env['useparmetis'] and not conf.CheckFunc('ParMETIS_V3_PartGeomKway'): env['useparmetis'] = 0 |
if env['useparmetis'] and not conf.CheckFunc('ParMETIS_V3_PartGeomKway'): env['useparmetis'] = 0 |
372 |
|
|
373 |
# Add ParMETIS to environment copy |
# Add ParMETIS to environment env_mpi |
374 |
if env['useparmetis']: |
if env['useparmetis']: |
375 |
if not seen_dir(seen_dirs_inc, env['parmetis_path']): env_mpi.Append(CPPPATH = [env['parmetis_path']]) |
env_mpi.AppendUnique(CPPPATH = [env['parmetis_path']]) |
376 |
if not seen_dir(seen_dirs_lib, env['parmetis_lib_path']): env_mpi.Append(LIBPATH = [env['parmetis_lib_path']]) |
env_mpi.AppendUnique(LIBPATH = [env['parmetis_lib_path']]) |
377 |
env_mpi.Append(LIBS = [env['parmetis_libs']]) |
env_mpi.Append(LIBS = [env['parmetis_libs']]) |
378 |
env_mpi.Append(CPPDEFINES = ['USE_PARMETIS']) |
env_mpi.Append(CPPDEFINES = ['USE_PARMETIS']) |
379 |
|
|