/[escript]/trunk-mpi-branch/SConstruct
ViewVC logotype

Contents of /trunk-mpi-branch/SConstruct

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1014 - (show annotations)
Wed Mar 7 09:55:41 2007 UTC (12 years, 5 months ago) by gross
File size: 20128 byte(s)
compiles with mpi now and runs on one processor.
1 # Copyright 2006 by ACcESS MNRF
2 #
3 # http://www.access.edu.au
4 # Primary Business: Queensland, Australia
5 # Licensed under the Open Software License version 3.0
6 # http://www.opensource.org/licenses/osl-3.0.php
7 #
8 #
9 #
10
11 # top-level Scons configuration file for all esys13 modules
12 # Begin initialisation Section
13 # all of this section just intialises default environments and helper
14 # scripts. You shouldn't need to modify this section.
15 EnsureSConsVersion(0,96,91)
16 EnsurePythonVersion(2,3)
17
18 # import tools:
19 import glob
20 import sys, os
21 import socket
22 # Add our extensions
23 if sys.path.count('scons')==0: sys.path.append('scons')
24 import scons_extensions
25
26 # check if UMFPACK is installed on the system:
27 if os.path.isdir('/opt/UMFPACK/Include') and os.path.isdir('/opt/UMFPACK/Lib'):
28 umf_path_default='/opt/UMFPACK/Include'
29 umf_lib_path_default='/opt/UMFPACK/Lib'
30 umf_libs_default=['umfpack']
31 else:
32 umf_path_default=None
33 umf_lib_path_default=None
34 umf_libs_default=[]
35
36 if os.path.isdir('/opt/AMD/Include') and os.path.isdir('/opt/AMD/Lib'):
37 amd_path_default='/opt/AMD/Include'
38 amd_lib_path_default='/opt/AMD/Lib'
39 amd_libs_default=['amd']
40 else:
41 amd_path_default=None
42 amd_lib_path_default=None
43 amd_libs_default=[]
44
45 if os.path.isdir('/opt/UFconfig'):
46 ufc_path_default='/opt/UFconfig'
47 else:
48 ufc_path_default=None
49
50 # Default options and options help text
51 # These are defaults and can be overridden using command line arguments or an options file.
52 # if the options_file or ARGUMENTS do not exist then the ones listed as default here are used
53 # DO NOT CHANGE THEM HERE
54 if ARGUMENTS.get('options_file',0):
55 options_file = ARGUMENTS.get('options_file',0)
56 else:
57 from string import ascii_letters,digits
58 hostname=""
59 for s in socket.gethostname().split('.')[0]:
60 if s in ascii_letters+digits:
61 hostname+=s
62 else:
63 hostname+="_"
64 options_file = "scons/"+hostname+"_options.py"
65
66 opts = Options(options_file, ARGUMENTS)
67 opts.AddOptions(
68 # Where to install esys stuff
69 ('incinstall', 'where the esys headers will be installed', Dir('#.').abspath+'/include'),
70 ('libinstall', 'where the esys libraries will be installed', Dir('#.').abspath+'/lib'),
71 ('pyinstall', 'where the esys python modules will be installed', Dir('#.').abspath),
72 ('src_zipfile', 'the source zip file will be installed.', Dir('#.').abspath+"/release/escript_src.zip"),
73 ('test_zipfile', 'the test zip file will be installed.', Dir('#.').abspath+"/release/escript_tests.zip"),
74 ('src_tarfile', 'the source tar file will be installed.', Dir('#.').abspath+"/release/escript_src.tar.gz"),
75 ('test_tarfile', 'the test tar file will be installed.', Dir('#.').abspath+"/release/escript_tests.tar.gz"),
76 ('examples_tarfile', 'the examples tar file will be installed.', Dir('#.').abspath+"/release/doc/escript_examples.tar.gz"),
77 ('examples_zipfile', 'the examples zip file will be installed.', Dir('#.').abspath+"/release/doc/escript_examples.zip"),
78 ('guide_pdf', 'name of the user guide in pdf format', Dir('#.').abspath+"/release/doc/user/guide.pdf"),
79 ('api_epydoc', 'name of the epydoc api docs directory',Dir('#.').abspath+"/release/doc/epydoc"),
80 ('guide_html', 'name of the directory for user guide in html format', Dir('#.').abspath+"/release/doc/user/html"),
81 # Compilation options
82 BoolOption('dodebug', 'Do you want a debug build?', 'no'),
83 ('options_file', "Optional file containing preferred options. Ignored if it doesn't exist (default: scons/hostname_options.py)", options_file),
84 ('cc_defines','C/C++ defines to use', None),
85 ('cc_flags','C compiler flags to use (Release build)', '-O3 -std=c99 -ffast-math -fPIC -Wno-unknown-pragmas'),
86 ('cc_flags_debug', 'C compiler flags to use (Debug build)', '-g -O0 -ffast-math -std=c99 -fPIC -Wno-unknown-pragmas'),
87 ('cxx_flags', 'C++ compiler flags to use (Release build)', '--no-warn -ansi'),
88 ('cxx_flags_debug', 'C++ compiler flags to use (Debug build)', '--no-warn -ansi -DDOASSERT -DDOPROF'),
89 ('ar_flags', 'Static library archiver flags to use', None),
90 ('sys_libs', 'System libraries to link with', None),
91 ('tar_flags','flags for zip files','-c -z'),
92 # MKL
93 PathOption('mkl_path', 'Path to MKL includes', None),
94 PathOption('mkl_lib_path', 'Path to MKL libs', None),
95 ('mkl_libs', 'MKL libraries to link with', None),
96 # TRILINOS
97 PathOption('trilinos_path', 'Path to TRILINOS includes', None),
98 PathOption('trilinos_lib_path', 'Path to TRILINOS libs', None),
99 ('trilinos_libs', 'TRILINOS libraries to link with', None),
100 # SCSL
101 PathOption('scsl_path', 'Path to SCSL includes', None),
102 PathOption('scsl_lib_path', 'Path to SCSL libs', None),
103 ('scsl_libs', 'SCSL libraries to link with', None),
104 # UMFPACK
105 PathOption('ufc_path', 'Path to UFconfig includes', ufc_path_default),
106 PathOption('umf_path', 'Path to UMFPACK includes', umf_path_default),
107 PathOption('umf_lib_path', 'Path to UMFPACK libs', umf_lib_path_default),
108 ('umf_libs', 'UMFPACK libraries to link with', umf_libs_default),
109 # AMD (used by UMFPACK)
110 PathOption('amd_path', 'Path to AMD includes', amd_path_default),
111 PathOption('amd_lib_path', 'Path to AMD libs', amd_lib_path_default),
112 ('amd_libs', 'AMD libraries to link with', amd_libs_default),
113 # BLAS
114 PathOption('blas_path', 'Path to BLAS includes', None),
115 PathOption('blas_lib_path', 'Path to BLAS libs', None),
116 ('blas_libs', 'BLAS libraries to link with', None),
117 # netCDF
118 PathOption('netCDF_path', 'Path to netCDF includes', '/usr/local/include'),
119 PathOption('netCDF_lib_path', 'Path to netCDF libs', '/usr/local/lib'),
120 ('netCDF_libs_cxx', 'netCDF C++ libraries to link with', [ 'netcdf_c++', 'netcdf'] ),
121 # Python
122 # locations of include files for python
123 PathOption('python_path', 'Path to Python includes', '/usr/include/python%s.%s'%(sys.version_info[0],sys.version_info[1])),
124 PathOption('python_lib_path', 'Path to Python libs', '/usr/lib'),
125 ('python_libs', 'Python libraries to link with', ["python%s.%s"%(sys.version_info[0],sys.version_info[1]),]),
126 # Boost
127 PathOption('boost_path', 'Path to Boost includes', '/usr/include'),
128 PathOption('boost_lib_path', 'Path to Boost libs', '/usr/lib'),
129 ('boost_libs', 'Boost libraries to link with', ['boost_python',]),
130 # Doc building
131 # PathOption('doxygen_path', 'Path to Doxygen executable', None),
132 # PathOption('epydoc_path', 'Path to Epydoc executable', None),
133 # PAPI
134 PathOption('papi_path', 'Path to PAPI includes', None),
135 PathOption('papi_lib_path', 'Path to PAPI libs', None),
136 ('papi_libs', 'PAPI libraries to link with', None),
137 # MPI
138 BoolOption('useMPI', 'Compile parallel version using MPI', 'no'),
139 PathOption('mpi_path', 'Path to MPI includes', '/usr/include'),
140 PathOption('mpi_lib_path', 'Path to MPI libs','/usr/lib'),
141 ('mpi_libs', 'MPI libraries to link with', [ 'mpich' ]),
142 )
143
144 # Initialise Scons Build Environment
145 # check for user environment variables we are interested in
146 try:
147 python_path = os.environ['PYTHONPATH']
148 except KeyError:
149 python_path = ''
150 try:
151 path = os.environ['PATH']
152 except KeyError:
153 path = ''
154 try:
155 ld_library_path = os.environ['LD_LIBRARY_PATH']
156 except KeyError:
157 ld_library_path = ''
158
159 # Note: On the Altix the intel compilers are not automatically
160 # detected by scons intelc.py script. The Altix has a different directory
161 # path and in some locations the "modules" facility is used to support
162 # multiple compiler versions. This forces the need to import the users PATH
163 # environment which isn't the "scons way"
164 # This doesn't impact linux and windows which will use the default compiler (g++ or msvc, or the intel compiler if it is installed on both platforms)
165 # FIXME: Perhaps a modification to intelc.py will allow better support for ia64 on altix
166
167 if os.name != "nt" and os.uname()[4]=='ia64':
168 env = Environment(ENV = {'PATH':path}, tools = ['default', 'intelc'], options = opts)
169 env['ENV']['PATH'] = path
170 env['ENV']['LD_LIBRARY_PATH'] = ld_library_path
171 env['ENV']['PYTHONPATH'] = python_path
172 if env['CXX'] == 'icpc':
173 env['LINK'] = env['CXX'] # version >=9 of intel c++ compiler requires use of icpc to link in C++ runtimes (icc does not). FIXME: this behaviour could be directly incorporated into scons intelc.py
174 elif os.name == "nt":
175 env = Environment(tools = ['default', 'intelc'], options = opts)
176 env['ENV']['PYTHONPATH'] = python_path
177 else:
178 env = Environment(tools = ['default'], options = opts)
179 env['ENV']['PATH'] = path
180 env['ENV']['LD_LIBRARY_PATH'] = ld_library_path
181 env['ENV']['PYTHONPATH'] = python_path
182
183 # Setup help for options
184 Help(opts.GenerateHelpText(env))
185
186 # Add some customer builders
187 py_builder = Builder(action = scons_extensions.build_py, suffix = '.pyc', src_suffix = '.py', single_source=True)
188 env.Append(BUILDERS = {'PyCompile' : py_builder});
189
190 if env['PLATFORM'] == "win32":
191 runUnitTest_builder = Builder(action = scons_extensions.runUnitTest, suffix = '.passed', src_suffix='.exe', single_source=True)
192 else:
193 runUnitTest_builder = Builder(action = scons_extensions.runUnitTest, suffix = '.passed', single_source=True)
194 env.Append(BUILDERS = {'RunUnitTest' : runUnitTest_builder});
195
196 runPyUnitTest_builder = Builder(action = scons_extensions.runPyUnitTest, suffix = '.passed', src_suffic='.py', single_source=True)
197 env.Append(BUILDERS = {'RunPyUnitTest' : runPyUnitTest_builder});
198
199 # Convert the options which are held in environment variable into python variables for ease of handling and configure compilation options
200 try:
201 incinstall = env['incinstall']
202 env.Append(CPPPATH = [incinstall,])
203 except KeyError:
204 incinstall = None
205 try:
206 libinstall = env['libinstall']
207 env.Append(LIBPATH = [libinstall,])
208 env.PrependENVPath('LD_LIBRARY_PATH', libinstall)
209 if env['PLATFORM'] == "win32":
210 env.PrependENVPath('PATH', libinstall)
211 env.PrependENVPath('PATH', env['boost_lib_path'])
212 except KeyError:
213 libinstall = None
214 try:
215 pyinstall = env['pyinstall']+'/esys' # all targets will install into pyinstall/esys but PYTHONPATH points at straight pyinstall so you go import esys.escript etc
216 env.PrependENVPath('PYTHONPATH', env['pyinstall'])
217 except KeyError:
218 pyinstall = None
219 try:
220 dodebug = env['dodebug']
221 except KeyError:
222 dodebug = None
223 try:
224 useMPI = env['useMPI']
225 except KeyError:
226 useMPI = None
227 try:
228 cc_defines = env['cc_defines']
229 env.Append(CPPDEFINES = cc_defines)
230 except KeyError:
231 pass
232
233 # mpi?
234 if useMPI:
235 env.Append(CPPDEFINES=['PASO_MPI',])
236 env.Append(CDEFINES=['PASO_MPI',])
237
238 if dodebug:
239 try:
240 flags = env['cc_flags_debug']
241 env.Append(CCFLAGS = flags)
242 except KeyError:
243 pass
244 else:
245 try:
246 flags = env['cc_flags']
247 env.Append(CCFLAGS = flags)
248 except KeyError:
249 pass
250 if dodebug:
251 try:
252 flags = env['cxx_flags_debug']
253 env.Append(CXXFLAGS = flags)
254 except KeyError:
255 pass
256 else:
257 try:
258 flags = env['cxx_flags']
259 env.Append(CXXFLAGS = flags)
260 except KeyError:
261 pass
262 try:
263 flags = env['ar_flags']
264 env.Append(ARFLAGS = flags)
265 except KeyError:
266 ar_flags = None
267 try:
268 sys_libs = env['sys_libs']
269 except KeyError:
270 sys_libs = []
271
272 try:
273 tar_flags = env['tar_flags']
274 env.Replace(TARFLAGS = tar_flags)
275 except KeyError:
276 pass
277
278
279 # ============= set mkl (but only of no MPI) =====================================
280 if not useMPI:
281 try:
282 includes = env['mkl_path']
283 env.Append(CPPPATH = [includes,])
284 except KeyError:
285 pass
286
287 try:
288 lib_path = env['mkl_lib_path']
289 env.Append(LIBPATH = [lib_path,])
290 except KeyError:
291 pass
292
293 try:
294 mkl_libs = env['mkl_libs']
295 except KeyError:
296 mkl_libs = []
297 else:
298 mkl_libs = []
299
300 # ============= set scsl (but only of no MPI) =====================================
301 if not useMPI:
302 try:
303 includes = env['scsl_path']
304 env.Append(CPPPATH = [includes,])
305 except KeyError:
306 pass
307
308 try:
309 lib_path = env['scsl_lib_path']
310 env.Append(LIBPATH = [lib_path,])
311 except KeyError:
312 pass
313
314 try:
315 scsl_libs = env['scsl_libs']
316 except KeyError:
317 scsl_libs = [ ]
318
319 else:
320 scsl_libs = []
321
322 # ============= set TRILINOS (but only with MPI) =====================================
323 if useMPI:
324 try:
325 includes = env['trilinos_path']
326 env.Append(CPPPATH = [includes,])
327 except KeyError:
328 pass
329
330 try:
331 lib_path = env['trilinos_lib_path']
332 env.Append(LIBPATH = [lib_path,])
333 except KeyError:
334 pass
335
336 try:
337 trilinos_libs = env['trilinos_libs']
338 except KeyError:
339 trilinos_libs = []
340 else:
341 trilinos_libs = []
342
343
344 # ============= set umfpack (but only without MPI) =====================================
345 umfpack_libs=[ ]
346 if not useMPI:
347 try:
348 includes = env['umf_path']
349 env.Append(CPPPATH = [includes,])
350 except KeyError:
351 pass
352
353 try:
354 lib_path = env['umf_lib_path']
355 env.Append(LIBPATH = [lib_path,])
356 except KeyError:
357 pass
358
359 try:
360 umf_libs = env['umf_libs']
361 umfpack_libs+=umf_libs
362 except KeyError:
363 pass
364
365 try:
366 includes = env['ufc_path']
367 env.Append(CPPPATH = [includes,])
368 except KeyError:
369 pass
370
371 try:
372 includes = env['amd_path']
373 env.Append(CPPPATH = [includes,])
374 except KeyError:
375 pass
376
377 try:
378 lib_path = env['amd_lib_path']
379 env.Append(LIBPATH = [lib_path,])
380 except KeyError:
381 pass
382
383 try:
384 amd_libs = env['amd_libs']
385 umfpack_libs+=amd_libs
386 except KeyError:
387 pass
388
389 # ============= set blas =====================================
390 try:
391 includes = env['blas_path']
392 env.Append(CPPPATH = [includes,])
393 except KeyError:
394 pass
395
396 try:
397 lib_path = env['blas_lib_path']
398 env.Append(LIBPATH = [lib_path,])
399 except KeyError:
400 pass
401
402 try:
403 blas_libs = env['blas_libs']
404 except KeyError:
405 blas_libs = [ ]
406
407 # ============= set netcdf =====================================
408 try:
409 includes = env['netCDF_path']
410 env.Append(CPPPATH = [includes,])
411 except KeyError:
412 pass
413
414 try:
415 lib_path = env['netCDF_lib_path']
416 env.Append(LIBPATH = [lib_path,])
417 except KeyError:
418 pass
419
420 try:
421 netCDF_libs_cxx = env['netCDF_libs_cxx']
422 except KeyError:
423 netCDF_lib_cxx = [ ]
424
425 # ============= set boost =====================================
426 try:
427 includes = env['boost_path']
428 env.Append(CPPPATH = [includes,])
429 except KeyError:
430 pass
431 try:
432 lib_path = env['boost_lib_path']
433 env.Append(LIBPATH = [lib_path,])
434 except KeyError:
435 pass
436 try:
437 boost_libs = env['boost_libs']
438 except KeyError:
439 boost_libs = [ ]
440 # ============= set python =====================================
441 try:
442 includes = env['python_path']
443 env.Append(CPPPATH = [includes,])
444 except KeyError:
445 pass
446 try:
447 lib_path = env['python_lib_path']
448 env.Append(LIBPATH = [lib_path,])
449 except KeyError:
450 pass
451 try:
452 python_libs = env['python_libs']
453 except KeyError:
454 python_libs = []
455
456 # ============= set mpi =====================================
457 if useMPI:
458 try:
459 includes = env['mpi_path']
460 env.Append(CPPPATH = [includes,])
461 except KeyError:
462 pass
463 try:
464 lib_path = env['mpi_lib_path']
465 env.Append(LIBPATH = [lib_path,])
466 except KeyError:
467 pass
468 try:
469 mpi_libs = env['mpi_libs']
470 except KeyError:
471 mpi_libs = []
472 else:
473 mpi_libs=[]
474 # ============= set papi =====================================
475 try:
476 includes = env['papi_path']
477 env.Append(CPPPATH = [includes,])
478 except KeyError:
479 pass
480 try:
481 lib_path = env['papi_lib_path']
482 env.Append(LIBPATH = [lib_path,])
483 except KeyError:
484 pass
485 try:
486 papi_libs = env['papi_libs']
487 except KeyError:
488 papi_libs = None
489
490
491 # ============= and some helpers =====================================
492 try:
493 doxygen_path = env['doxygen_path']
494 except KeyError:
495 doxygen_path = None
496 try:
497 epydoc_path = env['epydoc_path']
498 except KeyError:
499 epydoc_path = None
500 try:
501 src_zipfile = env.File(env['src_zipfile'])
502 except KeyError:
503 src_zipfile = None
504 try:
505 test_zipfile = env.File(env['test_zipfile'])
506 except KeyError:
507 test_zipfile = None
508 try:
509 examples_zipfile = env.File(env['examples_zipfile'])
510 except KeyError:
511 examples_zipfile = None
512
513 try:
514 src_tarfile = env.File(env['src_tarfile'])
515 except KeyError:
516 src_tarfile = None
517 try:
518 test_tarfile = env.File(env['test_tarfile'])
519 except KeyError:
520 test_tarfile = None
521 try:
522 examples_tarfile = env.File(env['examples_tarfile'])
523 except KeyError:
524 examples_tarfile = None
525
526 try:
527 guide_pdf = env.File(env['guide_pdf'])
528 except KeyError:
529 guide_pdf = None
530
531 try:
532 guide_html_index = env.File('index.htm',env['guide_html'])
533 except KeyError:
534 guide_html_index = None
535
536 try:
537 api_epydoc = env.Dir(env['api_epydoc'])
538 except KeyError:
539 api_epydoc = None
540
541
542
543 # Zipgets
544
545 env.Default(libinstall)
546 env.Default(incinstall)
547 env.Default(pyinstall)
548 env.Alias('release_src',[ src_zipfile, src_tarfile ])
549 env.Alias('release_tests',[ test_zipfile, test_tarfile])
550 env.Alias('release_examples',[ examples_zipfile, examples_tarfile])
551 env.Alias('api_epydoc',api_epydoc)
552 env.Alias('guide_pdf', guide_pdf)
553 env.Alias('docs',[ 'release_examples', 'guide_pdf', guide_html_index, api_epydoc])
554 env.Alias('release', ['release_src', 'release_tests', 'docs'])
555 env.Alias('build_tests') # target to build all C++ tests
556 env.Alias('build_py_tests') # target to build all python tests
557 env.Alias('build_all_tests', [ 'build_tests', 'build_py_tests' ] ) # target to build all python tests
558 env.Alias('run_tests', 'build_tests') # target to run all C++ test
559 env.Alias('py_tests', 'build_py_tests') # taget to run all released python tests
560 env.Alias('all_tests', ['run_tests', 'py_tests']) # target to run all C++ and released python tests
561
562 # Python install - esys __init__.py
563 init_target = env.Command(pyinstall+'/__init__.py', None, Touch('$TARGET'))
564 env.Alias(init_target)
565
566 # Allow sconscripts to see the env
567 Export(["env", "incinstall", "libinstall", "pyinstall", "dodebug", "mkl_libs", "scsl_libs", "umfpack_libs",
568 "blas_libs", "netCDF_libs_cxx", "trilinos_libs", "mpi_libs",
569 "boost_libs", "python_libs", "doxygen_path", "epydoc_path", "papi_libs",
570 "sys_libs", "test_zipfile", "src_zipfile", "test_tarfile", "src_tarfile", "examples_tarfile", "examples_zipfile",
571 "guide_pdf", "guide_html_index", "api_epydoc", "useMPI"])
572
573 # End initialisation section
574 # Begin configuration section
575 # adds this file and the scons option directore to the source tar
576 release_srcfiles=[env.File('SConstruct'),]+[ env.File(x) for x in glob.glob('scons/*.py') ]
577 release_testfiles=[env.File('README_TESTS'),]
578 env.Zip(src_zipfile, release_srcfiles)
579 env.Zip(test_zipfile, release_testfiles)
580 env.Tar(src_tarfile, release_srcfiles)
581 env.Tar(test_tarfile, release_testfiles)
582
583 # Insert new components to be build here
584 # FIXME: might be nice to replace this verbosity with a list of targets and some
585 # FIXME: nifty python to create the lengthy but very similar env.Sconscript lines
586 # Third Party libraries
587 env.SConscript(dirs = ['tools/CppUnitTest/src'], build_dir='build/$PLATFORM/tools/CppUnitTest', duplicate=0)
588 # C/C++ Libraries
589 env.SConscript(dirs = ['paso/src'], build_dir='build/$PLATFORM/paso', duplicate=0)
590 # bruce is removed for now as it doesn't really do anything
591 # env.SConscript(dirs = ['bruce/src'], build_dir='build/$PLATFORM/bruce', duplicate=0)
592 env.SConscript(dirs = ['escript/src'], build_dir='build/$PLATFORM/escript', duplicate=0)
593 env.SConscript(dirs = ['esysUtils/src'], build_dir='build/$PLATFORM/esysUtils', duplicate=0)
594 env.SConscript(dirs = ['finley/src'], build_dir='build/$PLATFORM/finley', duplicate=0)
595 env.SConscript(dirs = ['modellib/py_src'], build_dir='build/$PLATFORM/modellib', duplicate=0)
596 env.SConscript(dirs = ['doc'], build_dir='build/$PLATFORM/doc', duplicate=0)
597 env.SConscript(dirs = ['pyvisi/py_src'], build_dir='build/$PLATFORM/pyvisi', duplicate=0)
598 env.SConscript(dirs = ['pycad/py_src'], build_dir='build/$PLATFORM/pycad', duplicate=0)
599
600 # added by Ben Cumming
601 env.SConscript(dirs = ['pythonMPI/src'], build_dir='build/$PLATFORM/pythonMPI', duplicate=0)
602 #env.SConscript(dirs = ['../test'], build_dir='../test/build', duplicate=0)

  ViewVC Help
Powered by ViewVC 1.1.26