/[escript]/trunk/SConstruct
ViewVC logotype

Diff of /trunk/SConstruct

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

revision 268 by jgs, Wed Nov 30 01:39:47 2005 UTC revision 762 by bcumming, Fri Jun 30 00:09:19 2006 UTC
# Line 1  Line 1 
1  # top-level Scons configuration file for all esys13 modules  #          Copyright 2006 by ACcESS MNRF                  
2    #                                                          
3  import os  #              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  #  #
 # ensure correct versions of python and scons  
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)  EnsurePythonVersion(2,3)
 EnsureSConsVersion(0,96)  
17    
18  #  # import tools:
19  # retreive command-line arguments if any  import glob
20  # these are passed through to SConscripts  import sys, os
21    # Add our extensions
22  if ARGUMENTS.get('libinstall',0):  if sys.path.count('scons')==0: sys.path.append('scons')
23    libinstall = ARGUMENTS.get('libinstall',0)  import scons_extensions
24    
25    # Default options and options help text
26    # 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:  else:
32    libinstall = Dir('#lib')     import socket
33  Export(["libinstall"])     from string import ascii_letters,digits
34       hostname=""
35  if ARGUMENTS.get('options',0):     for s in socket.gethostname().split('.')[0]:
36    options = ARGUMENTS.get('options',0)        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    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      ('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'),
66      ('cc_flags_debug_MPI', 'C compiler flags to use (Debug MPI build)', '-g -O0 -c99 -w1 -fpic -wd161'),
67      ('cxx_flags_MPI', 'C++ compiler flags to use (Release MPI build)', '-ansi -wd1563 -wd161'),
68      ('cxx_flags_debug_MPI', 'C++ compiler flags to use (Debug MPI build)', '-ansi -DDOASSERT -DDOPROF -wd1563 -wd161'),
69      ('ar_flags', 'Static library archiver flags to use', None),
70      ('sys_libs', 'System libraries to link with', None),
71      ('tar_flags','flags for zip files','-c -z'),
72    # MKL
73      PathOption('mkl_path', 'Path to MKL includes', None),
74      PathOption('mkl_lib_path', 'Path to MKL libs', None),
75      ('mkl_libs', 'MKL libraries to link with', None),
76    # SCSL
77      PathOption('scsl_path', 'Path to SCSL includes', None),
78      PathOption('scsl_lib_path', 'Path to SCSL libs', None),
79      ('scsl_libs', 'SCSL libraries to link with', None),
80      ('scsl_libs_MPI', 'SCSL libraries to link with for MPI build', None),
81    # UMFPACK
82      PathOption('umf_path', 'Path to UMF includes', None),
83      PathOption('umf_lib_path', 'Path to UMF libs', None),
84      ('umf_libs', 'UMF libraries to link with', None),
85    # Python
86    # locations of include files for python
87      PathOption('python_path', 'Path to Python includes', '/usr/include/python%s.%s'%(sys.version_info[0],sys.version_info[1])),
88      PathOption('python_lib_path', 'Path to Python libs', '/usr/lib'),
89      ('python_lib', 'Python libraries to link with', ["python%s.%s"%(sys.version_info[0],sys.version_info[1]),]),
90    # Boost
91      PathOption('boost_path', 'Path to Boost includes', '/usr/include'),
92      PathOption('boost_lib_path', 'Path to Boost libs', '/usr/lib'),
93      ('boost_lib', 'Boost libraries to link with', ['boost_python',]),
94    # Doc building
95    #  PathOption('doxygen_path', 'Path to Doxygen executable', None),
96    #  PathOption('epydoc_path', 'Path to Epydoc executable', None),
97    # PAPI
98      PathOption('papi_path', 'Path to PAPI includes', None),
99      PathOption('papi_lib_path', 'Path to PAPI libs', None),
100      ('papi_libs', 'PAPI libraries to link with', None),
101    # MPI
102      BoolOption('useMPI', 'Compile parallel version using MPI', 'no'),
103    )
104    
105    # Initialise Scons Build Environment
106    # check for user environment variables we are interested in
107    try:
108       python_path = os.environ['PYTHONPATH']
109    except KeyError:
110       python_path = ''
111    try:
112       path = os.environ['PATH']
113    except KeyError:
114       path = ''
115    try:
116       ld_library_path = os.environ['LD_LIBRARY_PATH']
117    except KeyError:
118       ld_library_path = ''
119    
120    # Note: On the Altix the intel compilers are not automatically
121    # detected by scons intelc.py script. The Altix has a different directory
122    # path and in some locations the "modules" facility is used to support
123    # multiple compiler versions. This forces the need to import the users PATH
124    # environment which isn't the "scons way"
125    # 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)
126    # FIXME: Perhaps a modification to intelc.py will allow better support for ia64 on altix
127    
128    if os.name != "nt" and os.uname()[4]=='ia64':
129       env = Environment(ENV = {'PATH':path}, tools = ['default', 'intelc'], options = opts)
130       env['ENV']['PATH'] = path
131       env['ENV']['LD_LIBRARY_PATH'] = ld_library_path
132       env['ENV']['PYTHONPATH'] = python_path
133       if env['CXX'] == 'icpc':
134          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
135    elif os.name == "nt":
136       env = Environment(tools = ['default', 'intelc'], options = opts)
137       env['ENV']['PYTHONPATH'] = python_path
138  else:  else:
139    options = None     env = Environment(tools = ['default'], options = opts)
140  Export(["options"])     env['ENV']['PATH'] = path
141       env['ENV']['LD_LIBRARY_PATH'] = ld_library_path
142       env['ENV']['PYTHONPATH'] = python_path
143    
144    # Setup help for options
145    Help(opts.GenerateHelpText(env))
146    
147    # Add some customer builders
148    py_builder = Builder(action = scons_extensions.build_py, suffix = '.pyc', src_suffix = '.py', single_source=True)
149    env.Append(BUILDERS = {'PyCompile' : py_builder});
150    
151  if ARGUMENTS.get('debug',0):  if env['PLATFORM'] == "win32":
152    dodebug = 1     runUnitTest_builder = Builder(action = scons_extensions.runUnitTest, suffix = '.passed', src_suffix='.exe', single_source=True)
153  else:  else:
154    dodebug = 0     runUnitTest_builder = Builder(action = scons_extensions.runUnitTest, suffix = '.passed', single_source=True)
155  Export(["dodebug"])  env.Append(BUILDERS = {'RunUnitTest' : runUnitTest_builder});
156    
157  if ARGUMENTS.get('usegcc',0):  runPyUnitTest_builder = Builder(action = scons_extensions.runPyUnitTest, suffix = '.passed', src_suffic='.py', single_source=True)
158    usegcc = 1  env.Append(BUILDERS = {'RunPyUnitTest' : runPyUnitTest_builder});
 else:  
   usegcc = 0  
 Export(["usegcc"])  
159    
160  #  # Convert the options which are held in environment variable into python variables for ease of handling and configure compilation options
161  # set and export esysroot  try:
162       incinstall = env['incinstall']
163  esysroot = Dir('#.')     env.Append(CPPPATH = [incinstall,])
164  Export(["esysroot"])  except KeyError:
165       incinstall = None  
166  #  try:
167  # call appropriate SConscripts     libinstall = env['libinstall']
168       env.Append(LIBPATH = [libinstall,])
169  target_scripts = ['tools/CppUnitTest/SConstruct',     env.PrependENVPath('LD_LIBRARY_PATH', libinstall)
170                    'tools/mmio/SConstruct',     if env['PLATFORM'] == "win32":
171                    'esysUtils/SConstruct',        env.PrependENVPath('PATH', libinstall)
172                    'escript/SConstruct',        env.PrependENVPath('PATH', env['boost_lib_path'])
173                    'bruce/SConstruct',  except KeyError:
174                    'paso/SConstruct',     libinstall = None  
175                    'finley/SConstruct',  try:
176                    'modellib/SConstruct']     pyinstall = env['pyinstall']+'/esys' # all targets will install into pyinstall/esys but PYTHONPATH points at straight pyinstall so you go import esys.escript etc
177       env.PrependENVPath('PYTHONPATH', env['pyinstall'])
178  SConscript(target_scripts, duplicate=0)  except KeyError:
179       pyinstall = None  
180    try:
181       dodebug = env['dodebug']
182    except KeyError:
183       dodebug = None  
184    try:
185       useMPI = env['useMPI']
186    except KeyError:
187       useMPI = None  
188    try:
189       cc_defines = env['cc_defines']
190       env.Append(CPPDEFINES = cc_defines)
191    except KeyError:
192       pass
193    if dodebug:
194      if useMPI:
195        try:
196          flags = env['cc_flags_debug_MPI']
197          env.Append(CCFLAGS = flags)
198        except KeyError:
199          pass
200      else:                      
201        try:
202          flags = env['cc_flags_debug']
203          env.Append(CCFLAGS = flags)
204        except KeyError:
205          pass
206    else:
207      if useMPI:
208       try:
209         flags = env['cc_flags_MPI']
210         env.Append(CCFLAGS = flags)
211       except KeyError:
212          pass
213      else:
214       try:
215          flags = env['cc_flags']
216          env.Append(CCFLAGS = flags)
217       except KeyError:
218          pass
219    if dodebug:
220       if useMPI:
221         try:
222            flags = env['cxx_flags_debug_MPI']
223            env.Append(CXXFLAGS = flags)
224         except KeyError:
225            pass
226       else:
227         try:
228            flags = env['cxx_flags_debug']
229            env.Append(CXXFLAGS = flags)
230         except KeyError:
231            pass
232    else:
233       if useMPI:
234         try:
235            flags = env['cxx_flags_MPI']
236            env.Append(CXXFLAGS = flags)
237         except KeyError:
238            pass
239       else:
240         try:
241            flags = env['cxx_flags']
242            env.Append(CXXFLAGS = flags)
243         except KeyError:
244            pass
245    try:
246       flags = env['ar_flags']
247       env.Append(ARFLAGS = flags)
248    except KeyError:
249       ar_flags = None  
250    try:
251       sys_libs = env['sys_libs']
252    except KeyError:
253       sys_libs = ''
254    
255    try:
256       tar_flags = env['tar_flags']
257       env.Replace(TARFLAGS = tar_flags)
258    except KeyError:
259       pass
260    
261    try:
262       includes = env['mkl_path']
263       env.Append(CPPPATH = [includes,])
264    except KeyError:
265       pass
266    
267    try:
268       lib_path = env['mkl_lib_path']
269       env.Append(LIBPATH = [lib_path,])
270    except KeyError:
271       pass
272    
273    try:
274       mkl_libs = env['mkl_libs']
275    except KeyError:
276       mkl_libs = ''
277    try:
278       includes = env['scsl_path']
279       env.Append(CPPPATH = [includes,])
280    except KeyError:
281       pass
282    try:
283       lib_path = env['scsl_lib_path']
284       env.Append(LIBPATH = [lib_path,])
285    except KeyError:
286       pass
287    if useMPI:  
288      try:
289        scsl_libs = env['scsl_libs_MPI']
290      except KeyError:
291        scsl_libs = ''
292    else:        
293      try:
294        scsl_libs = env['scsl_libs']
295      except KeyError:
296        scsl_libs = ''
297    try:
298       includes = env['umf_path']
299       env.Append(CPPPATH = [includes,])
300    except KeyError:
301       pass
302    try:
303       lib_path = env['umf_lib_path']
304       env.Append(LIBPATH = [lib_path,])
305    except KeyError:
306       pass
307    try:
308       umf_libs = env['umf_libs']
309    except KeyError:
310       umf_libs = ''
311    try:
312       includes = env['boost_path']
313       env.Append(CPPPATH = [includes,])
314    except KeyError:
315       pass
316    try:
317       lib_path = env['boost_lib_path']
318       env.Append(LIBPATH = [lib_path,])
319    except KeyError:
320       pass
321    try:
322       boost_lib = env['boost_lib']
323    except KeyError:
324       boost_lib = None  
325    try:
326       includes = env['python_path']
327       env.Append(CPPPATH = [includes,])
328    except KeyError:
329       pass
330    try:
331       lib_path = env['python_lib_path']
332       env.Append(LIBPATH = [lib_path,])
333    except KeyError:
334       pass
335    try:
336       python_lib = env['python_lib']
337    except KeyError:
338       python_lib = None  
339    try:
340       doxygen_path = env['doxygen_path']
341    except KeyError:
342       doxygen_path = None  
343    try:
344       epydoc_path = env['epydoc_path']
345    except KeyError:
346       epydoc_path = None  
347    try:
348       includes = env['papi_path']
349       env.Append(CPPPATH = [includes,])
350    except KeyError:
351       pass
352    try:
353       lib_path = env['papi_lib_path']
354       env.Append(LIBPATH = [lib_path,])
355    except KeyError:
356       pass
357    try:
358       papi_libs = env['papi_libs']
359    except KeyError:
360       papi_libs = None  
361    
362    
363    try:
364       src_zipfile = env.File(env['src_zipfile'])
365    except KeyError:
366       src_zipfile = None  
367    try:
368       test_zipfile = env.File(env['test_zipfile'])
369    except KeyError:
370       test_zipfile = None  
371    try:
372       examples_zipfile = env.File(env['examples_zipfile'])
373    except KeyError:
374       examples_zipfile = None  
375    
376    try:
377       src_tarfile = env.File(env['src_tarfile'])
378    except KeyError:
379       src_tarfile = None  
380    try:
381       test_tarfile = env.File(env['test_tarfile'])
382    except KeyError:
383       test_tarfile = None  
384    try:
385       examples_tarfile = env.File(env['examples_tarfile'])
386    except KeyError:
387       examples_tarfile = None  
388    
389    try:
390       guide_pdf = env.File(env['guide_pdf'])
391    except KeyError:
392       guide_pdf = None  
393    
394    try:
395       guide_html_index = env.File('index.htm',env['guide_html'])
396    except KeyError:
397       guide_html_index = None  
398    
399    try:
400       api_epydoc = env.Dir(env['api_epydoc'])
401    except KeyError:
402       api_epydoc = None  
403    
404    # Zipgets
405      
406    env.Default(libinstall)
407    env.Default(incinstall)
408    env.Default(pyinstall)
409    env.Alias('release_src',[ src_zipfile, src_tarfile ])  
410    env.Alias('release_tests',[ test_zipfile, test_tarfile])
411    env.Alias('release_examples',[ examples_zipfile, examples_tarfile])
412    env.Alias('api_epydoc',api_epydoc)
413    env.Alias('docs',[ 'release_examples', guide_pdf, guide_html_index, api_epydoc])
414    env.Alias('release', ['release_src', 'release_tests', 'docs'])
415    env.Alias('build_tests')    # target to build all C++ tests
416    env.Alias('build_py_tests') # target to build all python tests
417    env.Alias('build_all_tests', [ 'build_tests', 'build_py_tests' ] ) # target to build all python tests
418    env.Alias('run_tests', 'build_tests')   # target to run all C++ test
419    env.Alias('py_tests', 'build_py_tests') # taget to run all released python tests
420    env.Alias('all_tests', ['run_tests', 'py_tests']) # target to run all C++ and released python tests
421    
422    # Python install - esys __init__.py
423    init_target = env.Command(pyinstall+'/__init__.py', None, Touch('$TARGET'))
424    env.Alias(init_target)
425    
426    # Allow sconscripts to see the env
427    Export(["env", "incinstall", "libinstall", "pyinstall", "dodebug", "mkl_libs", "scsl_libs", "umf_libs",
428        "boost_lib", "python_lib", "doxygen_path", "epydoc_path", "papi_libs",
429            "sys_libs", "test_zipfile", "src_zipfile", "test_tarfile", "src_tarfile", "examples_tarfile", "examples_zipfile",
430            "guide_pdf", "guide_html_index", "api_epydoc", "useMPI"])
431    
432    # End initialisation section
433    # Begin configuration section
434    # adds this file and the scons option directore to the source tar
435    release_srcfiles=[env.File('SConstruct'),]+[ env.File(x) for x in glob.glob('scons/*.py') ]
436    release_testfiles=[env.File('README_TESTS'),]
437    env.Zip(src_zipfile, release_srcfiles)
438    env.Zip(test_zipfile, release_testfiles)
439    env.Tar(src_tarfile, release_srcfiles)
440    env.Tar(test_tarfile, release_testfiles)
441    
442    # Insert new components to be build here
443    # FIXME: might be nice to replace this verbosity with a list of targets and some
444    # FIXME: nifty python to create the lengthy but very similar env.Sconscript lines
445    # Third Party libraries
446    env.SConscript(dirs = ['tools/CppUnitTest/src'], build_dir='build/$PLATFORM/tools/CppUnitTest', duplicate=0)
447    # C/C++ Libraries
448    env.SConscript(dirs = ['paso/src'], build_dir='build/$PLATFORM/paso', duplicate=0)
449    env.SConscript(dirs = ['bruce/src'], build_dir='build/$PLATFORM/bruce', duplicate=0)
450    env.SConscript(dirs = ['escript/src'], build_dir='build/$PLATFORM/escript', duplicate=0)
451    env.SConscript(dirs = ['esysUtils/src'], build_dir='build/$PLATFORM/esysUtils', duplicate=0)
452    env.SConscript(dirs = ['finley/src'], build_dir='build/$PLATFORM/finley', duplicate=0)
453    env.SConscript(dirs = ['modellib/py_src'], build_dir='build/$PLATFORM/modellib', duplicate=0)
454    env.SConscript(dirs = ['doc'], build_dir='build/$PLATFORM/doc', duplicate=0)
455    env.SConscript(dirs = ['pyvisi/py_src'], build_dir='build/$PLATFORM/pyvisi', duplicate=0)
456    
457    # added by Ben Cumming
458    env.SConscript(dirs = ['pythonMPI/src'], build_dir='build/$PLATFORM/pythonMPI', duplicate=0)
459    #env.SConscript(dirs = ['../test'], build_dir='../test/build', duplicate=0)

Legend:
Removed from v.268  
changed lines
  Added in v.762

  ViewVC Help
Powered by ViewVC 1.1.26