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

Diff of /branches/cookbookdev/SConstruct

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

revision 1235 by phornby, Mon Aug 13 00:25:29 2007 UTC revision 1560 by ksteube, Wed May 21 05:55:30 2008 UTC
# Line 15  EnsurePythonVersion(2,3) Line 15  EnsurePythonVersion(2,3)
15  #===============================================================  #===============================================================
16  #   import tools:  #   import tools:
17  import glob  import glob
18  import sys, os  import sys, os, re
 import socket  
19  # Add our extensions  # Add our extensions
20  if sys.path.count('scons')==0: sys.path.append('scons')  if sys.path.count('scons')==0: sys.path.append('scons')
21  import scons_extensions  import scons_extensions
22    
23    # We may also need to know where python's site-packages subdirectory lives
24    python_version = 'python%s.%s'%(sys.version_info[0],sys.version_info[1])
25    
26  #===============================================================  #===============================================================
27    
28  tools_prefix="/usr"  tools_prefix="/usr"
# Line 29  tools_prefix="/usr" Line 31  tools_prefix="/usr"
31  #      #    
32  #    get the installation prefix  #    get the installation prefix
33  #  #
34  prefix = ARGUMENTS.get('prefix', Dir('#.').abspath)  prefix = ARGUMENTS.get('prefix', sys.prefix )
35    
36  # We may also need to know where python's site-packages subdirectory lives  # We may also need to know where python's site-packages subdirectory lives
37  python_version = 'python%s.%s'%(sys.version_info[0],sys.version_info[1])  python_version = 'python%s.%s'%(sys.version_info[0],sys.version_info[1])
38    # Install as a standard python package in /usr/lib64 if available, else in /usr/lib
39  if prefix == "/usr":  if os.path.isdir(  prefix+"/lib64/"+python_version+"/site-packages"):
40     # Install as a standard python package in /usr/lib64 if available, else in /usr/lib     sys_dir_packages =  prefix+"/lib64/"+python_version+"/site-packages/esys"
41     if os.path.isdir(  prefix+"/lib64/"+python_version+"/site-packages"):     sys_dir_libraries = prefix+"/lib64"
42        dir_packages =  prefix+"/lib64/"+python_version+"/site-packages"  else:
43        dir_libraries = prefix+"/lib64"     sys_dir_packages =  prefix+"/lib/"+python_version+"/site-packages/esys"
44     elif os.path.isdir(prefix+"/lib/"+python_version+"/site-packages"):     sys_dir_libraries = prefix+"/lib"
45        dir_packages =  prefix+"/lib/"+python_version+"/site-packages"  
46        dir_libraries = prefix+"/lib"  sys_dir_examples = prefix+"/share/doc/esys"
47     else:  
48        print "Install prefix is /usr but couldn't find python package directory in either"  source_root = Dir('#.').abspath
49        print "/usr/lib64/"+python_version+"/site-packages or /usr/lib/"+python_version+"/site-packages"  
50        sys.exit(1)  dir_packages = os.path.join(source_root,"esys")
51     dir_examples = prefix+"/share/doc/esys"  dir_examples = os.path.join(source_root,"examples")
52  else:  dir_libraries = os.path.join(source_root,"lib")
53     # Install using the usual escript directory structure  
54     dir_packages = prefix  print "Source root is : ",source_root
55     dir_libraries = prefix+"/lib"  print " Default packages local installation:    ", dir_packages
56     dir_examples = prefix  print " Default library local installation  ", dir_libraries
57  dir_packages += "/esys"  print " Default example local  installation:    ", dir_examples
 dir_examples += "/examples"  
   
58  print "Install prefix is: ", prefix  print "Install prefix is: ", prefix
59  print " python packages will be installed in:   ", dir_packages  print " Default packages system installation:   ", sys_dir_packages
60  print " libraries will be installed in:     ", dir_libraries  print " Default library system installation     ", sys_dir_libraries
61  print " examples will be installed in:      ", dir_examples  print " Default example system installation:    ", sys_dir_examples
62    
63  #==============================================================================================      #==============================================================================================    
64    
# Line 71  print "    examples will be installed in: Line 71  print "    examples will be installed in:
71  #      #    
72  #    get the options file if present:  #    get the options file if present:
73  #  #
74  if ARGUMENTS.get('options_file',0):  options_file = ARGUMENTS.get('options_file','')
75     options_file = ARGUMENTS.get('options_file',0)  
76  else:  if not os.path.isfile(options_file) :
77     from string import ascii_letters,digits      options_file = False
78     hostname=""  
79     for s in socket.gethostname().split('.')[0]:  if not options_file :
80        if s in ascii_letters+digits:     import socket
81           hostname+=s     hostname = re.sub("[^0-9a-zA-Z]", "_", socket.gethostname().split('.')[0])
82        else:     tmp = os.path.join("scons",hostname+"_options.py")
83           hostname+="_"  
84     options_file = os.path.join("scons",hostname+"_options.py")     if os.path.isfile(tmp) :
85            options_file = tmp
86  if os.path.isfile(options_file):  
87     print "option file is ",options_file,"."  IS_WINDOWS_PLATFORM = (os.name== "nt")
88  else:  
89     print "option file is ",options_file, "(not present)."  # If you're not going to tell me then......
90    # FIXME: add one for the altix too.
91    if not options_file :
92       if IS_WINDOWS_PLATFORM :
93          options_file = "scons/windows_mscv71_options.py"
94       else:
95          options_file = "scons/linux_gcc_eg_options.py"
96    
97  # and load it  # and load it
98  opts = Options(options_file, ARGUMENTS)  opts = Options(options_file, ARGUMENTS)
99  #================================================================  #================================================================
# Line 131  python_lib_default="python%s.%s"%(sys.ve Line 138  python_lib_default="python%s.%s"%(sys.ve
138  boost_path_default=os.path.join(tools_prefix,'include')  boost_path_default=os.path.join(tools_prefix,'include')
139  boost_lib_path_default=os.path.join(tools_prefix,'lib')  boost_lib_path_default=os.path.join(tools_prefix,'lib')
140  boost_lib_default=['boost_python']  boost_lib_default=['boost_python']
141    
142  #==========================================================================  #==========================================================================
143  #  #
144  #    check if netCDF is installed on the system:  #    check if netCDF is installed on the system:
145  #  #
146  netCDF_path_default=os.path.join(tools_prefix,'include','netcdf-3')  netCDF_path_default=os.path.join(tools_prefix,'include','netcdf-3')
147  netCDF_lib_path_default=os.path.join(tools_prefix,'lib','netcdf-3')  netCDF_lib_path_default=os.path.join(tools_prefix,'lib')
148    
149  if os.path.isdir(netCDF_path_default) and os.path.isdir(netCDF_lib_path_default):  if os.path.isdir(netCDF_path_default) and os.path.isdir(netCDF_lib_path_default):
150       useNetCDF_default='yes'       useNetCDF_default='yes'
# Line 149  else: Line 157  else:
157    
158  #==========================================================================  #==========================================================================
159  #  #
160    #  MPI:
161    #
162    if IS_WINDOWS_PLATFORM:
163       useMPI_default='no'
164       mpi_path_default=None
165       mpi_lib_path_default=None
166       mpi_libs_default=[]
167       mpi_run_default=None
168    else:
169       useMPI_default='no'
170       mpi_root='/usr/local'
171       mpi_path_default=os.path.join(mpi_root,'include')
172       mpi_lib_path_default=os.path.join(mpi_root,'lib')
173       mpi_libs_default=[ 'mpich' , 'pthread', 'rt' ]
174       mpi_run_default='mpiexec -np 1'
175    #
176    #==========================================================================
177    #
178  #    compile:  #    compile:
179  #  #
180  cc_flags_default='-O3 -std=c99 -ffast-math -fpic -Wno-unknown-pragmas -ansi -pedantic-errors'  cc_flags_default='-O3 -std=c99 -ffast-math -fpic -Wno-unknown-pragmas -ansi'
181  cc_flags_debug_default='-g -O0 -ffast-math -std=c99 -fpic -Wno-unknown-pragmas -ansi -pedantic-errors'  cc_flags_debug_default='-g -O0 -ffast-math -std=c99 -fpic -Wno-unknown-pragmas -ansi'
182  cxx_flags_default='--no-warn -ansi'  cxx_flags_default='--no-warn -ansi'
183  cxx_flags_debug_default='--no-warn -ansi -DDOASSERT'  cxx_flags_debug_default='--no-warn -ansi -DDOASSERT'
184    
185  #==============================================================================================      #==============================================================================================    
186  # Default options and options help text  # Default options and options help text
187  # These are defaults and can be overridden using command line arguments or an options file.  # These are defaults and can be overridden using command line arguments or an options file.
# Line 166  opts.AddOptions( Line 193  opts.AddOptions(
193    ('libinstall', 'where the esys libraries will be installed',           dir_libraries),    ('libinstall', 'where the esys libraries will be installed',           dir_libraries),
194    ('pyinstall', 'where the esys python modules will be installed',       dir_packages),    ('pyinstall', 'where the esys python modules will be installed',       dir_packages),
195    ('exinstall', 'where the esys examples will be installed',             dir_examples),    ('exinstall', 'where the esys examples will be installed',             dir_examples),
196      ('sys_libinstall', 'where the system esys libraries will be installed',       sys_dir_libraries),
197      ('sys_pyinstall', 'where the system esys python modules will be installed',   sys_dir_packages),
198      ('sys_exinstall', 'where the system esys examples will be installed',         sys_dir_examples),
199    ('src_zipfile', 'the source zip file will be installed.',              Dir('#.').abspath+"/release/escript_src.zip"),    ('src_zipfile', 'the source zip file will be installed.',              Dir('#.').abspath+"/release/escript_src.zip"),
200    ('test_zipfile', 'the test zip file will be installed.',               Dir('#.').abspath+"/release/escript_tests.zip"),    ('test_zipfile', 'the test zip file will be installed.',               Dir('#.').abspath+"/release/escript_tests.zip"),
201    ('src_tarfile', 'the source tar file will be installed.',              Dir('#.').abspath+"/release/escript_src.tar.gz"),    ('src_tarfile', 'the source tar file will be installed.',              Dir('#.').abspath+"/release/escript_src.tar.gz"),
# Line 178  opts.AddOptions( Line 208  opts.AddOptions(
208    ('api_doxygen', 'name of the doxygen api docs directory',prefix+"/release/doc/doxygen"),    ('api_doxygen', 'name of the doxygen api docs directory',prefix+"/release/doc/doxygen"),
209  # Compilation options  # Compilation options
210    BoolOption('dodebug', 'Do you want a debug build?', 'no'),    BoolOption('dodebug', 'Do you want a debug build?', 'no'),
211      BoolOption('bounds_check', 'Do you want extra array bounds checking?', 'no'),
212    ('options_file', "Optional file containing preferred options. Ignored if it doesn't exist (default: scons/<hostname>_options.py)", options_file),    ('options_file', "Optional file containing preferred options. Ignored if it doesn't exist (default: scons/<hostname>_options.py)", options_file),
213    ('cc_defines','C/C++ defines to use', None),    ('cc_defines','C/C++ defines to use', None),
214    ('cc_flags','C compiler flags to use (Release build)', cc_flags_default),    ('cc_flags','C compiler flags to use (Release build)', cc_flags_default),
215    ('cc_flags_debug', 'C compiler flags to use (Debug build)', cc_flags_debug_default),    ('cc_flags_debug', 'C compiler flags to use (Debug build)', cc_flags_debug_default),
216    ('cxx_flags', 'C++ compiler flags to use (Release build)', cxx_flags_default),    ('cxx_flags', 'C++ compiler flags to use (Release build)', cxx_flags_default),
217    ('cxx_flags_debug', 'C++ compiler flags to use (Debug build)', cxx_flags_debug_default),    ('cxx_flags_debug', 'C++ compiler flags to use (Debug build)', cxx_flags_debug_default),
218      ('omp_flags', 'OpenMP compiler flags to use (Release build)', ''),
219      ('omp_flags_debug', 'OpenMP compiler flags to use (Debug build)', ''),
220    ('ar_flags', 'Static library archiver flags to use', None),    ('ar_flags', 'Static library archiver flags to use', None),
221    ('sys_libs', 'System libraries to link with', None),    ('sys_libs', 'System libraries to link with', None),
222    ('tar_flags','flags for zip files','-c -z'),    ('tar_flags','flags for zip files','-c -z'),
# Line 205  opts.AddOptions( Line 238  opts.AddOptions(
238    PathOption('amd_path', 'Path to AMD includes', amd_path_default),    PathOption('amd_path', 'Path to AMD includes', amd_path_default),
239    PathOption('amd_lib_path', 'Path to AMD libs', amd_lib_path_default),    PathOption('amd_lib_path', 'Path to AMD libs', amd_lib_path_default),
240    ('amd_libs', 'AMD libraries to link with', amd_libs_default),    ('amd_libs', 'AMD libraries to link with', amd_libs_default),
241    # ParMETIS
242      ('parmetis_path', 'Path to ParMETIS includes', ''),
243      ('parmetis_lib_path', 'Path to ParMETIS library', ''),
244      ('parmetis_lib', 'ParMETIS library to link with', []),
245    # TRILINOS
246      PathOption('trilinos_path', 'Path to TRILINOS includes', None),
247      PathOption('trilinos_lib_path', 'Path to TRILINOS libs', None),
248      ('trilinos_libs', 'TRILINOS libraries to link with', None),
249  # BLAS  # BLAS
250    PathOption('blas_path', 'Path to BLAS includes', None),    PathOption('blas_path', 'Path to BLAS includes', None),
251    PathOption('blas_lib_path', 'Path to BLAS libs', None),    PathOption('blas_lib_path', 'Path to BLAS libs', None),
# Line 216  opts.AddOptions( Line 257  opts.AddOptions(
257    ('netCDF_libs', 'netCDF C++ libraries to link with', netCDF_libs_default),    ('netCDF_libs', 'netCDF C++ libraries to link with', netCDF_libs_default),
258  # Python  # Python
259  # locations of include files for python  # locations of include files for python
260    # FIXME: python_path should be python_inc_path and the same for boost etc.
261    PathOption('python_path', 'Path to Python includes', python_path_default),    PathOption('python_path', 'Path to Python includes', python_path_default),
262    PathOption('python_lib_path', 'Path to Python libs', python_lib_path_default),    PathOption('python_lib_path', 'Path to Python libs', python_lib_path_default),
263    ('python_lib', 'Python libraries to link with', python_lib_default),    ('python_lib', 'Python libraries to link with', python_lib_default),
264      ('python_cmd', 'Python command', 'python'),
265  # Boost  # Boost
266    PathOption('boost_path', 'Path to Boost includes', boost_path_default),    PathOption('boost_path', 'Path to Boost includes', boost_path_default),
267    PathOption('boost_lib_path', 'Path to Boost libs', boost_lib_path_default),    PathOption('boost_lib_path', 'Path to Boost libs', boost_lib_path_default),
# Line 230  opts.AddOptions( Line 273  opts.AddOptions(
273    PathOption('papi_path', 'Path to PAPI includes', None),    PathOption('papi_path', 'Path to PAPI includes', None),
274    PathOption('papi_lib_path', 'Path to PAPI libs', None),    PathOption('papi_lib_path', 'Path to PAPI libs', None),
275    ('papi_libs', 'PAPI libraries to link with', None),    ('papi_libs', 'PAPI libraries to link with', None),
276      ('papi_instrument_solver', 'use PAPI in Solver.c to instrument each iteration of the solver', None),
277  # MPI  # MPI
278    BoolOption('useMPI', 'Compile parallel version using MPI', 'no'),    BoolOption('useMPI', 'Compile parallel version using MPI', useMPI_default),
279      ('MPICH_IGNORE_CXX_SEEK', 'name of macro to ignore MPI settings of C++ SEEK macro (for MPICH)' , 'MPICH_IGNORE_CXX_SEEK'),
280      PathOption('mpi_path', 'Path to MPI includes', mpi_path_default),
281      ('mpi_run', 'mpirun name' , mpi_run_default),
282      PathOption('mpi_lib_path', 'Path to MPI libs (needs to be added to the LD_LIBRARY_PATH)',mpi_lib_path_default),
283      ('mpi_libs', 'MPI libraries to link with (needs to be shared!)', mpi_libs_default)
284  )  )
285  #=================================================================================================  #=================================================================================================
286  #  #
# Line 243  opts.AddOptions( Line 292  opts.AddOptions(
292  #   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)  #   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)
293  #   FIXME: Perhaps a modification to intelc.py will allow better support for ia64 on altix  #   FIXME: Perhaps a modification to intelc.py will allow better support for ia64 on altix
294  #  #
 IS_WINDOWS_PLATFORM = (os.name== "nt")  
295    
296  if IS_WINDOWS_PLATFORM:  if IS_WINDOWS_PLATFORM:
297        env = Environment(tools = ['default', 'msvc'], options = opts)        env = Environment(tools = ['default', 'msvc'], options = opts)
298          #env = Environment(tools = ['default', 'intelc'], options = opts)
299  else:  else:
300     if os.uname()[4]=='ia64':     if socket.gethostname().split('.')[0] == 'service0':
301          env = Environment(tools = ['default', 'intelc'], options = opts)
302       elif os.uname()[4]=='ia64':
303        env = Environment(tools = ['default', 'intelc'], options = opts)        env = Environment(tools = ['default', 'intelc'], options = opts)
304        if env['CXX'] == 'icpc':        if env['CXX'] == 'icpc':
305           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           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
# Line 256  else: Line 307  else:
307        env = Environment(tools = ['default'], options = opts)        env = Environment(tools = ['default'], options = opts)
308  Help(opts.GenerateHelpText(env))  Help(opts.GenerateHelpText(env))
309    
310    if env['bounds_check']:
311       env.Append(CPPDEFINES = [ 'BOUNDS_CHECK' ])
312       env.Append(CXXDEFINES = [ 'BOUNDS_CHECK' ])
313       bounds_check = env['bounds_check']
314    else:
315       bounds_check = 0
316    
317  #=================================================================================================  #=================================================================================================
318  #  #
319  #     Initialise Scons Build Environment  #     Initialise Scons Build Environment
320  #     check for user environment variables we are interested in  #     check for user environment variables we are interested in
321  try:  try:
322     python_path = os.environ['PYTHONPATH']     tmp = os.environ['PYTHONPATH']
323     env['ENV']['PYTHONPATH'] = python_path     env['ENV']['PYTHONPATH'] = tmp
324  except KeyError:  except KeyError:
325     python_path = ''     pass
326    
327    env.PrependENVPath('PYTHONPATH', source_root)
328    
329  try:  try:
330     omp_num_threads = os.environ['OMP_NUM_THREADS']     omp_num_threads = os.environ['OMP_NUM_THREADS']
# Line 273  except KeyError: Line 333  except KeyError:
333  env['ENV']['OMP_NUM_THREADS'] = omp_num_threads  env['ENV']['OMP_NUM_THREADS'] = omp_num_threads
334    
335  try:  try:
336       path = os.environ['PATH']
337       env['ENV']['PATH'] = path
338    except KeyError:
339       omp_num_threads = 1
340    
341    env['ENV']['OMP_NUM_THREADS'] = omp_num_threads
342    
343    
344    # Copy some variables from the system environment to the build environment
345    try:
346     env['ENV']['DISPLAY'] = os.environ['DISPLAY']     env['ENV']['DISPLAY'] = os.environ['DISPLAY']
347     env['ENV']['XAUTHORITY'] = os.environ['XAUTHORITY']     env['ENV']['XAUTHORITY'] = os.environ['XAUTHORITY']
348       home_temp = os.environ['HOME']   # MPICH2's mpd needs $HOME to find $HOME/.mpd.conf
349       env['ENV']['HOME'] = home_temp
350  except KeyError:  except KeyError:
351     pass     pass
352    
353  try:  try:
354     path = os.environ['PATH']     tmp = os.environ['PATH']
355     env['ENV']['PATH'] = path     env['ENV']['PATH'] = tmp
356  except KeyError:  except KeyError:
357     path = ''     pass
358    
359  try:  try:
360     ld_library_path = os.environ['LD_LIBRARY_PATH']     tmp = os.environ['LD_LIBRARY_PATH']
361     env['ENV']['LD_LIBRARY_PATH'] = ld_library_path     env['ENV']['LD_LIBRARY_PATH'] = tmp
362  except KeyError:  except KeyError:
363     ld_library_path = ''     pass
364  #==========================================================================  #==========================================================================
365  #  #
366  #    Add some customer builders  #    Add some customer builders
# Line 295  except KeyError: Line 368  except KeyError:
368  py_builder = Builder(action = scons_extensions.build_py, suffix = '.pyc', src_suffix = '.py', single_source=True)  py_builder = Builder(action = scons_extensions.build_py, suffix = '.pyc', src_suffix = '.py', single_source=True)
369  env.Append(BUILDERS = {'PyCompile' : py_builder});  env.Append(BUILDERS = {'PyCompile' : py_builder});
370    
371  # TODO: use the inbuilt scons suffix variable.  runUnitTest_builder = Builder(action = scons_extensions.runUnitTest, suffix = '.passed',
372  if IS_WINDOWS_PLATFORM:                                src_suffix=env['PROGSUFFIX'], single_source=True)
373     runUnitTest_builder = Builder(action = scons_extensions.runUnitTest, suffix = '.passed', src_suffix='.exe', single_source=True)  
 else:  
    runUnitTest_builder = Builder(action = scons_extensions.runUnitTest, suffix = '.passed', single_source=True)  
374  env.Append(BUILDERS = {'RunUnitTest' : runUnitTest_builder});  env.Append(BUILDERS = {'RunUnitTest' : runUnitTest_builder});
375    
376  runPyUnitTest_builder = Builder(action = scons_extensions.runPyUnitTest, suffix = '.passed', src_suffic='.py', single_source=True)  runPyUnitTest_builder = Builder(action = scons_extensions.runPyUnitTest, suffix = '.passed', src_suffic='.py', single_source=True)
# Line 315  try: Line 386  try:
386     libinstall = env['libinstall']     libinstall = env['libinstall']
387     env.Append(LIBPATH = [libinstall,]) # Adds -L for building of libescript.so libfinley.so escriptcpp.so finleycpp.so     env.Append(LIBPATH = [libinstall,]) # Adds -L for building of libescript.so libfinley.so escriptcpp.so finleycpp.so
388     env.PrependENVPath('LD_LIBRARY_PATH', libinstall)     env.PrependENVPath('LD_LIBRARY_PATH', libinstall)
389     if env['PLATFORM'] == "win32":     if IS_WINDOWS_PLATFORM :
390        env.PrependENVPath('PATH', libinstall)        env.PrependENVPath('PATH', libinstall)
391        env.PrependENVPath('PATH', env['boost_lib_path'])        env.PrependENVPath('PATH', env['boost_lib_path'])
392  except KeyError:  except KeyError:
393     libinstall = None     libinstall = None
394  try:  try:
395     pyinstall = env['pyinstall'] # all targets will install into pyinstall/esys but PYTHONPATH points at straight pyinstall so you go import esys.escript etc     pyinstall = env['pyinstall'] # all targets will install into pyinstall/esys but PYTHONPATH points at straight pyinstall so you go import esys.escript etc
    env.PrependENVPath('PYTHONPATH', env['pyinstall'])  
396  except KeyError:  except KeyError:
397     pyinstall = None     pyinstall = None
398    
399    try:
400       cc_defines = env['cc_defines']
401       env.Append(CPPDEFINES = cc_defines)
402    except KeyError:
403       pass
404    try:
405       flags = env['ar_flags']
406       env.Append(ARFLAGS = flags)
407    except KeyError:
408       ar_flags = None
409    try:
410       sys_libs = env['sys_libs']
411    except KeyError:
412       sys_libs = []
413    
414    try:
415       tar_flags = env['tar_flags']
416       env.Replace(TARFLAGS = tar_flags)
417    except KeyError:
418       pass
419    
420  try:  try:
421     exinstall = env['exinstall']     exinstall = env['exinstall']
422  except KeyError:  except KeyError:
423     exinstall = None     exinstall = None
424  try:  try:
425       sys_libinstall = env['sys_libinstall']
426    except KeyError:
427       sys_libinstall = None
428    try:
429       sys_pyinstall = env['sys_pyinstall']
430    except KeyError:
431       sys_pyinstall = None
432    try:
433       sys_exinstall = env['sys_exinstall']
434    except KeyError:
435       sys_exinstall = None
436    
437    # ====================== debugging ===================================
438    try:
439     dodebug = env['dodebug']     dodebug = env['dodebug']
440  except KeyError:  except KeyError:
441     dodebug = None     dodebug = None
442    
443    # === switch on omp ===================================================
444  try:  try:
445     useMPI = env['useMPI']    omp_flags = env['omp_flags']
446  except KeyError:  except KeyError:
447     useMPI = None    omp_flags = ''
448    
449  try:  try:
450     cc_defines = env['cc_defines']    omp_flags_debug = env['omp_flags_debug']
    env.Append(CPPDEFINES = cc_defines)  
451  except KeyError:  except KeyError:
452     pass    omp_flags_debug = ''
453    
454    # ========= use mpi? =====================================================
455    try:
456       useMPI = env['useMPI']
457    except KeyError:
458       useMPI = None
459    # ========= set compiler flags ===========================================
460    
461  if dodebug:  if dodebug:
   if useMPI:  
462      try:      try:
463        flags = env['cc_flags_debug_MPI']        flags = env['cc_flags_debug'] + ' ' + omp_flags_debug
       env.Append(CCFLAGS = flags)  
     except KeyError:  
       pass  
   else:  
     try:  
       flags = env['cc_flags_debug']  
464        env.Append(CCFLAGS = flags)        env.Append(CCFLAGS = flags)
465      except KeyError:      except KeyError:
466        pass        pass
467  else:  else:
   if useMPI:  
    try:  
      flags = env['cc_flags_MPI']  
      env.Append(CCFLAGS = flags)  
    except KeyError:  
       pass  
   else:  
468     try:     try:
469        flags = env['cc_flags']        flags = env['cc_flags'] + ' ' + omp_flags
470        env.Append(CCFLAGS = flags)        env.Append(CCFLAGS = flags)
471     except KeyError:     except KeyError:
472        pass        pass
473  if dodebug:  if dodebug:
    if useMPI:  
      try:  
         flags = env['cxx_flags_debug_MPI']  
         env.Append(CXXFLAGS = flags)  
      except KeyError:  
         pass  
    else:  
474       try:       try:
475          flags = env['cxx_flags_debug']          flags = env['cxx_flags_debug']
476          env.Append(CXXFLAGS = flags)          env.Append(CXXFLAGS = flags)
477       except KeyError:       except KeyError:
478          pass          pass
479  else:  else:
    if useMPI:  
      try:  
         flags = env['cxx_flags_MPI']  
         env.Append(CXXFLAGS = flags)  
      except KeyError:  
         pass  
    else:  
480       try:       try:
481          flags = env['cxx_flags']          flags = env['cxx_flags']
482          env.Append(CXXFLAGS = flags)          env.Append(CXXFLAGS = flags)
483       except KeyError:       except KeyError:
484          pass          pass
485  try:  try:
486     flags = env['ar_flags']       if env['CC'] == 'gcc': env.Append(CCFLAGS = "-pedantic-errors -Wno-long-long")
487     env.Append(ARFLAGS = flags)  except:
488  except KeyError:       pass
489     ar_flags = None  
490  try:  # ============= Remember what options were used in the compile =====================================
491     sys_libs = env['sys_libs']  if not IS_WINDOWS_PLATFORM:
492  except KeyError:    env.Execute("/bin/rm -f " + libinstall + "/Compiled.with.*")
493     sys_libs = []    if dodebug:       env.Execute("touch " + libinstall + "/Compiled.with.debug")
494      if useMPI:        env.Execute("touch " + libinstall + "/Compiled.with.mpi")
495  try:    if omp_flags != '':   env.Execute("touch " + libinstall + "/Compiled.with.OpenMP")
496     tar_flags = env['tar_flags']    if bounds_check:  env.Execute("touch " + libinstall + "/Compiled.with.bounds_check")
    env.Replace(TARFLAGS = tar_flags)  
 except KeyError:  
    pass  
497    
498  try:  # ============= set mkl (but only of no MPI) =====================================
499     includes = env['mkl_path']  if not useMPI:
500     env.Append(CPPPATH = [includes,])     try:
501  except KeyError:        includes = env['mkl_path']
502     pass        env.Append(CPPPATH = [includes,])
503       except KeyError:
504          pass
505    
506  try:     try:
507     lib_path = env['mkl_lib_path']        lib_path = env['mkl_lib_path']
508     env.Append(LIBPATH = [lib_path,])        env.Append(LIBPATH = [lib_path,])
509  except KeyError:        env['ENV']['LD_LIBRARY_PATH']+=":"+lib_path
510     pass     except KeyError:
511          pass
512    
 if useMPI:  
    mkl_libs = []  
 else:  
513     try:     try:
514        mkl_libs = env['mkl_libs']        mkl_libs = env['mkl_libs']
515     except KeyError:     except KeyError:
516        mkl_libs = []        mkl_libs = []
517    else:
518         mkl_libs = []
519    
520  try:  # ============= set scsl (but only of no MPI) =====================================
521     includes = env['scsl_path']  if not useMPI:
522     env.Append(CPPPATH = [includes,])     try:
523  except KeyError:        includes = env['scsl_path']
524     pass        env.Append(CPPPATH = [includes,])
525       except KeyError:
526          pass
527    
528  try:     try:
529     lib_path = env['scsl_lib_path']        lib_path = env['scsl_lib_path']
530     env.Append(LIBPATH = [lib_path,])        env.Append(LIBPATH = [lib_path,])
531  except KeyError:        env['ENV']['LD_LIBRARY_PATH']+=":"+lib_path
532     pass     except KeyError:
533          pass
534      
535       try:
536          scsl_libs = env['scsl_libs']
537       except KeyError:
538          scsl_libs = [ ]
539    
540  if useMPI:  else:
541    try:      scsl_libs =  []
     scsl_libs = env['scsl_libs_MPI']  
   except KeyError:  
     scsl_libs = []  
 else:  
   try:  
     scsl_libs = env['scsl_libs']  
   except KeyError:  
     scsl_libs = []  
542    
543  try:  # ============= set TRILINOS (but only with MPI) =====================================
544     includes = env['umf_path']  if useMPI:
545     env.Append(CPPPATH = [includes,])     try:
546  except KeyError:        includes = env['trilinos_path']
547     pass        env.Append(CPPPATH = [includes,])
548       except KeyError:
549          pass
550    
551  try:     try:
552     lib_path = env['umf_lib_path']        lib_path = env['trilinos_lib_path']
553     env.Append(LIBPATH = [lib_path,])        env.Append(LIBPATH = [lib_path,])
554  except KeyError:     except KeyError:
555     pass        pass
556    
557  if useMPI:     try:
558      umf_libs = []        trilinos_libs = env['trilinos_libs']
559       except KeyError:
560          trilinos_libs = []
561  else:  else:
562         trilinos_libs = []
563    
564    
565    # ============= set umfpack (but only without MPI) =====================================
566    umf_libs=[ ]
567    if not useMPI:
568       try:
569          includes = env['umf_path']
570          env.Append(CPPPATH = [includes,])
571       except KeyError:
572          pass
573    
574       try:
575          lib_path = env['umf_lib_path']
576          env.Append(LIBPATH = [lib_path,])
577       except KeyError:
578          pass
579    
580     try:     try:
581        umf_libs = env['umf_libs']        umf_libs = env['umf_libs']
582          umf_libs+=umf_libs
583     except KeyError:     except KeyError:
584        umf_libs = []        pass
585    
586  try:     try:
587     includes = env['ufc_path']        includes = env['ufc_path']
588     env.Append(CPPPATH = [includes,])        env.Append(CPPPATH = [includes,])
589  except KeyError:     except KeyError:
590     pass        pass
591    
592  try:     try:
593     includes = env['amd_path']        includes = env['amd_path']
594     env.Append(CPPPATH = [includes,])        env.Append(CPPPATH = [includes,])
595  except KeyError:     except KeyError:
596     pass        pass
597    
598  try:     try:
599     lib_path = env['amd_lib_path']        lib_path = env['amd_lib_path']
600     env.Append(LIBPATH = [lib_path,])        env.Append(LIBPATH = [lib_path,])
601  except KeyError:     except KeyError:
602     pass        pass
603    
 if useMPI:  
     amd_libs = []  
 else:  
604     try:     try:
605        amd_libs = env['amd_libs']        amd_libs = env['amd_libs']
606          umf_libs+=amd_libs
607       except KeyError:
608          pass
609    
610    # ============= set TRILINOS (but only with MPI) =====================================
611    if useMPI:
612       try:
613          includes = env['trilinos_path']
614          env.Append(CPPPATH = [includes,])
615       except KeyError:
616          pass
617    
618       try:
619          lib_path = env['trilinos_lib_path']
620          env.Append(LIBPATH = [lib_path,])
621       except KeyError:
622          pass
623    
624       try:
625          trilinos_libs = env['trilinos_libs']
626     except KeyError:     except KeyError:
627        amd_libs = []        trilinos_libs = []
628    else:
629         trilinos_libs = []
630    
631    # ============= set blas =====================================
632  try:  try:
633     includes = env['blas_path']     includes = env['blas_path']
634     env.Append(CPPPATH = [includes,])     env.Append(CPPPATH = [includes,])
# Line 515  except KeyError: Line 644  except KeyError:
644  try:  try:
645     blas_libs = env['blas_libs']     blas_libs = env['blas_libs']
646  except KeyError:  except KeyError:
647     blas_libs = []     blas_libs = [ ]
648    
649    # ========== netcdf ====================================
650  try:  try:
651     useNetCDF = env['useNetCDF']     useNetCDF = env['useNetCDF']
652  except KeyError:  except KeyError:
653     useNetCDF = 'yes'     useNetCDF = 'yes'
654     pass     pass
655        
 if not useNetCDF == 'yes':  
    print "Warning: Installation is not configured with netCDF. Some I/O function may not be available."  
     
656  if useNetCDF == 'yes':  if useNetCDF == 'yes':
657     try:     try:
658          netCDF_libs = env['netCDF_libs']
659       except KeyError:
660          pass
661    
662       env.Append(LIBS = netCDF_libs)
663       env.Append(CPPDEFINES = [ 'USE_NETCDF' ])
664       try:
665        includes = env['netCDF_path']        includes = env['netCDF_path']
666        env.Append(CPPPATH = [includes,])        env.Append(CPPPATH = [includes,])
667     except KeyError:     except KeyError:
# Line 535  if useNetCDF == 'yes': Line 669  if useNetCDF == 'yes':
669    
670     try:     try:
671        lib_path = env['netCDF_lib_path']        lib_path = env['netCDF_lib_path']
       if IS_WINDOWS_PLATFORM: env['ENV']['PATH']+=";"+lib_path  
672        env.Append(LIBPATH = [ lib_path, ])        env.Append(LIBPATH = [ lib_path, ])
673          env['ENV']['LD_LIBRARY_PATH']+=":"+lib_path
674          if IS_WINDOWS_PLATFORM :
675             env.PrependENVPath('PATH', lib_path)
676     except KeyError:     except KeyError:
677        pass        pass
   
    try:  
       netCDF_libs = env['netCDF_libs']  
    except KeyError:  
       netCDF_libs = [ ]  
678  else:  else:
679       print "Warning: Installation is not configured with netCDF. Some I/O function may not be available."
680     netCDF_libs=[ ]     netCDF_libs=[ ]
681    
682    # ====================== boost ======================================
683  try:  try:
684     includes = env['boost_path']     includes = env['boost_path']
685     env.Append(CPPPATH = [includes,])     env.Append(CPPPATH = [includes,])
# Line 555  except KeyError: Line 688  except KeyError:
688  try:  try:
689     lib_path = env['boost_lib_path']     lib_path = env['boost_lib_path']
690     env.Append(LIBPATH = [lib_path,])     env.Append(LIBPATH = [lib_path,])
691       env['ENV']['LD_LIBRARY_PATH']+=":"+lib_path
692       if IS_WINDOWS_PLATFORM :
693          env.PrependENVPath('PATH', lib_path)
694  except KeyError:  except KeyError:
695     pass     pass
696  try:  try:
697     boost_lib = env['boost_lib']     boost_lib = env['boost_lib']
698  except KeyError:  except KeyError:
699     boost_lib = None     boost_lib = None
700    # ====================== python ======================================
701  try:  try:
702     includes = env['python_path']     includes = env['python_path']
703     env.Append(CPPPATH = [includes,])     env.Append(CPPPATH = [includes,])
# Line 568  except KeyError: Line 705  except KeyError:
705     pass     pass
706  try:  try:
707     lib_path = env['python_lib_path']     lib_path = env['python_lib_path']
708       env['ENV']['LD_LIBRARY_PATH']+=":"+lib_path
709     env.Append(LIBPATH = [lib_path,])     env.Append(LIBPATH = [lib_path,])
710  except KeyError:  except KeyError:
711     pass     pass
# Line 575  try: Line 713  try:
713     python_lib = env['python_lib']     python_lib = env['python_lib']
714  except KeyError:  except KeyError:
715     python_lib = None     python_lib = None
716    # =============== documentation =======================================
717  try:  try:
718     doxygen_path = env['doxygen_path']     doxygen_path = env['doxygen_path']
719  except KeyError:  except KeyError:
# Line 583  try: Line 722  try:
722     epydoc_path = env['epydoc_path']     epydoc_path = env['epydoc_path']
723  except KeyError:  except KeyError:
724     epydoc_path = None     epydoc_path = None
725    # =============== ParMETIS =======================================
726    try:
727       parmetis_path = env['parmetis_path']
728       parmetis_lib_path = env['parmetis_lib_path']
729       parmetis_lib = env['parmetis_lib']
730    except KeyError:
731       parmetis_path = ''
732       parmetis_lib_path = ''
733       parmetis_lib = ''
734    
735    if useMPI and os.path.isdir(parmetis_lib_path):
736       env.Append(CPPDEFINES = [ 'PARMETIS' ])
737       env.Append(CXXDEFINES = [ 'PARMETIS' ])
738       env.Append(CPPPATH = [parmetis_path])
739       env.Append(LIBPATH = [parmetis_lib_path])
740       env.Append(LIBS = parmetis_lib)
741    # =============== PAPI =======================================
742    try:
743       includes = env['papi_path']
744       env.Append(CPPPATH = [includes,])
745    except KeyError:
746       pass
747    try:
748       lib_path = env['papi_lib_path']
749       env.Append(LIBPATH = [lib_path,])
750    except KeyError:
751       pass
752    try:
753       papi_libs = env['papi_libs']
754    except KeyError:
755       papi_libs = None
756    # ============= set mpi =====================================
757    if useMPI:
758       env.Append(CPPDEFINES=['PASO_MPI', 'MPI_NO_CPPBIND'])
759       try:
760          includes = env['mpi_path']
761          env.Append(CPPPATH = [includes,])
762       except KeyError:
763          pass
764       try:
765          lib_path = env['mpi_lib_path']
766          env.Append(LIBPATH = [lib_path,])
767          env['ENV']['LD_LIBRARY_PATH']+=":"+lib_path
768       except KeyError:
769          pass
770       try:
771          mpi_libs = env['mpi_libs']
772       except KeyError:
773          mpi_libs = []
774    
775       try:
776          mpi_run = env['mpi_run']
777       except KeyError:
778          mpi_run = ''
779    
780       try:
781           mpich_ignore_cxx_seek=env['MPICH_IGNORE_CXX_SEEK']
782           env.Append(CPPDEFINES = [ mpich_ignore_cxx_seek ] )
783       except KeyError:
784          pass
785    else:
786      mpi_libs=[]
787      mpi_run = mpi_run_default
788    # =========== zip files ===========================================
789  try:  try:
790     includes = env['papi_path']     includes = env['papi_path']
791     env.Append(CPPPATH = [includes,])     env.Append(CPPPATH = [includes,])
# Line 597  try: Line 800  try:
800     papi_libs = env['papi_libs']     papi_libs = env['papi_libs']
801  except KeyError:  except KeyError:
802     papi_libs = None     papi_libs = None
803    try:
804       papi_instrument_solver = env['papi_instrument_solver']
805    except KeyError:
806       papi_instrument_solver = None
807    
808    
809    # ============= and some helpers =====================================
810    try:
811       doxygen_path = env['doxygen_path']
812    except KeyError:
813       doxygen_path = None
814    try:
815       epydoc_path = env['epydoc_path']
816    except KeyError:
817       epydoc_path = None
818  try:  try:
819     src_zipfile = env.File(env['src_zipfile'])     src_zipfile = env.File(env['src_zipfile'])
820  except KeyError:  except KeyError:
# Line 645  try: Line 861  try:
861  except KeyError:  except KeyError:
862     api_doxygen = None     api_doxygen = None
863    
864    try:
865       svn_pipe = os.popen("svnversion -n .")
866       global_revision = svn_pipe.readlines()
867       svn_pipe.close()
868       global_revision = re.sub(":.*", "", global_revision[0])
869       global_revision = re.sub("[^0-9]", "", global_revision)
870    except:
871       global_revision="-1"
872       print "Warning: unable to recover global revsion number."
873    if global_revision == "": global_revision="0"
874    print "Revision number is %s."%global_revision
875    env.Append(CPPDEFINES = "SVN_VERSION="+global_revision)
876    
877    # Python install - esys __init__.py
878    init_target = env.Command(pyinstall+'/__init__.py', None, Touch('$TARGET'))
879    
880    # FIXME: exinstall and friends related to examples are not working.
881    build_target = env.Alias('build',[libinstall,incinstall,pyinstall,init_target])
882    
883    env.Default(build_target)
884    
885  # Zipgets  # Zipgets
 env.Default(libinstall)  
 env.Default(incinstall)  
 env.Default(pyinstall)  
 ### env.Default(exinstall) # ksteube this causes dependency error  
886  env.Alias('release_src',[ src_zipfile, src_tarfile ])  env.Alias('release_src',[ src_zipfile, src_tarfile ])
887  env.Alias('release_tests',[ test_zipfile, test_tarfile])  env.Alias('release_tests',[ test_zipfile, test_tarfile])
888  env.Alias('release_examples',[ examples_zipfile, examples_tarfile])  env.Alias('release_examples',[ examples_zipfile, examples_tarfile])
# Line 661  env.Alias('guide_html_index',guide_html_ Line 894  env.Alias('guide_html_index',guide_html_
894  env.Alias('guide_pdf', guide_pdf)  env.Alias('guide_pdf', guide_pdf)
895  env.Alias('docs',[ 'release_examples', 'guide_pdf', api_epydoc, api_doxygen, guide_html_index])  env.Alias('docs',[ 'release_examples', 'guide_pdf', api_epydoc, api_doxygen, guide_html_index])
896  env.Alias('release', ['release_src', 'release_tests', 'docs'])  env.Alias('release', ['release_src', 'release_tests', 'docs'])
897  env.Alias('build_tests')    # target to build all C++ tests  
898  env.Alias('build_py_tests') # target to build all python tests  env.Alias('build_tests',build_target)    # target to build all C++ tests
899    env.Alias('build_py_tests',build_target) # target to build all python tests
900  env.Alias('build_all_tests', [ 'build_tests', 'build_py_tests' ] ) # target to build all python tests  env.Alias('build_all_tests', [ 'build_tests', 'build_py_tests' ] ) # target to build all python tests
901  env.Alias('run_tests', 'build_tests')   # target to run all C++ test  env.Alias('run_tests', 'build_tests')   # target to run all C++ test
902  env.Alias('py_tests', 'build_py_tests') # taget to run all released python tests  env.Alias('py_tests', 'build_py_tests') # taget to run all released python tests
903  env.Alias('all_tests', ['run_tests', 'py_tests']) # target to run all C++ and released python tests  env.Alias('all_tests', ['run_tests', 'py_tests']) # target to run all C++ and released python tests
904    
 # Python install - esys __init__.py  
 init_target = env.Command(pyinstall+'/__init__.py', None, Touch('$TARGET'))  
 env.Alias(init_target)  
905    
906  # Allow sconscripts to see the env  # Allow sconscripts to see the env
907  Export(["IS_WINDOWS_PLATFORM", "env", "incinstall", "libinstall", "pyinstall", "exinstall", "dodebug", "mkl_libs", "scsl_libs", "umf_libs", "amd_libs", "blas_libs", "netCDF_libs", "useNetCDF",  Export(["IS_WINDOWS_PLATFORM", "env", "incinstall", "libinstall", "pyinstall", "dodebug", "mkl_libs", "scsl_libs", "umf_libs", "blas_libs", "netCDF_libs", "useNetCDF", "mpi_run",
908      "boost_lib", "python_lib", "doxygen_path", "epydoc_path", "papi_libs",      "boost_lib", "python_lib", "doxygen_path", "epydoc_path", "papi_libs",
909          "sys_libs", "test_zipfile", "src_zipfile", "test_tarfile", "src_tarfile", "examples_tarfile", "examples_zipfile",          "sys_libs", "test_zipfile", "src_zipfile", "test_tarfile", "src_tarfile", "examples_tarfile", "examples_zipfile", "trilinos_libs", "mpi_libs", "papi_instrument_solver",
910          "guide_pdf", "guide_html_index", "api_epydoc", "api_doxygen", "useMPI" ])          "guide_pdf", "guide_html_index", "api_epydoc", "api_doxygen", "useMPI" ])
911    
912  # End initialisation section  # End initialisation section
913  # Begin configuration section  # Begin configuration section
914  # adds this file and the scons option directore to the source tar  # adds this file and the scons option directore to the source tar
915  release_srcfiles=[env.File('SConstruct'),]+[ env.File(x) for x in glob.glob('scons/*.py') ]  release_srcfiles=[env.File('SConstruct'),env.Dir('lib'),env.Dir('include'),]+[ env.File(x) for x in glob.glob('scons/*.py') ]
916  release_testfiles=[env.File('README_TESTS'),]  release_testfiles=[env.File('README_TESTS'),]
917  env.Zip(src_zipfile, release_srcfiles)  env.Zip(src_zipfile, release_srcfiles)
918  env.Zip(test_zipfile, release_testfiles)  env.Zip(test_zipfile, release_testfiles)
# Line 706  env.SConscript(dirs = ['modellib/py_src' Line 937  env.SConscript(dirs = ['modellib/py_src'
937  env.SConscript(dirs = ['doc'], build_dir='build/$PLATFORM/doc', duplicate=0)  env.SConscript(dirs = ['doc'], build_dir='build/$PLATFORM/doc', duplicate=0)
938  env.SConscript(dirs = ['pyvisi/py_src'], build_dir='build/$PLATFORM/pyvisi', duplicate=0)  env.SConscript(dirs = ['pyvisi/py_src'], build_dir='build/$PLATFORM/pyvisi', duplicate=0)
939  env.SConscript(dirs = ['pycad/py_src'], build_dir='build/$PLATFORM/pycad', duplicate=0)  env.SConscript(dirs = ['pycad/py_src'], build_dir='build/$PLATFORM/pycad', duplicate=0)
   
 # added by Ben Cumming  
940  env.SConscript(dirs = ['pythonMPI/src'], build_dir='build/$PLATFORM/pythonMPI', duplicate=0)  env.SConscript(dirs = ['pythonMPI/src'], build_dir='build/$PLATFORM/pythonMPI', duplicate=0)
941  #env.SConscript(dirs = ['../test'], build_dir='../test/build', duplicate=0)  #env.SConscript(dirs = ['../test'], build_dir='../test/build', duplicate=0)
942    
943    
944    syslib_install_target = env.installDirectory(sys_libinstall,libinstall)
945    syspy_install_target = env.installDirectory(sys_pyinstall,pyinstall,recursive=True)
946    
947    install_target = env.Alias("install", env.Flatten([syslib_install_target, syspy_install_target]) )

Legend:
Removed from v.1235  
changed lines
  Added in v.1560

  ViewVC Help
Powered by ViewVC 1.1.26