/[escript]/trunk/SConstruct
ViewVC logotype

Diff of /trunk/SConstruct

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

revision 2297 by jfenwick, Fri Mar 6 04:46:14 2009 UTC revision 2388 by jfenwick, Wed Apr 15 06:21:25 2009 UTC
# Line 15  Line 15 
15  EnsureSConsVersion(0,96,91)  EnsureSConsVersion(0,96,91)
16  EnsurePythonVersion(2,3)  EnsurePythonVersion(2,3)
17    
18  import sys, os, re, socket, platform  import sys, os, re, socket, platform, stat
19    
20  # Add our extensions  # Add our extensions
21  if os.path.isdir('scons'): sys.path.append('scons')  if os.path.isdir('scons'): sys.path.append('scons')
# Line 35  prefix = ARGUMENTS.get('prefix', Dir('#. Line 35  prefix = ARGUMENTS.get('prefix', Dir('#.
35    
36  # Read configuration options from file scons/<hostname>_options.py  # Read configuration options from file scons/<hostname>_options.py
37  hostname = re.sub("[^0-9a-zA-Z]", "_", socket.gethostname().split('.')[0])  hostname = re.sub("[^0-9a-zA-Z]", "_", socket.gethostname().split('.')[0])
38  tmp = os.path.join("scons",hostname+"_options.py")  ehostname = scons_extensions.effectiveName(hostname)
39    tmp = os.path.join("scons",ehostname+"_options.py")
40  options_file = ARGUMENTS.get('options_file', tmp)  options_file = ARGUMENTS.get('options_file', tmp)
41  if not os.path.isfile(options_file):  if not os.path.isfile(options_file):
42    options_file = False    options_file = False
# Line 98  opts.AddOptions( Line 99  opts.AddOptions(
99    ('mpi_run', 'mpirun name' , 'mpiexec -np 1'),    ('mpi_run', 'mpirun name' , 'mpiexec -np 1'),
100    ('mpi_lib_path', 'Path to MPI libs (needs to be added to the LD_LIBRARY_PATH)', usr_lib),    ('mpi_lib_path', 'Path to MPI libs (needs to be added to the LD_LIBRARY_PATH)', usr_lib),
101    ('mpi_libs', 'MPI libraries to link with (needs to be shared!)', ['mpich' , 'pthread', 'rt']),    ('mpi_libs', 'MPI libraries to link with (needs to be shared!)', ['mpich' , 'pthread', 'rt']),
102      ('mpi_flavour','Type of MPI execution environment','none'),
103  # ParMETIS  # ParMETIS
104    BoolOption('useparmetis', 'Compile parallel version using ParMETIS', 'yes'),    BoolOption('useparmetis', 'Compile parallel version using ParMETIS', 'yes'),
105    ('parmetis_path', 'Path to ParMETIS includes', '/usr/include'),    ('parmetis_path', 'Path to ParMETIS includes', '/usr/include'),
# Line 189  elif env["CC"] == "gcc": Line 191  elif env["CC"] == "gcc":
191  #the long long warning occurs on the Mac  #the long long warning occurs on the Mac
192    cc_optim      = "-O3"    cc_optim      = "-O3"
193    cc_debug      = "-g -O0 -DDOASSERT -DDOPROF -DBOUNDS_CHECK"    cc_debug      = "-g -O0 -DDOASSERT -DDOPROF -DBOUNDS_CHECK"
194    omp_optim     = ""    omp_optim     = "-fopenmp"
195    omp_debug     = ""    omp_debug     = "-fopenmp"
196    omp_libs      = []    omp_libs      = ['gomp']
197    pedantic      = "-pedantic-errors -Wno-long-long"    pedantic      = "-pedantic-errors -Wno-long-long"
198    fatalwarning      = "-Werror"    fatalwarning      = "-Werror"
199    sysheaderopt      = "-isystem "    sysheaderopt      = "-isystem "
# Line 242  if env['omp_optim'] == "" and env['omp_d Line 244  if env['omp_optim'] == "" and env['omp_d
244  try: env['ENV']['OMP_NUM_THREADS'] = os.environ['OMP_NUM_THREADS']  try: env['ENV']['OMP_NUM_THREADS'] = os.environ['OMP_NUM_THREADS']
245  except KeyError: env['ENV']['OMP_NUM_THREADS'] = 1  except KeyError: env['ENV']['OMP_NUM_THREADS'] = 1
246    
247    try: env['ENV']['ESCRIPT_NUM_THREADS'] = os.environ['ESCRIPT_NUM_THREADS']
248    except KeyError: pass
249    
250    try: env['ENV']['ESCRIPT_NUM_PROCS'] = os.environ['ESCRIPT_NUM_PROCS']
251    except KeyError: pass
252    
253    try: env['ENV']['ESCRIPT_NUM_NODES'] = os.environ['ESCRIPT_NUM_NODES']
254    except KeyError: pass
255    
256    try: env['ENV']['ESCRIPT_HOSTFILE'] = os.environ['ESCRIPT_HOSTFILE']
257    except KeyError: pass
258    
259  try: env['ENV']['PATH'] = os.environ['PATH']  try: env['ENV']['PATH'] = os.environ['PATH']
260  except KeyError: pass  except KeyError: pass
261    
# Line 296  if env['usepedantic']: env.Append(CCFLAG Line 310  if env['usepedantic']: env.Append(CCFLAG
310    
311  # MS Windows  # MS Windows
312  if IS_WINDOWS_PLATFORM:  if IS_WINDOWS_PLATFORM:
313    env.PrependENVPath('PATH',    [env['boost_lib_path']])    env.AppendENVPath('PATH', [env['boost_lib_path']])
314    env.PrependENVPath('PATH',    [env['libinstall']])    env.AppendENVPath('PATH', [env['libinstall']])
315    if not env['share_esysUtils'] :    if not env['share_esysUtils'] :
316      env.Append(CPPDEFINES = ['ESYSUTILS_STATIC_LIB'])      env.Append(CPPDEFINES = ['ESYSUTILS_STATIC_LIB'])
317    if not env['share_paso'] :    if not env['share_paso'] :
318      env.Append(CPPDEFINES = ['PASO_STATIC_LIB'])      env.Append(CPPDEFINES = ['PASO_STATIC_LIB'])
319    
320    if env['usenetcdf']:    if env['usenetcdf']:
321      env.PrependENVPath('PATH',  [env['netCDF_lib_path']])      env.AppendENVPath('PATH',   [env['netCDF_lib_path']])
322    
323  env.Append(ARFLAGS = env['ar_flags'])  env.Append(ARFLAGS = env['ar_flags'])
324    
# Line 466  if env['usemkl']: Line 480  if env['usemkl']:
480    conf.env.PrependENVPath('LD_LIBRARY_PATH', env['libinstall'])    conf.env.PrependENVPath('LD_LIBRARY_PATH', env['libinstall'])
481    
482  if env['usemkl'] and not conf.CheckCHeader('mkl_solver.h'): env['usemkl'] = 0  if env['usemkl'] and not conf.CheckCHeader('mkl_solver.h'): env['usemkl'] = 0
483  if env['usemkl'] and not conf.CheckFunc('pardiso_'): env['usemkl'] = 0  if env['usemkl'] and not conf.CheckFunc('pardiso'): env['usemkl'] = 0
484    
485  # Add MKL to environment env if it was found  # Add MKL to environment env if it was found
486  if env['usemkl']:  if env['usemkl']:
# Line 542  else: Line 556  else:
556  env.Append(CCFLAGS      = env['cc_flags'])  env.Append(CCFLAGS      = env['cc_flags'])
557  env.Append(LIBS         = [env['omp_libs']])  env.Append(LIBS         = [env['omp_libs']])
558    
   
559  ############ Add some custom builders ##########################  ############ Add some custom builders ##########################
560    
561  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)
# Line 554  env.Append(BUILDERS = {'RunUnitTest' : r Line 567  env.Append(BUILDERS = {'RunUnitTest' : r
567  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)
568  env.Append(BUILDERS = {'RunPyUnitTest' : runPyUnitTest_builder});  env.Append(BUILDERS = {'RunPyUnitTest' : runPyUnitTest_builder});
569    
570    epstopdfbuilder = Builder(action = scons_extensions.eps2pdf, suffix=".pdf", src_suffix=".eps", single_source=True)
571    env.Append(BUILDERS = {'EpsToPDF' : epstopdfbuilder});
572    
573  ############ MPI (optional) ####################################  ############ MPI (optional) ####################################
574    if not env['usempi']: env['mpi_flavour']='none'
575    
576  # Create a modified environment for MPI programs (identical to env if usempi=no)  # Create a modified environment for MPI programs (identical to env if usempi=no)
577  env_mpi = clone_env(env)  env_mpi = clone_env(env)
# Line 563  env_mpi = clone_env(env) Line 580  env_mpi = clone_env(env)
580  conf = Configure(clone_env(env_mpi))  conf = Configure(clone_env(env_mpi))
581    
582  if env_mpi['usempi']:  if env_mpi['usempi']:
583      VALID_MPIs=[ "MPT", "MPICH", "MPICH2", "OPENMPI", "INTELMPI" ]
584      if not env_mpi['mpi_flavour'] in VALID_MPIs:
585          raise ValueError,"MPI is enabled but mpi_flavour = %s is not a valid key from %s."%( env_mpi['mpi_flavour'],VALID_MPIs)
586    conf.env.AppendUnique(CPPPATH = [env_mpi['mpi_path']])    conf.env.AppendUnique(CPPPATH = [env_mpi['mpi_path']])
587    conf.env.AppendUnique(LIBPATH = [env_mpi['mpi_lib_path']])    conf.env.AppendUnique(LIBPATH = [env_mpi['mpi_lib_path']])
588    conf.env.AppendUnique(LIBS    = [env_mpi['mpi_libs']])    conf.env.AppendUnique(LIBS    = [env_mpi['mpi_libs']])
# Line 572  if env_mpi['usempi']: Line 592  if env_mpi['usempi']:
592    conf.env.PrependENVPath('LD_LIBRARY_PATH', env['libinstall'])    conf.env.PrependENVPath('LD_LIBRARY_PATH', env['libinstall'])
593    
594  if env_mpi['usempi'] and not conf.CheckCHeader('mpi.h'): env_mpi['usempi'] = 0  if env_mpi['usempi'] and not conf.CheckCHeader('mpi.h'): env_mpi['usempi'] = 0
595  if env_mpi['usempi'] and not conf.CheckFunc('MPI_Init'): env_mpi['usempi'] = 0  # if env_mpi['usempi'] and not conf.CheckFunc('MPI_Init'): env_mpi['usempi'] = 0
596    
597  # Add MPI to environment env_mpi if it was found  # Add MPI to environment env_mpi if it was found
598  if env_mpi['usempi']:  if env_mpi['usempi']:
# Line 583  else: Line 603  else:
603    
604  env['usempi'] = env_mpi['usempi']  env['usempi'] = env_mpi['usempi']
605    
606    
607  ############ ParMETIS (optional) ###############################  ############ ParMETIS (optional) ###############################
608    
609  # Start a new configure environment that reflects what we've already found  # Start a new configure environment that reflects what we've already found
# Line 638  if env['usesilo']: print " Using Silo" Line 659  if env['usesilo']: print " Using Silo"
659  else: print "   Not using Silo"  else: print "   Not using Silo"
660  if env['useopenmp']: print "    Using OpenMP"  if env['useopenmp']: print "    Using OpenMP"
661  else: print "   Not using OpenMP"  else: print "   Not using OpenMP"
662  if env['usempi']: print "   Using MPI"  if env['usempi']: print "   Using MPI (flavour = %s)"%env['mpi_flavour']
663  else: print "   Not using MPI"  else: print "   Not using MPI"
664  if env['useparmetis']: print "  Using ParMETIS"  if env['useparmetis']: print "  Using ParMETIS"
665  else: print "   Not using ParMETIS (requires MPI)"  else: print "   Not using ParMETIS (requires MPI)"
# Line 653  print "" Line 674  print ""
674    
675  ############ Delete option-dependent files #####################  ############ Delete option-dependent files #####################
676    
677  Execute(Delete(env['libinstall'] + "/Compiled.with.debug"))  Execute(Delete(os.path.join(env['libinstall'],"Compiled.with.debug")))
678  Execute(Delete(env['libinstall'] + "/Compiled.with.mpi"))  Execute(Delete(os.path.join(env['libinstall'],"Compiled.with.mpi")))
679  Execute(Delete(env['libinstall'] + "/Compiled.with.openmp"))  Execute(Delete(os.path.join(env['libinstall'],"Compiled.with.openmp")))
680  if not env['usempi']: Execute(Delete(env['libinstall'] + "/pythonMPI"))  Execute(Delete(os.path.join(env['libinstall'],"pyversion")))
681    Execute(Delete(os.path.join(env['libinstall'],"buildvars")))
682    if not env['usempi']: Execute(Delete(os.path.join(env['libinstall'],"pythonMPI")))
683    
684    
685  ############ Build the subdirectories ##########################  ############ Build the subdirectories ##########################
# Line 694  env.SConscript(dirs = ['paso/profiling'] Line 717  env.SConscript(dirs = ['paso/profiling']
717  remember_list = []  remember_list = []
718    
719  if env['usedebug']:  if env['usedebug']:
720    remember_list += env.Command(env['libinstall'] + "/Compiled.with.debug", None, Touch('$TARGET'))    remember_list += env.Command(os.path.join(env['libinstall'],"Compiled.with.debug"), None, Touch('$TARGET'))
721    
722  if env['usempi']:  if env['usempi']:
723    remember_list += env.Command(env['libinstall'] + "/Compiled.with.mpi", None, Touch('$TARGET'))    remember_list += env.Command(os.path.join(env['libinstall'],"Compiled.with.mpi"), None, Touch('$TARGET'))
724    
725  if env['omp_optim'] != '':  if env['useopenmp']:
726    remember_list += env.Command(env['libinstall'] + "/Compiled.with.openmp", None, Touch('$TARGET'))    remember_list += env.Command(os.path.join(env['libinstall'],"Compiled.with.openmp"), None, Touch('$TARGET'))
727    
728  env.Alias('remember_options', remember_list)  env.Alias('remember_options', remember_list)
729    
# Line 709  env.Alias('remember_options', remember_l Line 732  env.Alias('remember_options', remember_l
732    
733  if not IS_WINDOWS_PLATFORM:  if not IS_WINDOWS_PLATFORM:
734    versionstring="Python "+str(sys.version_info[0])+"."+str(sys.version_info[1])+"."+str(sys.version_info[2])    versionstring="Python "+str(sys.version_info[0])+"."+str(sys.version_info[1])+"."+str(sys.version_info[2])
735    os.system("echo "+versionstring+" > "+env['libinstall']+"/pyversion")    os.system("echo "+versionstring+" > "+os.path.join(env['libinstall'],"pyversion"))
736    
737    ############## Populate the buildvars file #####################
738    
739    buildvars=open(os.path.join(env['libinstall'],'buildvars'),'w')
740    buildvars.write('python='+str(sys.version_info[0])+"."+str(sys.version_info[1])+"."+str(sys.version_info[2])+'\n')
741    
742    # Find the boost version by extracting it from version.hpp
743    boosthpp=open(os.path.join(env['boost_path'],'boost','version.hpp'))
744    boostversion='unknown'
745    try:
746        for line in boosthpp:
747            ver=re.match(r'#define BOOST_VERSION (\d+)',line)
748            if ver:
749                boostversion=ver.group(1)
750    except StopIteration:
751        pass
752    buildvars.write("boost="+boostversion+"\n")
753    buildvars.write("svn_revision="+str(global_revision)+"\n")
754    out="usedebug="
755    if env['usedebug']:
756        out+="y"
757    else:
758        out+="n"
759    out+="\nusempi="
760    if env['usempi']:
761        out+="y"
762    else:
763        out+="n"
764    out+="\nuseopenmp="
765    if env['useopenmp']:
766        out+="y"
767    else:
768        out+="n"
769    buildvars.write(out+"\n")
770    buildvars.write("mpi_flavour="+env['mpi_flavour']+'\n')
771    
772    buildvars.close()
773    
774    
775  ############ Targets to build and install libraries ############  ############ Targets to build and install libraries ############
776    
# Line 768  env.Alias('build_full',['install_all','b Line 829  env.Alias('build_full',['install_all','b
829    
830  ############ Targets to build the documentation ################  ############ Targets to build the documentation ################
831    
832  env.Alias('docs', ['examples_tarfile', 'examples_zipfile', 'api_epydoc', 'api_doxygen', 'guide_pdf', 'guide_html'])  env.Alias('docs', ['examples_tarfile', 'examples_zipfile', 'api_epydoc', 'api_doxygen', 'guide_pdf', 'guide_html','install_pdf'])
833    
834  if not IS_WINDOWS_PLATFORM:  if not IS_WINDOWS_PLATFORM:
835     try:     try:
# Line 780  if not IS_WINDOWS_PLATFORM: Line 841  if not IS_WINDOWS_PLATFORM:
841      for tests in TestGroups:      for tests in TestGroups:
842          utest.write(tests.makeString())          utest.write(tests.makeString())
843      utest.close()      utest.close()
844        os.chmod("utest.sh",stat.S_IRWXU|stat.S_IRGRP|stat.S_IXGRP|stat.S_IROTH|stat.S_IXOTH)
845      print "utest.sh written"      print "utest.sh written"
846     except IOError:     except IOError:
847      print "Error attempting to write unittests file."      print "Error attempting to write unittests file."

Legend:
Removed from v.2297  
changed lines
  Added in v.2388

  ViewVC Help
Powered by ViewVC 1.1.26