/[escript]/trunk/site_scons/dependencies.py
ViewVC logotype

Annotation of /trunk/site_scons/dependencies.py

Parent Directory Parent Directory | Revision Log Revision Log


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

  ViewVC Help
Powered by ViewVC 1.1.26