/[escript]/trunk/SConstruct
ViewVC logotype

Annotation of /trunk/SConstruct

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4640 - (hide annotations)
Fri Jan 31 00:56:51 2014 UTC (5 years, 2 months ago) by jfenwick
File size: 28082 byte(s)
Ensure that DYLD_LIBRARY_PATH is passed into scons.
Update mole_options to work with g++
(To get this to work, you will need to set up your env vars).


1 jfenwick 3982 ##############################################################################
2 jgs 214 #
3 jfenwick 4154 # Copyright (c) 2003-2013 by University of Queensland
4 jfenwick 3982 # http://www.uq.edu.au
5 ksteube 1811 #
6     # Primary Business: Queensland, Australia
7     # Licensed under the Open Software License version 3.0
8     # http://www.opensource.org/licenses/osl-3.0.php
9     #
10 jfenwick 3982 # Development until 2012 by Earth Systems Science Computational Center (ESSCC)
11     # Development since 2012 by School of Earth Sciences
12     #
13     ##############################################################################
14 jgs 455
15 jfenwick 3259 EnsureSConsVersion(0,98,1)
16     EnsurePythonVersion(2,5)
17 ksteube 1811
18 caltinay 4295 import atexit, sys, os, platform, re
19 jfenwick 3259 from distutils import sysconfig
20 caltinay 4295 from dependencies import *
21 jfenwick 3259 from site_init import *
22 jgs 214
23 jfenwick 3259 # Version number to check for in options file. Increment when new features are
24     # added or existing options changed.
25 caltinay 3597 REQUIRED_OPTS_VERSION=201
26 ksteube 1705
27     # MS Windows support, many thanks to PH
28 jfenwick 3259 IS_WINDOWS = (os.name == 'nt')
29 gross 806
30 jfenwick 4640 IS_OSX = (os.uname()[0] == 'Darwin')
31    
32 jfenwick 3259 ########################## Determine options file ############################
33     # 1. command line
34     # 2. scons/<hostname>_options.py
35     # 3. name as part of a cluster
36 jfenwick 2391 options_file=ARGUMENTS.get('options_file', None)
37     if not options_file:
38 jfenwick 3259 ext_dir = os.path.join(os.getcwd(), 'scons')
39     hostname = platform.node().split('.')[0]
40     for name in hostname, effectiveName(hostname):
41     mangledhostname = re.sub('[^0-9a-zA-Z]', '_', hostname)
42     options_file = os.path.join(ext_dir, mangledhostname+'_options.py')
43     if os.path.isfile(options_file): break
44 jfenwick 2391
45 ksteube 1866 if not os.path.isfile(options_file):
46 jfenwick 3259 print("\nWARNING:\nOptions file %s" % options_file)
47     print("not found! Default options will be used which is most likely suboptimal.")
48 jfenwick 4426 print("We recommend that you copy one of the TEMPLATE files in the scons/")
49 jfenwick 3259 print("subdirectory and customize it to your needs.\n")
50     options_file = None
51 ksteube 1217
52 jfenwick 3259 ############################### Build options ################################
53 gross 1149
54 jfenwick 3259 default_prefix='/usr'
55 jfenwick 3618 mpi_flavours=('no', 'none', 'MPT', 'MPICH', 'MPICH2', 'OPENMPI', 'INTELMPI')
56 jfenwick 3259 lapack_flavours=('none', 'clapack', 'mkl')
57 jfenwick 2430
58 jfenwick 3259 vars = Variables(options_file, ARGUMENTS)
59     vars.AddVariables(
60     PathVariable('options_file', 'Path to options file', options_file, PathVariable.PathIsFile),
61     PathVariable('prefix', 'Installation prefix', Dir('#.').abspath, PathVariable.PathIsDirCreate),
62 caltinay 3349 PathVariable('build_dir', 'Top-level build directory', Dir('#/build').abspath, PathVariable.PathIsDirCreate),
63 jfenwick 3259 BoolVariable('verbose', 'Output full compile/link lines', False),
64     # Compiler/Linker options
65     ('cxx', 'Path to C++ compiler', 'default'),
66 caltinay 4520 ('cc_flags', 'Base C++ compiler flags', 'default'),
67     ('cc_optim', 'Additional C++ flags for a non-debug build', 'default'),
68     ('cc_debug', 'Additional C++ flags for a debug build', 'default'),
69 caltinay 2967 ('cxx_extra', 'Extra C++ compiler flags', ''),
70 ksteube 1771 ('ld_extra', 'Extra linker flags', ''),
71 jfenwick 3259 BoolVariable('werror','Treat compiler warnings as errors', True),
72     BoolVariable('debug', 'Compile with debug flags', False),
73     BoolVariable('openmp', 'Compile parallel version using OpenMP', False),
74     ('omp_flags', 'OpenMP compiler flags', 'default'),
75     ('omp_ldflags', 'OpenMP linker flags', 'default'),
76     # Mandatory libraries
77     ('boost_prefix', 'Prefix/Paths of boost installation', default_prefix),
78 jfenwick 3338 ('boost_libs', 'Boost libraries to link with', ['boost_python-mt']),
79 caltinay 3597 # Mandatory for tests
80     ('cppunit_prefix', 'Prefix/Paths of CppUnit installation', default_prefix),
81     ('cppunit_libs', 'CppUnit libraries to link with', ['cppunit']),
82 jfenwick 3259 # Optional libraries and options
83     EnumVariable('mpi', 'Compile parallel version using MPI flavour', 'none', allowed_values=mpi_flavours),
84     ('mpi_prefix', 'Prefix/Paths of MPI installation', default_prefix),
85     ('mpi_libs', 'MPI shared libraries to link with', ['mpi']),
86     BoolVariable('netcdf', 'Enable netCDF file support', False),
87     ('netcdf_prefix', 'Prefix/Paths of netCDF installation', default_prefix),
88     ('netcdf_libs', 'netCDF libraries to link with', ['netcdf_c++', 'netcdf']),
89     BoolVariable('parmetis', 'Enable ParMETIS (requires MPI)', False),
90     ('parmetis_prefix', 'Prefix/Paths of ParMETIS installation', default_prefix),
91     ('parmetis_libs', 'ParMETIS libraries to link with', ['parmetis', 'metis']),
92     BoolVariable('papi', 'Enable PAPI', False),
93     ('papi_prefix', 'Prefix/Paths to PAPI installation', default_prefix),
94 ksteube 1705 ('papi_libs', 'PAPI libraries to link with', ['papi']),
95 jfenwick 3259 BoolVariable('papi_instrument_solver', 'Use PAPI to instrument each iteration of the solver', False),
96     BoolVariable('mkl', 'Enable the Math Kernel Library', False),
97     ('mkl_prefix', 'Prefix/Paths to MKL installation', default_prefix),
98     ('mkl_libs', 'MKL libraries to link with', ['mkl_solver','mkl_em64t','guide','pthread']),
99     BoolVariable('umfpack', 'Enable UMFPACK', False),
100     ('umfpack_prefix', 'Prefix/Paths to UMFPACK installation', default_prefix),
101     ('umfpack_libs', 'UMFPACK libraries to link with', ['umfpack']),
102 lgao 3508 BoolVariable('boomeramg', 'Enable BoomerAMG', False),
103     ('boomeramg_prefix', 'Prefix/Paths to BoomerAMG installation', default_prefix),
104     ('boomeramg_libs', 'BoomerAMG libraries to link with', ['boomeramg']),
105 jfenwick 3259 EnumVariable('lapack', 'Set LAPACK flavour', 'none', allowed_values=lapack_flavours),
106     ('lapack_prefix', 'Prefix/Paths to LAPACK installation', default_prefix),
107     ('lapack_libs', 'LAPACK libraries to link with', []),
108     BoolVariable('silo', 'Enable the Silo file format in weipa', False),
109     ('silo_prefix', 'Prefix/Paths to Silo installation', default_prefix),
110 caltinay 2184 ('silo_libs', 'Silo libraries to link with', ['siloh5', 'hdf5']),
111 jfenwick 3259 BoolVariable('visit', 'Enable the VisIt simulation interface', False),
112     ('visit_prefix', 'Prefix/Paths to VisIt installation', default_prefix),
113     ('visit_libs', 'VisIt libraries to link with', ['simV2']),
114 jfenwick 3506 BoolVariable('vsl_random', 'Use VSL from intel for random data', False),
115 jfenwick 3259 # Advanced settings
116     #dudley_assemble_flags = -funroll-loops to actually do something
117     ('dudley_assemble_flags', 'compiler flags for some dudley optimisations', ''),
118     # To enable passing function pointers through python
119     BoolVariable('iknowwhatimdoing', 'Allow non-standard C', False),
120     # An option for specifying the compiler tools (see windows branch)
121     ('tools_names', 'Compiler tools to use', ['default']),
122     ('env_export', 'Environment variables to be passed to tools',[]),
123     EnumVariable('forcelazy', 'For testing use only - set the default value for autolazy', 'leave_alone', allowed_values=('leave_alone', 'on', 'off')),
124     EnumVariable('forcecollres', 'For testing use only - set the default value for force resolving collective ops', 'leave_alone', allowed_values=('leave_alone', 'on', 'off')),
125     # finer control over library building, intel aggressive global optimisation
126     # works with dynamic libraries on windows.
127 caltinay 3598 ('build_shared', 'Build dynamic libraries only', False),
128 jfenwick 3259 ('sys_libs', 'Extra libraries to link with', []),
129     ('escript_opts_version', 'Version of options file (do not specify on command line)'),
130 jfenwick 3618 ('SVN_VERSION', 'Do not use from options file', -2),
131 jfenwick 3851 ('pythoncmd', 'which python to compile with','python'),
132 jfenwick 3892 ('usepython3', 'Is this a python3 build? (experimental)', False),
133     ('pythonlibname', 'Name of the python library to link. (This is found automatically for python2.X.)', ''),
134 jfenwick 3942 ('pythonlibpath', 'Path to the python library. (You should not need to set this unless your python has moved)',''),
135     ('pythonincpath','Path to python include files. (You should not need to set this unless your python has moved',''),
136 jfenwick 3961 BoolVariable('BADPYTHONMACROS','Extra \#include to get around a python bug.', True),
137 robwdcock 682 )
138 phornby 1232
139 jfenwick 3259 ##################### Create environment and help text #######################
140 jfenwick 3078
141 jfenwick 3259 # Intel's compiler uses regular expressions improperly and emits a warning
142     # about failing to find the compilers. This warning can be safely ignored.
143 jfenwick 3078
144 caltinay 3319 # PATH is needed so the compiler, linker and tools are found if they are not
145     # in default locations.
146     env = Environment(tools = ['default'], options = vars,
147     ENV = {'PATH': os.environ['PATH']})
148 jfenwick 3967
149 caltinay 4295 # set the vars for clang
150 jfenwick 3967 def mkclang(env):
151 caltinay 4295 env['CXX']='clang++'
152    
153 jfenwick 3259 if env['tools_names'] != 'default':
154 jfenwick 3967 zz=env['tools_names']
155     if 'clang' in zz:
156     zz.remove('clang')
157     zz.insert(0, mkclang)
158 caltinay 3319 env = Environment(tools = ['default'] + env['tools_names'], options = vars,
159     ENV = {'PATH' : os.environ['PATH']})
160 jfenwick 3078
161 jfenwick 3259 if options_file:
162     opts_valid=False
163     if 'escript_opts_version' in env.Dictionary() and \
164     int(env['escript_opts_version']) >= REQUIRED_OPTS_VERSION:
165     opts_valid=True
166     if opts_valid:
167     print("Using options in %s." % options_file)
168     else:
169     print("\nOptions file %s" % options_file)
170     print("is outdated! Please update the file by examining one of the TEMPLATE")
171     print("files in the scons/ subdirectory and setting escript_opts_version to %d.\n"%REQUIRED_OPTS_VERSION)
172     Exit(1)
173 jfenwick 3078
174 jfenwick 3259 # Generate help text (scons -h)
175     Help(vars.GenerateHelpText(env))
176 jfenwick 3078
177 jfenwick 3259 # Check for superfluous options
178 caltinay 3268 if len(vars.UnknownVariables())>0:
179     for k in vars.UnknownVariables():
180     print("Unknown option '%s'" % k)
181     Exit(1)
182 jfenwick 3078
183 caltinay 4295 # create dictionary which will be populated with info for buildvars file
184     env['buildvars']={}
185     # create list which will be populated with warnings if there are any
186     env['warnings']=[]
187    
188 jfenwick 3259 #################### Make sure install directories exist #####################
189 ksteube 1705
190 caltinay 4046 env['BUILD_DIR']=Dir(env['build_dir']).abspath
191 jfenwick 3259 prefix=Dir(env['prefix']).abspath
192 caltinay 4295 env['buildvars']['prefix']=prefix
193 jfenwick 3259 env['incinstall'] = os.path.join(prefix, 'include')
194     env['bininstall'] = os.path.join(prefix, 'bin')
195     env['libinstall'] = os.path.join(prefix, 'lib')
196     env['pyinstall'] = os.path.join(prefix, 'esys')
197 jfenwick 2604 if not os.path.isdir(env['bininstall']):
198     os.makedirs(env['bininstall'])
199     if not os.path.isdir(env['libinstall']):
200     os.makedirs(env['libinstall'])
201     if not os.path.isdir(env['pyinstall']):
202     os.makedirs(env['pyinstall'])
203    
204 jfenwick 3259 env.Append(CPPPATH = [env['incinstall']])
205     env.Append(LIBPATH = [env['libinstall']])
206 jfenwick 2603
207 jfenwick 3259 ################# Fill in compiler options if not set above ##################
208 ksteube 1312
209 jfenwick 3259 if env['cxx'] != 'default': env['CXX']=env['cxx']
210 gross 1024
211 jfenwick 3259 # version >=9 of intel C++ compiler requires use of icpc to link in C++
212     # runtimes (icc does not)
213     if not IS_WINDOWS and os.uname()[4]=='ia64' and env['CXX']=='icpc':
214     env['LINK'] = env['CXX']
215 phornby 1243
216 jfenwick 3259 # default compiler/linker options
217     cc_flags = ''
218     cc_optim = ''
219     cc_debug = ''
220     omp_flags = ''
221     omp_ldflags = ''
222     fatalwarning = '' # switch to turn warnings into errors
223     sysheaderopt = '' # how to indicate that a header is a system header
224 jfenwick 2130
225 jfenwick 3259 # env['CC'] might be a full path
226 caltinay 4520 cc_name=os.path.basename(env['CXX'])
227 caltinay 2882
228 caltinay 4520 if cc_name == 'icpc':
229 jfenwick 3259 # Intel compiler
230 caltinay 4090 # #1875: offsetof applied to non-POD types is nonstandard (in boost)
231 jfenwick 4542 # removed -std=c99 because icpc doesn't like it and we aren't using c anymore
232     cc_flags = "-fPIC -w2 -wd1875 -Wno-unknown-pragmas -DBLOCKTIMER -DCORE_ID1"
233 caltinay 4090 cc_optim = "-O3 -ftz -fno-alias -ipo -xHost"
234 jfenwick 3259 cc_debug = "-g -O0 -DDOASSERT -DDOPROF -DBOUNDS_CHECK"
235 caltinay 4090 omp_flags = "-openmp"
236     omp_ldflags = "-openmp -openmp_report=1"
237 jfenwick 3259 fatalwarning = "-Werror"
238 caltinay 4520 elif cc_name[:3] == 'g++':
239 jfenwick 3259 # GNU C on any system
240 caltinay 4173 # note that -ffast-math is not used because it breaks isnan(),
241     # see mantis #691
242     cc_flags = "-pedantic -Wall -fPIC -Wno-unknown-pragmas -DBLOCKTIMER -Wno-sign-compare -Wno-system-headers -Wno-long-long -Wno-strict-aliasing -finline-functions"
243 jfenwick 3259 cc_optim = "-O3"
244     cc_debug = "-g -O0 -DDOASSERT -DDOPROF -DBOUNDS_CHECK"
245     omp_flags = "-fopenmp"
246     omp_ldflags = "-fopenmp"
247     fatalwarning = "-Werror"
248     sysheaderopt = "-isystem"
249     elif cc_name == 'cl':
250     # Microsoft Visual C on Windows
251     cc_flags = "/EHsc /MD /GR /wd4068 /D_USE_MATH_DEFINES /DDLL_NETCDF"
252     cc_optim = "/O2 /Op /W3"
253     cc_debug = "/Od /RTCcsu /ZI /DBOUNDS_CHECK"
254     fatalwarning = "/WX"
255     elif cc_name == 'icl':
256     # Intel C on Windows
257     cc_flags = '/EHsc /GR /MD'
258     cc_optim = '/fast /Oi /W3 /Qssp /Qinline-factor- /Qinline-min-size=0 /Qunroll'
259     cc_debug = '/Od /RTCcsu /Zi /Y- /debug:all /Qtrapuv'
260     omp_flags = '/Qvec-report0 /Qopenmp /Qopenmp-report0 /Qparallel'
261     omp_ldflags = '/Qvec-report0 /Qopenmp /Qopenmp-report0 /Qparallel'
262 phornby 1243
263 caltinay 4295 env['sysheaderopt']=sysheaderopt
264    
265 jfenwick 3259 # set defaults if not otherwise specified
266     if env['cc_flags'] == 'default': env['cc_flags'] = cc_flags
267     if env['cc_optim'] == 'default': env['cc_optim'] = cc_optim
268     if env['cc_debug'] == 'default': env['cc_debug'] = cc_debug
269     if env['omp_flags'] == 'default': env['omp_flags'] = omp_flags
270     if env['omp_ldflags'] == 'default': env['omp_ldflags'] = omp_ldflags
271     if env['cxx_extra'] != '': env.Append(CXXFLAGS = env['cxx_extra'])
272     if env['ld_extra'] != '': env.Append(LINKFLAGS = env['ld_extra'])
273 jfenwick 2130
274 jfenwick 3961 if env['BADPYTHONMACROS']: env.Append(CXXFLAGS = ' -DBADPYTHONMACROS')
275    
276 jfenwick 3892 if env['usepython3']:
277     env.Append(CPPDEFINES=['ESPYTHON3'])
278    
279 jfenwick 3259 # set up the autolazy values
280     if env['forcelazy'] == 'on':
281     env.Append(CPPDEFINES=['FAUTOLAZYON'])
282     elif env['forcelazy'] == 'off':
283     env.Append(CPPDEFINES=['FAUTOLAZYOFF'])
284 ksteube 1312
285 jfenwick 3259 # set up the collective resolve values
286     if env['forcecollres'] == 'on':
287     env.Append(CPPDEFINES=['FRESCOLLECTON'])
288     elif env['forcecollres'] == 'off':
289     env.Append(CPPDEFINES=['FRESCOLLECTOFF'])
290 jfenwick 2273
291 jfenwick 3259 # allow non-standard C if requested
292 jfenwick 2827 if env['iknowwhatimdoing']:
293 jfenwick 3259 env.Append(CPPDEFINES=['IKNOWWHATIMDOING'])
294 jfenwick 2827
295 jfenwick 3259 # Disable OpenMP if no flags provided
296     if env['openmp'] and env['omp_flags'] == '':
297 caltinay 4295 env['warnings'].append("OpenMP requested but no flags provided - disabling OpenMP!")
298 jfenwick 3259 env['openmp'] = False
299 gross 1160
300 jfenwick 3259 if env['openmp']:
301     env.Append(CCFLAGS = env['omp_flags'])
302     if env['omp_ldflags'] != '': env.Append(LINKFLAGS = env['omp_ldflags'])
303     else:
304     env['omp_flags']=''
305     env['omp_ldflags']=''
306 ksteube 1312
307 caltinay 4295 env['buildvars']['openmp']=int(env['openmp'])
308    
309 jfenwick 3259 # add debug/non-debug compiler flags
310 caltinay 4295 env['buildvars']['debug']=int(env['debug'])
311 jfenwick 3259 if env['debug']:
312     env.Append(CCFLAGS = env['cc_debug'])
313 gross 2423 else:
314 jfenwick 3259 env.Append(CCFLAGS = env['cc_optim'])
315 gross 1163
316 jfenwick 3259 # always add cc_flags
317     env.Append(CCFLAGS = env['cc_flags'])
318 phornby 1243
319 jfenwick 3259 # add system libraries
320     env.AppendUnique(LIBS = env['sys_libs'])
321 gross 2363
322 caltinay 4295 # determine svn revision
323 jfenwick 3618 global_revision=ARGUMENTS.get('SVN_VERSION', None)
324     if global_revision:
325     global_revision = re.sub(':.*', '', global_revision)
326     global_revision = re.sub('[^0-9]', '', global_revision)
327     if global_revision == '': global_revision='-2'
328     else:
329     # Get the global Subversion revision number for the getVersion() method
330     try:
331 jfenwick 3259 global_revision = os.popen('svnversion -n .').read()
332     global_revision = re.sub(':.*', '', global_revision)
333     global_revision = re.sub('[^0-9]', '', global_revision)
334     if global_revision == '': global_revision='-2'
335 jfenwick 3618 except:
336 jfenwick 3259 global_revision = '-1'
337 caltinay 3271 env['svn_revision']=global_revision
338 caltinay 4295 env['buildvars']['svn_revision']=global_revision
339 jfenwick 3259 env.Append(CPPDEFINES=['SVN_VERSION='+global_revision])
340 gross 2363
341 jfenwick 3259 if IS_WINDOWS:
342 caltinay 3602 if not env['build_shared']:
343 jfenwick 3259 env.Append(CPPDEFINES = ['ESYSUTILS_STATIC_LIB'])
344     env.Append(CPPDEFINES = ['PASO_STATIC_LIB'])
345 gross 2363
346 caltinay 4295 # VSL random numbers
347     env['buildvars']['vsl_random']=int(env['vsl_random'])
348     if env['vsl_random']:
349     env.Append(CPPDEFINES = ['MKLRANDOM'])
350    
351     env['IS_WINDOWS']=IS_WINDOWS
352    
353 jfenwick 3259 ###################### Copy required environment vars ########################
354 gross 2363
355 jfenwick 3259 # Windows doesn't use LD_LIBRARY_PATH but PATH instead
356     if IS_WINDOWS:
357     LD_LIBRARY_PATH_KEY='PATH'
358     env['ENV']['LD_LIBRARY_PATH']=''
359     else:
360     LD_LIBRARY_PATH_KEY='LD_LIBRARY_PATH'
361 robwdcock 682
362 caltinay 4295 env['LD_LIBRARY_PATH_KEY']=LD_LIBRARY_PATH_KEY
363    
364 caltinay 3319 # the following env variables are exported for the unit tests
365 phornby 1244
366 jfenwick 3259 for key in 'OMP_NUM_THREADS', 'ESCRIPT_NUM_PROCS', 'ESCRIPT_NUM_NODES':
367     try:
368     env['ENV'][key] = os.environ[key]
369     except KeyError:
370     env['ENV'][key] = 1
371 robwdcock 682
372 jfenwick 3259 env_export=env['env_export']
373 caltinay 3977 env_export.extend(['ESCRIPT_NUM_THREADS','ESCRIPT_HOSTFILE','DISPLAY','XAUTHORITY','PATH','HOME','KMP_MONITOR_STACKSIZE','TMPDIR','TEMP','TMP'])
374 robwdcock 682
375 jfenwick 3259 for key in set(env_export):
376     try:
377     env['ENV'][key] = os.environ[key]
378     except KeyError:
379     pass
380 ksteube 1312
381 jfenwick 3259 try:
382     env.PrependENVPath(LD_LIBRARY_PATH_KEY, os.environ[LD_LIBRARY_PATH_KEY])
383     except KeyError:
384     pass
385 ksteube 1312
386 jfenwick 4640 if IS_OSX:
387     try:
388     env.PrependENVPath('DYLD_LIBRARY_PATH', os.environ['DYLD_LIBRARY_PATH'])
389     except KeyError:
390     pass
391    
392    
393 jfenwick 3259 # these shouldn't be needed
394     #for key in 'C_INCLUDE_PATH','CPLUS_INCLUDE_PATH','LIBRARY_PATH':
395     # try:
396     # env['ENV'][key] = os.environ[key]
397     # except KeyError:
398     # pass
399 ksteube 1312
400 jfenwick 3259 try:
401     env['ENV']['PYTHONPATH'] = os.environ['PYTHONPATH']
402     except KeyError:
403     pass
404 ksteube 1312
405 jfenwick 3259 ######################## Add some custom builders ############################
406 ksteube 1312
407 jfenwick 3851 if env['pythoncmd']=='python':
408     py_builder = Builder(action = build_py, suffix = '.pyc', src_suffix = '.py', single_source=True)
409     else:
410 jfenwick 3892 py_builder = Builder(action = env['pythoncmd']+" scripts/py_comp.py $SOURCE $TARGET", suffix = '.pyc', src_suffix = '.py', single_source=True)
411 jfenwick 3259 env.Append(BUILDERS = {'PyCompile' : py_builder});
412 gross 2423
413 jfenwick 3259 runUnitTest_builder = Builder(action = runUnitTest, suffix = '.passed', src_suffix=env['PROGSUFFIX'], single_source=True)
414     env.Append(BUILDERS = {'RunUnitTest' : runUnitTest_builder});
415 gross 2423
416 jfenwick 3259 runPyUnitTest_builder = Builder(action = runPyUnitTest, suffix = '.passed', src_suffic='.py', single_source=True)
417     env.Append(BUILDERS = {'RunPyUnitTest' : runPyUnitTest_builder});
418 ksteube 1756
419 jfenwick 3259 epstopdfbuilder = Builder(action = eps2pdf, suffix='.pdf', src_suffix='.eps', single_source=True)
420     env.Append(BUILDERS = {'EpsToPDF' : epstopdfbuilder});
421 ksteube 817
422 jfenwick 3259 ############################ Dependency checks ###############################
423 phornby 1246
424 caltinay 4295 ######## Compiler
425     env=checkCompiler(env)
426 phornby 1634
427 jfenwick 3259 ######## Python headers & library (required)
428 caltinay 4295 env=checkPython(env)
429 gross 806
430 caltinay 4295 ######## boost & boost-python (required)
431     env=checkBoost(env)
432 jfenwick 3892
433 caltinay 4295 ######## numpy (required) and numpy headers (optional)
434     env=checkNumpy(env)
435 jfenwick 3892
436 caltinay 3597 ######## CppUnit (required for tests)
437 caltinay 4295 env=checkCppUnit(env)
438 caltinay 3597
439 caltinay 4295 ######## optional python modules (sympy, pyproj)
440     env=checkOptionalModules(env)
441 caltinay 3597
442 caltinay 4295 ######## optional dependencies (netCDF, PAPI, MKL, UMFPACK, Lapack, Silo, ...)
443     env=checkOptionalLibraries(env)
444 caltinay 3975
445 caltinay 3604 ######## PDFLaTeX (for documentation)
446 caltinay 4295 env=checkPDFLatex(env)
447 caltinay 3604
448 jfenwick 3259 # keep some of our install paths first in the list for the unit tests
449     env.PrependENVPath(LD_LIBRARY_PATH_KEY, env['libinstall'])
450     env.PrependENVPath('PYTHONPATH', prefix)
451     env['ENV']['ESCRIPT_ROOT'] = prefix
452 ksteube 1705
453 jfenwick 3259 if not env['verbose']:
454     env['CXXCOMSTR'] = "Compiling $TARGET"
455     env['SHCXXCOMSTR'] = "Compiling $TARGET"
456     env['ARCOMSTR'] = "Linking $TARGET"
457     env['LINKCOMSTR'] = "Linking $TARGET"
458     env['SHLINKCOMSTR'] = "Linking $TARGET"
459 caltinay 3271 env['PDFLATEXCOMSTR'] = "Building $TARGET from LaTeX input $SOURCES"
460     env['BIBTEXCOMSTR'] = "Generating bibliography $TARGET"
461     env['MAKEINDEXCOMSTR'] = "Generating index $TARGET"
462     env['PDFLATEXCOMSTR'] = "Building $TARGET from LaTeX input $SOURCES"
463 jfenwick 3259 #Progress(['Checking -\r', 'Checking \\\r', 'Checking |\r', 'Checking /\r'], interval=17)
464 ksteube 1705
465 jfenwick 3259 ####################### Configure the subdirectories #########################
466 ksteube 1247
467 caltinay 4295 # remove obsolete files
468     if not env['usempi']:
469     Execute(Delete(os.path.join(env['libinstall'], 'pythonMPI')))
470     Execute(Delete(os.path.join(env['libinstall'], 'pythonMPIredirect')))
471    
472 jfenwick 2235 from grouptest import *
473     TestGroups=[]
474    
475 jfenwick 3259 # keep an environment without warnings-as-errors
476     dodgy_env=env.Clone()
477 jfenwick 2827
478 jfenwick 3259 # now add warnings-as-errors flags. This needs to be done after configuration
479     # because the scons test files have warnings in them
480     if ((fatalwarning != '') and (env['werror'])):
481     env.Append(CCFLAGS = fatalwarning)
482 jfenwick 2827
483 phornby 2027 Export(
484 jfenwick 3259 ['env',
485     'dodgy_env',
486     'IS_WINDOWS',
487     'TestGroups'
488     ]
489     )
490 ksteube 1705
491 caltinay 3349 env.SConscript(dirs = ['tools/escriptconvert'], variant_dir='$BUILD_DIR/$PLATFORM/tools/escriptconvert', duplicate=0)
492     env.SConscript(dirs = ['paso/src'], variant_dir='$BUILD_DIR/$PLATFORM/paso', duplicate=0)
493     env.SConscript(dirs = ['weipa/src'], variant_dir='$BUILD_DIR/$PLATFORM/weipa', duplicate=0)
494 jfenwick 4508 env.SConscript(dirs = ['escript/py_src'], variant_dir='$BUILD_DIR/$PLATFORM/escript', duplicate=0)
495    
496     #This will pull in the escriptcore/py_src and escriptcore/test
497     env.SConscript(dirs = ['escriptcore/src'], variant_dir='$BUILD_DIR/$PLATFORM/escriptcore', duplicate=0)
498     #env.SConscript(dirs = ['escript/test'], variant_dir='$BUILD_DIR/$PLATFORM/escript/test', duplicate=0)
499 caltinay 3349 env.SConscript(dirs = ['esysUtils/src'], variant_dir='$BUILD_DIR/$PLATFORM/esysUtils', duplicate=0)
500 jfenwick 3675 env.SConscript(dirs = ['pasowrap/src'], variant_dir='$BUILD_DIR/$PLATFORM/pasowrap', duplicate=0)
501 caltinay 3349 env.SConscript(dirs = ['dudley/src'], variant_dir='$BUILD_DIR/$PLATFORM/dudley', duplicate=0)
502     env.SConscript(dirs = ['finley/src'], variant_dir='$BUILD_DIR/$PLATFORM/finley', duplicate=0)
503 caltinay 3792 env.SConscript(dirs = ['ripley/src'], variant_dir='$BUILD_DIR/$PLATFORM/ripley', duplicate=0)
504 caltinay 3947 env.SConscript(dirs = ['downunder/py_src'], variant_dir='$BUILD_DIR/$PLATFORM/downunder', duplicate=0)
505 caltinay 3349 env.SConscript(dirs = ['modellib/py_src'], variant_dir='$BUILD_DIR/$PLATFORM/modellib', duplicate=0)
506     env.SConscript(dirs = ['pycad/py_src'], variant_dir='$BUILD_DIR/$PLATFORM/pycad', duplicate=0)
507     env.SConscript(dirs = ['pythonMPI/src'], variant_dir='$BUILD_DIR/$PLATFORM/pythonMPI', duplicate=0)
508 caltinay 3947 env.SConscript(dirs = ['doc'], variant_dir='$BUILD_DIR/$PLATFORM/doc', duplicate=0)
509 caltinay 3349 env.SConscript(dirs = ['paso/profiling'], variant_dir='$BUILD_DIR/$PLATFORM/paso/profiling', duplicate=0)
510 phornby 1243
511 jfenwick 3892
512 jfenwick 3259 ######################## Populate the buildvars file #########################
513 jfenwick 2235
514 caltinay 4295 write_buildvars(env)
515 phornby 1243
516 jfenwick 3259 ################### Targets to build and install libraries ###################
517 jfenwick 2302
518 caltinay 3604 target_init = env.Command(os.path.join(env['pyinstall'],'__init__.py'), None, Touch('$TARGET'))
519 ksteube 1705 env.Alias('target_init', [target_init])
520 caltinay 3604 # delete buildvars upon cleanup
521     env.Clean('target_init', os.path.join(env['libinstall'], 'buildvars'))
522 ksteube 1705
523 jfenwick 3259 # The headers have to be installed prior to build in order to satisfy
524     # #include <paso/Common.h>
525     env.Alias('build_esysUtils', ['install_esysUtils_headers', 'build_esysUtils_lib'])
526     env.Alias('install_esysUtils', ['build_esysUtils', 'install_esysUtils_lib'])
527 ksteube 1705
528 jfenwick 3259 env.Alias('build_paso', ['install_paso_headers', 'build_paso_lib'])
529     env.Alias('install_paso', ['build_paso', 'install_paso_lib'])
530 ksteube 1705
531 jfenwick 3259 env.Alias('build_escript', ['install_escript_headers', 'build_escript_lib', 'build_escriptcpp_lib'])
532 jfenwick 4508 env.Alias('install_escript', ['build_escript', 'install_escript_lib', 'install_escriptcpp_lib', 'install_escriptcore_py', 'install_escript_py'])
533 caltinay 2810
534 jfenwick 3675 env.Alias('build_pasowrap', ['install_pasowrap_headers', 'build_pasowrap_lib', 'build_pasowrapcpp_lib'])
535     env.Alias('install_pasowrap', ['build_pasowrap', 'install_pasowrap_lib', 'install_pasowrapcpp_lib', 'install_pasowrap_py'])
536    
537 jfenwick 3259 env.Alias('build_dudley', ['install_dudley_headers', 'build_dudley_lib', 'build_dudleycpp_lib'])
538     env.Alias('install_dudley', ['build_dudley', 'install_dudley_lib', 'install_dudleycpp_lib', 'install_dudley_py'])
539 caltinay 3096
540 jfenwick 3259 env.Alias('build_finley', ['install_finley_headers', 'build_finley_lib', 'build_finleycpp_lib'])
541     env.Alias('install_finley', ['build_finley', 'install_finley_lib', 'install_finleycpp_lib', 'install_finley_py'])
542 caltinay 2910
543 caltinay 3792 env.Alias('build_ripley', ['install_ripley_headers', 'build_ripley_lib', 'build_ripleycpp_lib'])
544     env.Alias('install_ripley', ['build_ripley', 'install_ripley_lib', 'install_ripleycpp_lib', 'install_ripley_py'])
545    
546 jfenwick 3259 env.Alias('build_weipa', ['install_weipa_headers', 'build_weipa_lib', 'build_weipacpp_lib'])
547     env.Alias('install_weipa', ['build_weipa', 'install_weipa_lib', 'install_weipacpp_lib', 'install_weipa_py'])
548 ksteube 1705
549 jfenwick 3259 env.Alias('build_escriptreader', ['install_weipa_headers', 'build_escriptreader_lib'])
550     env.Alias('install_escriptreader', ['build_escriptreader', 'install_escriptreader_lib'])
551 ksteube 1705
552 jfenwick 3259 # Now gather all the above into some easy targets: build_all and install_all
553 ksteube 1705 build_all_list = []
554     build_all_list += ['build_esysUtils']
555     build_all_list += ['build_paso']
556     build_all_list += ['build_escript']
557 jfenwick 3675 build_all_list += ['build_pasowrap']
558 jfenwick 3259 build_all_list += ['build_dudley']
559 ksteube 1705 build_all_list += ['build_finley']
560 caltinay 3792 build_all_list += ['build_ripley']
561 jfenwick 3259 build_all_list += ['build_weipa']
562     if not IS_WINDOWS: build_all_list += ['build_escriptreader']
563     if env['usempi']: build_all_list += ['build_pythonMPI']
564     build_all_list += ['build_escriptconvert']
565 ksteube 1705 env.Alias('build_all', build_all_list)
566    
567     install_all_list = []
568     install_all_list += ['target_init']
569     install_all_list += ['install_esysUtils']
570     install_all_list += ['install_paso']
571     install_all_list += ['install_escript']
572 jfenwick 3675 install_all_list += ['install_pasowrap']
573 jfenwick 3259 install_all_list += ['install_dudley']
574 ksteube 1705 install_all_list += ['install_finley']
575 caltinay 3792 install_all_list += ['install_ripley']
576 jfenwick 3259 install_all_list += ['install_weipa']
577     if not IS_WINDOWS: install_all_list += ['install_escriptreader']
578 caltinay 3947 install_all_list += ['install_downunder_py']
579 jfenwick 3259 install_all_list += ['install_modellib_py']
580     install_all_list += ['install_pycad_py']
581     if env['usempi']: install_all_list += ['install_pythonMPI']
582     install_all_list += ['install_escriptconvert']
583 ksteube 1705 env.Alias('install_all', install_all_list)
584    
585     # Default target is install
586     env.Default('install_all')
587    
588 jfenwick 3259 ################## Targets to build and run the test suite ###################
589 ksteube 1705
590 caltinay 3597 if not env['cppunit']:
591 caltinay 4520 test_msg = env.Command('.dummy.', None, '@echo "Cannot run C++ unit tests, CppUnit not found!";exit 1')
592 caltinay 3597 env.Alias('run_tests', test_msg)
593 caltinay 4249 env.Alias('build_tests', '')
594 caltinay 3597 env.Alias('run_tests', ['install_all'])
595     env.Alias('all_tests', ['install_all', 'run_tests', 'py_tests'])
596 jfenwick 2286 env.Alias('build_full',['install_all','build_tests','build_py_tests'])
597 caltinay 3349 env.Alias('build_PasoTests','$BUILD_DIR/$PLATFORM/paso/profiling/PasoTests')
598 ksteube 1705
599 jfenwick 3259 ##################### Targets to build the documentation #####################
600 artak 2820
601 jfenwick 4244 env.Alias('pdfdocs',['user_pdf', 'install_pdf', 'cookbook_pdf', 'inversion_pdf'])
602     env.Alias('basedocs', ['pdfdocs','examples_tarfile', 'examples_zipfile', 'api_doxygen'])
603 jfenwick 4167 env.Alias('docs', ['basedocs', 'sphinxdoc'])
604 jfenwick 3259 env.Alias('release_prep', ['docs', 'install_all'])
605 jfenwick 4167 env.Alias('release_prep_old', ['basedocs', 'api_epydoc', 'install_all'])
606 ksteube 1705
607 jfenwick 4078 # The test scripts are always generated, this target allows us to
608     # generate the testscripts without doing a full build
609     env.Alias('testscripts',[])
610    
611 jfenwick 3259 if not IS_WINDOWS:
612 caltinay 4295 generateTestScripts(env, TestGroups)
613 jfenwick 2879
614 caltinay 3604
615 jfenwick 2235
616 caltinay 4295 ######################## Summarize our environment ###########################
617     def print_summary():
618     print("")
619 caltinay 4299 print("*** Config Summary (see config.log and <prefix>/lib/buildvars for details) ***")
620 caltinay 4295 print("Escript/Finley revision %s"%global_revision)
621     print(" Install prefix: %s"%env['prefix'])
622     print(" Python: %s"%sysconfig.PREFIX)
623     print(" boost: %s"%env['boost_prefix'])
624 caltinay 4299 if env['numpy_h']:
625     print(" numpy: YES (with headers)")
626     else:
627     print(" numpy: YES (without headers)")
628 caltinay 4295 if env['usempi']:
629     print(" MPI: YES (flavour: %s)"%env['mpi'])
630     else:
631     print(" MPI: DISABLED")
632     if env['uselapack']:
633     print(" LAPACK: YES (flavour: %s)"%env['lapack'])
634     else:
635     print(" LAPACK: DISABLED")
636     d_list=[]
637     e_list=[]
638 caltinay 4300 for i in 'debug','openmp','boomeramg','gdal','mkl','netcdf','papi','parmetis','pyproj','scipy','silo','sympy','umfpack','visit','vsl_random':
639 caltinay 4295 if env[i]: e_list.append(i)
640     else: d_list.append(i)
641     for i in e_list:
642     print("%16s: YES"%i)
643     for i in d_list:
644     print("%16s: DISABLED"%i)
645     if env['cppunit']:
646     print(" CppUnit: FOUND")
647     else:
648     print(" CppUnit: NOT FOUND")
649     if env['gmsh']=='m':
650     print(" gmsh: FOUND, MPI-ENABLED")
651     elif env['gmsh']=='s':
652     print(" gmsh: FOUND")
653     else:
654     print(" gmsh: NOT FOUND")
655 caltinay 4299
656 caltinay 4295 if ((fatalwarning != '') and (env['werror'])):
657     print(" Treating warnings as errors")
658     else:
659     print(" NOT treating warnings as errors")
660     print("")
661     for w in env['warnings']:
662     print("WARNING: %s"%w)
663    
664     atexit.register(print_summary)
665    

  ViewVC Help
Powered by ViewVC 1.1.26