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

Annotation of /trunk/site_scons/dependencies.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6141 - (hide annotations)
Wed Apr 6 03:51:30 2016 UTC (2 years, 11 months ago) by caltinay
File MIME type: text/x-python
File size: 24725 byte(s)
more namespacing of defines.

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     def checkPython(env):
79     # First we check to see if the config file has specified
80     # where to find the file. Ideally, this should be automatic
81     # but we need to deal with the case where python is not in its INSTALL
82     # directory.
83     # Use the python scons is running
84     if env['pythoncmd']=='python':
85     python_inc_path=sysconfig.get_python_inc()
86     if env['IS_WINDOWS']:
87     python_lib_path=os.path.join(sysconfig.get_config_var('prefix'), 'libs')
88     elif env['PLATFORM']=='darwin':
89     python_lib_path=sysconfig.get_config_var('LIBPL')
90     else:
91     python_lib_path=sysconfig.get_config_var('LIBDIR')
92    
93     #python_libs=[sysconfig.get_config_var('LDLIBRARY')] # only on linux
94     if env['IS_WINDOWS']:
95     python_libs=['python%s%s'%(sys.version_info[0], sys.version_info[1])]
96     else:
97     python_libs=['python'+sysconfig.get_python_version()]
98    
99     env['buildvars']['python']=sys.executable
100     env['buildvars']['python_version']=str(sys.version_info[0])+"."+str(sys.version_info[1])+"."+str(sys.version_info[2])
101    
102     #if we want to use a python other than the one scons is running
103     else:
104     initstring='from __future__ import print_function;from distutils import sysconfig;'
105     if env['pythonlibname']!='':
106     python_libs=env['pythonlibname']
107 sshaw 5705 else: # work it out by calling python
108 caltinay 4295 if ['IS_WINDOWS']:
109     cmd='print("python%s%s"%(sys.version_info[0], sys.version_info[1]))'
110     else:
111     cmd='print("python"+sysconfig.get_python_version())'
112     p=Popen([env['pythoncmd'], '-c', initstring+cmd], stdout=PIPE)
113     python_libs=p.stdout.readline()
114 sshaw 5705 if env['usepython3']: # This is to convert unicode str into py2 string
115 caltinay 4295 python_libs=python_libs.encode() # If scons runs on py3 then this must be rethought
116     p.wait()
117     python_libs=python_libs.strip()
118    
119     # Now we know whether we are using python3 or not
120     p=Popen([env['pythoncmd'], '-c', initstring+'print(sysconfig.get_python_inc())'], stdout=PIPE)
121     python_inc_path=p.stdout.readline()
122     if env['usepython3']:
123     python_inc_path=python_inc_path.encode()
124 caltinay 4419 p.wait()
125 caltinay 4295 python_inc_path=python_inc_path.strip()
126 caltinay 4419 if env['IS_WINDOWS']:
127     cmd="import os;os.path.join(sysconfig.get_config_var('prefix'), 'libs')"
128 caltinay 4295 elif env['PLATFORM']=='darwin':
129     cmd="sysconfig.get_config_var(\"LIBPL\")"
130     else:
131     cmd="sysconfig.get_config_var(\"LIBDIR\")"
132    
133     p=Popen([env['pythoncmd'], '-c', initstring+'print('+cmd+')'], stdout=PIPE)
134     python_lib_path=p.stdout.readline()
135     if env['usepython3']:
136     python_lib_path=python_lib_path.decode()
137     p.wait()
138     python_lib_path=python_lib_path.strip()
139    
140     env['buildvars']['python']=env['pythoncmd']
141     p=Popen([env['pythoncmd'], '-c', 'from __future__ import print_function;import sys;print(str(sys.version_info[0])+"."+str(sys.version_info[1])+"."+str(sys.version_info[2]))'], stdout=PIPE)
142     verstring=p.stdout.readline().strip()
143     p.wait()
144     env['buildvars']['python_version']=verstring
145    
146     # Check for an override from the config file.
147     # Ideally, this should be automatic but we need to deal with the case
148     # where python is not in its INSTALL directory
149     if env['pythonlibpath']!='':
150     python_lib_path=env['pythonlibpath']
151    
152     if env['pythonincpath']!='':
153     python_inc_path=env['pythonincpath']
154    
155     conf = Configure(env.Clone())
156    
157     if env['sysheaderopt'] == '':
158     conf.env.AppendUnique(CPPPATH = [python_inc_path])
159     else:
160     conf.env.Append(CCFLAGS = [env['sysheaderopt'], python_inc_path])
161    
162     conf.env.AppendUnique(LIBPATH = [python_lib_path])
163     conf.env.AppendUnique(LIBS = python_libs)
164     # The wrapper script needs to find the libs
165     conf.env.PrependENVPath(env['LD_LIBRARY_PATH_KEY'], python_lib_path)
166    
167 caltinay 4520 if not conf.CheckCXXHeader('Python.h'):
168 caltinay 4295 print("Cannot find python include files (tried 'Python.h' in directory %s)" % (python_inc_path))
169 jfenwick 4323 env.Exit(1)
170 caltinay 4520 if not conf.CheckFunc('Py_Exit', language='c++'):
171 caltinay 4295 print("Cannot find python library method Py_Main (tried %s in directory %s)" % (python_libs, python_lib_path))
172 jfenwick 4323 env.Exit(1)
173 caltinay 4295
174     return conf.Finish()
175    
176 caltinay 5148 def checkCudaVersion(env):
177     # NVCC availability is already checked in the Tool file
178     p=Popen([env['NVCC'], '-V'], stdout=PIPE)
179     out=p.stdout.readlines()
180     env['nvcc_version']='(unknown version)'
181     p.wait()
182     for line in out:
183     if 'release' in line:
184     version=line[line.find('release'):].strip()
185     env['nvcc_version']=version
186     break
187     env['buildvars']['nvcc']=env['NVCC']
188     return env
189    
190 caltinay 4295 def checkBoost(env):
191     boost_inc_path,boost_lib_path=findLibWithHeader(env, env['boost_libs'], 'boost/python.hpp', env['boost_prefix'], lang='c++')
192     if env['sysheaderopt'] == '':
193     env.AppendUnique(CPPPATH = [boost_inc_path])
194     else:
195     # This is required because we can't -isystem /usr/include since it
196     # breaks std includes
197     if os.path.normpath(boost_inc_path) == '/usr/include':
198     env.Append(CCFLAGS=[env['sysheaderopt'], os.path.join(boost_inc_path,'boost')])
199     else:
200     env.Append(CCFLAGS=[env['sysheaderopt'], boost_inc_path])
201    
202     env.AppendUnique(LIBPATH = [boost_lib_path])
203     env.AppendUnique(LIBS = env['boost_libs'])
204     env.PrependENVPath(env['LD_LIBRARY_PATH_KEY'], boost_lib_path)
205    
206     # Try to extract the boost version from version.hpp
207     boosthpp=open(os.path.join(boost_inc_path, 'boost', 'version.hpp'))
208     boostversion='unknown'
209 sshaw 4947 for line in boosthpp:
210     ver=re.match(r'#define BOOST_VERSION (\d+)',line)
211     if ver:
212     boostversion=ver.group(1)
213     boostversion = int(boostversion)
214     maj = boostversion/100000
215     minor = (boostversion/100)%1000
216     sub = boostversion % 100
217 caltinay 5696 env['boost_version'] = "%d.%d.%d"%(maj,minor,sub)
218 sshaw 4947 if maj <= REQUIRED_BOOST[0] and minor < REQUIRED_BOOST[1]:
219 caltinay 5696 print("The boost version referenced must be at least version %d.%d "%REQUIRED_BOOST + "(have %d.%d.%d)"%(maj,minor,sub))
220     env.Exit(1)
221 caltinay 4295 boosthpp.close()
222     env['buildvars']['boost_inc_path']=boost_inc_path
223     env['buildvars']['boost_lib_path']=boost_lib_path
224     env['buildvars']['boostversion']=boostversion
225     return env
226    
227     def checkNumpy(env):
228     if not detectModule(env, 'numpy'):
229     print("Cannot import numpy. If it is installed try setting your PYTHONPATH and probably %s"%env['LD_LIBRARY_PATH_KEY'])
230 jfenwick 4323 env.Exit(1)
231 caltinay 4295
232     ## check for numpy header (optional)
233     conf = Configure(env.Clone())
234     if env['usepython3']:
235     # FIXME: This is until we can work out how to make the checks in python 3
236     conf.env['numpy_h']=False
237     else:
238     if conf.CheckCXXHeader(['Python.h','numpy/ndarrayobject.h']):
239     conf.env.Append(CPPDEFINES = ['HAVE_NUMPY_H'])
240     conf.env['numpy_h']=True
241     else:
242     conf.env['numpy_h']=False
243    
244     return conf.Finish()
245    
246 caltinay 5435 def checkCUDA(env):
247     try:
248     cuda_inc_path,cuda_lib_path=findLibWithHeader(env, 'cudart', 'thrust/version.h', env['cuda_prefix'], lang='c++')
249     env.AppendUnique(CPPPATH = [cuda_inc_path])
250     env.AppendUnique(LIBPATH = [cuda_lib_path])
251     env.PrependENVPath(env['LD_LIBRARY_PATH_KEY'], cuda_lib_path)
252     env['cuda']=True
253     except:
254     env['cuda']=False
255     return env
256    
257 caltinay 4295 def checkCppUnit(env):
258     try:
259     cppunit_inc_path,cppunit_lib_path=findLibWithHeader(env, env['cppunit_libs'], 'cppunit/TestFixture.h', env['cppunit_prefix'], lang='c++')
260     env.AppendUnique(CPPPATH = [cppunit_inc_path])
261     env.AppendUnique(LIBPATH = [cppunit_lib_path])
262     env.PrependENVPath(env['LD_LIBRARY_PATH_KEY'], cppunit_lib_path)
263     env['cppunit']=True
264     except:
265     env['cppunit']=False
266     return env
267    
268     def checkOptionalModules(env):
269 caltinay 4300 ######## scipy
270     if not detectModule(env, 'scipy'):
271     env['warnings'].append("Cannot import scipy. NetCDF sources will not be available for inversions.")
272    
273 caltinay 5391 ######## pyproj
274     if not detectModule(env, 'pyproj'):
275     env['warnings'].append("Cannot import pyproj. Inversions may not work.")
276    
277     ######## gdal
278     if not detectModule(env, 'gdal'):
279     env['warnings'].append("Cannot import gdal. Inversions will not honour WKT coordinate system information.")
280    
281 caltinay 4295 ######## sympy
282     if not detectModule(env, 'sympy'):
283 caltinay 4299 env['warnings'].append("Cannot import sympy. Symbolic toolbox and nonlinear PDEs will not be available.")
284 jduplessis 4897 else:
285     import sympy as sp
286     spVer=sp.__version__
287     spl=spVer.split('.')
288 jduplessis 4900 if int(spl[0]) == 0 and int(spl[1]) < 7:
289 jduplessis 4897 env['sympy']=False
290     env['warnings'].append("sympy version too old. Symbolic toolbox and nonlinear PDEs will not be available.")
291 caltinay 4299
292 caltinay 5391 ######## gmshpy
293     env['gmshpy'] = detectModule(env, 'gmshpy')
294 caltinay 4299
295 caltinay 4295 return env
296    
297 caltinay 6119 def checkForTrilinos(env):
298     trilinos_inc_path=''
299     trilinos_lib_path=''
300     if env['trilinos']:
301     havelibs = (len(env['trilinos_libs']) > 0)
302     trilinos_inc_path,trilinos_lib_path=findLibWithHeader(env,
303     env['trilinos_libs'], 'Tpetra_CrsMatrix.hpp',
304     env['trilinos_prefix'], lang='c++', try_link=havelibs)
305     if not havelibs:
306     packages=['Tpetra','Kokkos','Belos','Amesos2','Zoltan2','Ifpack2','MueLu']
307     libs = []
308     for pk in packages:
309     # find out what libraries to link with...
310     makefile = os.path.join(trilinos_inc_path, 'Makefile.export.%s'%pk)
311     try:
312     for l in open(makefile, 'r').readlines():
313     if l.startswith("%s_LIBRARIES"%pk): # or l.startswith("Trilinos_TPL_LIBRARIES"):
314     lst = l.split('=')[1].strip().split()
315     lst = [e.replace('-l','',1) for e in lst]
316     libs.append(lst)
317     elif l.startswith("%s_TPL_INCLUDE_DIRS"%pk):
318     lst = l.split('=')[1].strip().split()
319     lst = [e.replace('-I','',1) for e in lst]
320     env.AppendUnique(CPPPATH = lst)
321    
322     except Exception as e:
323     raise RuntimeError('Error reading Trilinos export Makefile\n%s'%(e))
324     env['trilinos_libs'] = libs
325    
326     env.AppendUnique(CPPPATH = [trilinos_inc_path])
327     env.AppendUnique(LIBPATH = [trilinos_lib_path])
328     env.Append(CPPDEFINES = ['USE_TRILINOS'])
329     # Note that we do not add the libs globally
330     env['buildvars']['trilinos_inc_path']=trilinos_inc_path
331     env['buildvars']['trilinos_lib_path']=trilinos_lib_path
332     env['buildvars']['trilinos']=int(env['trilinos'])
333     return env
334    
335 caltinay 4295 def checkOptionalLibraries(env):
336     ######## netCDF
337     netcdf_inc_path=''
338     netcdf_lib_path=''
339     if env['netcdf']:
340     netcdf_inc_path,netcdf_lib_path=findLibWithHeader(env, env['netcdf_libs'], 'netcdf.h', env['netcdf_prefix'], lang='c++')
341     env.AppendUnique(CPPPATH = [netcdf_inc_path])
342     env.AppendUnique(LIBPATH = [netcdf_lib_path])
343     env.AppendUnique(LIBS = env['netcdf_libs'])
344     env.PrependENVPath(env['LD_LIBRARY_PATH_KEY'], netcdf_lib_path)
345     env.Append(CPPDEFINES = ['USE_NETCDF'])
346     env['buildvars']['netcdf_inc_path']=netcdf_inc_path
347     env['buildvars']['netcdf_lib_path']=netcdf_lib_path
348     env['buildvars']['netcdf']=int(env['netcdf'])
349    
350     ######## PAPI
351     papi_inc_path=''
352     papi_lib_path=''
353     if env['papi']:
354 caltinay 4520 papi_inc_path,papi_lib_path=findLibWithHeader(env, env['papi_libs'], 'papi.h', env['papi_prefix'], lang='c++')
355 caltinay 4295 env.AppendUnique(CPPPATH = [papi_inc_path])
356     env.AppendUnique(LIBPATH = [papi_lib_path])
357     env.AppendUnique(LIBS = env['papi_libs'])
358     env.PrependENVPath(env['LD_LIBRARY_PATH_KEY'], papi_lib_path)
359 caltinay 4870 env.Append(CPPDEFINES = ['PAPI'])
360 caltinay 4295 env['buildvars']['papi_inc_path']=papi_inc_path
361     env['buildvars']['papi_lib_path']=papi_lib_path
362     env['buildvars']['papi']=int(env['papi'])
363    
364     ######## MKL
365     mkl_inc_path=''
366     mkl_lib_path=''
367     if env['mkl']:
368 caltinay 5824 mkl_inc_path,mkl_lib_path=findLibWithHeader(env, env['mkl_libs'], 'mkl_pardiso.h', env['mkl_prefix'], lang='c++')
369 caltinay 4295 env.AppendUnique(CPPPATH = [mkl_inc_path])
370     env.AppendUnique(LIBPATH = [mkl_lib_path])
371     env.AppendUnique(LIBS = env['mkl_libs'])
372     env.PrependENVPath(env['LD_LIBRARY_PATH_KEY'], mkl_lib_path)
373 caltinay 6138 env.Append(CPPDEFINES = ['ESYS_HAVE_MKL'])
374 caltinay 4295 env['buildvars']['mkl_inc_path']=mkl_inc_path
375     env['buildvars']['mkl_lib_path']=mkl_lib_path
376     env['buildvars']['mkl']=int(env['mkl'])
377    
378     ######## UMFPACK
379     umfpack_inc_path=''
380     umfpack_lib_path=''
381     if env['umfpack']:
382 caltinay 4520 umfpack_inc_path,umfpack_lib_path=findLibWithHeader(env, env['umfpack_libs'], 'umfpack.h', env['umfpack_prefix'], lang='c++')
383 caltinay 4295 env.AppendUnique(CPPPATH = [umfpack_inc_path])
384     env.AppendUnique(LIBPATH = [umfpack_lib_path])
385     env.AppendUnique(LIBS = env['umfpack_libs'])
386     env.PrependENVPath(env['LD_LIBRARY_PATH_KEY'], umfpack_lib_path)
387 caltinay 5183 env.Append(CPPDEFINES = ['USE_UMFPACK'])
388 caltinay 4295 env['buildvars']['umfpack_inc_path']=umfpack_inc_path
389     env['buildvars']['umfpack_lib_path']=umfpack_lib_path
390     env['buildvars']['umfpack']=int(env['umfpack'])
391    
392     ######## LAPACK
393     if env['lapack']=='mkl' and not env['mkl']:
394     print("mkl_lapack requires MKL!")
395 jfenwick 4323 env.Exit(1)
396 caltinay 4295
397     env['uselapack'] = env['lapack']!='none'
398     lapack_inc_path=''
399     lapack_lib_path=''
400     if env['uselapack']:
401 caltinay 5689 if env['longindices']:
402     print("Sorry, cannot use LAPACK with 64-bit index types. Set longindices to False or disable LAPACK.")
403     env.Exit(1)
404 caltinay 4295 header='clapack.h'
405     if env['lapack']=='mkl':
406     env.AppendUnique(CPPDEFINES = ['MKL_LAPACK'])
407     header='mkl_lapack.h'
408 caltinay 4520 lapack_inc_path,lapack_lib_path=findLibWithHeader(env, env['lapack_libs'], header, env['lapack_prefix'], lang='c++')
409 caltinay 4295 env.AppendUnique(CPPPATH = [lapack_inc_path])
410     env.AppendUnique(LIBPATH = [lapack_lib_path])
411     env.AppendUnique(LIBS = env['lapack_libs'])
412     env.Append(CPPDEFINES = ['USE_LAPACK'])
413     env['buildvars']['lapack_inc_path']=lapack_inc_path
414     env['buildvars']['lapack_lib_path']=lapack_lib_path
415     env['buildvars']['lapack']=env['lapack']
416    
417     ######## Silo
418     silo_inc_path=''
419     silo_lib_path=''
420     if env['silo']:
421 caltinay 4520 silo_inc_path,silo_lib_path=findLibWithHeader(env, env['silo_libs'], 'silo.h', env['silo_prefix'], lang='c++')
422 caltinay 4295 env.AppendUnique(CPPPATH = [silo_inc_path])
423     env.AppendUnique(LIBPATH = [silo_lib_path])
424     # Note that we do not add the libs since they are only needed for the
425     # weipa library and tools.
426     #env.AppendUnique(LIBS = [env['silo_libs']])
427     env['buildvars']['silo_inc_path']=silo_inc_path
428     env['buildvars']['silo_lib_path']=silo_lib_path
429     env['buildvars']['silo']=int(env['silo'])
430    
431     ######## VisIt
432     visit_inc_path=''
433     visit_lib_path=''
434     if env['visit']:
435 caltinay 4520 visit_inc_path,visit_lib_path=findLibWithHeader(env, env['visit_libs'], 'VisItControlInterface_V2.h', env['visit_prefix'], lang='c++')
436 caltinay 4295 env.AppendUnique(CPPPATH = [visit_inc_path])
437     env.AppendUnique(LIBPATH = [visit_lib_path])
438     env['buildvars']['visit_inc_path']=visit_inc_path
439     env['buildvars']['visit_lib_path']=visit_lib_path
440     env['buildvars']['visit']=int(env['visit'])
441    
442     ######## MPI
443     if env['mpi']=='no':
444     env['mpi']='none'
445    
446     env['usempi'] = env['mpi']!='none'
447     mpi_inc_path=''
448     mpi_lib_path=''
449     if env['usempi']:
450 caltinay 4520 mpi_inc_path,mpi_lib_path=findLibWithHeader(env, env['mpi_libs'], 'mpi.h', env['mpi_prefix'], lang='c++')
451 caltinay 4295 env.AppendUnique(CPPPATH = [mpi_inc_path])
452     env.AppendUnique(LIBPATH = [mpi_lib_path])
453     env.AppendUnique(LIBS = env['mpi_libs'])
454     env.PrependENVPath(env['LD_LIBRARY_PATH_KEY'], mpi_lib_path)
455     env.Append(CPPDEFINES = ['ESYS_MPI', 'MPI_NO_CPPBIND', 'MPICH_IGNORE_CXX_SEEK'])
456     # NetCDF 4.1 defines MPI_Comm et al. if MPI_INCLUDED is not defined!
457     # On the other hand MPT and OpenMPI don't define the latter so we have
458     # to do that here
459     if env['netcdf'] and env['mpi'] in ['MPT','OPENMPI']:
460     env.Append(CPPDEFINES = ['MPI_INCLUDED'])
461 caltinay 4296 env['buildvars']['mpi_inc_path']=mpi_inc_path
462     env['buildvars']['mpi_lib_path']=mpi_lib_path
463     env['buildvars']['mpi']=env['mpi']
464 caltinay 4295
465     ######## BOOMERAMG
466     if env['mpi'] == 'none': env['boomeramg'] = False
467     boomeramg_inc_path=''
468     boomeramg_lib_path=''
469     if env['boomeramg']:
470 caltinay 4520 boomeramg_inc_path,boomeramg_lib_path=findLibWithHeader(env, env['boomeramg_libs'], 'HYPRE.h', env['boomeramg_prefix'], lang='c++')
471 caltinay 4295 env.AppendUnique(CPPPATH = [boomeramg_inc_path])
472     env.AppendUnique(LIBPATH = [boomeramg_lib_path])
473     env.AppendUnique(LIBS = env['boomeramg_libs'])
474     env.PrependENVPath(env['LD_LIBRARY_PATH_KEY'], boomeramg_lib_path)
475 caltinay 6141 env.Append(CPPDEFINES = ['ESYS_HAVE_BOOMERAMG'])
476 caltinay 4295 env['buildvars']['boomeramg_inc_path']=boomeramg_inc_path
477     env['buildvars']['boomeramg_lib_path']=boomeramg_lib_path
478     env['buildvars']['boomeramg']=int(env['boomeramg'])
479    
480     ######## ParMETIS
481     if not env['usempi']: env['parmetis'] = False
482     parmetis_inc_path=''
483     parmetis_lib_path=''
484     if env['parmetis']:
485 caltinay 4520 parmetis_inc_path,parmetis_lib_path=findLibWithHeader(env, env['parmetis_libs'], 'parmetis.h', env['parmetis_prefix'], lang='c++')
486 caltinay 4295 env.AppendUnique(CPPPATH = [parmetis_inc_path])
487     env.AppendUnique(LIBPATH = [parmetis_lib_path])
488     env.AppendUnique(LIBS = env['parmetis_libs'])
489     env.PrependENVPath(env['LD_LIBRARY_PATH_KEY'], parmetis_lib_path)
490 caltinay 5696
491     # Try to extract the parmetis version from parmetis.h
492     header=open(os.path.join(parmetis_inc_path, 'parmetis.h')).readlines()
493     major,minor,sub = None,None,None
494     for line in header:
495     ver=re.match(r'#define PARMETIS_MAJOR_VERSION\s*(\d+)',line)
496     if ver:
497     major = int(ver.group(1))
498     continue
499     ver=re.match(r'#define PARMETIS_MINOR_VERSION\s*(\d+)',line)
500     if ver:
501     minor = int(ver.group(1))
502     continue
503     ver=re.match(r'#define PARMETIS_SUBMINOR_VERSION\s*(\d+)',line)
504     if ver:
505     sub = int(ver.group(1))
506     continue
507     if major is not None:
508     env['parmetis_version'] = "%d.%d.%d"%(major,minor,0 if sub is None else sub)
509     if env['longindices']:
510     # ParMETIS version 3.x does not support 64-bit indices
511     if major < 4:
512     print("Sorry, cannot use ParMETIS version < 4.0 with 64-bit index types. Set longindices to False or disable ParMETIS.")
513     env.Exit(1)
514     else:
515     # check if ParMETIS was built with 64-bit indices
516     conf = Configure(env.Clone())
517     idxsize=conf.CheckTypeSize('idx_t', '#include <parmetis.h>', 'C++')
518     if idxsize != 8:
519     print("Sorry, ParMETIS was not compiled with 64-bit indices. Set longindices to False or disable/rebuild ParMETIS.")
520     env.Exit(1)
521     else:
522     env['parmetis_version'] = "unknown"
523    
524 caltinay 6141 env.Append(CPPDEFINES = ['ESYS_HAVE_PARMETIS'])
525 caltinay 4295 env['buildvars']['parmetis_inc_path']=parmetis_inc_path
526     env['buildvars']['parmetis_lib_path']=parmetis_lib_path
527     env['buildvars']['parmetis']=int(env['parmetis'])
528    
529 jfenwick 5407 ######## gmsh (for tests)
530     env['gmsh'] = False
531     if env['IS_WINDOWS']:
532     try:
533     p=Popen(['gmsh', '-info'], stderr=PIPE)
534     _,e=p.communicate()
535     if e.split().count("MPI"):
536     env['gmsh']='m'
537     else:
538     env['gmsh']='s'
539     p.wait()
540     except OSError:
541     pass
542     else:
543     which = Popen(['which', 'gmsh'], stdout=PIPE)
544     path,_ = which.communicate()
545     if which.wait() == 0:
546     cmd = ['ldd', path[:-1]]
547     if env['IS_OSX']:
548     cmd = ['otool','-L', path[:-1]]
549     try:
550     p=Popen(cmd, stdout=PIPE)
551     gmshlibs,_ = p.communicate()
552     ret = p.wait()
553 caltinay 6141 env.Append(CPPDEFINES=['ESYS_HAVE_GMSH'])
554 jfenwick 5407 if ret == 0 and 'libmpi' in gmshlibs:
555     env['gmsh'] = 'm'
556 caltinay 6141 env.Append(CPPDEFINES=['ESYS_GMSH_MPI'])
557 jfenwick 5407 else:
558     env['gmsh'] = 's'
559     except OSError:
560     pass
561    
562 caltinay 6119 ######## boost::iostreams
563 sshaw 4738 if env['compressed_files']:
564     try:
565     boost_inc_path, boost_lib_path = findLibWithHeader(env, env['compression_libs'], 'boost/iostreams/filter/gzip.hpp', env['boost_prefix'], lang='c++')
566 caltinay 6141 #env.Append(CPPDEFINES = ['ESYS_HAVE_BOOST_IO'])
567 sshaw 4738 env.AppendUnique(LIBS = env['compression_libs'])
568     except RuntimeError as e:
569     env['compressed_files'] = False
570 sshaw 4740 env['buildvars']['compressed_files']=int(env['compressed_files'])
571 caltinay 5391
572 caltinay 6119 ######## Trilinos
573     env = checkForTrilinos(env)
574 caltinay 4295 return env
575    
576     def checkPDFLatex(env):
577     if 'PDF' in dir(env) and '.tex' in env.PDF.builder.src_suffixes(env):
578     env['pdflatex']=True
579     else:
580     env['pdflatex']=False
581     return env
582    
583    

  ViewVC Help
Powered by ViewVC 1.1.26