1 |
# Copyright 2006 by ACcESS MNRF |
2 |
# |
3 |
# http://www.access.edu.au |
4 |
# Primary Business: Queensland, Australia |
5 |
# Licensed under the Open Software License version 3.0 |
6 |
# http://www.opensource.org/licenses/osl-3.0.php |
7 |
# |
8 |
# |
9 |
# |
10 |
|
11 |
# top-level Scons configuration file for all esys13 modules |
12 |
# Begin initialisation Section |
13 |
# all of this section just intialises default environments and helper |
14 |
# scripts. You shouldn't need to modify this section. |
15 |
EnsureSConsVersion(0,96,91) |
16 |
EnsurePythonVersion(2,3) |
17 |
|
18 |
import sys, os |
19 |
# Add our extensions |
20 |
if sys.path.count('scons')==0: sys.path.append('scons') |
21 |
import scons_extensions |
22 |
|
23 |
# Default options and options help text |
24 |
# These are defaults and can be overridden using command line arguments or an options file. |
25 |
# if the options_file or ARGUMENTS do not exist then the ones listed as default here are used |
26 |
# DO NOT CHANGE THEM HERE |
27 |
if ARGUMENTS.get('options_file',0): |
28 |
options_file = ARGUMENTS.get('options_file',0) |
29 |
else: |
30 |
import socket |
31 |
from string import ascii_letters,digits |
32 |
hostname="" |
33 |
for s in socket.gethostname().split('.')[0]: |
34 |
if s in ascii_letters+digits: |
35 |
hostname+=s |
36 |
else: |
37 |
hostname+="_" |
38 |
options_file = "scons/"+hostname+"_options.py" |
39 |
|
40 |
opts = Options(options_file, ARGUMENTS) |
41 |
opts.AddOptions( |
42 |
# Where to install esys stuff |
43 |
('incinstall', 'where the esys headers will be installed', Dir('#.').abspath+'/include'), |
44 |
('libinstall', 'where the esys libraries will be installed', Dir('#.').abspath+'/lib'), |
45 |
('pyinstall', 'where the esys python modules will be installed', Dir('#.').abspath), |
46 |
# Compilation options |
47 |
BoolOption('dodebug', 'Do you want a debug build?', 'yes'), |
48 |
('options_file', "Optional file containing preferred options. Ignored if it doesn't exist (default: scons/hostname_options.py)", options_file), |
49 |
('cc_defines','C/C++ defines to use', None), |
50 |
('cc_flags','C compiler flags to use (Release build)', None), |
51 |
('cc_flags_debug', 'C compiler flags to use (Debug build)', None), |
52 |
('cxx_flags', 'C++ compiler flags to use (Release build)', None), |
53 |
('cxx_flags_debug', 'C++ compiler flags to use (Debug build)', None), |
54 |
('ar_flags', 'Static library archiver flags to use', None), |
55 |
('sys_libs', 'System libraries to link with', None), |
56 |
# MKL |
57 |
PathOption('mkl_path', 'Path to MKL includes', None), |
58 |
PathOption('mkl_lib_path', 'Path to MKL libs', None), |
59 |
('mkl_libs', 'MKL libraries to link with', None), |
60 |
# SCSL |
61 |
PathOption('scsl_path', 'Path to SCSL includes', None), |
62 |
PathOption('scsl_lib_path', 'Path to SCSL libs', None), |
63 |
('scsl_libs', 'SCSL libraries to link with', None), |
64 |
# UMFPACK |
65 |
PathOption('umf_path', 'Path to UMF includes', None), |
66 |
PathOption('umf_lib_path', 'Path to UMF libs', None), |
67 |
('umf_libs', 'UMF libraries to link with', None), |
68 |
# Python |
69 |
PathOption('python_path', 'Path to Python includes', '/usr/include'), |
70 |
PathOption('python_lib_path', 'Path to Python libs', '/usr/lib'), |
71 |
('python_lib', 'Python libraries to link with', ['python2.3',]), |
72 |
# Boost |
73 |
PathOption('boost_path', 'Path to Boost includes', '/usr/include'), |
74 |
PathOption('boost_lib_path', 'Path to Boost libs', '/usr/lib'), |
75 |
('boost_lib', 'Boost libraries to link with', ['boost_python',]), |
76 |
# CppUnit |
77 |
PathOption('cppunit_path', 'Path to CppUnit includes', Dir('#.').abspath+'/tools/CppUnitTest/inc'), |
78 |
PathOption('cppunit_lib_path', 'Path to CppUnit libs', Dir('#.').abspath+'/lib'), |
79 |
('cppunit_lib', 'CppUnit libraries to link with', ['CppUnitTest',]), |
80 |
# Doc building |
81 |
PathOption('doxygen_path', 'Path to Doxygen executable', None), |
82 |
PathOption('epydoc_path', 'Path to Epydoc executable', None), |
83 |
PathOption('epydoc_pythonpath', 'Path to Epydoc python files', None), |
84 |
# PAPI |
85 |
PathOption('papi_path', 'Path to PAPI includes', None), |
86 |
PathOption('papi_lib_path', 'Path to PAPI libs', None), |
87 |
('papi_libs', 'PAPI libraries to link with', None), |
88 |
) |
89 |
|
90 |
# Initialise Scons Build Environment |
91 |
# check for user environment variables we are interested in |
92 |
try: |
93 |
python_path = os.environ['PYTHONPATH'] |
94 |
except KeyError: |
95 |
python_path = '' |
96 |
try: |
97 |
path = os.environ['PATH'] |
98 |
except KeyError: |
99 |
path = '' |
100 |
try: |
101 |
ld_library_path = os.environ['LD_LIBRARY_PATH'] |
102 |
except KeyError: |
103 |
ld_library_path = '' |
104 |
|
105 |
# Note: On the Altix the intel compilers are not automatically |
106 |
# detected by scons intelc.py script. The Altix has a different directory |
107 |
# path and in some locations the "modules" facility is used to support |
108 |
# multiple compiler versions. This forces the need to import the users PATH |
109 |
# environment which isn't the "scons way" |
110 |
# This doesn't impact linux and windows which will use the default compiler (g++ or msvc, or the intel compiler if it is installed on both platforms) |
111 |
# FIXME: Perhaps a modification to intelc.py will allow better support for ia64 on altix |
112 |
|
113 |
if os.name != "nt" and os.uname()[4]=='ia64': |
114 |
env = Environment(tools = ['default', 'intelc'], options = opts) |
115 |
env['ENV']['PATH'] = path |
116 |
env['ENV']['LD_LIBRARY_PATH'] = ld_library_path |
117 |
env['ENV']['PYTHONPATH'] = python_path |
118 |
if env['CXX'] == 'icpc': |
119 |
env['LINK'] = env['CXX'] # version >=9 of intel c++ compiler requires use of icpc to link in C++ runtimes (icc does not). FIXME: this behaviour could be directly incorporated into scons intelc.py |
120 |
elif os.name == "nt": |
121 |
# FIXME: Need to implement equivalent of ld library path for windoze |
122 |
env = Environment(tools = ['default', 'intelc'], options = opts) |
123 |
env['ENV']['PYTHONPATH'] = python_path |
124 |
else: |
125 |
env = Environment(tools = ['default'], options = opts) |
126 |
env['ENV']['PATH'] = path |
127 |
env['ENV']['LD_LIBRARY_PATH'] = ld_library_path |
128 |
env['ENV']['PYTHONPATH'] = python_path |
129 |
|
130 |
# Setup help for options |
131 |
Help(opts.GenerateHelpText(env)) |
132 |
|
133 |
# Add some customer builders |
134 |
py_builder = Builder(action = scons_extensions.build_py, suffix = '.pyc', src_suffix = '.py', single_source=True) |
135 |
env.Append(BUILDERS = {'PyCompile' : py_builder}); |
136 |
|
137 |
if env['PLATFORM'] == "win32": |
138 |
runUnitTest_builder = Builder(action = scons_extensions.runUnitTest, suffix = '.passed', src_suffix='.exe', single_source=True) |
139 |
else: |
140 |
runUnitTest_builder = Builder(action = scons_extensions.runUnitTest, suffix = '.passed', single_source=True) |
141 |
env.Append(BUILDERS = {'RunUnitTest' : runUnitTest_builder}); |
142 |
|
143 |
runPyUnitTest_builder = Builder(action = scons_extensions.runPyUnitTest, suffix = '.passed', src_suffic='.py', single_source=True) |
144 |
env.Append(BUILDERS = {'RunPyUnitTest' : runPyUnitTest_builder}); |
145 |
|
146 |
# Convert the options which are held in environment variable into python variables for ease of handling and configure compilation options |
147 |
try: |
148 |
incinstall = env['incinstall'] |
149 |
env.Append(CPPPATH = [incinstall,]) |
150 |
except KeyError: |
151 |
incinstall = None |
152 |
try: |
153 |
libinstall = env['libinstall'] |
154 |
env.Append(LIBPATH = [libinstall,]) |
155 |
env.PrependENVPath('LD_LIBRARY_PATH', libinstall) |
156 |
except KeyError: |
157 |
libinstall = None |
158 |
try: |
159 |
pyinstall = env['pyinstall']+'/esys' # all targets will install into pyinstall/esys but PYTHONPATH points at straight pyinstall so you go import esys.escript etc |
160 |
env.PrependENVPath('PYTHONPATH', env['pyinstall']) |
161 |
except KeyError: |
162 |
pyinstall = None |
163 |
try: |
164 |
dodebug = env['dodebug'] |
165 |
except KeyError: |
166 |
dodebug = None |
167 |
try: |
168 |
cc_defines = env['cc_defines'] |
169 |
env.Append(CPPDEFINES = [cc_defines,]) |
170 |
except KeyError: |
171 |
pass |
172 |
if dodebug: |
173 |
try: |
174 |
flags = env['cc_flags_debug'] |
175 |
env.Append(CCFLAGS = flags) |
176 |
except KeyError: |
177 |
pass |
178 |
else: |
179 |
try: |
180 |
flags = env['cc_flags'] |
181 |
env.Append(CCFLAGS = flags) |
182 |
except KeyError: |
183 |
pass |
184 |
|
185 |
if dodebug: |
186 |
try: |
187 |
flags = env['cxx_flags_debug'] |
188 |
env.Append(CXXFLAGS = flags) |
189 |
except KeyError: |
190 |
pass |
191 |
else: |
192 |
try: |
193 |
flags = env['cxx_flags'] |
194 |
env.Append(CXXFLAGS = flags) |
195 |
except KeyError: |
196 |
pass |
197 |
|
198 |
try: |
199 |
flags = env['ar_flags'] |
200 |
env.Append(ARFLAGS = flags) |
201 |
except KeyError: |
202 |
ar_flags = None |
203 |
try: |
204 |
sys_libs = env['sys_libs'] |
205 |
except KeyError: |
206 |
sys_libs = '' |
207 |
|
208 |
try: |
209 |
includes = env['mkl_path'] |
210 |
env.Append(CPPPATH = [includes,]) |
211 |
except KeyError: |
212 |
pass |
213 |
try: |
214 |
lib_path = env['mkl_lib_path'] |
215 |
env.Append(LIBPATH = [lib_path,]) |
216 |
except KeyError: |
217 |
pass |
218 |
try: |
219 |
mkl_libs = env['mkl_libs'] |
220 |
except KeyError: |
221 |
mkl_libs = '' |
222 |
try: |
223 |
includes = env['scsl_path'] |
224 |
env.Append(CPPPATH = [includes,]) |
225 |
except KeyError: |
226 |
pass |
227 |
try: |
228 |
lib_path = env['scsl_lib_path'] |
229 |
env.Append(LIBPATH = [lib_path,]) |
230 |
except KeyError: |
231 |
pass |
232 |
try: |
233 |
scsl_libs = env['scsl_libs'] |
234 |
except KeyError: |
235 |
scsl_libs = '' |
236 |
try: |
237 |
includes = env['umf_path'] |
238 |
env.Append(CPPPATH = [includes,]) |
239 |
except KeyError: |
240 |
pass |
241 |
try: |
242 |
lib_path = env['umf_lib_path'] |
243 |
env.Append(LIBPATH = [lib_path,]) |
244 |
except KeyError: |
245 |
pass |
246 |
try: |
247 |
umf_libs = env['umf_libs'] |
248 |
except KeyError: |
249 |
umf_libs = '' |
250 |
try: |
251 |
includes = env['boost_path'] |
252 |
env.Append(CPPPATH = [includes,]) |
253 |
except KeyError: |
254 |
pass |
255 |
try: |
256 |
lib_path = env['boost_lib_path'] |
257 |
env.Append(LIBPATH = [lib_path,]) |
258 |
except KeyError: |
259 |
pass |
260 |
try: |
261 |
boost_lib = env['boost_lib'] |
262 |
except KeyError: |
263 |
boost_lib = None |
264 |
try: |
265 |
includes = env['cppunit_path'] |
266 |
env.Append(CPPPATH = [includes,]) |
267 |
except KeyError: |
268 |
pass |
269 |
try: |
270 |
lib_path = env['cppunit_lib_path'] |
271 |
env.Append(LIBPATH = [lib_path,]) |
272 |
except KeyError: |
273 |
pass |
274 |
try: |
275 |
cppunit_lib = env['cppunit_lib'] |
276 |
except KeyError: |
277 |
boost_lib = None |
278 |
try: |
279 |
includes = env['python_path'] |
280 |
env.Append(CPPPATH = [includes,]) |
281 |
except KeyError: |
282 |
pass |
283 |
try: |
284 |
lib_path = env['python_lib_path'] |
285 |
env.Append(LIBPATH = [lib_path,]) |
286 |
except KeyError: |
287 |
pass |
288 |
try: |
289 |
python_lib = env['python_lib'] |
290 |
except KeyError: |
291 |
python_lib = None |
292 |
try: |
293 |
doxygen_path = env['doxygen_path'] |
294 |
except KeyError: |
295 |
doxygen_path = None |
296 |
try: |
297 |
epydoc_path = env['epydoc_path'] |
298 |
except KeyError: |
299 |
epydoc_path = None |
300 |
try: |
301 |
epydoc_pythonpath = env['epydoc_pythonpath'] |
302 |
except KeyError: |
303 |
epydoc_pythonpath = None |
304 |
try: |
305 |
includes = env['papi_path'] |
306 |
env.Append(CPPPATH = [includes,]) |
307 |
except KeyError: |
308 |
pass |
309 |
try: |
310 |
lib_path = env['papi_lib_path'] |
311 |
env.Append(LIBPATH = [lib_path,]) |
312 |
except KeyError: |
313 |
pass |
314 |
try: |
315 |
papi_libs = env['papi_libs'] |
316 |
except KeyError: |
317 |
papi_libs = None |
318 |
|
319 |
# Targets |
320 |
env.Default(libinstall) |
321 |
env.Default(incinstall) |
322 |
env.Default(pyinstall) |
323 |
env.Alias('build_tests') |
324 |
env.Alias('run_tests') |
325 |
env.Alias('py_tests') |
326 |
env.Alias('all_tests', ['run_tests', 'py_tests']) |
327 |
|
328 |
# Python install - esys __init__.py |
329 |
# This is just an empty file but stills need to be touched so add a special target and Command. Note you can't use the scons Touch() function as it will not |
330 |
# create the file if it doesn't exist |
331 |
env.Command('esys/__init__.py', None, 'touch $TARGET') |
332 |
|
333 |
# Allow sconscripts to see the env |
334 |
Export(["env", "incinstall", "libinstall", "pyinstall", "dodebug", "mkl_libs", "scsl_libs", "umf_libs", |
335 |
"boost_lib", "python_lib", "doxygen_path", "epydoc_path", "epydoc_pythonpath", "papi_libs", "cppunit_lib", "sys_libs" ]) |
336 |
|
337 |
# End initialisation section |
338 |
# Begin configuration section |
339 |
# Insert new components to be build here |
340 |
# FIXME: might be nice to replace this verbosity with a list of targets and some |
341 |
# FIXME: nifty python to create the lengthy but very similar env.Sconscript lines |
342 |
# Third Party libraries |
343 |
env.SConscript(dirs = ['tools/CppUnitTest/src'], build_dir='build/$PLATFORM/tools/CppUnitTest', duplicate=0) |
344 |
# C/C++ Libraries |
345 |
env.SConscript(dirs = ['paso/src'], build_dir='build/$PLATFORM/paso', duplicate=0) |
346 |
env.SConscript(dirs = ['bruce/src'], build_dir='build/$PLATFORM/bruce', duplicate=0) |
347 |
env.SConscript(dirs = ['escript/src'], build_dir='build/$PLATFORM/escript', duplicate=0) |
348 |
env.SConscript(dirs = ['esysUtils/src'], build_dir='build/$PLATFORM/esysUtils', duplicate=0) |
349 |
env.SConscript(dirs = ['finley/src'], build_dir='build/$PLATFORM/finley', duplicate=0) |
350 |
env.SConscript(dirs = ['modellib/py_src'], build_dir='build/$PLATFORM/modellib', duplicate=0) |
351 |
|
352 |
# FIXME:need to be incorporated into build system |
353 |
# FIXME: 'pyvisi/SConstruct'] |
354 |
# FIXME: 'doc/SConstruct'] |
355 |
# FIXME: 'doc/SConstruct'] |