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

Contents of /branches/lapack2681/SConstruct

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2740 - (show annotations)
Tue Nov 10 06:48:24 2009 UTC (9 years, 5 months ago) by jfenwick
File size: 37255 byte(s)


1
2 ########################################################
3 #
4 # Copyright (c) 2003-2009 by University of Queensland
5 # Earth Systems Science Computational Center (ESSCC)
6 # http://www.uq.edu.au/esscc
7 #
8 # Primary Business: Queensland, Australia
9 # Licensed under the Open Software License version 3.0
10 # http://www.opensource.org/licenses/osl-3.0.php
11 #
12 ########################################################
13
14
15 EnsureSConsVersion(0,96,91)
16 EnsurePythonVersion(2,3)
17
18 import sys, os, re, socket, platform, stat
19 # For copy()
20 import shutil
21
22 # Add our extensions
23 if os.path.isdir('scons'): sys.path.append('scons')
24 import scons_extensions
25
26 # Use /usr/lib64 if available, else /usr/lib
27 usr_lib = '/usr/lib'
28 if os.path.isfile('/usr/lib64/libc.so'): usr_lib = '/usr/lib64'
29
30 # The string python2.4 or python2.5
31 python_version = 'python%s.%s' % (sys.version_info[0], sys.version_info[1])
32
33 # MS Windows support, many thanks to PH
34 IS_WINDOWS_PLATFORM = (os.name== "nt")
35
36 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:
43 #1. command line
44 #2. scons/<hostname>_options.py
45 #3. name as part of a cluster
46 options_file=ARGUMENTS.get('options_file', None)
47 effective_hostname=socket.gethostname().split('.')[0]
48 if not options_file:
49 mangledhostname = re.sub("[^0-9a-zA-Z]", "_", effective_hostname)
50 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
52 if not os.path.isfile(options_file):
53 effective_hostname = scons_extensions.effectiveName(effective_hostname)
54 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):
58 print "Options file not found (expected '%s')" % options_file
59 options_file = False
60 else:
61 print "Options file is", options_file
62
63 #Does our scons support the newer Variables class or do we need to use Options?
64
65 try:
66 dummyvar=Variables
67 opts = Variables(options_file, ARGUMENTS)
68 adder = opts.AddVariables
69 except:
70 opts = Options(options_file, ARGUMENTS)
71 adder = opts.AddOptions
72 BoolVariable = BoolOption
73
74 ############ Load build options ################################
75
76 adder(
77 #opts.AddOptions(
78 # Where to install esys stuff
79 ('prefix', 'where everything will be installed', Dir('#.').abspath),
80 ('incinstall', 'where the esys headers will be installed', os.path.join(Dir('#.').abspath,'include')),
81 ('bininstall', 'where the esys binaries will be installed', os.path.join(prefix,'bin')),
82 ('libinstall', 'where the esys libraries will be installed', os.path.join(prefix,'lib')),
83 ('pyinstall', 'where the esys python modules will be installed', os.path.join(prefix,'esys')),
84 # Compilation options
85 BoolVariable('dodebug', 'For backwards compatibility', 'no'),
86 BoolVariable('usedebug', 'Do you want a debug build?', 'no'),
87 BoolVariable('usevtk', 'Do you want to use VTK?', 'yes'),
88 ('options_file', 'File of paths/options. Default: scons/<hostname>_options.py', options_file),
89 ('win_cc_name', 'windows C compiler name if needed', 'msvc'),
90 # The strings -DDEFAULT_ get replaced by scons/<hostname>_options.py or by defaults below
91 ('cc_flags', 'C compiler flags to use', '-DEFAULT_1'),
92 ('cc_optim', 'C compiler optimization flags to use', '-DEFAULT_2'),
93 ('cc_debug', 'C compiler debug flags to use', '-DEFAULT_3'),
94 ('omp_optim', 'OpenMP compiler flags to use (Release build)', '-DEFAULT_4'),
95 ('omp_debug', 'OpenMP compiler flags to use (Debug build)', '-DEFAULT_5'),
96 ('omp_libs', 'OpenMP compiler libraries to link with', '-DEFAULT_6'),
97 ('cc_extra', 'Extra C/C++ flags', ''),
98 ('ld_extra', 'Extra linker flags', ''),
99 ('sys_libs', 'System libraries to link with', []),
100 ('ar_flags', 'Static library archiver flags to use', ''),
101 BoolVariable('useopenmp', 'Compile parallel version using OpenMP', 'no'),
102 BoolVariable('usepedantic', 'Compile with -pedantic if using gcc', 'no'),
103 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'),
105 # Python
106 ('python_path', 'Path to Python includes', '/usr/include/'+python_version),
107 ('python_lib_path', 'Path to Python libs', usr_lib),
108 ('python_libs', 'Python libraries to link with', [python_version]),
109 ('python_cmd', 'Python command', 'python'),
110 # Boost
111 ('boost_path', 'Path to Boost includes', '/usr/include'),
112 ('boost_lib_path', 'Path to Boost libs', usr_lib),
113 ('boost_libs', 'Boost libraries to link with', ['boost_python']),
114 # NetCDF
115 BoolVariable('usenetcdf', 'switch on/off the usage of netCDF', 'yes'),
116 ('netCDF_path', 'Path to netCDF includes', '/usr/include'),
117 ('netCDF_lib_path', 'Path to netCDF libs', usr_lib),
118 ('netCDF_libs', 'netCDF C++ libraries to link with', ['netcdf_c++', 'netcdf']),
119 # MPI
120 BoolVariable('useMPI', 'For backwards compatibility', 'no'),
121 BoolVariable('usempi', 'Compile parallel version using MPI', 'no'),
122 ('MPICH_IGNORE_CXX_SEEK', 'name of macro to ignore MPI settings of C++ SEEK macro (for MPICH)' , 'MPICH_IGNORE_CXX_SEEK'),
123 ('mpi_path', 'Path to MPI includes', '/usr/include'),
124 ('mpi_run', 'mpirun name' , 'mpiexec -np 1'),
125 ('mpi_lib_path', 'Path to MPI libs (needs to be added to the LD_LIBRARY_PATH)', usr_lib),
126 ('mpi_libs', 'MPI libraries to link with (needs to be shared!)', ['mpich' , 'pthread', 'rt']),
127 ('mpi_flavour','Type of MPI execution environment','none'),
128 # ParMETIS
129 BoolVariable('useparmetis', 'Compile parallel version using ParMETIS', 'yes'),
130 ('parmetis_path', 'Path to ParMETIS includes', '/usr/include'),
131 ('parmetis_lib_path', 'Path to ParMETIS library', usr_lib),
132 ('parmetis_libs', 'ParMETIS library to link with', ['parmetis', 'metis']),
133 # PAPI
134 BoolVariable('usepapi', 'switch on/off the usage of PAPI', 'no'),
135 ('papi_path', 'Path to PAPI includes', '/usr/include'),
136 ('papi_lib_path', 'Path to PAPI libs', usr_lib),
137 ('papi_libs', 'PAPI libraries to link with', ['papi']),
138 BoolVariable('papi_instrument_solver', 'use PAPI in Solver.c to instrument each iteration of the solver', False),
139 # MKL
140 BoolVariable('usemkl', 'switch on/off the usage of MKL', 'no'),
141 ('mkl_path', 'Path to MKL includes', '/sw/sdev/cmkl/10.0.2.18/include'),
142 ('mkl_lib_path', 'Path to MKL libs', '/sw/sdev/cmkl/10.0.2.18/lib/em64t'),
143 ('mkl_libs', 'MKL libraries to link with', ['mkl_solver', 'mkl_em64t', 'guide', 'pthread']),
144 # UMFPACK
145 BoolVariable('useumfpack', 'switch on/off the usage of UMFPACK', 'no'),
146 ('ufc_path', 'Path to UFconfig includes', '/usr/include/suitesparse'),
147 ('umf_path', 'Path to UMFPACK includes', '/usr/include/suitesparse'),
148 ('umf_lib_path', 'Path to UMFPACK libs', usr_lib),
149 ('umf_libs', 'UMFPACK libraries to link with', ['umfpack']),
150 # Silo
151 BoolVariable('usesilo', 'switch on/off the usage of Silo', 'yes'),
152 ('silo_path', 'Path to Silo includes', '/usr/include'),
153 ('silo_lib_path', 'Path to Silo libs', usr_lib),
154 ('silo_libs', 'Silo libraries to link with', ['siloh5', 'hdf5']),
155 # AMD (used by UMFPACK)
156 ('amd_path', 'Path to AMD includes', '/usr/include/suitesparse'),
157 ('amd_lib_path', 'Path to AMD libs', usr_lib),
158 ('amd_libs', 'AMD libraries to link with', ['amd']),
159 # BLAS (used by UMFPACK)
160 ('blas_path', 'Path to BLAS includes', '/usr/include/suitesparse'),
161 ('blas_lib_path', 'Path to BLAS libs', usr_lib),
162 ('blas_libs', 'BLAS libraries to link with', ['blas']),
163 #Lapack options
164 BoolVariable('uselapack','switch on/off use of Lapack','no'),
165 ('lapack_path', 'Path to Lapack includes','/usr/include'),
166 ('lapack_lib_path', 'Path to Lapack libs', usr_lib),
167 ('lapack_libs', 'Lapack libraries to link with', ['lapack']),
168 # An option for specifying the compiler tools set (see windows branch).
169 ('tools_names', 'allow control over the tools in the env setup', ['intelc']),
170 # finer control over library building, intel aggressive global optimisation
171 # works with dynamic libraries on windows.
172 ('share_esysUtils', 'control static or dynamic esysUtils lib', False),
173 ('share_paso', 'control static or dynamic paso lib', False),
174 ('env_export','Environment variables to be passed to children',[])
175 )
176
177
178
179 ############ Specify which compilers to use ####################
180
181 # intelc uses regular expressions improperly and emits a warning about
182 # failing to find the compilers. This warning can be safely ignored.
183
184 if IS_WINDOWS_PLATFORM:
185 env = Environment(options = opts)
186 env = Environment(tools = ['default'] + env['tools_names'],
187 options = opts)
188 else:
189 if effective_hostname == 'service0':
190 env = Environment(tools = ['default', 'intelc'], options = opts)
191 elif os.uname()[4]=='ia64':
192 env = Environment(tools = ['default', 'intelc'], options = opts)
193 if env['CXX'] == 'icpc':
194 env['LINK'] = env['CXX'] # version >=9 of intel c++ compiler requires use of icpc to link in C++ runtimes (icc does not)
195 else:
196 env = Environment(tools = ['default'], options = opts)
197 Help(opts.GenerateHelpText(env))
198
199
200 ############ Make sure target directories exist ################
201
202 if not os.path.isdir(env['bininstall']):
203 os.makedirs(env['bininstall'])
204 if not os.path.isdir(env['libinstall']):
205 os.makedirs(env['libinstall'])
206 if not os.path.isdir(env['pyinstall']):
207 os.makedirs(env['pyinstall'])
208
209 ########## Copy required environment vars ######################
210
211 for i in env['env_export']:
212 env.Append(ENV = {i:os.environ[i]})
213
214 ############ Fill in compiler options if not set above #########
215
216 # Backwards compatibility: allow dodebug=yes and useMPI=yes
217 if env['dodebug']: env['usedebug'] = 1
218 if env['useMPI']: env['usempi'] = 1
219
220 # Default compiler options (override allowed in hostname_options.py, but should not be necessary)
221 # For both C and C++ you get: cc_flags and either the optim flags or debug flags
222
223 sysheaderopt = "" # how do we indicate that a header is a system header. Use "" for no action.
224
225 if env["CC"] == "icc":
226 # Intel compilers
227 cc_flags = "-fPIC -ansi -wd161 -w1 -vec-report0 -DBLOCKTIMER -DCORE_ID1"
228 cc_optim = "-O3 -ftz -IPF_ftlacc- -IPF_fma -fno-alias"
229 cc_debug = "-g -O0 -DDOASSERT -DDOPROF -DBOUNDS_CHECK"
230 omp_optim = "-openmp -openmp_report0"
231 omp_debug = "-openmp -openmp_report0"
232 omp_libs = ['guide', 'pthread']
233 pedantic = ""
234 fatalwarning = "" # Switch to turn warnings into errors
235 sysheaderopt = ""
236 elif env["CC"] == "gcc":
237 # GNU C on any system
238 cc_flags = "-pedantic -Wall -fPIC -ansi -ffast-math -Wno-unknown-pragmas -DBLOCKTIMER -Wno-sign-compare -Wno-system-headers -Wno-long-long -Wno-strict-aliasing"
239 #the long long warning occurs on the Mac
240 cc_optim = "-O3"
241 cc_debug = "-g -O0 -DDOASSERT -DDOPROF -DBOUNDS_CHECK"
242 omp_optim = "-fopenmp"
243 omp_debug = "-fopenmp"
244 omp_libs = ['gomp']
245 pedantic = "-pedantic-errors -Wno-long-long"
246 fatalwarning = "-Werror"
247 sysheaderopt = "-isystem "
248 elif env["CC"] == "cl":
249 # Microsoft Visual C on Windows
250 cc_flags = "/FD /EHsc /GR /wd4068 -D_USE_MATH_DEFINES -DDLL_NETCDF"
251 cc_optim = "/O2 /Op /MT /W3"
252 cc_debug = "/Od /RTC1 /MTd /ZI -DBOUNDS_CHECK"
253 omp_optim = ""
254 omp_debug = ""
255 omp_libs = []
256 pedantic = ""
257 fatalwarning = ""
258 sysheaderopt = ""
259 elif env["CC"] == "icl":
260 # intel C on Windows, see windows_intelc_options.py for a start
261 pedantic = ""
262 fatalwarning = ""
263 sysheaderopt = ""
264
265
266 # If not specified in hostname_options.py then set them here
267 if env["cc_flags"] == "-DEFAULT_1": env['cc_flags'] = cc_flags
268 if env["cc_optim"] == "-DEFAULT_2": env['cc_optim'] = cc_optim
269 if env["cc_debug"] == "-DEFAULT_3": env['cc_debug'] = cc_debug
270 if env["omp_optim"] == "-DEFAULT_4": env['omp_optim'] = omp_optim
271 if env["omp_debug"] == "-DEFAULT_5": env['omp_debug'] = omp_debug
272 if env["omp_libs"] == "-DEFAULT_6": env['omp_libs'] = omp_libs
273
274 #set up the autolazy values
275 if env['forcelazy'] != "leave_alone":
276 if env['forcelazy'] == 'on':
277 env.Append(CPPDEFINES='FAUTOLAZYON')
278 else:
279 if env['forcelazy'] == 'off':
280 env.Append(CPPDEFINES='FAUTOLAZYOFF')
281
282 # OpenMP is disabled if useopenmp=no or both variables omp_optim and omp_debug are empty
283 if not env["useopenmp"]:
284 env['omp_optim'] = ""
285 env['omp_debug'] = ""
286 env['omp_libs'] = []
287
288 if env['omp_optim'] == "" and env['omp_debug'] == "": env["useopenmp"] = 0
289
290 # Windows doesn't use LD_LIBRARY_PATH but PATH instead
291 if IS_WINDOWS_PLATFORM:
292 LD_LIBRARY_PATH_KEY='PATH'
293 env['ENV']['LD_LIBRARY_PATH']=''
294 else:
295 LD_LIBRARY_PATH_KEY='LD_LIBRARY_PATH'
296 ############ Copy environment variables into scons env #########
297
298 try: env['ENV']['OMP_NUM_THREADS'] = os.environ['OMP_NUM_THREADS']
299 except KeyError: env['ENV']['OMP_NUM_THREADS'] = 1
300
301 try: env['ENV']['ESCRIPT_NUM_THREADS'] = os.environ['ESCRIPT_NUM_THREADS']
302 except KeyError: pass
303
304 try: env['ENV']['ESCRIPT_NUM_PROCS'] = os.environ['ESCRIPT_NUM_PROCS']
305 except KeyError: env['ENV']['ESCRIPT_NUM_PROCS']=1
306
307 try: env['ENV']['ESCRIPT_NUM_NODES'] = os.environ['ESCRIPT_NUM_NODES']
308 except KeyError: env['ENV']['ESCRIPT_NUM_NODES']=1
309
310 try: env['ENV']['ESCRIPT_HOSTFILE'] = os.environ['ESCRIPT_HOSTFILE']
311 except KeyError: pass
312
313 try: env['ENV']['PATH'] = os.environ['PATH']
314 except KeyError: pass
315
316 try: env['ENV']['PYTHONPATH'] = os.environ['PYTHONPATH']
317 except KeyError: pass
318
319 try: env['ENV']['C_INCLUDE_PATH'] = os.environ['C_INCLUDE_PATH']
320 except KeyError: pass
321
322 try: env['ENV']['CPLUS_INCLUDE_PATH'] = os.environ['CPLUS_INCLUDE_PATH']
323 except KeyError: pass
324
325 try: env.PrependENVPath(LD_LIBRARY_PATH_KEY,os.environ['LD_LIBRARY_PATH'])
326 except KeyError: pass
327
328 try: env['ENV']['LIBRARY_PATH'] = os.environ['LIBRARY_PATH']
329 except KeyError: pass
330
331 try: env['ENV']['DISPLAY'] = os.environ['DISPLAY']
332 except KeyError: pass
333
334 try: env['ENV']['XAUTHORITY'] = os.environ['XAUTHORITY']
335 except KeyError: pass
336
337 try: env['ENV']['HOME'] = os.environ['HOME']
338 except KeyError: pass
339
340 # Configure for test suite
341
342
343 env.PrependENVPath(LD_LIBRARY_PATH_KEY, env['libinstall'])
344 env.PrependENVPath('PYTHONPATH', prefix)
345 env['ENV']['ESCRIPT_ROOT'] = prefix
346
347 ############ Set up paths for Configure() ######################
348
349 # Make a copy of an environment
350 # Use env.Clone if available, but fall back on env.Copy for older version of scons
351 def clone_env(env):
352 if 'Clone' in dir(env): return env.Clone() # scons-0.98
353 else: return env.Copy() # scons-0.96
354
355 # Add cc option -I<Escript>/trunk/include
356 env.Append(CPPPATH = [Dir('include')])
357
358 # Add cc option -L<Escript>/trunk/lib
359 env.Append(LIBPATH = [Dir(env['libinstall'])])
360
361 if env['cc_extra'] != '': env.Append(CCFLAGS = env['cc_extra'])
362 if env['ld_extra'] != '': env.Append(LINKFLAGS = env['ld_extra'])
363
364 if env['usepedantic']: env.Append(CCFLAGS = pedantic)
365
366 # MS Windows
367 if IS_WINDOWS_PLATFORM:
368 env.AppendENVPath('PATH', [env['boost_lib_path']])
369 env.AppendENVPath('PATH', [env['libinstall']])
370 if not env['share_esysUtils'] :
371 env.Append(CPPDEFINES = ['ESYSUTILS_STATIC_LIB'])
372 if not env['share_paso'] :
373 env.Append(CPPDEFINES = ['PASO_STATIC_LIB'])
374
375 if env['usenetcdf']:
376 env.AppendENVPath('PATH', [env['netCDF_lib_path']])
377
378 env.Append(ARFLAGS = env['ar_flags'])
379
380 # Get the global Subversion revision number for getVersion() method
381 try:
382 global_revision = os.popen("svnversion -n .").read()
383 global_revision = re.sub(":.*", "", global_revision)
384 global_revision = re.sub("[^0-9]", "", global_revision)
385 except:
386 global_revision="-1"
387 if global_revision == "": global_revision="-2"
388 env.Append(CPPDEFINES = ["SVN_VERSION="+global_revision])
389
390 ############ numpy (required) ###############################
391
392 try:
393 from numpy import identity
394 except ImportError:
395 print "Cannot import numpy, you need to set your PYTHONPATH"
396 sys.exit(1)
397
398 ############ C compiler (required) #############################
399
400 # Create a Configure() environment for checking existence of required libraries and headers
401 conf = Configure(clone_env(env))
402
403 # Test that the compiler is working
404 if not conf.CheckFunc('printf'):
405 print "Cannot run C compiler '%s' (or libc is missing)" % (env['CC'])
406 sys.exit(1)
407
408 if conf.CheckFunc('gethostname'):
409 conf.env.Append(CPPDEFINES = ['HAVE_GETHOSTNAME'])
410
411 ############ python libraries (required) #######################
412
413
414 if not sysheaderopt =="":
415 conf.env.Append(CCFLAGS=sysheaderopt+env['python_path'])
416 else:
417 conf.env.AppendUnique(CPPPATH = [env['python_path']])
418
419 conf.env.AppendUnique(LIBPATH = [env['python_lib_path']])
420 conf.env.AppendUnique(LIBS = [env['python_libs']])
421
422 conf.env.PrependENVPath('PYTHONPATH', prefix)
423 conf.env.PrependENVPath(LD_LIBRARY_PATH_KEY, env['python_lib_path']) # The wrapper script needs to find these libs
424 conf.env.PrependENVPath(LD_LIBRARY_PATH_KEY, env['libinstall'])
425
426 if not conf.CheckCHeader('Python.h'):
427 print "Cannot find python include files (tried 'Python.h' in directory %s)" % (env['python_path'])
428 sys.exit(1)
429 if not conf.CheckFunc('Py_Exit'):
430 print "Cannot find python library method Py_Main (tried lib %s in directory %s)" % (env['python_libs'], env['python_lib_path'])
431 sys.exit(1)
432
433 ############ boost (required) ##################################
434
435 if not sysheaderopt =="":
436 # This is required because we can't -isystem /usr/system because it breaks std includes
437 if os.path.normpath(env['boost_path']) =="/usr/include":
438 conf.env.Append(CCFLAGS=sysheaderopt+os.path.join(env['boost_path'],'boost'))
439 else:
440 conf.env.Append(CCFLAGS=sysheaderopt+env['boost_path'])
441 else:
442 conf.env.AppendUnique(CPPPATH = [env['boost_path']])
443
444 conf.env.AppendUnique(LIBPATH = [env['boost_lib_path']])
445 conf.env.AppendUnique(LIBS = [env['boost_libs']])
446
447 conf.env.PrependENVPath(LD_LIBRARY_PATH_KEY, env['boost_lib_path']) # The wrapper script needs to find these libs
448 #ensure that our path entries remain at the front
449 conf.env.PrependENVPath('PYTHONPATH', prefix)
450 conf.env.PrependENVPath(LD_LIBRARY_PATH_KEY, env['libinstall'])
451
452 if not conf.CheckCXXHeader('boost/python.hpp'):
453 print "Cannot find boost include files (tried boost/python.hpp in directory %s)" % (env['boost_path'])
454 sys.exit(1)
455
456 if not conf.CheckFunc('PyObject_SetAttr'):
457 print "Cannot find boost library method PyObject_SetAttr (tried method PyObject_SetAttr in library %s in directory %s)" % (env['boost_libs'], env['boost_lib_path'])
458 sys.exit(1)
459
460 # Commit changes to environment
461 env = conf.Finish()
462
463 ############ VTK (optional) ####################################
464
465 if env['usevtk']:
466 try:
467 import vtk
468 env['usevtk'] = 1
469 except ImportError:
470 env['usevtk'] = 0
471
472 # Add VTK to environment env if it was found
473 if env['usevtk']:
474 env.Append(CPPDEFINES = ['USE_VTK'])
475
476 ############ NetCDF (optional) #################################
477
478 conf = Configure(clone_env(env))
479
480 if env['usenetcdf']:
481 conf.env.AppendUnique(CPPPATH = [env['netCDF_path']])
482 conf.env.AppendUnique(LIBPATH = [env['netCDF_lib_path']])
483 conf.env.AppendUnique(LIBS = [env['netCDF_libs']])
484 conf.env.PrependENVPath(LD_LIBRARY_PATH_KEY, env['netCDF_lib_path']) # The wrapper script needs to find these libs
485 #ensure that our path entries remain at the front
486 conf.env.PrependENVPath('PYTHONPATH', prefix)
487 conf.env.PrependENVPath(LD_LIBRARY_PATH_KEY, env['libinstall'])
488
489 if env['usenetcdf'] and not conf.CheckCHeader('netcdf.h'): env['usenetcdf'] = 0
490 if env['usenetcdf'] and not conf.CheckFunc('nc_open'): env['usenetcdf'] = 0
491
492 # Add NetCDF to environment env if it was found
493 if env['usenetcdf']:
494 env = conf.Finish()
495 env.Append(CPPDEFINES = ['USE_NETCDF'])
496 else:
497 conf.Finish()
498
499 ############ PAPI (optional) ###################################
500
501 # Start a new configure environment that reflects what we've already found
502 conf = Configure(clone_env(env))
503
504 if env['usepapi']:
505 conf.env.AppendUnique(CPPPATH = [env['papi_path']])
506 conf.env.AppendUnique(LIBPATH = [env['papi_lib_path']])
507 conf.env.AppendUnique(LIBS = [env['papi_libs']])
508 conf.env.PrependENVPath(LD_LIBRARY_PATH_KEY, env['papi_lib_path']) # The wrapper script needs to find these libs
509 #ensure that our path entries remain at the front
510 conf.env.PrependENVPath('PYTHONPATH', prefix)
511 conf.env.PrependENVPath(LD_LIBRARY_PATH_KEY, env['libinstall'])
512
513 if env['usepapi'] and not conf.CheckCHeader('papi.h'): env['usepapi'] = 0
514 if env['usepapi'] and not conf.CheckFunc('PAPI_start_counters'): env['usepapi'] = 0
515
516 # Add PAPI to environment env if it was found
517 if env['usepapi']:
518 env = conf.Finish()
519 env.Append(CPPDEFINES = ['BLOCKPAPI'])
520 else:
521 conf.Finish()
522
523 ############ MKL (optional) ####################################
524
525 # Start a new configure environment that reflects what we've already found
526 conf = Configure(clone_env(env))
527
528 if env['usemkl']:
529 conf.env.AppendUnique(CPPPATH = [env['mkl_path']])
530 conf.env.AppendUnique(LIBPATH = [env['mkl_lib_path']])
531 conf.env.AppendUnique(LIBS = [env['mkl_libs']])
532 conf.env.PrependENVPath(LD_LIBRARY_PATH_KEY, env['mkl_lib_path']) # The wrapper script needs to find these libs
533 #ensure that our path entries remain at the front
534 conf.env.PrependENVPath('PYTHONPATH', prefix)
535 conf.env.PrependENVPath(LD_LIBRARY_PATH_KEY, env['libinstall'])
536
537 if env['usemkl'] and not conf.CheckCHeader('mkl_solver.h'): env['usemkl'] = 0
538 if env['usemkl'] and not conf.CheckFunc('pardiso'): env['usemkl'] = 0
539
540 # Add MKL to environment env if it was found
541 if env['usemkl']:
542 env = conf.Finish()
543 env.Append(CPPDEFINES = ['MKL'])
544 else:
545 conf.Finish()
546
547 ############ UMFPACK (optional) ################################
548
549 # Start a new configure environment that reflects what we've already found
550 conf = Configure(clone_env(env))
551
552 if env['useumfpack']:
553 conf.env.AppendUnique(CPPPATH = [env['ufc_path']])
554 conf.env.AppendUnique(CPPPATH = [env['umf_path']])
555 conf.env.AppendUnique(LIBPATH = [env['umf_lib_path']])
556 conf.env.AppendUnique(LIBS = [env['umf_libs']])
557 conf.env.AppendUnique(CPPPATH = [env['amd_path']])
558 conf.env.AppendUnique(LIBPATH = [env['amd_lib_path']])
559 conf.env.AppendUnique(LIBS = [env['amd_libs']])
560 conf.env.AppendUnique(CPPPATH = [env['blas_path']])
561 conf.env.AppendUnique(LIBPATH = [env['blas_lib_path']])
562 conf.env.AppendUnique(LIBS = [env['blas_libs']])
563 conf.env.PrependENVPath(LD_LIBRARY_PATH_KEY, env['umf_lib_path']) # The wrapper script needs to find these libs
564 conf.env.PrependENVPath(LD_LIBRARY_PATH_KEY, env['amd_lib_path']) # The wrapper script needs to find these libs
565 conf.env.PrependENVPath(LD_LIBRARY_PATH_KEY, env['blas_lib_path']) # The wrapper script needs to find these libs
566 #ensure that our path entries remain at the front
567 conf.env.PrependENVPath('PYTHONPATH', prefix)
568 conf.env.PrependENVPath(LD_LIBRARY_PATH_KEY, env['libinstall'])
569
570 if env['useumfpack'] and not conf.CheckCHeader('umfpack.h'): env['useumfpack'] = 0
571 if env['useumfpack'] and not conf.CheckFunc('umfpack_di_symbolic'): env['useumfpack'] = 0
572 # if env['useumfpack'] and not conf.CheckFunc('daxpy'): env['useumfpack'] = 0 # this does not work on shake73?
573
574 # Add UMFPACK to environment env if it was found
575 if env['useumfpack']:
576 env = conf.Finish()
577 env.Append(CPPDEFINES = ['UMFPACK'])
578 else:
579 conf.Finish()
580
581 ############ Silo (optional) ###################################
582
583 if env['usesilo']:
584 conf = Configure(clone_env(env))
585 conf.env.AppendUnique(CPPPATH = [env['silo_path']])
586 conf.env.AppendUnique(LIBPATH = [env['silo_lib_path']])
587 conf.env.AppendUnique(LIBS = [env['silo_libs']])
588 if not conf.CheckCHeader('silo.h'): env['usesilo'] = 0
589 if not conf.CheckFunc('DBMkDir'): env['usesilo'] = 0
590 conf.Finish()
591
592 # Add the path to Silo to environment env if it was found.
593 # Note that we do not add the libs since they are only needed for the
594 # escriptreader library and tools.
595 if env['usesilo']:
596 env.AppendUnique(CPPPATH = [env['silo_path']])
597 env.AppendUnique(LIBPATH = [env['silo_lib_path']])
598 env.Append(CPPDEFINES = ['HAVE_SILO'])
599
600 ########### Lapack (optional) ##################################
601
602
603 if env['uselapack']:
604 env.Append(CPPDEFINES='USE_LAPACK')
605 env.AppendUnique(CPPATH = [env['lapack_path']])
606 env.AppendUnique(LIBPATH =[env['lapack_lib_path']])
607
608 env.Append(LIBPATH = '/usr/lib/atlas')
609 env.Append(LIBS = [env['lapack_libs']])
610 #env.Append(LIBS = ['blas'])
611
612 ############ Add the compiler flags ############################
613
614 # Enable debug by choosing either cc_debug or cc_optim
615 if env['usedebug']:
616 env.Append(CCFLAGS = env['cc_debug'])
617 env.Append(CCFLAGS = env['omp_debug'])
618 else:
619 env.Append(CCFLAGS = env['cc_optim'])
620 env.Append(CCFLAGS = env['omp_optim'])
621
622 # Always use cc_flags
623 env.Append(CCFLAGS = env['cc_flags'])
624 env.Append(LIBS = [env['omp_libs']])
625
626 ############ Add some custom builders ##########################
627
628 py_builder = Builder(action = scons_extensions.build_py, suffix = '.pyc', src_suffix = '.py', single_source=True)
629 env.Append(BUILDERS = {'PyCompile' : py_builder});
630
631 runUnitTest_builder = Builder(action = scons_extensions.runUnitTest, suffix = '.passed', src_suffix=env['PROGSUFFIX'], single_source=True)
632 env.Append(BUILDERS = {'RunUnitTest' : runUnitTest_builder});
633
634 runPyUnitTest_builder = Builder(action = scons_extensions.runPyUnitTest, suffix = '.passed', src_suffic='.py', single_source=True)
635 env.Append(BUILDERS = {'RunPyUnitTest' : runPyUnitTest_builder});
636
637 epstopdfbuilder = Builder(action = scons_extensions.eps2pdf, suffix=".pdf", src_suffix=".eps", single_source=True)
638 env.Append(BUILDERS = {'EpsToPDF' : epstopdfbuilder});
639
640 ############ MPI (optional) ####################################
641 if not env['usempi']: env['mpi_flavour']='none'
642
643 # Create a modified environment for MPI programs (identical to env if usempi=no)
644 env_mpi = clone_env(env)
645
646 # Start a new configure environment that reflects what we've already found
647 conf = Configure(clone_env(env_mpi))
648
649 if env_mpi['usempi']:
650 VALID_MPIs=[ "MPT", "MPICH", "MPICH2", "OPENMPI", "INTELMPI" ]
651 if not env_mpi['mpi_flavour'] in VALID_MPIs:
652 raise ValueError,"MPI is enabled but mpi_flavour = %s is not a valid key from %s."%( env_mpi['mpi_flavour'],VALID_MPIs)
653 conf.env.AppendUnique(CPPPATH = [env_mpi['mpi_path']])
654 conf.env.AppendUnique(LIBPATH = [env_mpi['mpi_lib_path']])
655 conf.env.AppendUnique(LIBS = [env_mpi['mpi_libs']])
656 conf.env.PrependENVPath(LD_LIBRARY_PATH_KEY, env['mpi_lib_path']) # The wrapper script needs to find these libs
657 #ensure that our path entries remain at the front
658 conf.env.PrependENVPath('PYTHONPATH', prefix)
659 conf.env.PrependENVPath(LD_LIBRARY_PATH_KEY, env['libinstall'])
660
661 if env_mpi['usempi'] and not conf.CheckCHeader('mpi.h'): env_mpi['usempi'] = 0
662 # if env_mpi['usempi'] and not conf.CheckFunc('MPI_Init'): env_mpi['usempi'] = 0
663
664 # Add MPI to environment env_mpi if it was found
665 if env_mpi['usempi']:
666 env_mpi = conf.Finish()
667 env_mpi.Append(CPPDEFINES = ['PASO_MPI', 'MPI_NO_CPPBIND', env_mpi['MPICH_IGNORE_CXX_SEEK']])
668 else:
669 conf.Finish()
670
671 env['usempi'] = env_mpi['usempi']
672
673
674 ############ ParMETIS (optional) ###############################
675
676 # Start a new configure environment that reflects what we've already found
677 conf = Configure(clone_env(env_mpi))
678
679 if not env_mpi['usempi']: env_mpi['useparmetis'] = 0
680
681 if env_mpi['useparmetis']:
682 conf.env.AppendUnique(CPPPATH = [env_mpi['parmetis_path']])
683 conf.env.AppendUnique(LIBPATH = [env_mpi['parmetis_lib_path']])
684 conf.env.AppendUnique(LIBS = [env_mpi['parmetis_libs']])
685 conf.env.PrependENVPath(LD_LIBRARY_PATH_KEY, env['parmetis_lib_path']) # The wrapper script needs to find these libs
686 #ensure that our path entries remain at the front
687 conf.env.PrependENVPath('PYTHONPATH', prefix)
688 conf.env.PrependENVPath(LD_LIBRARY_PATH_KEY, env['libinstall'])
689
690 if env_mpi['useparmetis'] and not conf.CheckCHeader('parmetis.h'): env_mpi['useparmetis'] = 0
691 if env_mpi['useparmetis'] and not conf.CheckFunc('ParMETIS_V3_PartGeomKway'): env_mpi['useparmetis'] = 0
692
693 # Add ParMETIS to environment env_mpi if it was found
694 if env_mpi['useparmetis']:
695 env_mpi = conf.Finish()
696 env_mpi.Append(CPPDEFINES = ['USE_PARMETIS'])
697 else:
698 conf.Finish()
699
700 env['useparmetis'] = env_mpi['useparmetis']
701
702 ############ Now we switch on Warnings as errors ###############
703
704 #this needs to be done after configuration because the scons test files have warnings in them
705
706 if ((fatalwarning != "") and (env['usewarnings'])):
707 env.Append(CCFLAGS = fatalwarning)
708 env_mpi.Append(CCFLAGS = fatalwarning)
709
710 ############ Summarize our environment #########################
711
712 print ""
713 print "Summary of configuration (see ./config.log for information)"
714 print " Using python libraries"
715 print " Using numpy"
716 print " Using boost"
717 if env['usenetcdf']: print " Using NetCDF"
718 else: print " Not using NetCDF"
719 if env['usevtk']: print " Using VTK"
720 else: print " Not using VTK"
721 if env['usemkl']: print " Using MKL"
722 else: print " Not using MKL"
723 if env['useumfpack']: print " Using UMFPACK"
724 else: print " Not using UMFPACK"
725 if env['usesilo']: print " Using Silo"
726 else: print " Not using Silo"
727 if env['useopenmp']: print " Using OpenMP"
728 else: print " Not using OpenMP"
729 if env['usempi']: print " Using MPI (flavour = %s)"%env['mpi_flavour']
730 else: print " Not using MPI"
731 if env['useparmetis']: print " Using ParMETIS"
732 else: print " Not using ParMETIS (requires MPI)"
733 if env['usepapi']: print " Using PAPI"
734 else: print " Not using PAPI"
735 if env['usedebug']: print " Compiling for debug"
736 else: print " Not compiling for debug"
737 print " Installing in", prefix
738 if ((fatalwarning != "") and (env['usewarnings'])): print " Treating warnings as errors"
739 else: print " Not treating warnings as errors"
740 print ""
741
742 ############ Delete option-dependent files #####################
743
744 Execute(Delete(os.path.join(env['libinstall'],"Compiled.with.debug")))
745 Execute(Delete(os.path.join(env['libinstall'],"Compiled.with.mpi")))
746 Execute(Delete(os.path.join(env['libinstall'],"Compiled.with.openmp")))
747 Execute(Delete(os.path.join(env['libinstall'],"pyversion")))
748 Execute(Delete(os.path.join(env['libinstall'],"buildvars")))
749 if not env['usempi']: Execute(Delete(os.path.join(env['libinstall'],"pythonMPI")))
750
751
752 ############ Build the subdirectories ##########################
753
754 from grouptest import *
755
756 TestGroups=[]
757
758 Export(
759 ["env",
760 "env_mpi",
761 "clone_env",
762 "IS_WINDOWS_PLATFORM",
763 "TestGroups"
764 ]
765 )
766
767 env.SConscript(dirs = ['tools/CppUnitTest/src'], build_dir='build/$PLATFORM/tools/CppUnitTest', duplicate=0)
768 env.SConscript(dirs = ['tools/libescriptreader/src'], build_dir='build/$PLATFORM/tools/libescriptreader', duplicate=0)
769 env.SConscript(dirs = ['paso/src'], build_dir='build/$PLATFORM/paso', duplicate=0)
770 env.SConscript(dirs = ['escript/src'], build_dir='build/$PLATFORM/escript', duplicate=0)
771 env.SConscript(dirs = ['esysUtils/src'], build_dir='build/$PLATFORM/esysUtils', duplicate=0)
772 env.SConscript(dirs = ['finley/src'], build_dir='build/$PLATFORM/finley', duplicate=0)
773 env.SConscript(dirs = ['modellib/py_src'], build_dir='build/$PLATFORM/modellib', duplicate=0)
774 env.SConscript(dirs = ['doc'], build_dir='build/$PLATFORM/doc', duplicate=0)
775 env.SConscript(dirs = ['pyvisi/py_src'], build_dir='build/$PLATFORM/pyvisi', duplicate=0)
776 env.SConscript(dirs = ['pycad/py_src'], build_dir='build/$PLATFORM/pycad', duplicate=0)
777 env.SConscript(dirs = ['pythonMPI/src'], build_dir='build/$PLATFORM/pythonMPI', duplicate=0)
778 env.SConscript(dirs = ['scripts'], build_dir='build/$PLATFORM/scripts', duplicate=0)
779 env.SConscript(dirs = ['paso/profiling'], build_dir='build/$PLATFORM/paso/profiling', duplicate=0)
780
781
782 ############ Remember what optimizations we used ###############
783
784 remember_list = []
785
786 if env['usedebug']:
787 remember_list += env.Command(os.path.join(env['libinstall'],"Compiled.with.debug"), None, Touch('$TARGET'))
788
789 if env['usempi']:
790 remember_list += env.Command(os.path.join(env['libinstall'],"Compiled.with.mpi"), None, Touch('$TARGET'))
791
792 if env['useopenmp']:
793 remember_list += env.Command(os.path.join(env['libinstall'],"Compiled.with.openmp"), None, Touch('$TARGET'))
794
795 env.Alias('remember_options', remember_list)
796
797
798 ############### Record python interpreter version ##############
799
800 if not IS_WINDOWS_PLATFORM:
801 versionstring="Python "+str(sys.version_info[0])+"."+str(sys.version_info[1])+"."+str(sys.version_info[2])
802 os.system("echo "+versionstring+" > "+os.path.join(env['libinstall'],"pyversion"))
803
804 ############## Populate the buildvars file #####################
805
806 buildvars=open(os.path.join(env['libinstall'],'buildvars'),'w')
807 buildvars.write('python='+str(sys.version_info[0])+"."+str(sys.version_info[1])+"."+str(sys.version_info[2])+'\n')
808
809 # Find the boost version by extracting it from version.hpp
810 boosthpp=open(os.path.join(env['boost_path'],'boost','version.hpp'))
811 boostversion='unknown'
812 try:
813 for line in boosthpp:
814 ver=re.match(r'#define BOOST_VERSION (\d+)',line)
815 if ver:
816 boostversion=ver.group(1)
817 except StopIteration:
818 pass
819 buildvars.write("boost="+boostversion+"\n")
820 buildvars.write("svn_revision="+str(global_revision)+"\n")
821 out="usedebug="
822 if env['usedebug']:
823 out+="y"
824 else:
825 out+="n"
826 out+="\nusempi="
827 if env['usempi']:
828 out+="y"
829 else:
830 out+="n"
831 out+="\nuseopenmp="
832 if env['useopenmp']:
833 out+="y"
834 else:
835 out+="n"
836 buildvars.write(out+"\n")
837 buildvars.write("mpi_flavour="+env['mpi_flavour']+'\n')
838 buildvars.write("lapack=")
839 if env['uselapack']:
840 buildvars.write('y')
841 else:
842 buildvars.write('n')
843 buildvars.write('\n')
844 buildvars.close()
845
846
847 ############ Targets to build and install libraries ############
848
849 target_init = env.Command(env['pyinstall']+'/__init__.py', None, Touch('$TARGET'))
850 env.Alias('target_init', [target_init])
851
852 # The headers have to be installed prior to build in order to satisfy #include <paso/Common.h>
853 env.Alias('build_esysUtils', ['target_install_esysUtils_headers', 'target_esysUtils_a'])
854 env.Alias('install_esysUtils', ['build_esysUtils', 'target_install_esysUtils_a'])
855
856 env.Alias('build_paso', ['target_install_paso_headers', 'target_paso_a'])
857 env.Alias('install_paso', ['build_paso', 'target_install_paso_a'])
858
859 env.Alias('build_escript', ['target_install_escript_headers', 'target_escript_so', 'target_escriptcpp_so'])
860 env.Alias('install_escript', ['build_escript', 'target_install_escript_so', 'target_install_escriptcpp_so', 'target_install_escript_py'])
861
862 env.Alias('build_finley', ['target_install_finley_headers', 'target_finley_so', 'target_finleycpp_so'])
863 env.Alias('install_finley', ['build_finley', 'target_install_finley_so', 'target_install_finleycpp_so', 'target_install_finley_py'])
864
865 # Now gather all the above into a couple easy targets: build_all and install_all
866 build_all_list = []
867 build_all_list += ['build_esysUtils']
868 build_all_list += ['build_paso']
869 build_all_list += ['build_escript']
870 build_all_list += ['build_finley']
871 if env['usempi']: build_all_list += ['target_pythonMPI_exe']
872 #if not IS_WINDOWS_PLATFORM: build_all_list += ['target_escript_wrapper']
873 if env['usesilo']: build_all_list += ['target_escript2silo']
874 env.Alias('build_all', build_all_list)
875
876 install_all_list = []
877 install_all_list += ['target_init']
878 install_all_list += ['install_esysUtils']
879 install_all_list += ['install_paso']
880 install_all_list += ['install_escript']
881 install_all_list += ['install_finley']
882 install_all_list += ['target_install_pyvisi_py']
883 install_all_list += ['target_install_modellib_py']
884 install_all_list += ['target_install_pycad_py']
885 if env['usempi']: install_all_list += ['target_install_pythonMPI_exe']
886 #if not IS_WINDOWS_PLATFORM: install_all_list += ['target_install_escript_wrapper']
887 if env['usesilo']: install_all_list += ['target_install_escript2silo']
888 install_all_list += ['remember_options']
889 env.Alias('install_all', install_all_list)
890
891 # Default target is install
892 env.Default('install_all')
893
894 ############ Targets to build and run the test suite ###########
895
896 env.Alias('build_cppunittest', ['target_install_cppunittest_headers', 'target_cppunittest_a'])
897 env.Alias('install_cppunittest', ['build_cppunittest', 'target_install_cppunittest_a'])
898 env.Alias('run_tests', ['install_all', 'target_install_cppunittest_a'])
899 env.Alias('all_tests', ['install_all', 'target_install_cppunittest_a', 'run_tests', 'py_tests'])
900 env.Alias('build_full',['install_all','build_tests','build_py_tests'])
901
902 ############ Targets to build the documentation ################
903
904 env.Alias('api_epydoc','install_all')
905
906 env.Alias('docs', ['examples_tarfile', 'examples_zipfile', 'api_epydoc', 'api_doxygen', 'guide_pdf', 'guide_html','install_pdf'])
907
908 if not IS_WINDOWS_PLATFORM:
909 try:
910 utest=open("utest.sh","w")
911 build_platform=os.name #Sometimes Mac python says it is posix
912 if (build_platform=='posix') and platform.system()=="Darwin":
913 build_platform='darwin'
914 utest.write(GroupTest.makeHeader(build_platform))
915 for tests in TestGroups:
916 utest.write(tests.makeString())
917 utest.close()
918 os.chmod("utest.sh",stat.S_IRWXU|stat.S_IRGRP|stat.S_IXGRP|stat.S_IROTH|stat.S_IXOTH)
919 print "utest.sh written"
920 except IOError:
921 print "Error attempting to write unittests file."
922 sys.exit(1)
923
924 #Make sure that the escript wrapper is in place
925 if not os.path.isfile(os.path.join(env['bininstall'],'escript')):
926 print "Copying escript wrapper"
927 shutil.copy("bin/escript",os.path.join(env['bininstall'],'escript'))

  ViewVC Help
Powered by ViewVC 1.1.26