/[escript]/trunk/SConstruct
ViewVC logotype

Annotation of /trunk/SConstruct

Parent Directory Parent Directory | Revision Log Revision Log


Revision 805 - (hide annotations)
Thu Aug 10 06:09:02 2006 UTC (12 years, 9 months ago) by gross
File size: 17934 byte(s)
first steps toward UMFPACK
1 elspeth 643 # 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 jgs 214 #
9 elspeth 643 #
10 jgs 455
11 robwdcock 682 # 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 jgs 214
18 gross 700 # import tools:
19     import glob
20 robwdcock 682 import sys, os
21     # Add our extensions
22     if sys.path.count('scons')==0: sys.path.append('scons')
23     import scons_extensions
24 jgs 192
25 gross 805 # check if UMFPACK is installed on the system:
26     if os.path.isdir('/opt/UMFPACK/Include') and os.path.isdir('/opt/UMFPACK/Lib') and os.path.isdir('/opt/AMD/Lib'):
27     umf_path_default='/opt/UMFPACK/Include'
28     umf_lib_path_default='/opt/UMFPACK/Lib'
29     amd_lib_path_default='/opt/AMD/Lib'
30     umf_libs_default=['amd', 'umfpack']
31     else:
32     umf_path_default=None
33     umf_lib_path_default=None
34     amd_lib_path_default=None
35     umf_libs_default=None
36     if os.path.isdir('/opt/GotoBLAS'):
37     blas_path_default='/opt/GotoBLAS'
38     blas_lib_path_default='/opt/GotoBLAS'
39     blas_libs_default=['goto',]
40     else:
41     blas_path_default=None
42     blas_lib_path_default=None
43     blas_libs_default=None
44 robwdcock 682 # Default options and options help text
45     # These are defaults and can be overridden using command line arguments or an options file.
46     # if the options_file or ARGUMENTS do not exist then the ones listed as default here are used
47     # DO NOT CHANGE THEM HERE
48     if ARGUMENTS.get('options_file',0):
49     options_file = ARGUMENTS.get('options_file',0)
50     else:
51     import socket
52     from string import ascii_letters,digits
53     hostname=""
54     for s in socket.gethostname().split('.')[0]:
55     if s in ascii_letters+digits:
56     hostname+=s
57     else:
58     hostname+="_"
59     options_file = "scons/"+hostname+"_options.py"
60 jgs 214
61 robwdcock 682 opts = Options(options_file, ARGUMENTS)
62     opts.AddOptions(
63     # Where to install esys stuff
64     ('incinstall', 'where the esys headers will be installed', Dir('#.').abspath+'/include'),
65     ('libinstall', 'where the esys libraries will be installed', Dir('#.').abspath+'/lib'),
66     ('pyinstall', 'where the esys python modules will be installed', Dir('#.').abspath),
67 gross 700 ('src_zipfile', 'the source zip file will be installed.', Dir('#.').abspath+"/release/escript_src.zip"),
68 gross 707 ('test_zipfile', 'the test zip file will be installed.', Dir('#.').abspath+"/release/escript_tests.zip"),
69 gross 700 ('src_tarfile', 'the source tar file will be installed.', Dir('#.').abspath+"/release/escript_src.tar.gz"),
70 gross 707 ('test_tarfile', 'the test tar file will be installed.', Dir('#.').abspath+"/release/escript_tests.tar.gz"),
71     ('examples_tarfile', 'the examples tar file will be installed.', Dir('#.').abspath+"/release/doc/escript_examples.tar.gz"),
72     ('examples_zipfile', 'the examples zip file will be installed.', Dir('#.').abspath+"/release/doc/escript_examples.zip"),
73     ('guide_pdf', 'name of the user guide in pdf format', Dir('#.').abspath+"/release/doc/user/guide.pdf"),
74 elspeth 712 ('api_epydoc', 'name of the epydoc api docs directory',Dir('#.').abspath+"/release/doc/epydoc"),
75 gross 707 ('guide_html', 'name of the directory for user guide in html format', Dir('#.').abspath+"/release/doc/user/html"),
76 robwdcock 682 # Compilation options
77 gross 700 BoolOption('dodebug', 'Do you want a debug build?', 'no'),
78 robwdcock 682 ('options_file', "Optional file containing preferred options. Ignored if it doesn't exist (default: scons/hostname_options.py)", options_file),
79     ('cc_defines','C/C++ defines to use', None),
80 gross 700 ('cc_flags','C compiler flags to use (Release build)', '-O3 -std=c99 -ffast-math -fpic -Wno-unknown-pragmas'),
81     ('cc_flags_debug', 'C compiler flags to use (Debug build)', '-g -O0 -ffast-math -std=c99 -fpic -Wno-unknown-pragmas'),
82     ('cxx_flags', 'C++ compiler flags to use (Release build)', '--no-warn -ansi'),
83     ('cxx_flags_debug', 'C++ compiler flags to use (Debug build)', '--no-warn -ansi -DDOASSERT -DDOPROF'),
84 bcumming 759 ('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'),
85     ('cc_flags_debug_MPI', 'C compiler flags to use (Debug MPI build)', '-g -O0 -c99 -w1 -fpic -wd161'),
86     ('cxx_flags_MPI', 'C++ compiler flags to use (Release MPI build)', '-ansi -wd1563 -wd161'),
87     ('cxx_flags_debug_MPI', 'C++ compiler flags to use (Debug MPI build)', '-ansi -DDOASSERT -DDOPROF -wd1563 -wd161'),
88 robwdcock 682 ('ar_flags', 'Static library archiver flags to use', None),
89     ('sys_libs', 'System libraries to link with', None),
90 gross 700 ('tar_flags','flags for zip files','-c -z'),
91 robwdcock 682 # MKL
92     PathOption('mkl_path', 'Path to MKL includes', None),
93     PathOption('mkl_lib_path', 'Path to MKL libs', None),
94     ('mkl_libs', 'MKL libraries to link with', None),
95     # SCSL
96     PathOption('scsl_path', 'Path to SCSL includes', None),
97     PathOption('scsl_lib_path', 'Path to SCSL libs', None),
98     ('scsl_libs', 'SCSL libraries to link with', None),
99 bcumming 759 ('scsl_libs_MPI', 'SCSL libraries to link with for MPI build', None),
100 robwdcock 682 # UMFPACK
101 gross 805 PathOption('umf_path', 'Path to UMF includes', umf_path_default),
102     PathOption('umf_lib_path', 'Path to UMF libs', umf_lib_path_default),
103     PathOption('amd_lib_path', 'Path to UMF libs', amd_lib_path_default),
104     ('umf_libs', 'UMF libraries to link with', umf_libs_default),
105     # BLAS
106     PathOption('blas_path', 'Path to BLAS includes', blas_path_default),
107     PathOption('blas_lib_path', 'Path to BLAS libs', blas_lib_path_default ),
108     ('blas_libs', 'BLAS libraries to link with', blas_libs_default ),
109 robwdcock 682 # Python
110 gross 685 # locations of include files for python
111     PathOption('python_path', 'Path to Python includes', '/usr/include/python%s.%s'%(sys.version_info[0],sys.version_info[1])),
112 robwdcock 682 PathOption('python_lib_path', 'Path to Python libs', '/usr/lib'),
113 gross 685 ('python_lib', 'Python libraries to link with', ["python%s.%s"%(sys.version_info[0],sys.version_info[1]),]),
114 robwdcock 682 # Boost
115     PathOption('boost_path', 'Path to Boost includes', '/usr/include'),
116     PathOption('boost_lib_path', 'Path to Boost libs', '/usr/lib'),
117     ('boost_lib', 'Boost libraries to link with', ['boost_python',]),
118     # Doc building
119 gross 722 # PathOption('doxygen_path', 'Path to Doxygen executable', None),
120     # PathOption('epydoc_path', 'Path to Epydoc executable', None),
121 robwdcock 682 # PAPI
122     PathOption('papi_path', 'Path to PAPI includes', None),
123     PathOption('papi_lib_path', 'Path to PAPI libs', None),
124     ('papi_libs', 'PAPI libraries to link with', None),
125 bcumming 759 # MPI
126     BoolOption('useMPI', 'Compile parallel version using MPI', 'no'),
127 robwdcock 682 )
128    
129     # Initialise Scons Build Environment
130     # check for user environment variables we are interested in
131     try:
132     python_path = os.environ['PYTHONPATH']
133     except KeyError:
134     python_path = ''
135     try:
136     path = os.environ['PATH']
137     except KeyError:
138     path = ''
139     try:
140     ld_library_path = os.environ['LD_LIBRARY_PATH']
141     except KeyError:
142     ld_library_path = ''
143    
144     # Note: On the Altix the intel compilers are not automatically
145     # detected by scons intelc.py script. The Altix has a different directory
146     # path and in some locations the "modules" facility is used to support
147     # multiple compiler versions. This forces the need to import the users PATH
148     # environment which isn't the "scons way"
149     # 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)
150     # FIXME: Perhaps a modification to intelc.py will allow better support for ia64 on altix
151    
152     if os.name != "nt" and os.uname()[4]=='ia64':
153 robwdcock 688 env = Environment(ENV = {'PATH':path}, tools = ['default', 'intelc'], options = opts)
154 robwdcock 684 env['ENV']['PATH'] = path
155     env['ENV']['LD_LIBRARY_PATH'] = ld_library_path
156     env['ENV']['PYTHONPATH'] = python_path
157 robwdcock 682 if env['CXX'] == 'icpc':
158     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
159     elif os.name == "nt":
160 robwdcock 684 env = Environment(tools = ['default', 'intelc'], options = opts)
161     env['ENV']['PYTHONPATH'] = python_path
162 robwdcock 682 else:
163 robwdcock 684 env = Environment(tools = ['default'], options = opts)
164     env['ENV']['PATH'] = path
165     env['ENV']['LD_LIBRARY_PATH'] = ld_library_path
166     env['ENV']['PYTHONPATH'] = python_path
167 robwdcock 682
168     # Setup help for options
169     Help(opts.GenerateHelpText(env))
170    
171     # Add some customer builders
172     py_builder = Builder(action = scons_extensions.build_py, suffix = '.pyc', src_suffix = '.py', single_source=True)
173     env.Append(BUILDERS = {'PyCompile' : py_builder});
174    
175     if env['PLATFORM'] == "win32":
176     runUnitTest_builder = Builder(action = scons_extensions.runUnitTest, suffix = '.passed', src_suffix='.exe', single_source=True)
177     else:
178     runUnitTest_builder = Builder(action = scons_extensions.runUnitTest, suffix = '.passed', single_source=True)
179     env.Append(BUILDERS = {'RunUnitTest' : runUnitTest_builder});
180    
181     runPyUnitTest_builder = Builder(action = scons_extensions.runPyUnitTest, suffix = '.passed', src_suffic='.py', single_source=True)
182     env.Append(BUILDERS = {'RunPyUnitTest' : runPyUnitTest_builder});
183    
184     # Convert the options which are held in environment variable into python variables for ease of handling and configure compilation options
185     try:
186     incinstall = env['incinstall']
187     env.Append(CPPPATH = [incinstall,])
188     except KeyError:
189     incinstall = None
190     try:
191     libinstall = env['libinstall']
192     env.Append(LIBPATH = [libinstall,])
193     env.PrependENVPath('LD_LIBRARY_PATH', libinstall)
194 woo409 757 if env['PLATFORM'] == "win32":
195     env.PrependENVPath('PATH', libinstall)
196     env.PrependENVPath('PATH', env['boost_lib_path'])
197 robwdcock 682 except KeyError:
198     libinstall = None
199     try:
200     pyinstall = env['pyinstall']+'/esys' # all targets will install into pyinstall/esys but PYTHONPATH points at straight pyinstall so you go import esys.escript etc
201     env.PrependENVPath('PYTHONPATH', env['pyinstall'])
202     except KeyError:
203     pyinstall = None
204     try:
205     dodebug = env['dodebug']
206     except KeyError:
207     dodebug = None
208     try:
209 bcumming 759 useMPI = env['useMPI']
210     except KeyError:
211     useMPI = None
212     try:
213 robwdcock 682 cc_defines = env['cc_defines']
214 woo409 757 env.Append(CPPDEFINES = cc_defines)
215 robwdcock 682 except KeyError:
216     pass
217     if dodebug:
218 bcumming 759 if useMPI:
219     try:
220     flags = env['cc_flags_debug_MPI']
221     env.Append(CCFLAGS = flags)
222     except KeyError:
223     pass
224     else:
225     try:
226 robwdcock 682 flags = env['cc_flags_debug']
227     env.Append(CCFLAGS = flags)
228 bcumming 759 except KeyError:
229 robwdcock 682 pass
230     else:
231 bcumming 759 if useMPI:
232 robwdcock 682 try:
233 bcumming 759 flags = env['cc_flags_MPI']
234     env.Append(CCFLAGS = flags)
235     except KeyError:
236     pass
237     else:
238     try:
239 robwdcock 682 flags = env['cc_flags']
240     env.Append(CCFLAGS = flags)
241     except KeyError:
242     pass
243     if dodebug:
244 bcumming 759 if useMPI:
245     try:
246     flags = env['cxx_flags_debug_MPI']
247     env.Append(CXXFLAGS = flags)
248     except KeyError:
249     pass
250     else:
251     try:
252     flags = env['cxx_flags_debug']
253     env.Append(CXXFLAGS = flags)
254     except KeyError:
255     pass
256 robwdcock 682 else:
257 bcumming 759 if useMPI:
258     try:
259     flags = env['cxx_flags_MPI']
260     env.Append(CXXFLAGS = flags)
261     except KeyError:
262     pass
263     else:
264     try:
265     flags = env['cxx_flags']
266     env.Append(CXXFLAGS = flags)
267     except KeyError:
268     pass
269 robwdcock 682 try:
270     flags = env['ar_flags']
271     env.Append(ARFLAGS = flags)
272     except KeyError:
273     ar_flags = None
274     try:
275     sys_libs = env['sys_libs']
276     except KeyError:
277     sys_libs = ''
278    
279     try:
280 gross 700 tar_flags = env['tar_flags']
281     env.Replace(TARFLAGS = tar_flags)
282     except KeyError:
283     pass
284    
285     try:
286 robwdcock 682 includes = env['mkl_path']
287     env.Append(CPPPATH = [includes,])
288     except KeyError:
289     pass
290 gross 700
291 robwdcock 682 try:
292     lib_path = env['mkl_lib_path']
293     env.Append(LIBPATH = [lib_path,])
294     except KeyError:
295     pass
296 gross 700
297 robwdcock 682 try:
298     mkl_libs = env['mkl_libs']
299     except KeyError:
300     mkl_libs = ''
301     try:
302     includes = env['scsl_path']
303     env.Append(CPPPATH = [includes,])
304     except KeyError:
305     pass
306     try:
307     lib_path = env['scsl_lib_path']
308     env.Append(LIBPATH = [lib_path,])
309     except KeyError:
310     pass
311 bcumming 759 if useMPI:
312     try:
313     scsl_libs = env['scsl_libs_MPI']
314     except KeyError:
315     scsl_libs = ''
316     else:
317     try:
318     scsl_libs = env['scsl_libs']
319     except KeyError:
320     scsl_libs = ''
321 gross 805
322 robwdcock 682 try:
323     includes = env['umf_path']
324     env.Append(CPPPATH = [includes,])
325     except KeyError:
326     pass
327 gross 805
328 robwdcock 682 try:
329     lib_path = env['umf_lib_path']
330     env.Append(LIBPATH = [lib_path,])
331     except KeyError:
332     pass
333 gross 805
334 robwdcock 682 try:
335 gross 805 lib_path = env['amd_lib_path']
336     env.Append(LIBPATH = [lib_path,])
337     except KeyError:
338     pass
339    
340     try:
341 robwdcock 682 umf_libs = env['umf_libs']
342     except KeyError:
343     umf_libs = ''
344 gross 805
345 robwdcock 682 try:
346 gross 805 includes = env['blas_path']
347     env.Append(CPPPATH = [includes,])
348     except KeyError:
349     pass
350     try:
351     lib_path = env['blas_lib_path']
352     env.Append(LIBPATH = [lib_path,])
353     except KeyError:
354     pass
355     try:
356     blas_libs = env['blas_libs']
357     except KeyError:
358     blas_libs = ''
359    
360     try:
361 robwdcock 682 includes = env['boost_path']
362     env.Append(CPPPATH = [includes,])
363     except KeyError:
364     pass
365     try:
366     lib_path = env['boost_lib_path']
367     env.Append(LIBPATH = [lib_path,])
368     except KeyError:
369     pass
370     try:
371     boost_lib = env['boost_lib']
372     except KeyError:
373     boost_lib = None
374     try:
375     includes = env['python_path']
376     env.Append(CPPPATH = [includes,])
377     except KeyError:
378     pass
379     try:
380     lib_path = env['python_lib_path']
381     env.Append(LIBPATH = [lib_path,])
382     except KeyError:
383     pass
384     try:
385     python_lib = env['python_lib']
386     except KeyError:
387     python_lib = None
388     try:
389     doxygen_path = env['doxygen_path']
390     except KeyError:
391     doxygen_path = None
392     try:
393     epydoc_path = env['epydoc_path']
394     except KeyError:
395     epydoc_path = None
396     try:
397     includes = env['papi_path']
398     env.Append(CPPPATH = [includes,])
399     except KeyError:
400     pass
401     try:
402     lib_path = env['papi_lib_path']
403     env.Append(LIBPATH = [lib_path,])
404     except KeyError:
405     pass
406     try:
407     papi_libs = env['papi_libs']
408     except KeyError:
409     papi_libs = None
410    
411 gross 707
412 gross 700 try:
413 gross 707 src_zipfile = env.File(env['src_zipfile'])
414 gross 700 except KeyError:
415     src_zipfile = None
416     try:
417 gross 707 test_zipfile = env.File(env['test_zipfile'])
418 gross 700 except KeyError:
419     test_zipfile = None
420 gross 707 try:
421     examples_zipfile = env.File(env['examples_zipfile'])
422     except KeyError:
423     examples_zipfile = None
424 gross 700
425     try:
426 gross 707 src_tarfile = env.File(env['src_tarfile'])
427 gross 700 except KeyError:
428     src_tarfile = None
429     try:
430 gross 707 test_tarfile = env.File(env['test_tarfile'])
431 gross 700 except KeyError:
432     test_tarfile = None
433 gross 707 try:
434     examples_tarfile = env.File(env['examples_tarfile'])
435     except KeyError:
436     examples_tarfile = None
437 gross 700
438     try:
439 gross 707 guide_pdf = env.File(env['guide_pdf'])
440 gross 700 except KeyError:
441 gross 707 guide_pdf = None
442 gross 700
443 gross 707 try:
444     guide_html_index = env.File('index.htm',env['guide_html'])
445     except KeyError:
446     guide_html_index = None
447    
448 elspeth 712 try:
449     api_epydoc = env.Dir(env['api_epydoc'])
450     except KeyError:
451     api_epydoc = None
452    
453 gross 700 # Zipgets
454 elspeth 712
455 robwdcock 682 env.Default(libinstall)
456     env.Default(incinstall)
457     env.Default(pyinstall)
458 gross 705 env.Alias('release_src',[ src_zipfile, src_tarfile ])
459 gross 700 env.Alias('release_tests',[ test_zipfile, test_tarfile])
460 gross 707 env.Alias('release_examples',[ examples_zipfile, examples_tarfile])
461 gross 720 env.Alias('api_epydoc',api_epydoc)
462 elspeth 712 env.Alias('docs',[ 'release_examples', guide_pdf, guide_html_index, api_epydoc])
463 gross 707 env.Alias('release', ['release_src', 'release_tests', 'docs'])
464 gross 705 env.Alias('build_tests') # target to build all C++ tests
465     env.Alias('build_py_tests') # target to build all python tests
466 gross 706 env.Alias('build_all_tests', [ 'build_tests', 'build_py_tests' ] ) # target to build all python tests
467     env.Alias('run_tests', 'build_tests') # target to run all C++ test
468     env.Alias('py_tests', 'build_py_tests') # taget to run all released python tests
469 gross 705 env.Alias('all_tests', ['run_tests', 'py_tests']) # target to run all C++ and released python tests
470 robwdcock 682
471     # Python install - esys __init__.py
472 woo409 757 init_target = env.Command(pyinstall+'/__init__.py', None, Touch('$TARGET'))
473     env.Alias(init_target)
474 robwdcock 682
475     # Allow sconscripts to see the env
476     Export(["env", "incinstall", "libinstall", "pyinstall", "dodebug", "mkl_libs", "scsl_libs", "umf_libs",
477 gross 722 "boost_lib", "python_lib", "doxygen_path", "epydoc_path", "papi_libs",
478 gross 707 "sys_libs", "test_zipfile", "src_zipfile", "test_tarfile", "src_tarfile", "examples_tarfile", "examples_zipfile",
479 bcumming 759 "guide_pdf", "guide_html_index", "api_epydoc", "useMPI"])
480 robwdcock 682
481     # End initialisation section
482     # Begin configuration section
483 gross 700 # adds this file and the scons option directore to the source tar
484     release_srcfiles=[env.File('SConstruct'),]+[ env.File(x) for x in glob.glob('scons/*.py') ]
485     release_testfiles=[env.File('README_TESTS'),]
486 gross 706 env.Zip(src_zipfile, release_srcfiles)
487 gross 700 env.Zip(test_zipfile, release_testfiles)
488     env.Tar(src_tarfile, release_srcfiles)
489     env.Tar(test_tarfile, release_testfiles)
490    
491 robwdcock 682 # Insert new components to be build here
492     # FIXME: might be nice to replace this verbosity with a list of targets and some
493     # FIXME: nifty python to create the lengthy but very similar env.Sconscript lines
494     # Third Party libraries
495     env.SConscript(dirs = ['tools/CppUnitTest/src'], build_dir='build/$PLATFORM/tools/CppUnitTest', duplicate=0)
496     # C/C++ Libraries
497     env.SConscript(dirs = ['paso/src'], build_dir='build/$PLATFORM/paso', duplicate=0)
498     env.SConscript(dirs = ['bruce/src'], build_dir='build/$PLATFORM/bruce', duplicate=0)
499     env.SConscript(dirs = ['escript/src'], build_dir='build/$PLATFORM/escript', duplicate=0)
500     env.SConscript(dirs = ['esysUtils/src'], build_dir='build/$PLATFORM/esysUtils', duplicate=0)
501     env.SConscript(dirs = ['finley/src'], build_dir='build/$PLATFORM/finley', duplicate=0)
502     env.SConscript(dirs = ['modellib/py_src'], build_dir='build/$PLATFORM/modellib', duplicate=0)
503 gross 707 env.SConscript(dirs = ['doc'], build_dir='build/$PLATFORM/doc', duplicate=0)
504 gross 792 env.SConscript(dirs = ['pyvisi/py_src'], build_dir='build/$PLATFORM/pyvisi', duplicate=0)
505 bcumming 751
506     # added by Ben Cumming
507     env.SConscript(dirs = ['pythonMPI/src'], build_dir='build/$PLATFORM/pythonMPI', duplicate=0)
508 bcumming 784 #env.SConscript(dirs = ['../test'], build_dir='../test/build', duplicate=0)

  ViewVC Help
Powered by ViewVC 1.1.26