-
Notifications
You must be signed in to change notification settings - Fork 1
/
SConfigure
225 lines (179 loc) · 7.99 KB
/
SConfigure
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
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-geothermal', 'with_geothermal', 'Enable Geothermal repository compile', os.path.isdir("Geothermal"), 'int'),
('--with-solvers', 'with_solvers', 'Enable Solvers repository compile', os.path.isdir("Solvers"), '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-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'),
]
#
# 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(1)
env.AddMethod( UWExit )
#
# Declare which packages we're going to use.
#
env.UsePackage(packages.libm)
env.UsePackage(packages.libXML2)
env.UsePackage(packages.HDF5)
env.UsePackage(packages.MPI)
env.UsePackage(packages.PETSc)
# this flag is required to prevent possible issues with AssertMacro.h defining 'check'
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_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_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");
else:
print("Solvers 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=True)
env.ConfigurePackage(packages.PETSc)
#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
# Export the environments
uw_env.SaveConfig()
Execute(Delete(File('viewer.cfg')))
Execute(Delete(File('offscreen.cfg')))
#
# Print success message.
#
print
print '***************************************'
print '* Successfully configured. *'
print '* Now run \'./scons.py\' to build. *'
print '***************************************'
print