/[escript]/branches/arrayview_from_1695_trunk/SConstruct
ViewVC logotype

Contents of /branches/arrayview_from_1695_trunk/SConstruct

Parent Directory Parent Directory | Revision Log Revision Log


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

  ViewVC Help
Powered by ViewVC 1.1.26