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

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

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

  ViewVC Help
Powered by ViewVC 1.1.26