/[escript]/trunk/SConstruct
ViewVC logotype

Diff of /trunk/SConstruct

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

revision 3259 by jfenwick, Mon Oct 11 01:48:14 2010 UTC revision 3597 by caltinay, Thu Sep 15 06:03:17 2011 UTC
# Line 19  from site_init import * Line 19  from site_init import *
19    
20  # Version number to check for in options file. Increment when new features are  # Version number to check for in options file. Increment when new features are
21  # added or existing options changed.  # added or existing options changed.
22  REQUIRED_OPTS_VERSION=200  REQUIRED_OPTS_VERSION=201
23    
24  # MS Windows support, many thanks to PH  # MS Windows support, many thanks to PH
25  IS_WINDOWS = (os.name == 'nt')  IS_WINDOWS = (os.name == 'nt')
# Line 54  vars = Variables(options_file, ARGUMENTS Line 54  vars = Variables(options_file, ARGUMENTS
54  vars.AddVariables(  vars.AddVariables(
55    PathVariable('options_file', 'Path to options file', options_file, PathVariable.PathIsFile),    PathVariable('options_file', 'Path to options file', options_file, PathVariable.PathIsFile),
56    PathVariable('prefix', 'Installation prefix', Dir('#.').abspath, PathVariable.PathIsDirCreate),    PathVariable('prefix', 'Installation prefix', Dir('#.').abspath, PathVariable.PathIsDirCreate),
57      PathVariable('build_dir', 'Top-level build directory', Dir('#/build').abspath, PathVariable.PathIsDirCreate),
58    BoolVariable('verbose', 'Output full compile/link lines', False),    BoolVariable('verbose', 'Output full compile/link lines', False),
59  # Compiler/Linker options  # Compiler/Linker options
60    ('cc', 'Path to C compiler', 'default'),    ('cc', 'Path to C compiler', 'default'),
# Line 71  vars.AddVariables( Line 72  vars.AddVariables(
72    ('omp_ldflags', 'OpenMP linker flags', 'default'),    ('omp_ldflags', 'OpenMP linker flags', 'default'),
73  # Mandatory libraries  # Mandatory libraries
74    ('boost_prefix', 'Prefix/Paths of boost installation', default_prefix),    ('boost_prefix', 'Prefix/Paths of boost installation', default_prefix),
75    ('boost_libs', 'Boost libraries to link with', ['boost_python']),    ('boost_libs', 'Boost libraries to link with', ['boost_python-mt']),
76    # Mandatory for tests
77      ('cppunit_prefix', 'Prefix/Paths of CppUnit installation', default_prefix),
78      ('cppunit_libs', 'CppUnit libraries to link with', ['cppunit']),
79  # Optional libraries and options  # Optional libraries and options
80    EnumVariable('mpi', 'Compile parallel version using MPI flavour', 'none', allowed_values=mpi_flavours),    EnumVariable('mpi', 'Compile parallel version using MPI flavour', 'none', allowed_values=mpi_flavours),
81    ('mpi_prefix', 'Prefix/Paths of MPI installation', default_prefix),    ('mpi_prefix', 'Prefix/Paths of MPI installation', default_prefix),
# Line 92  vars.AddVariables( Line 96  vars.AddVariables(
96    BoolVariable('umfpack', 'Enable UMFPACK', False),    BoolVariable('umfpack', 'Enable UMFPACK', False),
97    ('umfpack_prefix', 'Prefix/Paths to UMFPACK installation', default_prefix),    ('umfpack_prefix', 'Prefix/Paths to UMFPACK installation', default_prefix),
98    ('umfpack_libs', 'UMFPACK libraries to link with', ['umfpack']),    ('umfpack_libs', 'UMFPACK libraries to link with', ['umfpack']),
99      BoolVariable('boomeramg', 'Enable BoomerAMG', False),
100      ('boomeramg_prefix', 'Prefix/Paths to BoomerAMG installation', default_prefix),
101      ('boomeramg_libs', 'BoomerAMG libraries to link with', ['boomeramg']),
102    EnumVariable('lapack', 'Set LAPACK flavour', 'none', allowed_values=lapack_flavours),    EnumVariable('lapack', 'Set LAPACK flavour', 'none', allowed_values=lapack_flavours),
103    ('lapack_prefix', 'Prefix/Paths to LAPACK installation', default_prefix),    ('lapack_prefix', 'Prefix/Paths to LAPACK installation', default_prefix),
104    ('lapack_libs', 'LAPACK libraries to link with', []),    ('lapack_libs', 'LAPACK libraries to link with', []),
# Line 102  vars.AddVariables( Line 109  vars.AddVariables(
109    ('visit_prefix', 'Prefix/Paths to VisIt installation', default_prefix),    ('visit_prefix', 'Prefix/Paths to VisIt installation', default_prefix),
110    ('visit_libs', 'VisIt libraries to link with', ['simV2']),    ('visit_libs', 'VisIt libraries to link with', ['simV2']),
111    BoolVariable('pyvisi', 'Enable pyvisi (deprecated, requires VTK module)', False),    BoolVariable('pyvisi', 'Enable pyvisi (deprecated, requires VTK module)', False),
112      BoolVariable('vsl_random', 'Use VSL from intel for random data', False),
113  # Advanced settings  # Advanced settings
114    #dudley_assemble_flags = -funroll-loops      to actually do something    #dudley_assemble_flags = -funroll-loops      to actually do something
115    ('dudley_assemble_flags', 'compiler flags for some dudley optimisations', ''),    ('dudley_assemble_flags', 'compiler flags for some dudley optimisations', ''),
# Line 125  vars.AddVariables( Line 133  vars.AddVariables(
133  # Intel's compiler uses regular expressions improperly and emits a warning  # Intel's compiler uses regular expressions improperly and emits a warning
134  # about failing to find the compilers. This warning can be safely ignored.  # about failing to find the compilers. This warning can be safely ignored.
135    
136  env = Environment(tools = ['default'], options = vars)  # PATH is needed so the compiler, linker and tools are found if they are not
137    # in default locations.
138    env = Environment(tools = ['default'], options = vars,
139                      ENV = {'PATH': os.environ['PATH']})
140  if env['tools_names'] != 'default':  if env['tools_names'] != 'default':
141      env = Environment(tools = ['default'] + env['tools_names'], options = vars)      env = Environment(tools = ['default'] + env['tools_names'], options = vars,
142                          ENV = {'PATH' : os.environ['PATH']})
143    
144  if options_file:  if options_file:
145      opts_valid=False      opts_valid=False
# Line 146  if options_file: Line 158  if options_file:
158  Help(vars.GenerateHelpText(env))  Help(vars.GenerateHelpText(env))
159    
160  # Check for superfluous options  # Check for superfluous options
161  for k in vars.UnknownVariables():  if len(vars.UnknownVariables())>0:
162      print("WARNING: Ignoring unknown option '%s'" % k)      for k in vars.UnknownVariables():
163            print("Unknown option '%s'" % k)
164        Exit(1)
165    
166  #################### Make sure install directories exist #####################  #################### Make sure install directories exist #####################
167    
168    env['BUILD_DIR']=env['build_dir']
169  prefix=Dir(env['prefix']).abspath  prefix=Dir(env['prefix']).abspath
170  env['incinstall'] = os.path.join(prefix, 'include')  env['incinstall'] = os.path.join(prefix, 'include')
171  env['bininstall'] = os.path.join(prefix, 'bin')  env['bininstall'] = os.path.join(prefix, 'bin')
# Line 277  try: Line 292  try:
292      if global_revision == '': global_revision='-2'      if global_revision == '': global_revision='-2'
293  except:  except:
294      global_revision = '-1'      global_revision = '-1'
295    env['svn_revision']=global_revision
296  env.Append(CPPDEFINES=['SVN_VERSION='+global_revision])  env.Append(CPPDEFINES=['SVN_VERSION='+global_revision])
297    
298  if IS_WINDOWS:  if IS_WINDOWS:
# Line 294  if IS_WINDOWS: Line 310  if IS_WINDOWS:
310  else:  else:
311      LD_LIBRARY_PATH_KEY='LD_LIBRARY_PATH'      LD_LIBRARY_PATH_KEY='LD_LIBRARY_PATH'
312    
313  # the following env variables are exported for the unit tests, PATH is needed  # the following env variables are exported for the unit tests
 # so the compiler/linker is found if they are not in default locations.  
314    
315  for key in 'OMP_NUM_THREADS', 'ESCRIPT_NUM_PROCS', 'ESCRIPT_NUM_NODES':  for key in 'OMP_NUM_THREADS', 'ESCRIPT_NUM_PROCS', 'ESCRIPT_NUM_NODES':
316      try:      try:
# Line 304  for key in 'OMP_NUM_THREADS', 'ESCRIPT_N Line 319  for key in 'OMP_NUM_THREADS', 'ESCRIPT_N
319          env['ENV'][key] = 1          env['ENV'][key] = 1
320    
321  env_export=env['env_export']  env_export=env['env_export']
322  env_export.extend(['ESCRIPT_NUM_THREADS','ESCRIPT_HOSTFILE','DISPLAY','XAUTHORITY','PATH','HOME'])  env_export.extend(['ESCRIPT_NUM_THREADS','ESCRIPT_HOSTFILE','DISPLAY','XAUTHORITY','PATH','HOME','TMPDIR','TEMP','TMP'])
323    
324  for key in set(env_export):  for key in set(env_export):
325      try:      try:
# Line 373  if conf.CheckFunc('gethostname'): Line 388  if conf.CheckFunc('gethostname'):
388  python_inc_path=sysconfig.get_python_inc()  python_inc_path=sysconfig.get_python_inc()
389  if IS_WINDOWS:  if IS_WINDOWS:
390      python_lib_path=os.path.join(sysconfig.get_config_var('prefix'), 'libs')      python_lib_path=os.path.join(sysconfig.get_config_var('prefix'), 'libs')
391    elif env['PLATFORM']=='darwin':
392        python_lib_path=sysconfig.get_config_var('LIBPL')
393  else:  else:
394      python_lib_path=sysconfig.get_config_var('LIBDIR')      python_lib_path=sysconfig.get_config_var('LIBDIR')
395  #python_libs=[sysconfig.get_config_var('LDLIBRARY')] # only on linux  #python_libs=[sysconfig.get_config_var('LDLIBRARY')] # only on linux
# Line 426  except ImportError: Line 443  except ImportError:
443      print("Cannot import numpy, you need to set your PYTHONPATH and probably %s"%LD_LIBRARY_PATH_KEY)      print("Cannot import numpy, you need to set your PYTHONPATH and probably %s"%LD_LIBRARY_PATH_KEY)
444      Exit(1)      Exit(1)
445    
446    ######## CppUnit (required for tests)
447    
448    try:
449        cppunit_inc_path,cppunit_lib_path=findLibWithHeader(env, env['cppunit_libs'], 'cppunit/TestFixture.h', env['cppunit_prefix'], lang='c++')
450        env.AppendUnique(CPPPATH = [cppunit_inc_path])
451        env.AppendUnique(LIBPATH = [cppunit_lib_path])
452        env.PrependENVPath(LD_LIBRARY_PATH_KEY, cppunit_lib_path)
453        env['cppunit']=True
454    except:
455        env['cppunit']=False
456    
457  ######## VTK (optional)  ######## VTK (optional)
458    
459  if env['pyvisi']:  if env['pyvisi']:
# Line 516  if env['silo']: Line 544  if env['silo']:
544      # weipa library and tools.      # weipa library and tools.
545      #env.AppendUnique(LIBS = [env['silo_libs']])      #env.AppendUnique(LIBS = [env['silo_libs']])
546    
547    ######## VSL random numbers (optional)
548    if env['vsl_random']:
549        env.Append(CPPDEFINES = ['MKLRANDOM'])
550    
551  ######## VisIt (optional)  ######## VisIt (optional)
552    
553  visit_inc_path=''  visit_inc_path=''
# Line 543  if env['usempi']: Line 575  if env['usempi']:
575      if env['netcdf'] and env['mpi'] in ['MPT','OPENMPI']:      if env['netcdf'] and env['mpi'] in ['MPT','OPENMPI']:
576          env.Append(CPPDEFINES = ['MPI_INCLUDED'])          env.Append(CPPDEFINES = ['MPI_INCLUDED'])
577    
578    ######## BOOMERAMG (optional)
579    
580    if env['mpi'] == 'none': env['boomeramg'] = False
581    
582    boomeramg_inc_path=''
583    boomeramg_lib_path=''
584    if env['boomeramg']:
585        boomeramg_inc_path,boomeramg_lib_path=findLibWithHeader(env, env['boomeramg_libs'], 'HYPRE.h', env['boomeramg_prefix'], lang='c')
586        env.AppendUnique(CPPPATH = [boomeramg_inc_path])
587        env.AppendUnique(LIBPATH = [boomeramg_lib_path])
588        env.AppendUnique(LIBS = env['boomeramg_libs'])
589        env.PrependENVPath(LD_LIBRARY_PATH_KEY, boomeramg_lib_path)
590        env.Append(CPPDEFINES = ['BOOMERAMG'])
591    
592  ######## ParMETIS (optional)  ######## ParMETIS (optional)
593    
594  if not env['usempi']: env['parmetis'] = False  if not env['usempi']: env['parmetis'] = False
# Line 557  if env['parmetis']: Line 603  if env['parmetis']:
603      env.PrependENVPath(LD_LIBRARY_PATH_KEY, parmetis_lib_path)      env.PrependENVPath(LD_LIBRARY_PATH_KEY, parmetis_lib_path)
604      env.Append(CPPDEFINES = ['USE_PARMETIS'])      env.Append(CPPDEFINES = ['USE_PARMETIS'])
605    
606    ######## gmsh (optional, for tests)
607    
608    try:
609        import subprocess
610        p=subprocess.Popen(['gmsh', '-info'], stderr=subprocess.PIPE)
611        _,e=p.communicate()
612        if e.split().count("MPI"):
613            env['gmsh']='m'
614        else:
615            env['gmsh']='s'
616    except OSError:
617        env['gmsh']=False
618    
619  ######################## Summarize our environment ###########################  ######################## Summarize our environment ###########################
620    
621  # keep some of our install paths first in the list for the unit tests  # keep some of our install paths first in the list for the unit tests
# Line 572  if not env['verbose']: Line 631  if not env['verbose']:
631      env['ARCOMSTR'] = "Linking $TARGET"      env['ARCOMSTR'] = "Linking $TARGET"
632      env['LINKCOMSTR'] = "Linking $TARGET"      env['LINKCOMSTR'] = "Linking $TARGET"
633      env['SHLINKCOMSTR'] = "Linking $TARGET"      env['SHLINKCOMSTR'] = "Linking $TARGET"
634        env['PDFLATEXCOMSTR'] = "Building $TARGET from LaTeX input $SOURCES"
635        env['BIBTEXCOMSTR'] = "Generating bibliography $TARGET"
636        env['MAKEINDEXCOMSTR'] = "Generating index $TARGET"
637        env['PDFLATEXCOMSTR'] = "Building $TARGET from LaTeX input $SOURCES"
638      #Progress(['Checking -\r', 'Checking \\\r', 'Checking |\r', 'Checking /\r'], interval=17)      #Progress(['Checking -\r', 'Checking \\\r', 'Checking |\r', 'Checking /\r'], interval=17)
639    
640  print("")  print("")
# Line 591  else: Line 654  else:
654      print("          LAPACK:  DISABLED")      print("          LAPACK:  DISABLED")
655  d_list=[]  d_list=[]
656  e_list=[]  e_list=[]
657  for i in 'debug','openmp','netcdf','parmetis','papi','mkl','umfpack','silo','visit','pyvisi':  for i in 'debug','openmp','netcdf','parmetis','papi','mkl','umfpack','boomeramg','silo','visit':
658      if env[i]: e_list.append(i)      if env[i]: e_list.append(i)
659      else: d_list.append(i)      else: d_list.append(i)
660  for i in e_list:  for i in e_list:
661      print("%16s:  YES"%i)      print("%16s:  YES"%i)
662  for i in d_list:  for i in d_list:
663      print("%16s:  DISABLED"%i)      print("%16s:  DISABLED"%i)
664    if env['cppunit']:
665        print("         CppUnit:  FOUND")
666    else:
667        print("         CppUnit:  NOT FOUND")
668    if env['gmsh']=='m':
669        print("            gmsh:  FOUND, MPI-ENABLED")
670    elif env['gmsh']=='s':
671        print("            gmsh:  FOUND")
672    else:
673        print("            gmsh:  NOT FOUND")
674    print("      vsl_random:  %s"%env['vsl_random'])
675        
676  if ((fatalwarning != '') and (env['werror'])):  if ((fatalwarning != '') and (env['werror'])):
677      print("  Treating warnings as errors")      print("  Treating warnings as errors")
678  else:  else:
# Line 626  Export( Line 701  Export(
701    ]    ]
702  )  )
703    
704  env.SConscript(dirs = ['tools/CppUnitTest/src'], variant_dir='build/$PLATFORM/tools/CppUnitTest', duplicate=0)  env.SConscript(dirs = ['tools/escriptconvert'], variant_dir='$BUILD_DIR/$PLATFORM/tools/escriptconvert', duplicate=0)
705  env.SConscript(dirs = ['tools/escriptconvert'], variant_dir='build/$PLATFORM/tools/escriptconvert', duplicate=0)  env.SConscript(dirs = ['paso/src'], variant_dir='$BUILD_DIR/$PLATFORM/paso', duplicate=0)
706  env.SConscript(dirs = ['paso/src'], variant_dir='build/$PLATFORM/paso', duplicate=0)  env.SConscript(dirs = ['weipa/src'], variant_dir='$BUILD_DIR/$PLATFORM/weipa', duplicate=0)
707  env.SConscript(dirs = ['weipa/src'], variant_dir='build/$PLATFORM/weipa', duplicate=0)  env.SConscript(dirs = ['escript/src'], variant_dir='$BUILD_DIR/$PLATFORM/escript', duplicate=0)
708  env.SConscript(dirs = ['escript/src'], variant_dir='build/$PLATFORM/escript', duplicate=0)  env.SConscript(dirs = ['esysUtils/src'], variant_dir='$BUILD_DIR/$PLATFORM/esysUtils', duplicate=0)
709  env.SConscript(dirs = ['esysUtils/src'], variant_dir='build/$PLATFORM/esysUtils', duplicate=0)  env.SConscript(dirs = ['dudley/src'], variant_dir='$BUILD_DIR/$PLATFORM/dudley', duplicate=0)
710  env.SConscript(dirs = ['dudley/src'], variant_dir='build/$PLATFORM/dudley', duplicate=0)  env.SConscript(dirs = ['finley/src'], variant_dir='$BUILD_DIR/$PLATFORM/finley', duplicate=0)
711  env.SConscript(dirs = ['finley/src'], variant_dir='build/$PLATFORM/finley', duplicate=0)  env.SConscript(dirs = ['modellib/py_src'], variant_dir='$BUILD_DIR/$PLATFORM/modellib', duplicate=0)
712  env.SConscript(dirs = ['modellib/py_src'], variant_dir='build/$PLATFORM/modellib', duplicate=0)  env.SConscript(dirs = ['doc'], variant_dir='$BUILD_DIR/$PLATFORM/doc', duplicate=0)
713  env.SConscript(dirs = ['doc'], variant_dir='build/$PLATFORM/doc', duplicate=0)  env.SConscript(dirs = ['pyvisi/py_src'], variant_dir='$BUILD_DIR/$PLATFORM/pyvisi', duplicate=0)
714  env.SConscript(dirs = ['pyvisi/py_src'], variant_dir='build/$PLATFORM/pyvisi', duplicate=0)  env.SConscript(dirs = ['pycad/py_src'], variant_dir='$BUILD_DIR/$PLATFORM/pycad', duplicate=0)
715  env.SConscript(dirs = ['pycad/py_src'], variant_dir='build/$PLATFORM/pycad', duplicate=0)  env.SConscript(dirs = ['pythonMPI/src'], variant_dir='$BUILD_DIR/$PLATFORM/pythonMPI', duplicate=0)
716  env.SConscript(dirs = ['pythonMPI/src'], variant_dir='build/$PLATFORM/pythonMPI', duplicate=0)  env.SConscript(dirs = ['paso/profiling'], variant_dir='$BUILD_DIR/$PLATFORM/paso/profiling', duplicate=0)
 env.SConscript(dirs = ['paso/profiling'], variant_dir='build/$PLATFORM/paso/profiling', duplicate=0)  
717    
718  ######################## Populate the buildvars file #########################  ######################## Populate the buildvars file #########################
719    
# Line 677  buildvars.write("mpi_inc_path=%s\n"%mpi_ Line 751  buildvars.write("mpi_inc_path=%s\n"%mpi_
751  buildvars.write("mpi_lib_path=%s\n"%mpi_lib_path)  buildvars.write("mpi_lib_path=%s\n"%mpi_lib_path)
752  buildvars.write("lapack=%s\n"%env['lapack'])  buildvars.write("lapack=%s\n"%env['lapack'])
753  buildvars.write("pyvisi=%d\n"%env['pyvisi'])  buildvars.write("pyvisi=%d\n"%env['pyvisi'])
754  for i in 'netcdf','parmetis','papi','mkl','umfpack','silo','visit':  buildvars.write("vsl_random=%d\n"%int(env['vsl_random']))
755    for i in 'netcdf','parmetis','papi','mkl','umfpack','boomeramg','silo','visit':
756      buildvars.write("%s=%d\n"%(i, int(env[i])))      buildvars.write("%s=%d\n"%(i, int(env[i])))
757      if env[i]:      if env[i]:
758          buildvars.write("%s_inc_path=%s\n"%(i, eval(i+'_inc_path')))          buildvars.write("%s_inc_path=%s\n"%(i, eval(i+'_inc_path')))
# Line 746  env.Default('install_all') Line 821  env.Default('install_all')
821    
822  ################## Targets to build and run the test suite ###################  ################## Targets to build and run the test suite ###################
823    
824  env.Alias('build_cppunittest', ['install_cppunittest_headers', 'build_cppunittest_lib'])  test_msg = env.Command('.dummy.', None, '@echo "Cannot run C/C++ unit tests, CppUnit not found!";exit 1')
825  env.Alias('install_cppunittest', ['build_cppunittest', 'install_cppunittest_lib'])  if not env['cppunit']:
826  env.Alias('run_tests', ['install_all', 'install_cppunittest_lib'])      env.Alias('run_tests', test_msg)
827  env.Alias('all_tests', ['install_all', 'install_cppunittest_lib', 'run_tests', 'py_tests'])  env.Alias('run_tests', ['install_all'])
828    env.Alias('all_tests', ['install_all', 'run_tests', 'py_tests'])
829  env.Alias('build_full',['install_all','build_tests','build_py_tests'])  env.Alias('build_full',['install_all','build_tests','build_py_tests'])
830  env.Alias('build_PasoTests','build/$PLATFORM/paso/profiling/PasoTests')  env.Alias('build_PasoTests','$BUILD_DIR/$PLATFORM/paso/profiling/PasoTests')
831    
832  ##################### Targets to build the documentation #####################  ##################### Targets to build the documentation #####################
833    
834  env.Alias('api_epydoc','install_all')  env.Alias('api_epydoc','install_all')
835  env.Alias('docs', ['examples_tarfile', 'examples_zipfile', 'api_epydoc', 'api_doxygen', 'guide_pdf', 'guide_html','install_pdf', 'cookbook_pdf'])  env.Alias('docs', ['examples_tarfile', 'examples_zipfile', 'api_epydoc', 'api_doxygen', 'user_pdf', 'install_pdf', 'cookbook_pdf'])
836  env.Alias('release_prep', ['docs', 'install_all'])  env.Alias('release_prep', ['docs', 'install_all'])
837    
838  if not IS_WINDOWS:  if not IS_WINDOWS:
# Line 775  if not IS_WINDOWS: Line 851  if not IS_WINDOWS:
851      # Make sure that the escript wrapper is in place      # Make sure that the escript wrapper is in place
852      if not os.path.isfile(os.path.join(env['bininstall'], 'run-escript')):      if not os.path.isfile(os.path.join(env['bininstall'], 'run-escript')):
853          print("Copying escript wrapper.")          print("Copying escript wrapper.")
854          Execute(Copy(os.path.join(env['bininstall'],'escript'), 'bin/run-escript'))          Execute(Copy(os.path.join(env['bininstall'],'run-escript'), 'bin/run-escript'))
855    

Legend:
Removed from v.3259  
changed lines
  Added in v.3597

  ViewVC Help
Powered by ViewVC 1.1.26