/[escript]/release/5.2/site_scons/dependencies.py
ViewVC logotype

Contents of /release/5.2/site_scons/dependencies.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6692 - (show annotations)
Mon Jun 25 02:31:06 2018 UTC (2 years, 11 months ago) by jfenwick
File MIME type: text/x-python
File size: 26545 byte(s)
Fix

1
2 ##############################################################################
3 #
4 # Copyright (c) 2003-2018 by The University of Queensland
5 # http://www.uq.edu.au
6 #
7 # Primary Business: Queensland, Australia
8 # Licensed under the Apache License, version 2.0
9 # http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12 # Development 2012-2013 by School of Earth Sciences
13 # Development from 2014 by Centre for Geoscience Computing (GeoComp)
14 #
15 ##############################################################################
16
17 from __future__ import print_function, division
18
19 __copyright__="""Copyright (c) 2003-2018 by The University of Queensland
20 http://www.uq.edu.au
21 Primary Business: Queensland, Australia"""
22 __license__="""Licensed under the Apache License, version 2.0
23 http://www.apache.org/licenses/LICENSE-2.0"""
24 __url__="https://launchpad.net/escript-finley"
25
26 import os, re, sys
27 from distutils import sysconfig
28 from subprocess import PIPE, Popen
29 from SCons.Script.SConscript import Configure
30 from site_init import findLibWithHeader, detectModule
31
32 REQUIRED_BOOST = (1, 46)
33
34 def CheckComplexAcos(context):
35 context.Message('Checking for working complex std::acos()... ')
36 result = context.TryRun("""
37 #include <complex>
38 int main() { std::complex<double> x(0,3.14159265359), y(1.5707963,-1.8622957);
39 return std::abs(std::acos(x)-y) < 1e-6 ? 0:-1;}
40 """, '.cpp')
41 # scons < 2.4 fix:
42 if type(result)==tuple:
43 result = result[0]
44 context.Result(result)
45 return result
46
47 def checkCompiler(env):
48 conf = Configure(env.Clone(), custom_tests = {'CheckComplexAcos': CheckComplexAcos})
49 if 'CheckCXX' in dir(conf): # exists since scons 1.1.0
50 if not conf.CheckCXX():
51 print("Cannot run C++ compiler '%s' (check config.log)" % (env['CXX']))
52 env.Exit(1)
53 else:
54 if not conf.CheckFunc('printf', language='c++'):
55 print("Cannot run C++ compiler '%s' (check config.log)" % (env['CXX']))
56 env.Exit(1)
57
58 conf.env['buildvars']['cxx']=conf.env['CXX']
59
60 if conf.CheckFunc('gethostname', language='c++'):
61 conf.env.Append(CPPDEFINES = ['HAVE_GETHOSTNAME'])
62
63 if conf.CheckCXXHeader('byteswap.h'):
64 checkhdr="""#include <byteswap.h>
65 #define SCbswap32() {int x=0;bswap_32(x);}"""
66 if conf.CheckFunc('SCbswap32', header=checkhdr, language='c++'):
67 conf.env.Append(CPPDEFINES = ['HAVE_BYTESWAP_H'])
68 if conf.CheckCXXHeader('sys/endian.h'):
69 conf.env.Append(CPPDEFINES = ['HAVE_SYS_ENDIAN_H'])
70 if conf.CheckCXXHeader('libkern/OSByteOrder.h'):
71 conf.env.Append(CPPDEFINES = ['HAVE_OSBYTEORDER_H'])
72
73 if not conf.CheckComplexAcos():
74 conf.env.Append(CPPDEFINES = ['ESYS_USE_BOOST_ACOS'])
75
76 return conf.Finish()
77
78 def get_external_python_sympy(bin):
79 import subprocess
80 cmd=''
81 cmd+='import sympy\n'
82 cmd+='print(sympy.__version__)\n'
83 sp=subprocess.Popen([bin, '-c', cmd], stdin=None, stderr=None, stdout=subprocess.PIPE)
84 ver=sp.stdout.readline().strip().split('.')
85 if int(ver[0]) == 0 and int(ver[1]) < 7:
86 env['sympy'] = False
87 env['warnings'].append("sympy version is too old.")
88
89 def call_python_config(bin=None):
90 import subprocess
91 cmd=''
92 cmd+='import subprocess\n'
93 cmd+='import os\n'
94 cmd+='from distutils import sysconfig\n'
95 cmd+='pyversion=sysconfig.get_python_version()\n'
96 cmd+='sp=subprocess.Popen(["python"+pyversion+"-config","--ldflags"], stdout=subprocess.PIPE)\n'
97 cmd+='d=sp.stdout.readline().split()\n'
98 cmd+="libdirs=[z[2:] for z in d if z.startswith(b'-L')]\n"
99 cmd+="libs=[z[2:] for z in d if z.startswith(b'-lpython')]\n"
100 cmd+="target=''\n"
101 cmd+="libname=''\n"
102 cmd+="for d in libdirs:\n"
103 cmd+=" for f in libs:\n"
104 cmd+=" s=os.path.join(d,b'lib'+f+b'.so')\n"
105 cmd+=" try:\n"
106 cmd+=" dummy=os.stat(s)\n"
107 cmd+=" if target=='':\n"
108 cmd+=" target=d\n"
109 cmd+=" libname=f\n"
110 cmd+=" except Exception:\n"
111 cmd+=" pass\n"
112 cmd+=" s=os.path.join(d,b'lib'+f+b'.dylib')\n"
113 cmd+=" try:\n"
114 cmd+=" dummy=os.stat(s)\n"
115 cmd+=" if target=='':\n"
116 cmd+=" target=d\n"
117 cmd+=" libname=f\n"
118 cmd+=" except Exception:\n"
119 cmd+=" pass\n"
120 if bin is None:
121 exec(cmd)
122 ver=str(sys.version_info[0])+'.'+str(sys.version_info[1])+'.'+str(sys.version_info[2])
123 return (target,libname,ver, sysconfig.get_python_inc())
124 # run an external python to get its library location
125 # yes we are starting another python just to run python?-config
126 cmd+="if 'decode' in dir(target):\n"
127 cmd+=" target=target.decode()\n"
128 cmd+=" libname=libname.decode()\n"
129 cmd+="print(target)\n"
130 cmd+="print(libname)\n"
131 cmd+="import sys\n"
132 cmd+="print(str(sys.version_info[0])+'.'+str(sys.version_info[1])+'.'+str(sys.version_info[2]))\n"
133 cmd+="print(sysconfig.get_python_inc())\n"
134 sp=subprocess.Popen([bin, '-c', cmd], stdin=None, stderr=None, stdout=subprocess.PIPE)
135 target=sp.stdout.readline().strip()
136 libname=sp.stdout.readline().strip()
137 ver=sp.stdout.readline().strip()
138 pinc=sp.stdout.readline().strip()
139 return (target, libname, ver, pinc)
140
141 def checkPython(env):
142 # First we check to see if the config file has specified
143 # where to find the file. Ideally, this should be automatic
144 # but we need to deal with the case where python is not in its INSTALL
145 # directory.
146 # Use the python scons is running
147 if env['pythoncmd'] == sys.executable:
148 if env['IS_WINDOWS']:
149 python_inc_path=sysconfig.get_python_inc()
150 python_lib_path=os.path.join(sysconfig.get_config_var('prefix'), 'libs')
151 python_libs=['python%s%s'%(sys.version_info[0], sys.version_info[1])]
152 verstring=".".join([str(i) for i in sys.version_info[:3]])
153 else:
154 (python_lib_path, python_libs,verstring, python_inc_path)=call_python_config()
155
156 # if we want to use a python other than the one scons is running
157 # Note: we assume scons is running python 2 in the following.
158 else:
159 (python_lib_path, python_libs,verstring, python_inc_path)=call_python_config(env['pythoncmd'])
160 env['python_version'] = verstring
161 ispython3 = (verstring[0] == '3')
162 if ispython3:
163 env.Append(CPPDEFINES=['ESPYTHON3'])
164 env['buildvars']['python_version'] = verstring
165 env['buildvars']['python'] = env['pythoncmd']
166 # Check for an override from the config file.
167 # Ideally, this should be automatic but we need to deal with the case
168 # where python is not in its INSTALL directory
169 if env['pythonlibpath'] != '':
170 python_lib_path = env['pythonlibpath']
171
172 if env['pythonincpath'] != '':
173 python_inc_path = env['pythonincpath']
174
175 if env['pythonlibname'] != '':
176 python_libs = env['pythonlibname']
177
178 conf = Configure(env.Clone())
179
180 if env['sysheaderopt'] == '':
181 conf.env.AppendUnique(CPPPATH = [python_inc_path])
182 else:
183 conf.env.Append(CCFLAGS = [env['sysheaderopt'], python_inc_path])
184
185 conf.env.AppendUnique(LIBPATH = [python_lib_path])
186 conf.env.AppendUnique(LIBS = python_libs)
187 # The wrapper script needs to find the libs
188 conf.env.PrependENVPath(env['LD_LIBRARY_PATH_KEY'], python_lib_path)
189
190 if not conf.CheckCXXHeader('Python.h'):
191 print("Cannot find python include files (tried 'Python.h' in directory %s)" % (python_inc_path))
192 env.Exit(1)
193 if not conf.CheckFunc('Py_Exit', language='c++'):
194 print("Cannot find python library method Py_Exit (tried %s in directory %s)" % (python_libs, python_lib_path))
195 env.Exit(1)
196
197 return conf.Finish()
198
199 def checkCudaVersion(env):
200 # NVCC availability is already checked in the Tool file
201 p = Popen([env['NVCC'], '-V'], stdout=PIPE)
202 out,_ = p.communicate()
203 env['nvcc_version'] = '(unknown version)'
204 for line in out.split('\n'):
205 if 'release' in line:
206 version = line[line.find('release'):].strip()
207 env['nvcc_version'] = version
208 break
209 env['buildvars']['nvcc']=env['NVCC']
210 return env
211
212 def checkBoost(env):
213 boost_inc_path,boost_lib_path=findLibWithHeader(env, env['boost_libs'], 'boost/python.hpp', env['boost_prefix'], lang='c++')
214 if env['sysheaderopt'] == '':
215 env.AppendUnique(CPPPATH = [boost_inc_path])
216 else:
217 # This is required because we can't -isystem /usr/include since it
218 # breaks std includes
219 if os.path.normpath(boost_inc_path) == '/usr/include':
220 env.Append(CCFLAGS=[env['sysheaderopt'], os.path.join(boost_inc_path,'boost')])
221 else:
222 env.Append(CCFLAGS=[env['sysheaderopt'], boost_inc_path])
223
224 env.AppendUnique(LIBPATH = [boost_lib_path])
225 env.AppendUnique(LIBS = env['boost_libs'])
226 env.PrependENVPath(env['LD_LIBRARY_PATH_KEY'], boost_lib_path)
227
228 # Try to extract the boost version from version.hpp
229 boosthpp=open(os.path.join(boost_inc_path, 'boost', 'version.hpp'))
230 boostversion='unknown'
231 for line in boosthpp:
232 ver=re.match(r'#define BOOST_VERSION (\d+)',line)
233 if ver:
234 boostversion=ver.group(1)
235 boostversion = int(boostversion)
236 maj = boostversion/100000
237 minor = (boostversion/100)%1000
238 sub = boostversion % 100
239 env['boost_version'] = "%d.%d.%d"%(maj,minor,sub)
240 if maj <= REQUIRED_BOOST[0] and minor < REQUIRED_BOOST[1]:
241 print("The boost version referenced must be at least version %d.%d "%REQUIRED_BOOST + "(have %d.%d.%d)"%(maj,minor,sub))
242 env.Exit(1)
243 boosthpp.close()
244 env['buildvars']['boost_inc_path']=boost_inc_path
245 env['buildvars']['boost_lib_path']=boost_lib_path
246 env['buildvars']['boostversion']=boostversion
247 return env
248
249 def checkNumpy(env):
250 if not detectModule(env, 'numpy'):
251 print("Cannot import numpy. If it is installed try setting your PYTHONPATH and probably %s"%env['LD_LIBRARY_PATH_KEY'])
252 env.Exit(1)
253
254 ## check for numpy header (optional)
255 conf = Configure(env.Clone())
256 if conf.CheckCXXHeader(['Python.h','numpy/ndarrayobject.h']):
257 conf.env.Append(CPPDEFINES = ['ESYS_HAVE_NUMPY_H'])
258 conf.env['numpy_h']=True
259 else:
260 conf.env['numpy_h']=False
261
262 return conf.Finish()
263
264 def checkCUDA(env):
265 try:
266 cuda_inc_path,cuda_lib_path=findLibWithHeader(env, 'cudart', 'thrust/version.h', env['cuda_prefix'], lang='c++')
267 env.AppendUnique(CPPPATH = [cuda_inc_path])
268 env.AppendUnique(LIBPATH = [cuda_lib_path])
269 env.PrependENVPath(env['LD_LIBRARY_PATH_KEY'], cuda_lib_path)
270 env.Append(CPPDEFINES = ['ESYS_HAVE_CUDA'])
271 env['cuda']=True
272 except:
273 env['cuda']=False
274 return env
275
276 def checkCppUnit(env):
277 try:
278 cppunit_inc_path,cppunit_lib_path=findLibWithHeader(env, env['cppunit_libs'], 'cppunit/TestFixture.h', env['cppunit_prefix'], lang='c++')
279 env.AppendUnique(CPPPATH = [cppunit_inc_path])
280 env.AppendUnique(LIBPATH = [cppunit_lib_path])
281 env.PrependENVPath(env['LD_LIBRARY_PATH_KEY'], cppunit_lib_path)
282 env['cppunit']=True
283 except:
284 env['cppunit']=False
285 return env
286
287 def checkOptionalModules(env):
288 ######## scipy
289 if not detectModule(env, 'scipy'):
290 env['warnings'].append("Cannot import scipy. NetCDF sources will not be available for inversions.")
291
292 ######## pyproj
293 if not detectModule(env, 'pyproj'):
294 env['warnings'].append("Cannot import pyproj. Inversions may not work.")
295
296 ######## gdal
297 if not detectModule(env, 'gdal'):
298 env['warnings'].append("Cannot import gdal. Inversions will not honour WKT coordinate system information.")
299
300 ######## sympy
301 if not detectModule(env, 'sympy'):
302 env['warnings'].append("Cannot import sympy. Symbolic toolbox and nonlinear PDEs will not be available.")
303 else:
304 if env['pythoncmd'] is not None:
305 get_external_python_sympy(env['pythoncmd'])
306 else:
307 import sympy as sp
308 spVer=sp.__version__
309 spl=spVer.split('.')
310 if int(spl[0]) == 0 and int(spl[1]) < 7:
311 env['sympy']=False
312 env['warnings'].append("sympy version too old. Symbolic toolbox and nonlinear PDEs will not be available.")
313
314 ######## gmshpy
315 env['gmshpy'] = detectModule(env, 'gmshpy')
316
317 return env
318
319 def checkForTrilinos(env):
320 trilinos_inc_path=''
321 trilinos_lib_path=''
322 if env['trilinos']:
323 havelibs = (len(env['trilinos_libs']) > 0)
324 trilinos_inc_path,trilinos_lib_path=findLibWithHeader(env,
325 env['trilinos_libs'], 'Tpetra_CrsMatrix.hpp',
326 env['trilinos_prefix'], lang='c++', try_link=havelibs)
327 if not havelibs:
328 packages=['Tpetra','Kokkos','Belos','Amesos2','Ifpack2','MueLu']
329 libs = []
330 for pk in packages:
331 # find out what libraries to link with...
332 makefile = os.path.join(trilinos_inc_path, 'Makefile.export.%s'%pk)
333 try:
334 for l in open(makefile, 'r').readlines():
335 if l.startswith("%s_LIBRARIES"%pk): # or l.startswith("Trilinos_TPL_LIBRARIES"):
336 lst = l.split('=')[1].strip().split()
337 lst = [e.replace('-l','',1) for e in lst]
338 libs += lst
339 elif l.startswith("%s_TPL_INCLUDE_DIRS"%pk):
340 lst = l.split('=')[1].strip().split()
341 lst = [e.replace('-I','',1) for e in lst]
342 env.AppendUnique(CPPPATH = lst)
343
344 except Exception as e:
345 raise RuntimeError('Error reading Trilinos export Makefile\n%s'%(e))
346 env['trilinos_libs'] = libs
347
348 env.AppendUnique(CPPPATH = [trilinos_inc_path])
349 env.AppendUnique(LIBPATH = [trilinos_lib_path])
350 env.Append(CPPDEFINES = ['ESYS_HAVE_TRILINOS'])
351 env.PrependENVPath(env['LD_LIBRARY_PATH_KEY'], trilinos_lib_path)
352 env['buildvars']['trilinos_inc_path']=trilinos_inc_path
353 env['buildvars']['trilinos_lib_path']=trilinos_lib_path
354 env['buildvars']['trilinos']=int(env['trilinos'])
355 return env
356
357 def checkOptionalLibraries(env):
358 ######## netCDF
359 netcdf_inc_path=''
360 netcdf_lib_path=''
361 if env['netcdf']:
362 if env['netcdf']==4:
363 env.Append(CPPDEFINES = ['NETCDF4'])
364 netcdf_inc_path,netcdf_lib_path=findLibWithHeader(env, env['netcdf_libs'], 'ncVar.h', env['netcdf_prefix'], lang='c++')
365 else:
366 netcdf_inc_path,netcdf_lib_path=findLibWithHeader(env, env['netcdf_libs'], 'netcdfcpp.h', env['netcdf_prefix'], lang='c++')
367 env.AppendUnique(CPPPATH = [netcdf_inc_path])
368 env.AppendUnique(LIBPATH = [netcdf_lib_path])
369 env.PrependENVPath(env['LD_LIBRARY_PATH_KEY'], netcdf_lib_path)
370 env.Append(CPPDEFINES = ['ESYS_HAVE_NETCDF'])
371 env['buildvars']['netcdf_inc_path']=netcdf_inc_path
372 env['buildvars']['netcdf_lib_path']=netcdf_lib_path
373 env['buildvars']['netcdf']=int(env['netcdf'])
374
375 ######## PAPI
376 papi_inc_path=''
377 papi_lib_path=''
378 if env['papi']:
379 papi_inc_path,papi_lib_path=findLibWithHeader(env, env['papi_libs'], 'papi.h', env['papi_prefix'], lang='c++')
380 env.AppendUnique(CPPPATH = [papi_inc_path])
381 env.AppendUnique(LIBPATH = [papi_lib_path])
382 env.PrependENVPath(env['LD_LIBRARY_PATH_KEY'], papi_lib_path)
383 env.Append(CPPDEFINES = ['ESYS_HAVE_PAPI'])
384 env['buildvars']['papi_inc_path']=papi_inc_path
385 env['buildvars']['papi_lib_path']=papi_lib_path
386 env['buildvars']['papi']=int(env['papi'])
387
388 ######## MKL
389 mkl_inc_path=''
390 mkl_lib_path=''
391 if env['mkl']:
392 mkl_inc_path,mkl_lib_path=findLibWithHeader(env, env['mkl_libs'], 'mkl_pardiso.h', env['mkl_prefix'], lang='c++')
393 env.AppendUnique(CPPPATH = [mkl_inc_path])
394 env.AppendUnique(LIBPATH = [mkl_lib_path])
395 env.PrependENVPath(env['LD_LIBRARY_PATH_KEY'], mkl_lib_path)
396 env.Append(CPPDEFINES = ['ESYS_HAVE_MKL'])
397 env['buildvars']['mkl_inc_path']=mkl_inc_path
398 env['buildvars']['mkl_lib_path']=mkl_lib_path
399 env['buildvars']['mkl']=int(env['mkl'])
400
401 ######## UMFPACK
402 umfpack_inc_path=''
403 umfpack_lib_path=''
404 if env['umfpack']:
405 umfpack_inc_path,umfpack_lib_path=findLibWithHeader(env, env['umfpack_libs'], 'umfpack.h', env['umfpack_prefix'], lang='c++')
406 env.AppendUnique(CPPPATH = [umfpack_inc_path])
407 env.AppendUnique(LIBPATH = [umfpack_lib_path])
408 env.PrependENVPath(env['LD_LIBRARY_PATH_KEY'], umfpack_lib_path)
409 env.Append(CPPDEFINES = ['ESYS_HAVE_UMFPACK'])
410 env['buildvars']['umfpack_inc_path']=umfpack_inc_path
411 env['buildvars']['umfpack_lib_path']=umfpack_lib_path
412 env['buildvars']['umfpack']=int(env['umfpack'])
413
414 ######## LAPACK
415 lapack_inc_path=''
416 lapack_lib_path=''
417 flavour = 'none'
418 env['uselapack'] = False
419 if env['lapack'] != 0:
420 # not explicitly disabled so run the checks
421 if env['longindices']:
422 # you want longindices + lapack? sorry.
423 if env['lapack'] == 1:
424 print("LAPACK requires index type = int. Set longindices to False or disable LAPACK.")
425 env.Exit(1)
426 else:
427 if env['mkl']:
428 # we detected MKL so try the MKL header+libs
429 flavour = 'mkl'
430 header = 'mkl_lapack.h'
431 prefix = env['mkl_prefix']
432 if len(env['lapack_libs']) == 0:
433 libs = env['mkl_libs']
434 else:
435 libs = env['lapack_libs']
436 else:
437 # try for clapack
438 flavour = 'clapack'
439 header = 'clapack.h'
440 prefix = env['lapack_prefix']
441 if len(env['lapack_libs']) == 0:
442 libs = ['lapack_atlas']
443 else:
444 libs = env['lapack_libs']
445
446 try:
447 lapack_inc_path,lapack_lib_path=findLibWithHeader(env, libs, header, prefix, lang='c++')
448 env['lapack_libs'] = libs
449 env['uselapack'] = True
450 env.AppendUnique(CPPPATH = [lapack_inc_path])
451 env.AppendUnique(LIBPATH = [lapack_lib_path])
452 env.Append(CPPDEFINES = ['ESYS_HAVE_LAPACK'])
453 if flavour == 'mkl':
454 env.AppendUnique(CPPDEFINES = ['ESYS_MKL_LAPACK'])
455 env['buildvars']['lapack_inc_path']=lapack_inc_path
456 env['buildvars']['lapack_lib_path']=lapack_lib_path
457 except:
458 if env['lapack'] == 1:
459 raise
460 # lapack was set to auto-detect so not a fatal error
461 flavour = 'none'
462
463 env['lapack'] = flavour
464 env['buildvars']['lapack'] = flavour
465
466 ######## Silo
467 silo_inc_path=''
468 silo_lib_path=''
469 if env['silo']:
470 silo_inc_path,silo_lib_path=findLibWithHeader(env, env['silo_libs'], 'silo.h', env['silo_prefix'], lang='c++')
471 env.AppendUnique(CPPPATH = [silo_inc_path])
472 env.AppendUnique(LIBPATH = [silo_lib_path])
473 env.Append(CPPDEFINES = ['ESYS_HAVE_SILO'])
474 env['buildvars']['silo_inc_path']=silo_inc_path
475 env['buildvars']['silo_lib_path']=silo_lib_path
476 env['buildvars']['silo']=int(env['silo'])
477
478 ######## VisIt
479 visit_inc_path=''
480 visit_lib_path=''
481 if env['visit']:
482 visit_inc_path,visit_lib_path=findLibWithHeader(env, env['visit_libs'], 'VisItControlInterface_V2.h', env['visit_prefix'], lang='c++')
483 env.AppendUnique(CPPPATH = [visit_inc_path])
484 env.AppendUnique(LIBPATH = [visit_lib_path])
485 env['buildvars']['visit_inc_path']=visit_inc_path
486 env['buildvars']['visit_lib_path']=visit_lib_path
487 env['buildvars']['visit']=int(env['visit'])
488
489 ######## MPI
490 if env['mpi']=='no':
491 env['mpi']='none'
492
493 env['usempi'] = env['mpi']!='none'
494 mpi_inc_path=''
495 mpi_lib_path=''
496 if env['usempi']:
497 mpi_inc_path,mpi_lib_path=findLibWithHeader(env, env['mpi_libs'], 'mpi.h', env['mpi_prefix'], lang='c++')
498 env.AppendUnique(CPPPATH = [mpi_inc_path])
499 env.AppendUnique(LIBPATH = [mpi_lib_path])
500 env.AppendUnique(LIBS = env['mpi_libs'])
501 env.PrependENVPath(env['LD_LIBRARY_PATH_KEY'], mpi_lib_path)
502 env.Append(CPPDEFINES = ['ESYS_MPI', 'MPI_NO_CPPBIND', 'MPICH_IGNORE_CXX_SEEK'])
503 # NetCDF 4.1 defines MPI_Comm et al. if MPI_INCLUDED is not defined!
504 # On the other hand MPT and OpenMPI don't define the latter so we have
505 # to do that here
506 if env['netcdf'] and env['mpi'] in ['MPT','OPENMPI']:
507 env.Append(CPPDEFINES = ['MPI_INCLUDED'])
508
509 if env['mpi'] == 'OPENMPI':
510 # try to get version for correct launcher arguments
511 try:
512 p = Popen(['orterun', '-V'], stdout=PIPE, stderr=PIPE)
513 o,e = p.communicate()
514 try:
515 ver = e.split('\n')[0].split()[-1]
516 except IndexError:
517 ver = o.split('\n')[0].split()[-1]
518 if len(ver) > 0:
519 env['orte_version'] = ver
520 except OSError:
521 pass
522
523 env['buildvars']['mpi_inc_path']=mpi_inc_path
524 env['buildvars']['mpi_lib_path']=mpi_lib_path
525 env['buildvars']['mpi']=env['mpi']
526
527 ######## BOOMERAMG
528 if env['mpi'] == 'none': env['boomeramg'] = False
529 boomeramg_inc_path=''
530 boomeramg_lib_path=''
531 if env['boomeramg']:
532 boomeramg_inc_path,boomeramg_lib_path=findLibWithHeader(env, env['boomeramg_libs'], 'HYPRE.h', env['boomeramg_prefix'], lang='c++')
533 env.AppendUnique(CPPPATH = [boomeramg_inc_path])
534 env.AppendUnique(LIBPATH = [boomeramg_lib_path])
535 env.PrependENVPath(env['LD_LIBRARY_PATH_KEY'], boomeramg_lib_path)
536 env.Append(CPPDEFINES = ['ESYS_HAVE_BOOMERAMG'])
537 env['buildvars']['boomeramg_inc_path']=boomeramg_inc_path
538 env['buildvars']['boomeramg_lib_path']=boomeramg_lib_path
539 env['buildvars']['boomeramg']=int(env['boomeramg'])
540
541 ######## ParMETIS
542 if not env['usempi']: env['parmetis'] = False
543 parmetis_inc_path=''
544 parmetis_lib_path=''
545 if env['parmetis']:
546 parmetis_inc_path,parmetis_lib_path=findLibWithHeader(env, env['parmetis_libs'], 'parmetis.h', env['parmetis_prefix'], lang='c++')
547 env.AppendUnique(CPPPATH = [parmetis_inc_path])
548 env.AppendUnique(LIBPATH = [parmetis_lib_path])
549 env.PrependENVPath(env['LD_LIBRARY_PATH_KEY'], parmetis_lib_path)
550
551 # Try to extract the parmetis version from parmetis.h
552 header=open(os.path.join(parmetis_inc_path, 'parmetis.h')).readlines()
553 major,minor,sub = None,None,None
554 for line in header:
555 ver=re.match(r'#define PARMETIS_MAJOR_VERSION\s*(\d+)',line)
556 if ver:
557 major = int(ver.group(1))
558 continue
559 ver=re.match(r'#define PARMETIS_MINOR_VERSION\s*(\d+)',line)
560 if ver:
561 minor = int(ver.group(1))
562 continue
563 ver=re.match(r'#define PARMETIS_SUBMINOR_VERSION\s*(\d+)',line)
564 if ver:
565 sub = int(ver.group(1))
566 continue
567 if major is not None:
568 env['parmetis_version'] = "%d.%d.%d"%(major,minor,0 if sub is None else sub)
569 if env['longindices']:
570 # ParMETIS version 3.x does not support 64-bit indices
571 if major < 4:
572 print("Sorry, cannot use ParMETIS version < 4.0 with 64-bit index types. Set longindices to False or disable ParMETIS.")
573 env.Exit(1)
574 else:
575 # check if ParMETIS was built with 64-bit indices
576 conf = Configure(env.Clone())
577 idxsize=conf.CheckTypeSize('idx_t', '#include <parmetis.h>', 'C++')
578 if idxsize != 8:
579 print("Sorry, ParMETIS was not compiled with 64-bit indices. Set longindices to False or disable/rebuild ParMETIS.")
580 env.Exit(1)
581 else:
582 env['parmetis_version'] = "unknown"
583
584 env.Append(CPPDEFINES = ['ESYS_HAVE_PARMETIS'])
585 env['buildvars']['parmetis_inc_path']=parmetis_inc_path
586 env['buildvars']['parmetis_lib_path']=parmetis_lib_path
587 env['buildvars']['parmetis']=int(env['parmetis'])
588
589 ######## gmsh (for tests)
590 env['gmsh'] = False
591 if env['IS_WINDOWS']:
592 try:
593 p=Popen(['gmsh', '-info'], stderr=PIPE)
594 _,e=p.communicate()
595 if e.split().count("MPI"):
596 env['gmsh']='m'
597 else:
598 env['gmsh']='s'
599 except OSError:
600 pass
601 else:
602 which = Popen(['which', 'gmsh'], stdout=PIPE)
603 path,_ = which.communicate()
604 if which.wait() == 0:
605 cmd = ['ldd', path[:-1]]
606 if env['IS_OSX']:
607 cmd = ['otool','-L', path[:-1]]
608 try:
609 p=Popen(cmd, stdout=PIPE)
610 gmshlibs,_ = p.communicate()
611 env.Append(CPPDEFINES=['ESYS_HAVE_GMSH'])
612 if p.returncode == 0 and 'libmpi' in gmshlibs:
613 env['gmsh'] = 'm'
614 env.Append(CPPDEFINES=['ESYS_GMSH_MPI'])
615 else:
616 env['gmsh'] = 's'
617 except OSError:
618 pass
619
620 ######## boost::iostreams
621 if env['compressed_files']:
622 try:
623 boost_inc_path, boost_lib_path = findLibWithHeader(env, env['compression_libs'], 'boost/iostreams/filter/gzip.hpp', env['boost_prefix'], lang='c++')
624 env.Append(CPPDEFINES = ['ESYS_HAVE_BOOST_IO'])
625 except RuntimeError as e:
626 env['compressed_files'] = False
627 env['buildvars']['compressed_files']=int(env['compressed_files'])
628
629 ######## Trilinos
630 env = checkForTrilinos(env)
631 return env
632
633 def checkPDFLatex(env):
634 if 'PDF' in dir(env) and '.tex' in env.PDF.builder.src_suffixes(env):
635 env['pdflatex']=True
636 else:
637 env['pdflatex']=False
638 return env
639
640

  ViewVC Help
Powered by ViewVC 1.1.26