/[escript]/trunk/SConstruct
ViewVC logotype

Diff of /trunk/SConstruct

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

revision 2548 by jfenwick, Mon Jul 20 06:20:06 2009 UTC revision 2742 by jfenwick, Thu Nov 12 06:03:37 2009 UTC
# Line 16  EnsureSConsVersion(0,96,91) Line 16  EnsureSConsVersion(0,96,91)
16  EnsurePythonVersion(2,3)  EnsurePythonVersion(2,3)
17    
18  import sys, os, re, socket, platform, stat  import sys, os, re, socket, platform, stat
19    # For copy()
20    import shutil
21    
22  # Add our extensions  # Add our extensions
23  if os.path.isdir('scons'): sys.path.append('scons')  if os.path.isdir('scons'): sys.path.append('scons')
# Line 33  IS_WINDOWS_PLATFORM = (os.name== "nt") Line 35  IS_WINDOWS_PLATFORM = (os.name== "nt")
35    
36  prefix = ARGUMENTS.get('prefix', Dir('#.').abspath)  prefix = ARGUMENTS.get('prefix', Dir('#.').abspath)
37    
38    #Holds names of variables from the calling environment which need to be passed
39    #to tools
40    env_export=[]
41    
42  #Determine where to read options from use:  #Determine where to read options from use:
43  #1. command line  #1. command line
44  #2. scons/<hostname>_options.py  #2. scons/<hostname>_options.py
45  #3. name as part of a cluster  #3. name as part of a cluster
46  options_file=ARGUMENTS.get('options_file', None)  options_file=ARGUMENTS.get('options_file', None)
47    effective_hostname=socket.gethostname().split('.')[0]
48  if not options_file:  if not options_file:
49    hostname = re.sub("[^0-9a-zA-Z]", "_", socket.gethostname().split('.')[0])    mangledhostname = re.sub("[^0-9a-zA-Z]", "_", effective_hostname)
50    options_file = os.path.join("scons",hostname+"_options.py")    options_file = os.path.join("scons",mangledhostname+"_options.py")
51    #If there is no options file with that name see if there is a substitute    #If there is no options file with that name see if there is a substitute
52    if not os.path.isfile(options_file):    if not os.path.isfile(options_file):
53      tmp = scons_extensions.effectiveName(hostname)      effective_hostname = scons_extensions.effectiveName(effective_hostname)
54      options_file = os.path.join("scons",tmp+"_options.py")      mangledhostname = re.sub("[^0-9a-zA-Z]", "_", effective_hostname)
55        options_file = os.path.join("scons",mangledhostname+"_options.py")
56    
57  if not os.path.isfile(options_file):  if not os.path.isfile(options_file):
58    print "Options file not found (expected '%s')" % options_file    print "Options file not found (expected '%s')" % options_file
# Line 94  adder( Line 102  adder(
102    BoolVariable('usepedantic', 'Compile with -pedantic if using gcc', 'no'),    BoolVariable('usepedantic', 'Compile with -pedantic if using gcc', 'no'),
103    BoolVariable('usewarnings','Compile with warnings as errors if using gcc','yes'),    BoolVariable('usewarnings','Compile with warnings as errors if using gcc','yes'),
104    ('forcelazy','for testing use only - set the default value for autolazy','leave_alone'),    ('forcelazy','for testing use only - set the default value for autolazy','leave_alone'),
105      ('forcecollres','for testing use only - set the default value for force resolving collective ops','leave_alone'),
106  # Python  # Python
107    ('python_path', 'Path to Python includes', '/usr/include/'+python_version),    ('python_path', 'Path to Python includes', '/usr/include/'+python_version),
108    ('python_lib_path', 'Path to Python libs', usr_lib),    ('python_lib_path', 'Path to Python libs', usr_lib),
# Line 115  adder( Line 124  adder(
124    ('mpi_path', 'Path to MPI includes', '/usr/include'),    ('mpi_path', 'Path to MPI includes', '/usr/include'),
125    ('mpi_run', 'mpirun name' , 'mpiexec -np 1'),    ('mpi_run', 'mpirun name' , 'mpiexec -np 1'),
126    ('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),
127    ('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!)', []),
128    ('mpi_flavour','Type of MPI execution environment','none'),    ('mpi_flavour','Type of MPI execution environment','none'),
129  # ParMETIS  # ParMETIS
130    BoolVariable('useparmetis', 'Compile parallel version using ParMETIS', 'yes'),    BoolVariable('useparmetis', 'Compile parallel version using ParMETIS', 'yes'),
# Line 152  adder( Line 161  adder(
161    ('blas_path', 'Path to BLAS includes', '/usr/include/suitesparse'),    ('blas_path', 'Path to BLAS includes', '/usr/include/suitesparse'),
162    ('blas_lib_path', 'Path to BLAS libs', usr_lib),    ('blas_lib_path', 'Path to BLAS libs', usr_lib),
163    ('blas_libs', 'BLAS libraries to link with', ['blas']),    ('blas_libs', 'BLAS libraries to link with', ['blas']),
164    #Lapack options
165      BoolVariable('uselapack','switch on/off use of Lapack','no'),
166      ('lapack_path', 'Path to Lapack includes','/usr/include'),
167      ('lapack_lib_path', 'Path to Lapack libs', usr_lib),
168      ('lapack_libs', 'Lapack libraries to link with', []),
169      ('lapack_type', '{clapack,mkl}','clapack'),
170  # An option for specifying the compiler tools set (see windows branch).  # An option for specifying the compiler tools set (see windows branch).
171    ('tools_names', 'allow control over the tools in the env setup', ['intelc']),    ('tools_names', 'allow control over the tools in the env setup', ['intelc']),
172  # finer control over library building, intel aggressive global optimisation  # finer control over library building, intel aggressive global optimisation
173  # works with dynamic libraries on windows.  # works with dynamic libraries on windows.
174    ('share_esysUtils', 'control static or dynamic esysUtils lib', False),    ('share_esysUtils', 'control static or dynamic esysUtils lib', False),
175    ('share_paso', 'control static or dynamic paso lib', False)    ('share_paso', 'control static or dynamic paso lib', False),
176      ('env_export','Environment variables to be passed to children',[])
177  )  )
178    
179    
180    
181  ############ Specify which compilers to use ####################  ############ Specify which compilers to use ####################
182    
183  # intelc uses regular expressions improperly and emits a warning about  # intelc uses regular expressions improperly and emits a warning about
# Line 170  if IS_WINDOWS_PLATFORM: Line 188  if IS_WINDOWS_PLATFORM:
188        env = Environment(tools = ['default'] + env['tools_names'],        env = Environment(tools = ['default'] + env['tools_names'],
189                          options = opts)                          options = opts)
190  else:  else:
191     if socket.gethostname().split('.')[0] == 'service0':     if effective_hostname == 'service0':
192        env = Environment(tools = ['default', 'intelc'], options = opts)        env = Environment(tools = ['default', 'intelc'], options = opts)
193     elif os.uname()[4]=='ia64':     elif os.uname()[4]=='ia64':
194        env = Environment(tools = ['default', 'intelc'], options = opts)        env = Environment(tools = ['default', 'intelc'], options = opts)
# Line 180  else: Line 198  else:
198        env = Environment(tools = ['default'], options = opts)        env = Environment(tools = ['default'], options = opts)
199  Help(opts.GenerateHelpText(env))  Help(opts.GenerateHelpText(env))
200    
201    
202    ############ Make sure target directories exist ################
203    
204    if not os.path.isdir(env['bininstall']):
205        os.makedirs(env['bininstall'])
206    if not os.path.isdir(env['libinstall']):
207        os.makedirs(env['libinstall'])
208    if not os.path.isdir(env['pyinstall']):
209        os.makedirs(env['pyinstall'])
210    
211    ########## Copy required environment vars ######################
212    
213    for i in env['env_export']:
214       env.Append(ENV = {i:os.environ[i]})
215    
216  ############ Fill in compiler options if not set above #########  ############ Fill in compiler options if not set above #########
217    
218  # Backwards compatibility: allow dodebug=yes and useMPI=yes  # Backwards compatibility: allow dodebug=yes and useMPI=yes
# Line 210  elif env["CC"] == "gcc": Line 243  elif env["CC"] == "gcc":
243    cc_debug      = "-g -O0 -DDOASSERT -DDOPROF -DBOUNDS_CHECK"    cc_debug      = "-g -O0 -DDOASSERT -DDOPROF -DBOUNDS_CHECK"
244    omp_optim     = "-fopenmp"    omp_optim     = "-fopenmp"
245    omp_debug     = "-fopenmp"    omp_debug     = "-fopenmp"
246    omp_libs      = ['gomp']    omp_libs      = []
247    pedantic      = "-pedantic-errors -Wno-long-long"    pedantic      = "-pedantic-errors -Wno-long-long"
248    fatalwarning      = "-Werror"    fatalwarning      = "-Werror"
249    sysheaderopt      = "-isystem "    sysheaderopt      = "-isystem "
# Line 243  if env["omp_libs"] == "-DEFAULT_6": env[ Line 276  if env["omp_libs"] == "-DEFAULT_6": env[
276  #set up the autolazy values  #set up the autolazy values
277  if env['forcelazy']    != "leave_alone":  if env['forcelazy']    != "leave_alone":
278    if env['forcelazy'] == 'on':    if env['forcelazy'] == 'on':
279      env.Append(CPPDEFINES='FAUTOLAZYON')      env.Append(CPPDEFINES=['FAUTOLAZYON'])
280    else:    else:
281       if env['forcelazy'] == 'off':       if env['forcelazy'] == 'off':
282      env.Append(CPPDEFINES='FAUTOLAZYOFF')      env.Append(CPPDEFINES=['FAUTOLAZYOFF'])
283    
284    #set up the colective resolve values
285    if env['forcecollres']    != "leave_alone":
286      print env['forcecollres']
287      if env['forcecollres'] == 'on':
288        env.Append(CPPDEFINES=['FRESCOLLECTON'])
289      else:
290         if env['forcecollres'] == 'off':
291        env.Append(CPPDEFINES=['FRESCOLLECTOFF'])
292    
293    
294  # OpenMP is disabled if useopenmp=no or both variables omp_optim and omp_debug are empty  # OpenMP is disabled if useopenmp=no or both variables omp_optim and omp_debug are empty
295  if not env["useopenmp"]:  if not env["useopenmp"]:
# Line 566  if env['usesilo']: Line 609  if env['usesilo']:
609    env.AppendUnique(LIBPATH = [env['silo_lib_path']])    env.AppendUnique(LIBPATH = [env['silo_lib_path']])
610    env.Append(CPPDEFINES = ['HAVE_SILO'])    env.Append(CPPDEFINES = ['HAVE_SILO'])
611    
612    ########### Lapack (optional) ##################################
613    
614    
615    if env['uselapack']:
616        env.AppendUnique(CPPDEFINES='USE_LAPACK')
617        env.AppendUnique(CPPPATH = [env['lapack_path']])
618        env.AppendUnique(LIBPATH =[env['lapack_lib_path']])
619    
620        env.Append(LIBPATH = '/usr/lib/atlas')
621        env.Append(LIBS = [env['lapack_libs']])
622        if env['lapack_type']=='mkl':
623           env.AppendUnique(CPPDEFINES='MKL_LAPACK')
624    
625  ############ Add the compiler flags ############################  ############ Add the compiler flags ############################
626    
627  # Enable debug by choosing either cc_debug or cc_optim  # Enable debug by choosing either cc_debug or cc_optim
# Line 792  else: Line 848  else:
848      out+="n"      out+="n"
849  buildvars.write(out+"\n")  buildvars.write(out+"\n")
850  buildvars.write("mpi_flavour="+env['mpi_flavour']+'\n')  buildvars.write("mpi_flavour="+env['mpi_flavour']+'\n')
851    buildvars.write("lapack=")
852    if env['uselapack']:
853       buildvars.write('y')
854    else:
855       buildvars.write('n')
856    buildvars.write('\n')
857  buildvars.close()  buildvars.close()
858    
859    
# Line 873  if not IS_WINDOWS_PLATFORM: Line 934  if not IS_WINDOWS_PLATFORM:
934      print "Error attempting to write unittests file."      print "Error attempting to write unittests file."
935      sys.exit(1)      sys.exit(1)
936    
937       #Make sure that the escript wrapper is in place
938       if not os.path.isfile(os.path.join(env['bininstall'],'escript')):
939           print "Copying escript wrapper"
940           shutil.copy("bin/escript",os.path.join(env['bininstall'],'escript'))

Legend:
Removed from v.2548  
changed lines
  Added in v.2742

  ViewVC Help
Powered by ViewVC 1.1.26