/[escript]/trunk/SConstruct
ViewVC logotype

Diff of /trunk/SConstruct

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

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

Legend:
Removed from v.584  
changed lines
  Added in v.807

  ViewVC Help
Powered by ViewVC 1.1.26