-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathSConfigure
More file actions
396 lines (329 loc) · 14.8 KB
/
SConfigure
File metadata and controls
396 lines (329 loc) · 14.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
import platform, os, sys
from config import Package, packages, cc
#
# Add options to be passed on to build.
#
# (This is a bit of a hack but, disable osmesa so not used unless explicitly enabled on macs, better to use agl)
osmesa_default = eval(os.getenv('WITH_OSMESA','1'))
if platform.system() == 'Darwin':
osmesa_default = 0
options = [
('--prefix', 'prefix', 'Installation prefix.', None),
('--build-dir', 'build_dir', 'Sandbox location.', 'build'),
('--with-debugging', 'with_debugging', 'Build with debugging (default 1)', eval(os.getenv('WITH_DEBUGGING','1')), 'int'),
('--with-profiling', 'with_profiling', 'Build with profiling', eval(os.getenv('WITH_PROFILING','0')), 'int'),
('--optimisation-flag', 'optimisation_flag', 'Choose flag for optimisation', 'default', None),
('--with-warnings', 'with_warnings', 'Print all warnings at compile time (default 1)', eval(os.getenv('WITH_WARNINGS','1')), 'int'),
('--lib-type', 'lib_type', 'Library type: shared or static (default shared)', 'shared'),
('--cc', 'CC', 'C compiler', None),
('--cxx', 'CXX', 'C++ compiler', None),
('--cflags', 'CFLAGS', 'Flags for the C compiler', None),
('--with-credo', 'with_credo', 'Enable the CREDO sys test system (default 1)', eval(os.getenv('WITH_CREDO','1')), 'int'),
('--with-glucifer', 'with_glucifer', 'Enable gLucifer (default 1)', eval(os.getenv('WITH_GLUCIFER','1')), 'int'),
('--with-viewer', 'with_viewer', 'Enable gLucifer viewer (default 1)', eval(os.getenv('WITH_VIEWER','1')), 'int'),
('--with-experimental', 'with_experimental', 'Enable Experimental Repository compile', os.path.isdir("Experimental"), 'int'),
('--with-spmodel', 'with_spmodel', 'Enable SPModel repository compile', os.path.isdir("SPModel"), 'int'),
('--with-geothermal', 'with_geothermal', 'Enable Geothermal repository compile', os.path.isdir("Geothermal"), 'int'),
('--with-groundwater', 'with_groundwater', 'Enable groundwater repository compile', os.path.isdir("Groundwater"), 'int'),
('--with-solvers', 'with_solvers', 'Enable Solvers repository compile', os.path.isdir("Solvers"), 'int'),
('--with-gocad', 'with_gocad', 'Enable gocad tools repository compile', os.path.isdir("GocadToolbox"), 'int'),
('--with-importers', 'with_importers', 'Enable importer toolbox compile', os.path.isdir("ImportersToolbox"), 'int'),
('--with-spherical', 'with_spherical', 'Enable Spherical repository compile', os.path.isdir("Spherical"), 'int'),
('--with-viscoelastic', 'with_viscoelastic', 'Enable Viscoelastic repository compile', os.path.isdir("Viscoelastic"), 'int'),
('--with-pderework', 'with_pderework', 'Enable PDERework repository compile', os.path.isdir("PDERework"), 'int'),
('--with-osmesa', 'with_osmesa', 'Enable OSMesa output', osmesa_default, 'int'),
('--with-sdl', 'with_sdl', 'Enable SDL output (default 1)', eval(os.getenv('WITH_SDL','1')), 'int'),
('--with-x11', 'with_x11', 'Enable X11 output (default 1)', eval(os.getenv('WITH_X11','1')), 'int'),
('--with-agl', 'with_agl', 'Enable AGL output (default 1)', eval(os.getenv('WITH_AGL','1')), 'int'),
('--with-glut', 'with_glut', 'Enable glut window (default 1)', eval(os.getenv('WITH_GLUT','1')), 'int'),
('--with-png', 'with_png', 'Enable PNG output (default 1)', eval(os.getenv('WITH_PNG','1')), 'int'),
('--with-avcodec', 'with_avcodec', 'Enable avcodec movie output (default 1)', eval(os.getenv('WITH_AVCODEC','1')), 'int'),
('--with-gl2ps', 'with_gl2ps', 'Enable gl2ps vector output (default 1)', eval(os.getenv('WITH_GL2PS','1')), 'int'),
('--eptiming', 'eptiming', 'Enable Entry point timings: \'1\' will enable profiling for proc 0 only \'2\' will enable profiling per proc (previous setup)', 0, 'int'),
('--with-memory-stats', 'with_memory_stats', 'Enable detailed Stg Memory statistics', 0, 'int'),
('--with-cautious-mode', 'with_cautious_mode', 'Enable extra checking on heavily used functions', 0, 'int'),
('--with-sedsim', 'with_sedsim', 'Enable SedSim code to compile (default 0)', eval(os.getenv('WITH_SEDSIM','0')), 'int'),
('--with-tellus', 'with_tellus', 'Enable Tellus code to compile (default 0)', eval(os.getenv('WITH_TELLUS','0')), 'int')
]
#
# Setup the environment.
#
env = Environment(ENV=os.environ)
env.Tool('config', toolpath=['config'], options=options)
#
# Definition of our error function
#
def UWExit( self ):
print '\n'
print '***************************************'
print 'If you require help, send the files:'
print '\tconfig.log'
print '\tconfig.cfg (if it exists)'
print 'to: development@underworldproject.org'
print '************************************'
env.Exit()
env.AddMethod( UWExit )
#
# Build PetscExt here.
#
import os
class cd:
"""Create a context manager to work in an insulated environment with a changed directory"""
def __init__(self, newPath):
self.newPath = newPath
def __enter__(self):
self.savedPath = os.getcwd()
os.chdir(self.newPath)
def __exit__(self, etype, value, traceback):
os.chdir(self.savedPath)
#
# Declare which packages we're going to use.
#
env.UsePackage(packages.libm)
env.UsePackage(packages.libXML2)
env.UsePackage(packages.PETScExt)
env.UsePackage(packages.HDF5)
env.UsePackage(packages.OSMesa)
env.UsePackage(packages.OpenGL)
env.UsePackage(packages.SDL)
env.UsePackage(packages.X11)
env.UsePackage(packages.Glut)
env.UsePackage(packages.AGL)
env.UsePackage(packages.libPNG)
env.UsePackage(packages.libavcodec)
env.UsePackage(packages.gl2ps)
env.UsePackage(packages.SedSIM)
env.UsePackage(packages.Tellus)
env.UsePackage(packages.spatialdata)
env.UsePackage(packages.Python)
# add this flag
if platform.system() == 'Darwin':
env.MergeFlags('-D__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES=0')
#
# Perform configuration.
#
if not (GetOption('help') or GetOption('clean')):
if env.get('CC', None) is not None:
cc.apply_cc(env, env['CC'])
# Switch off auto compilers if we were given one.
if '--cc' in ARGUMENTS:
env['packages'][packages.MPI].try_compilers = False
if env.get('prefix', None) is None:
env['prefix'] = env.GetLaunchDir()
# time profiling of entry points:
# 2 - for profiling per proc
# 1 - for profiling proc 0 only
if env.get('eptiming', None) == 1:
env.MergeFlags('-DENABLE_STGERMAIN_LOG=1')
elif env.get('eptiming', None) == 2:
env.MergeFlags('-DENABLE_STGERMAIN_LOG=2')
# confirm with_experimental configure
if env.get('with_experimental', None):
if os.path.isdir("Experimental"):
print("Checking for Experimental... yes");
else:
print("Experimental not found");
env.Exit()
# confirm with_spmodel configure
if env.get('with_spmodel', None):
if os.path.isdir("SPModel"):
print("Checking for SPModel... yes");
else:
print("SPModel not found");
env.Exit()
# confirm with_geothermal configure
if env.get('with_geothermal', None):
if os.path.isdir("Geothermal"):
print("Checking for Geothermal... yes");
else:
print("Geothermal not found");
env.Exit()
# confirm with_groundwater configure
if env.get('with_groundwater', None):
if os.path.isdir("Groundwater"):
print("Checking for Groundwater... yes");
else:
print("Groundwater not found");
env.Exit()
# confirm with_gocad configure
if env.get('with_gocad', None):
if os.path.isdir("GocadToolbox"):
print("Checking for Gocad toolbox... yes");
else:
print("Gocad toolbox not found");
env.Exit()
# confirm with_importers configure
if env.get('with_importers', None):
if os.path.isdir("ImportersToolbox"):
print("Checking for Importers toolbox... yes");
else:
print("Importers toolbox not found");
env.Exit()
# confirm with_solvers configure
if env.get('with_solvers', None):
if os.path.isdir("Solvers"):
print("Checking for Solvers... yes");
import subprocess
with cd("./Solvers/PetscExt"):
subprocess.call('./config/configure.py',shell=True)
subprocess.call('make all',shell=True)
else:
print("Solvers not found");
env.Exit()
# confirm with_pderework configure
if env.get('with_pderework', None):
if os.path.isdir("PDERework"):
print("Checking for PDERework... yes");
else:
print("PDERework not found");
env.Exit()
# confirm with_spherical configure
if env.get('with_spherical', None):
if os.path.isdir("Spherical"):
print("Checking for Spherical... yes");
else:
print("Spherical not found");
env.Exit()
# confirm with_viscoelastic configure
if env.get('with_viscoelastic', None):
if os.path.isdir("Viscoelastic"):
print("Checking for Viscoelastic... yes");
else:
print("Viscoelastic not found");
env.Exit()
if env.get('with_memory_stats', None):
env.MergeFlags('-DMEMORY_STATS')
if env.get('with_cautious_mode', None):
env.MergeFlags('-DCAUTIOUS')
env['save_vars'] += ['shared_libs', 'static_libs']
if env.get('lib_type', None) == 'shared':
env['shared_libs'] = 1
env['static_libs'] = 0
elif env.get('lib_type', None) == 'static':
env['shared_libs'] = 0
env['static_libs'] = 1
#env.MergeFlags('-static')
#env.AppendUnique(LINKFLAGS=['-static'])
Package.static = True
else:
print
print '**** ERROR ****'
print 'Invalid option \'--lib-type\''
env.UWExit()
# enable all warnings.
if env.get('with_warnings', None):
env.MergeFlags('-Wall')
if env.get('CC', None) == 'icc':
env.MergeFlags('-wd869 -wd1419')
# Copies base environment
base_env = env.Clone()
env.ConfigurePackage(packages.libm, required=False)
env.ConfigurePackage(packages.libXML2)
env.ConfigurePackage(packages.MPI)
env.ConfigurePackage(packages.HDF5, required=False)
env.ConfigurePackage(packages.spatialdata, required=False)
env.ConfigurePackage(packages.Python, required=False)
env.ConfigurePackage(packages.PETSc)
env.ConfigurePackage(packages.PETScExt, required=False)
if env.get('with_sedsim'):
env.ConfigurePackage(packages.SedSIM, required=False)
if env.get('with_tellus'):
env.ConfigurePackage(packages.Tellus, required=False)
#Set debug and optimise settings last to override any from PETSc
if env.get('optimisation_flag', None) == 'default':
if env.get('with_debugging', None):
env.MergeFlags('-g -DDEBUG -O0')
else:
env.MergeFlags('-O2 -DNDEBUG')
else:
if env.get('with_debugging', None):
env.MergeFlags('-g -DDEBUG '+env.get('optimisation_flag', None))
else:
env.MergeFlags('-DNDEBUG '+env.get('optimisation_flag', None))
if env.get('with_profiling'):
env.MergeFlags('-DUSE_PROFILE -DENABLE_STGERMAIN_LOG')
# Save environment
uw_env = env
# If we're building gLucifer viewer then we need some more packages.
offscreen_env = 0
viewer_env = 0
if env.get('with_glucifer', None):
# Configure auxilliary gLucifer packages.
vis_env = base_env.Clone()
env = vis_env
if env.get('with_png'):
env.ConfigurePackage(packages.libPNG, required=False)
if env.get('with_avcodec'):
env.ConfigurePackage(packages.libavcodec, required=False)
if env.get('with_gl2ps'):
env.ConfigurePackage(packages.gl2ps, required=False)
# Have base gLucifer environment, clone it
offscreen_env = base_env.Clone()
viewer_env = base_env.Clone()
#gLucifer output env
env = offscreen_env
# Try for OSMesa first
osmesa = 0
if env.get('with_osmesa'):
osmesa = env.ConfigurePackage(packages.OSMesa, required=False).result
# If OSMesa found, use it for gLucifer in Underworld
# If not, try AGL (mac) or use config of other windowing systems detected for interactive
agl = 0
if not osmesa:
# Try for AGL window if on Darwin...
if platform.system() == 'Darwin' and env.get('with_agl'):
agl = env.ConfigurePackage(packages.AGL, required=False).result
else:
offscreen_env = 0
#Interactive mode viewer window (also for offscreen if no config found yet)
if not (agl or osmesa) or env.get('with_viewer', None):
env = viewer_env
win = 0
# Try for Glut window first on OS X
glut = 0
if platform.system() == 'Darwin' and env.get('with_glut'):
glut = win = env.ConfigurePackage(packages.Glut, required=False).result
#Try configuring X11
x11 = 0
if (not win or platform.system() != 'Darwin') and env.get('with_x11'):
x11 = win = env.ConfigurePackage(packages.X11, required=False).result
# Try for SDL window
sdl = 0
if (not win or platform.system() != 'Darwin') and env.get('with_sdl'):
sdl = win = env.ConfigurePackage(packages.SDL, required=False).result
# Try for Glut window on Linux
if platform.system() != 'Darwin' and env.get('with_glut'):
glut = win = env.ConfigurePackage(packages.Glut, required=False).result
#Configure OpenGL
if x11 or platform.system() != 'Darwin':
env.ConfigurePackage(packages.OpenGL, required=False).result
# An interactive windowing system is required for viewer
viewer_env = env
if not (x11 or glut or sdl or agl or osmesa):
print
print '**** WARNING ****'
print 'Need a windowing system for gLucifer Viewer, either'
print 'X11, SDL, Glut, AGL or OSMesa. None of these could be found.'
print 'The viewer will not be compiled.'
uw_env['with_viewer'] = 0
viewer_env = 0
# Export the environments
uw_env.SaveConfig()
if env.get('with_glucifer'):
vis_env.SaveConfig('output.cfg')
Execute(Delete(File('viewer.cfg')))
Execute(Delete(File('offscreen.cfg')))
if env.get('with_viewer'):
if viewer_env:
viewer_env.SaveConfig('viewer.cfg')
if offscreen_env:
offscreen_env.SaveConfig('offscreen.cfg')
#
# Print success message.
#
print
print '***************************************'
print '* Successfully configured. *'
print '* Now run \'./scons.py\' to build. *'
print '***************************************'
print