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

Contents of /trunk-mpi-branch/SConstruct

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1007 - (show annotations)
Mon Mar 5 01:00:53 2007 UTC (12 years, 6 months ago) by gross
File size: 19324 byte(s)
addSystemMatrix compiles
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=None
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=None
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 ('cc_flags_MPI','C compiler flags to use (Release MPI build)', '-O3 -IPF_ftlacc- -IPF_fma -fno-alias -fno-alias -c99 -w1 -fpic'),
90 ('cc_flags_debug_MPI', 'C compiler flags to use (Debug MPI build)', '-g -O0 -c99 -w1 -fpic '),
91 ('cxx_flags_MPI', 'C++ compiler flags to use (Release MPI build)', '-ansi'),
92 ('cxx_flags_debug_MPI', 'C++ compiler flags to use (Debug MPI build)', '-ansi -DDOASSERT -DDOPROF'),
93 ('ar_flags', 'Static library archiver flags to use', None),
94 ('sys_libs', 'System libraries to link with', None),
95 ('tar_flags','flags for zip files','-c -z'),
96 # MKL
97 PathOption('mkl_path', 'Path to MKL includes', None),
98 PathOption('mkl_lib_path', 'Path to MKL libs', None),
99 ('mkl_libs', 'MKL 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 ('scsl_libs_MPI', 'SCSL libraries to link with for MPI build', None),
105 # UMFPACK
106 PathOption('ufc_path', 'Path to UFconfig includes', ufc_path_default),
107 PathOption('umf_path', 'Path to UMFPACK includes', umf_path_default),
108 PathOption('umf_lib_path', 'Path to UMFPACK libs', umf_lib_path_default),
109 ('umf_libs', 'UMFPACK libraries to link with', umf_libs_default),
110 # AMD (used by UMFPACK)
111 PathOption('amd_path', 'Path to AMD includes', amd_path_default),
112 PathOption('amd_lib_path', 'Path to AMD libs', amd_lib_path_default),
113 ('amd_libs', 'AMD libraries to link with', amd_libs_default),
114 # BLAS
115 PathOption('blas_path', 'Path to BLAS includes', None),
116 PathOption('blas_lib_path', 'Path to BLAS libs', None),
117 ('blas_libs', 'BLAS libraries to link with', None),
118 # netCDF
119 PathOption('netCDF_path', 'Path to netCDF includes', '/usr/local/include'),
120 PathOption('netCDF_lib_path', 'Path to netCDF libs', '/usr/local/lib'),
121 ('netCDF_libs_cxx', 'netCDF C++ libraries to link with', [ 'netcdf_c++', 'netcdf'] ),
122 # Python
123 # locations of include files for python
124 PathOption('python_path', 'Path to Python includes', '/usr/include/python%s.%s'%(sys.version_info[0],sys.version_info[1])),
125 PathOption('python_lib_path', 'Path to Python libs', '/usr/lib'),
126 ('python_lib', 'Python libraries to link with', ["python%s.%s"%(sys.version_info[0],sys.version_info[1]),]),
127 # Boost
128 PathOption('boost_path', 'Path to Boost includes', '/usr/include'),
129 PathOption('boost_lib_path', 'Path to Boost libs', '/usr/lib'),
130 ('boost_lib', 'Boost libraries to link with', ['boost_python',]),
131 # Doc building
132 # PathOption('doxygen_path', 'Path to Doxygen executable', None),
133 # PathOption('epydoc_path', 'Path to Epydoc executable', None),
134 # PAPI
135 PathOption('papi_path', 'Path to PAPI includes', None),
136 PathOption('papi_lib_path', 'Path to PAPI libs', None),
137 ('papi_libs', 'PAPI libraries to link with', None),
138 # MPI
139 BoolOption('useMPI', 'Compile parallel version using MPI', 'no'),
140 PathOption('mpi_path', 'Path to MPI includes', '/usr/include'),
141 PathOption('mpi_lib_path', 'Path to MPI libs','/usr/lib'),
142 ('mpi_libs', 'MPI libraries to link with', [ 'a', 'b' ]),
143 )
144
145 # Initialise Scons Build Environment
146 # check for user environment variables we are interested in
147 try:
148 python_path = os.environ['PYTHONPATH']
149 except KeyError:
150 python_path = ''
151 try:
152 path = os.environ['PATH']
153 except KeyError:
154 path = ''
155 try:
156 ld_library_path = os.environ['LD_LIBRARY_PATH']
157 except KeyError:
158 ld_library_path = ''
159
160 # Note: On the Altix the intel compilers are not automatically
161 # detected by scons intelc.py script. The Altix has a different directory
162 # path and in some locations the "modules" facility is used to support
163 # multiple compiler versions. This forces the need to import the users PATH
164 # environment which isn't the "scons way"
165 # 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)
166 # FIXME: Perhaps a modification to intelc.py will allow better support for ia64 on altix
167
168 if os.name != "nt" and os.uname()[4]=='ia64':
169 env = Environment(ENV = {'PATH':path}, tools = ['default', 'intelc'], options = opts)
170 env['ENV']['PATH'] = path
171 env['ENV']['LD_LIBRARY_PATH'] = ld_library_path
172 env['ENV']['PYTHONPATH'] = python_path
173 if env['CXX'] == 'icpc':
174 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
175 elif os.name == "nt":
176 env = Environment(tools = ['default', 'intelc'], options = opts)
177 env['ENV']['PYTHONPATH'] = python_path
178 else:
179 env = Environment(tools = ['default'], options = opts)
180 env['ENV']['PATH'] = path
181 env['ENV']['LD_LIBRARY_PATH'] = ld_library_path
182 env['ENV']['PYTHONPATH'] = python_path
183
184 # Setup help for options
185 Help(opts.GenerateHelpText(env))
186
187 # Add some customer builders
188 py_builder = Builder(action = scons_extensions.build_py, suffix = '.pyc', src_suffix = '.py', single_source=True)
189 env.Append(BUILDERS = {'PyCompile' : py_builder});
190
191 if env['PLATFORM'] == "win32":
192 runUnitTest_builder = Builder(action = scons_extensions.runUnitTest, suffix = '.passed', src_suffix='.exe', single_source=True)
193 else:
194 runUnitTest_builder = Builder(action = scons_extensions.runUnitTest, suffix = '.passed', single_source=True)
195 env.Append(BUILDERS = {'RunUnitTest' : runUnitTest_builder});
196
197 runPyUnitTest_builder = Builder(action = scons_extensions.runPyUnitTest, suffix = '.passed', src_suffic='.py', single_source=True)
198 env.Append(BUILDERS = {'RunPyUnitTest' : runPyUnitTest_builder});
199
200 # Convert the options which are held in environment variable into python variables for ease of handling and configure compilation options
201 try:
202 incinstall = env['incinstall']
203 env.Append(CPPPATH = [incinstall,])
204 except KeyError:
205 incinstall = None
206 try:
207 libinstall = env['libinstall']
208 env.Append(LIBPATH = [libinstall,])
209 env.PrependENVPath('LD_LIBRARY_PATH', libinstall)
210 if env['PLATFORM'] == "win32":
211 env.PrependENVPath('PATH', libinstall)
212 env.PrependENVPath('PATH', env['boost_lib_path'])
213 except KeyError:
214 libinstall = None
215 try:
216 pyinstall = env['pyinstall']+'/esys' # all targets will install into pyinstall/esys but PYTHONPATH points at straight pyinstall so you go import esys.escript etc
217 env.PrependENVPath('PYTHONPATH', env['pyinstall'])
218 except KeyError:
219 pyinstall = None
220 try:
221 dodebug = env['dodebug']
222 except KeyError:
223 dodebug = None
224 try:
225 useMPI = env['useMPI']
226 except KeyError:
227 useMPI = None
228 try:
229 cc_defines = env['cc_defines']
230 env.Append(CPPDEFINES = cc_defines)
231 except KeyError:
232 pass
233
234 if 'shake71' == socket.gethostname().split('.')[0]:
235 if useMPI:
236 env['CC'] = 'mpicc'
237 env['CXX'] = 'mpiCC'
238
239 if dodebug:
240 if useMPI:
241 try:
242 flags = env['cc_flags_debug_MPI']
243 env.Append(CCFLAGS = flags)
244 except KeyError:
245 pass
246 else:
247 try:
248 flags = env['cc_flags_debug']
249 env.Append(CCFLAGS = flags)
250 except KeyError:
251 pass
252 else:
253 if useMPI:
254 try:
255 flags = env['cc_flags_MPI']
256 env.Append(CCFLAGS = flags)
257 except KeyError:
258 pass
259 else:
260 try:
261 flags = env['cc_flags']
262 env.Append(CCFLAGS = flags)
263 except KeyError:
264 pass
265 if dodebug:
266 if useMPI:
267 try:
268 flags = env['cxx_flags_debug_MPI']
269 env.Append(CXXFLAGS = flags)
270 except KeyError:
271 pass
272 else:
273 try:
274 flags = env['cxx_flags_debug']
275 env.Append(CXXFLAGS = flags)
276 except KeyError:
277 pass
278 else:
279 if useMPI:
280 try:
281 flags = env['cxx_flags_MPI']
282 env.Append(CXXFLAGS = flags)
283 except KeyError:
284 pass
285 else:
286 try:
287 flags = env['cxx_flags']
288 env.Append(CXXFLAGS = flags)
289 except KeyError:
290 pass
291 try:
292 flags = env['ar_flags']
293 env.Append(ARFLAGS = flags)
294 except KeyError:
295 ar_flags = None
296 try:
297 sys_libs = env['sys_libs']
298 except KeyError:
299 sys_libs = ''
300
301 try:
302 tar_flags = env['tar_flags']
303 env.Replace(TARFLAGS = tar_flags)
304 except KeyError:
305 pass
306
307 try:
308 includes = env['mkl_path']
309 env.Append(CPPPATH = [includes,])
310 except KeyError:
311 pass
312
313 try:
314 lib_path = env['mkl_lib_path']
315 env.Append(LIBPATH = [lib_path,])
316 except KeyError:
317 pass
318
319 if useMPI:
320 mkl_libs = ''
321 else:
322 try:
323 mkl_libs = env['mkl_libs']
324 except KeyError:
325 mkl_libs = ''
326
327 try:
328 includes = env['scsl_path']
329 env.Append(CPPPATH = [includes,])
330 except KeyError:
331 pass
332
333 try:
334 lib_path = env['scsl_lib_path']
335 env.Append(LIBPATH = [lib_path,])
336 except KeyError:
337 pass
338
339 if useMPI:
340 try:
341 scsl_libs = env['scsl_libs_MPI']
342 except KeyError:
343 scsl_libs = ''
344 else:
345 try:
346 scsl_libs = env['scsl_libs']
347 except KeyError:
348 scsl_libs = ''
349
350 try:
351 includes = env['umf_path']
352 env.Append(CPPPATH = [includes,])
353 except KeyError:
354 pass
355
356 try:
357 lib_path = env['umf_lib_path']
358 env.Append(LIBPATH = [lib_path,])
359 except KeyError:
360 pass
361
362 if useMPI:
363 umf_libs = ''
364 else:
365 try:
366 umf_libs = env['umf_libs']
367 except KeyError:
368 umf_libs = ''
369
370 try:
371 includes = env['ufc_path']
372 env.Append(CPPPATH = [includes,])
373 except KeyError:
374 pass
375
376 try:
377 includes = env['amd_path']
378 env.Append(CPPPATH = [includes,])
379 except KeyError:
380 pass
381
382 try:
383 lib_path = env['amd_lib_path']
384 env.Append(LIBPATH = [lib_path,])
385 except KeyError:
386 pass
387
388 if useMPI:
389 amd_libs = ''
390 else:
391 try:
392 amd_libs = env['amd_libs']
393 except KeyError:
394 amd_libs = ''
395
396 try:
397 includes = env['blas_path']
398 env.Append(CPPPATH = [includes,])
399 except KeyError:
400 pass
401
402 try:
403 lib_path = env['blas_lib_path']
404 env.Append(LIBPATH = [lib_path,])
405 except KeyError:
406 pass
407
408 try:
409 blas_libs = env['blas_libs']
410 except KeyError:
411 blas_libs = ''
412
413 try:
414 includes = env['netCDF_path']
415 env.Append(CPPPATH = [includes,])
416 except KeyError:
417 pass
418
419 try:
420 lib_path = env['netCDF_lib_path']
421 env.Append(LIBPATH = [lib_path,])
422 except KeyError:
423 pass
424
425 try:
426 netCDF_libs_cxx = env['netCDF_libs_cxx']
427 except KeyError:
428 netCDF_lib_cxx = [ ]
429
430 try:
431 includes = env['boost_path']
432 env.Append(CPPPATH = [includes,])
433 except KeyError:
434 pass
435 try:
436 lib_path = env['boost_lib_path']
437 env.Append(LIBPATH = [lib_path,])
438 except KeyError:
439 pass
440 try:
441 boost_lib = env['boost_lib']
442 except KeyError:
443 boost_lib = None
444 try:
445 includes = env['python_path']
446 env.Append(CPPPATH = [includes,])
447 except KeyError:
448 pass
449 try:
450 lib_path = env['python_lib_path']
451 env.Append(LIBPATH = [lib_path,])
452 except KeyError:
453 pass
454 try:
455 python_lib = env['python_lib']
456 except KeyError:
457 python_lib = None
458 try:
459 doxygen_path = env['doxygen_path']
460 except KeyError:
461 doxygen_path = None
462 try:
463 epydoc_path = env['epydoc_path']
464 except KeyError:
465 epydoc_path = None
466 try:
467 includes = env['papi_path']
468 env.Append(CPPPATH = [includes,])
469 except KeyError:
470 pass
471 try:
472 lib_path = env['papi_lib_path']
473 env.Append(LIBPATH = [lib_path,])
474 except KeyError:
475 pass
476 try:
477 papi_libs = env['papi_libs']
478 except KeyError:
479 papi_libs = None
480
481
482 try:
483 src_zipfile = env.File(env['src_zipfile'])
484 except KeyError:
485 src_zipfile = None
486 try:
487 test_zipfile = env.File(env['test_zipfile'])
488 except KeyError:
489 test_zipfile = None
490 try:
491 examples_zipfile = env.File(env['examples_zipfile'])
492 except KeyError:
493 examples_zipfile = None
494
495 try:
496 src_tarfile = env.File(env['src_tarfile'])
497 except KeyError:
498 src_tarfile = None
499 try:
500 test_tarfile = env.File(env['test_tarfile'])
501 except KeyError:
502 test_tarfile = None
503 try:
504 examples_tarfile = env.File(env['examples_tarfile'])
505 except KeyError:
506 examples_tarfile = None
507
508 try:
509 guide_pdf = env.File(env['guide_pdf'])
510 except KeyError:
511 guide_pdf = None
512
513 try:
514 guide_html_index = env.File('index.htm',env['guide_html'])
515 except KeyError:
516 guide_html_index = None
517
518 try:
519 api_epydoc = env.Dir(env['api_epydoc'])
520 except KeyError:
521 api_epydoc = None
522
523 # Zipgets
524
525 env.Default(libinstall)
526 env.Default(incinstall)
527 env.Default(pyinstall)
528 env.Alias('release_src',[ src_zipfile, src_tarfile ])
529 env.Alias('release_tests',[ test_zipfile, test_tarfile])
530 env.Alias('release_examples',[ examples_zipfile, examples_tarfile])
531 env.Alias('api_epydoc',api_epydoc)
532 env.Alias('guide_pdf', guide_pdf)
533 env.Alias('docs',[ 'release_examples', 'guide_pdf', guide_html_index, api_epydoc])
534 env.Alias('release', ['release_src', 'release_tests', 'docs'])
535 env.Alias('build_tests') # target to build all C++ tests
536 env.Alias('build_py_tests') # target to build all python tests
537 env.Alias('build_all_tests', [ 'build_tests', 'build_py_tests' ] ) # target to build all python tests
538 env.Alias('run_tests', 'build_tests') # target to run all C++ test
539 env.Alias('py_tests', 'build_py_tests') # taget to run all released python tests
540 env.Alias('all_tests', ['run_tests', 'py_tests']) # target to run all C++ and released python tests
541
542 # Python install - esys __init__.py
543 init_target = env.Command(pyinstall+'/__init__.py', None, Touch('$TARGET'))
544 env.Alias(init_target)
545
546 # Allow sconscripts to see the env
547 Export(["env", "incinstall", "libinstall", "pyinstall", "dodebug", "mkl_libs", "scsl_libs", "umf_libs", "amd_libs", "blas_libs", "netCDF_libs_cxx",
548 "boost_lib", "python_lib", "doxygen_path", "epydoc_path", "papi_libs",
549 "sys_libs", "test_zipfile", "src_zipfile", "test_tarfile", "src_tarfile", "examples_tarfile", "examples_zipfile",
550 "guide_pdf", "guide_html_index", "api_epydoc", "useMPI"])
551
552 # End initialisation section
553 # Begin configuration section
554 # adds this file and the scons option directore to the source tar
555 release_srcfiles=[env.File('SConstruct'),]+[ env.File(x) for x in glob.glob('scons/*.py') ]
556 release_testfiles=[env.File('README_TESTS'),]
557 env.Zip(src_zipfile, release_srcfiles)
558 env.Zip(test_zipfile, release_testfiles)
559 env.Tar(src_tarfile, release_srcfiles)
560 env.Tar(test_tarfile, release_testfiles)
561
562 # Insert new components to be build here
563 # FIXME: might be nice to replace this verbosity with a list of targets and some
564 # FIXME: nifty python to create the lengthy but very similar env.Sconscript lines
565 # Third Party libraries
566 env.SConscript(dirs = ['tools/CppUnitTest/src'], build_dir='build/$PLATFORM/tools/CppUnitTest', duplicate=0)
567 # C/C++ Libraries
568 env.SConscript(dirs = ['paso/src'], build_dir='build/$PLATFORM/paso', duplicate=0)
569 # bruce is removed for now as it doesn't really do anything
570 # env.SConscript(dirs = ['bruce/src'], build_dir='build/$PLATFORM/bruce', duplicate=0)
571 env.SConscript(dirs = ['escript/src'], build_dir='build/$PLATFORM/escript', duplicate=0)
572 env.SConscript(dirs = ['esysUtils/src'], build_dir='build/$PLATFORM/esysUtils', duplicate=0)
573 env.SConscript(dirs = ['finley/src'], build_dir='build/$PLATFORM/finley', duplicate=0)
574 env.SConscript(dirs = ['modellib/py_src'], build_dir='build/$PLATFORM/modellib', duplicate=0)
575 env.SConscript(dirs = ['doc'], build_dir='build/$PLATFORM/doc', duplicate=0)
576 env.SConscript(dirs = ['pyvisi/py_src'], build_dir='build/$PLATFORM/pyvisi', duplicate=0)
577 env.SConscript(dirs = ['pycad/py_src'], build_dir='build/$PLATFORM/pycad', duplicate=0)
578
579 # added by Ben Cumming
580 env.SConscript(dirs = ['pythonMPI/src'], build_dir='build/$PLATFORM/pythonMPI', duplicate=0)
581 #env.SConscript(dirs = ['../test'], build_dir='../test/build', duplicate=0)

  ViewVC Help
Powered by ViewVC 1.1.26