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

Diff of /trunk-mpi-branch/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 720 by gross, Thu Apr 27 10:16:05 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)  # Default options and options help text
26  execfile(str(File(esysroot+"/scons/esys_options.py")))  # These are defaults and can be overridden using command line arguments or an options file.
27    # if the options_file or ARGUMENTS do not exist then the ones listed as default here are used
28    # DO NOT CHANGE THEM HERE
29    if ARGUMENTS.get('options_file',0):
30       options_file = ARGUMENTS.get('options_file',0)
31    else:
32       import socket
33       from string import ascii_letters,digits
34       hostname=""
35       for s in socket.gethostname().split('.')[0]:
36          if s in ascii_letters+digits:
37             hostname+=s
38          else:
39             hostname+="_"
40       options_file = "scons/"+hostname+"_options.py"
41    
42  #  opts = Options(options_file, ARGUMENTS)
43  # call appropriate SConscripts  opts.AddOptions(
44    # Where to install esys stuff
45      ('incinstall', 'where the esys headers will be installed', Dir('#.').abspath+'/include'),
46      ('libinstall', 'where the esys libraries will be installed', Dir('#.').abspath+'/lib'),
47      ('pyinstall', 'where the esys python modules will be installed', Dir('#.').abspath),
48      ('src_zipfile', 'the source zip file will be installed.', Dir('#.').abspath+"/release/escript_src.zip"),
49      ('test_zipfile', 'the test zip file will be installed.', Dir('#.').abspath+"/release/escript_tests.zip"),
50      ('src_tarfile', 'the source tar file will be installed.', Dir('#.').abspath+"/release/escript_src.tar.gz"),
51      ('test_tarfile', 'the test tar file will be installed.', Dir('#.').abspath+"/release/escript_tests.tar.gz"),
52      ('examples_tarfile', 'the examples tar file will be installed.', Dir('#.').abspath+"/release/doc/escript_examples.tar.gz"),
53      ('examples_zipfile', 'the examples zip file will be installed.', Dir('#.').abspath+"/release/doc/escript_examples.zip"),
54      ('guide_pdf', 'name of the user guide in pdf format', Dir('#.').abspath+"/release/doc/user/guide.pdf"),
55      ('api_epydoc', 'name of the epydoc api docs directory',Dir('#.').abspath+"/release/doc/epydoc"),
56      ('guide_html', 'name of the directory for user guide in html format', Dir('#.').abspath+"/release/doc/user/html"),
57    # Compilation options
58      BoolOption('dodebug', 'Do you want a debug build?', 'no'),
59      ('options_file', "Optional file containing preferred options. Ignored if it doesn't exist (default: scons/hostname_options.py)", options_file),
60      ('cc_defines','C/C++ defines to use', None),
61      ('cc_flags','C compiler flags to use (Release build)', '-O3 -std=c99 -ffast-math -fpic -Wno-unknown-pragmas'),
62      ('cc_flags_debug', 'C compiler flags to use (Debug build)', '-g -O0 -ffast-math -std=c99 -fpic -Wno-unknown-pragmas'),
63      ('cxx_flags', 'C++ compiler flags to use (Release build)', '--no-warn -ansi'),
64      ('cxx_flags_debug', 'C++ compiler flags to use (Debug build)', '--no-warn -ansi -DDOASSERT -DDOPROF'),
65      ('ar_flags', 'Static library archiver flags to use', None),
66      ('sys_libs', 'System libraries to link with', None),
67      ('tar_flags','flags for zip files','-c -z'),
68    # MKL
69      PathOption('mkl_path', 'Path to MKL includes', None),
70      PathOption('mkl_lib_path', 'Path to MKL libs', None),
71      ('mkl_libs', 'MKL libraries to link with', None),
72    # SCSL
73      PathOption('scsl_path', 'Path to SCSL includes', None),
74      PathOption('scsl_lib_path', 'Path to SCSL libs', None),
75      ('scsl_libs', 'SCSL libraries to link with', None),
76    # UMFPACK
77      PathOption('umf_path', 'Path to UMF includes', None),
78      PathOption('umf_lib_path', 'Path to UMF libs', None),
79      ('umf_libs', 'UMF libraries to link with', None),
80    # Python
81    # locations of include files for python
82      PathOption('python_path', 'Path to Python includes', '/usr/include/python%s.%s'%(sys.version_info[0],sys.version_info[1])),
83      PathOption('python_lib_path', 'Path to Python libs', '/usr/lib'),
84      ('python_lib', 'Python libraries to link with', ["python%s.%s"%(sys.version_info[0],sys.version_info[1]),]),
85    # Boost
86      PathOption('boost_path', 'Path to Boost includes', '/usr/include'),
87      PathOption('boost_lib_path', 'Path to Boost libs', '/usr/lib'),
88      ('boost_lib', 'Boost libraries to link with', ['boost_python',]),
89    # Doc building
90      PathOption('doxygen_path', 'Path to Doxygen executable', None),
91      PathOption('epydoc_path', 'Path to Epydoc executable', None),
92      PathOption('epydoc_pythonpath', 'Path to Epydoc python files', None),
93    # PAPI
94      PathOption('papi_path', 'Path to PAPI includes', None),
95      PathOption('papi_lib_path', 'Path to PAPI libs', None),
96      ('papi_libs', 'PAPI libraries to link with', None),
97    )
98    
99    # Initialise Scons Build Environment
100    # check for user environment variables we are interested in
101    try:
102       python_path = os.environ['PYTHONPATH']
103    except KeyError:
104       python_path = ''
105    try:
106       path = os.environ['PATH']
107    except KeyError:
108       path = ''
109    try:
110       ld_library_path = os.environ['LD_LIBRARY_PATH']
111    except KeyError:
112       ld_library_path = ''
113    
114    # Note: On the Altix the intel compilers are not automatically
115    # detected by scons intelc.py script. The Altix has a different directory
116    # path and in some locations the "modules" facility is used to support
117    # multiple compiler versions. This forces the need to import the users PATH
118    # environment which isn't the "scons way"
119    # 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)
120    # FIXME: Perhaps a modification to intelc.py will allow better support for ia64 on altix
121    
122    if os.name != "nt" and os.uname()[4]=='ia64':
123       env = Environment(ENV = {'PATH':path}, tools = ['default', 'intelc'], options = opts)
124       env['ENV']['PATH'] = path
125       env['ENV']['LD_LIBRARY_PATH'] = ld_library_path
126       env['ENV']['PYTHONPATH'] = python_path
127       if env['CXX'] == 'icpc':
128          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
129    elif os.name == "nt":
130       # FIXME: Need to implement equivalent of ld library path for windoze
131       env = Environment(tools = ['default', 'intelc'], options = opts)
132       env['ENV']['PYTHONPATH'] = python_path
133    else:
134       env = Environment(tools = ['default'], options = opts)
135       env['ENV']['PATH'] = path
136       env['ENV']['LD_LIBRARY_PATH'] = ld_library_path
137       env['ENV']['PYTHONPATH'] = python_path
138    
139    # Setup help for options
140    Help(opts.GenerateHelpText(env))
141    
142    # Add some customer builders
143    py_builder = Builder(action = scons_extensions.build_py, suffix = '.pyc', src_suffix = '.py', single_source=True)
144    env.Append(BUILDERS = {'PyCompile' : py_builder});
145    
146    if env['PLATFORM'] == "win32":
147       runUnitTest_builder = Builder(action = scons_extensions.runUnitTest, suffix = '.passed', src_suffix='.exe', single_source=True)
148    else:
149       runUnitTest_builder = Builder(action = scons_extensions.runUnitTest, suffix = '.passed', single_source=True)
150    env.Append(BUILDERS = {'RunUnitTest' : runUnitTest_builder});
151    
152    runPyUnitTest_builder = Builder(action = scons_extensions.runPyUnitTest, suffix = '.passed', src_suffic='.py', single_source=True)
153    env.Append(BUILDERS = {'RunPyUnitTest' : runPyUnitTest_builder});
154    
155    # Convert the options which are held in environment variable into python variables for ease of handling and configure compilation options
156    try:
157       incinstall = env['incinstall']
158       env.Append(CPPPATH = [incinstall,])
159    except KeyError:
160       incinstall = None  
161    try:
162       libinstall = env['libinstall']
163       env.Append(LIBPATH = [libinstall,])
164       env.PrependENVPath('LD_LIBRARY_PATH', libinstall)
165    except KeyError:
166       libinstall = None  
167    try:
168       pyinstall = env['pyinstall']+'/esys' # all targets will install into pyinstall/esys but PYTHONPATH points at straight pyinstall so you go import esys.escript etc
169       env.PrependENVPath('PYTHONPATH', env['pyinstall'])
170    except KeyError:
171       pyinstall = None  
172    try:
173       dodebug = env['dodebug']
174    except KeyError:
175       dodebug = None  
176    try:
177       cc_defines = env['cc_defines']
178       env.Append(CPPDEFINES = [cc_defines,])
179    except KeyError:
180       pass
181    if dodebug:
182       try:
183          flags = env['cc_flags_debug']
184          env.Append(CCFLAGS = flags)
185       except KeyError:
186          pass
187    else:
188       try:
189          flags = env['cc_flags']
190          env.Append(CCFLAGS = flags)
191       except KeyError:
192          pass
193    
194    if dodebug:
195       try:
196          flags = env['cxx_flags_debug']
197          env.Append(CXXFLAGS = flags)
198       except KeyError:
199          pass
200    else:
201       try:
202          flags = env['cxx_flags']
203          env.Append(CXXFLAGS = flags)
204       except KeyError:
205          pass
206    
207    try:
208       flags = env['ar_flags']
209       env.Append(ARFLAGS = flags)
210    except KeyError:
211       ar_flags = None  
212    try:
213       sys_libs = env['sys_libs']
214    except KeyError:
215       sys_libs = ''
216    
217    try:
218       tar_flags = env['tar_flags']
219       env.Replace(TARFLAGS = tar_flags)
220    except KeyError:
221       pass
222    
223    try:
224       includes = env['mkl_path']
225       env.Append(CPPPATH = [includes,])
226    except KeyError:
227       pass
228    
229    try:
230       lib_path = env['mkl_lib_path']
231       env.Append(LIBPATH = [lib_path,])
232    except KeyError:
233       pass
234    
235    try:
236       mkl_libs = env['mkl_libs']
237    except KeyError:
238       mkl_libs = ''
239    try:
240       includes = env['scsl_path']
241       env.Append(CPPPATH = [includes,])
242    except KeyError:
243       pass
244    try:
245       lib_path = env['scsl_lib_path']
246       env.Append(LIBPATH = [lib_path,])
247    except KeyError:
248       pass
249    try:
250       scsl_libs = env['scsl_libs']
251    except KeyError:
252       scsl_libs = ''
253    try:
254       includes = env['umf_path']
255       env.Append(CPPPATH = [includes,])
256    except KeyError:
257       pass
258    try:
259       lib_path = env['umf_lib_path']
260       env.Append(LIBPATH = [lib_path,])
261    except KeyError:
262       pass
263    try:
264       umf_libs = env['umf_libs']
265    except KeyError:
266       umf_libs = ''
267    try:
268       includes = env['boost_path']
269       env.Append(CPPPATH = [includes,])
270    except KeyError:
271       pass
272    try:
273       lib_path = env['boost_lib_path']
274       env.Append(LIBPATH = [lib_path,])
275    except KeyError:
276       pass
277    try:
278       boost_lib = env['boost_lib']
279    except KeyError:
280       boost_lib = None  
281    try:
282       includes = env['python_path']
283       env.Append(CPPPATH = [includes,])
284    except KeyError:
285       pass
286    try:
287       lib_path = env['python_lib_path']
288       env.Append(LIBPATH = [lib_path,])
289    except KeyError:
290       pass
291    try:
292       python_lib = env['python_lib']
293    except KeyError:
294       python_lib = None  
295    try:
296       doxygen_path = env['doxygen_path']
297    except KeyError:
298       doxygen_path = None  
299    try:
300       epydoc_path = env['epydoc_path']
301    except KeyError:
302       epydoc_path = None  
303    try:
304       epydoc_pythonpath = env['epydoc_pythonpath']
305    except KeyError:
306       epydoc_pythonpath = None  
307    try:
308       includes = env['papi_path']
309       env.Append(CPPPATH = [includes,])
310    except KeyError:
311       pass
312    try:
313       lib_path = env['papi_lib_path']
314       env.Append(LIBPATH = [lib_path,])
315    except KeyError:
316       pass
317    try:
318       papi_libs = env['papi_libs']
319    except KeyError:
320       papi_libs = None  
321    
322    
323    try:
324       src_zipfile = env.File(env['src_zipfile'])
325    except KeyError:
326       src_zipfile = None  
327    try:
328       test_zipfile = env.File(env['test_zipfile'])
329    except KeyError:
330       test_zipfile = None  
331    try:
332       examples_zipfile = env.File(env['examples_zipfile'])
333    except KeyError:
334       examples_zipfile = None  
335    
336    try:
337       src_tarfile = env.File(env['src_tarfile'])
338    except KeyError:
339       src_tarfile = None  
340    try:
341       test_tarfile = env.File(env['test_tarfile'])
342    except KeyError:
343       test_tarfile = None  
344    try:
345       examples_tarfile = env.File(env['examples_tarfile'])
346    except KeyError:
347       examples_tarfile = None  
348    
349    try:
350       guide_pdf = env.File(env['guide_pdf'])
351    except KeyError:
352       guide_pdf = None  
353    
354    try:
355       guide_html_index = env.File('index.htm',env['guide_html'])
356    except KeyError:
357       guide_html_index = None  
358    
359    try:
360       api_epydoc = env.Dir(env['api_epydoc'])
361    except KeyError:
362       api_epydoc = None  
363    
364    # Zipgets
365      
366    env.Default(libinstall)
367    env.Default(incinstall)
368    env.Default(pyinstall)
369    env.Alias('release_src',[ src_zipfile, src_tarfile ])  
370    env.Alias('release_tests',[ test_zipfile, test_tarfile])
371    env.Alias('release_examples',[ examples_zipfile, examples_tarfile])
372    env.Alias('api_epydoc',api_epydoc)
373    env.Alias('docs',[ 'release_examples', guide_pdf, guide_html_index, api_epydoc])
374    env.Alias('release', ['release_src', 'release_tests', 'docs'])
375    env.Alias('build_tests')    # target to build all C++ tests
376    env.Alias('build_py_tests') # target to build all python tests
377    env.Alias('build_all_tests', [ 'build_tests', 'build_py_tests' ] ) # target to build all python tests
378    env.Alias('run_tests', 'build_tests')   # target to run all C++ test
379    env.Alias('py_tests', 'build_py_tests') # taget to run all released python tests
380    env.Alias('all_tests', ['run_tests', 'py_tests']) # target to run all C++ and released python tests
381    
382    # Python install - esys __init__.py
383    # This is just an empty file but stills need to be touched so add a special target and Command. Note you can't use the scons Touch() function as it will not
384    # create the file if it doesn't exist
385    env.Command(pyinstall+'/__init__.py', None, 'touch $TARGET')
386    
387    # Allow sconscripts to see the env
388    Export(["env", "incinstall", "libinstall", "pyinstall", "dodebug", "mkl_libs", "scsl_libs", "umf_libs",
389        "boost_lib", "python_lib", "doxygen_path", "epydoc_path", "epydoc_pythonpath", "papi_libs",
390            "sys_libs", "test_zipfile", "src_zipfile", "test_tarfile", "src_tarfile", "examples_tarfile", "examples_zipfile",
391            "guide_pdf", "guide_html_index", "api_epydoc"])
392    
393  target_scripts = ['tools/CppUnitTest/SConstruct',  # End initialisation section
394                    'tools/mmio/SConstruct',  # Begin configuration section
395                    'esysUtils/SConstruct',  # adds this file and the scons option directore to the source tar
396                    'escript/SConstruct',  release_srcfiles=[env.File('SConstruct'),]+[ env.File(x) for x in glob.glob('scons/*.py') ]
397                    'bruce/SConstruct',  release_testfiles=[env.File('README_TESTS'),]
398                    'paso/SConstruct',  env.Zip(src_zipfile, release_srcfiles)
399                    'finley/SConstruct',  env.Zip(test_zipfile, release_testfiles)
400                    'modellib/SConstruct',  env.Tar(src_tarfile, release_srcfiles)
401                    'doc/SConstruct']  env.Tar(test_tarfile, release_testfiles)
                   # 'doc/SConstruct']  
402    
403  SConscript(target_scripts, duplicate=0)  # Insert new components to be build here
404    # FIXME: might be nice to replace this verbosity with a list of targets and some
405    # FIXME: nifty python to create the lengthy but very similar env.Sconscript lines
406    # Third Party libraries
407    env.SConscript(dirs = ['tools/CppUnitTest/src'], build_dir='build/$PLATFORM/tools/CppUnitTest', duplicate=0)
408    # C/C++ Libraries
409    env.SConscript(dirs = ['paso/src'], build_dir='build/$PLATFORM/paso', duplicate=0)
410    env.SConscript(dirs = ['bruce/src'], build_dir='build/$PLATFORM/bruce', duplicate=0)
411    env.SConscript(dirs = ['escript/src'], build_dir='build/$PLATFORM/escript', duplicate=0)
412    env.SConscript(dirs = ['esysUtils/src'], build_dir='build/$PLATFORM/esysUtils', duplicate=0)
413    env.SConscript(dirs = ['finley/src'], build_dir='build/$PLATFORM/finley', duplicate=0)
414    env.SConscript(dirs = ['modellib/py_src'], build_dir='build/$PLATFORM/modellib', duplicate=0)
415    env.SConscript(dirs = ['doc'], build_dir='build/$PLATFORM/doc', duplicate=0)
416    env.SConscript(dirs = ['pyvisi/py_src'], build_dir='build/$PLATFORM/pyvisi', duplicate=0)

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

  ViewVC Help
Powered by ViewVC 1.1.26