3 # Copyright (c) 2004-2005 The Regents of The University of Michigan
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions are
8 # met: redistributions of source code must retain the above copyright
9 # notice, this list of conditions and the following disclaimer;
10 # redistributions in binary form must reproduce the above copyright
11 # notice, this list of conditions and the following disclaimer in the
12 # documentation and/or other materials provided with the distribution;
13 # neither the name of the copyright holders nor the names of its
14 # contributors may be used to endorse or promote products derived from
15 # this software without specific prior written permission.
17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 # Authors: Steve Reinhardt
31 ###################################################
33 # SCons top-level build description (SConstruct) file.
35 # While in this directory ('m5'), just type 'scons' to build the default
36 # configuration (see below), or type 'scons build/<CONFIG>/<binary>'
37 # to build some other configuration (e.g., 'build/ALPHA_FS/m5.opt' for
38 # the optimized full-system version).
40 # You can build M5 in a different directory as long as there is a
41 # 'build/<CONFIG>' somewhere along the target path. The build system
42 # expects that all configs under the same build directory are being
43 # built for the same host system.
47 # The following two commands are equivalent. The '-u' option tells
48 # scons to search up the directory tree for this SConstruct file.
49 # % cd <path-to-src>/m5 ; scons build/ALPHA_FS/m5.debug
50 # % cd <path-to-src>/m5/build/ALPHA_FS; scons -u m5.debug
52 # The following two commands are equivalent and demonstrate building
53 # in a directory outside of the source tree. The '-C' option tells
54 # scons to chdir to the specified directory to find this SConstruct
56 # % cd <path-to-src>/m5 ; scons /local/foo/build/ALPHA_FS/m5.debug
57 # % cd /local/foo/build/ALPHA_FS; scons -C <path-to-src>/m5 m5.debug
59 # You can use 'scons -H' to print scons options. If you're in this
60 # 'm5' directory (or use -u or -C to tell scons where to find this
61 # file), you can use 'scons -h' to print all the M5-specific build
64 ###################################################
70 from os
.path
import isdir
, join
as joinpath
72 # Check for recent-enough Python and SCons versions. If your system's
73 # default installation of Python is not recent enough, you can use a
74 # non-default installation of the Python interpreter by either (1)
75 # rearranging your PATH so that scons finds the non-default 'python'
76 # first or (2) explicitly invoking an alternative interpreter on the
77 # scons script, e.g., "/usr/local/bin/python2.4 `which scons` [args]".
78 EnsurePythonVersion(2,4)
80 # Ironically, SCons 0.96 dies if you give EnsureSconsVersion a
81 # 3-element version number.
82 min_scons_version
= (0,96,91)
84 EnsureSConsVersion(*min_scons_version
)
86 print "Error checking current SCons version."
87 print "SCons", ".".join(map(str,min_scons_version
)), "or greater required."
91 # The absolute path to the current directory (where this file lives).
92 ROOT
= Dir('.').abspath
94 # Path to the M5 source tree.
95 SRCDIR
= joinpath(ROOT
, 'src')
97 # tell python where to find m5 python code
98 sys
.path
.append(joinpath(ROOT
, 'src/python'))
100 def check_style_hook(ui
):
101 ui
.readconfig(joinpath(ROOT
, '.hg', 'hgrc'))
102 style_hook
= ui
.config('hooks', 'pretxncommit.style', None)
106 You're missing the M5 style hook.
107 Please install the hook so we can ensure that all code fits a common style.
109 All you'd need to do is add the following lines to your repository .hg/hgrc
110 or your personal .hgrc
114 style = %s/util/style.py
117 pretxncommit.style = python:style.check_whitespace
121 if isdir(joinpath(ROOT
, '.hg')):
123 from mercurial
import ui
124 check_style_hook(ui
.ui())
128 ###################################################
130 # Figure out which configurations to set up based on the path(s) of
133 ###################################################
135 # Find default configuration & binary.
136 Default(os
.environ
.get('M5_DEFAULT_BINARY', 'build/ALPHA_SE/m5.debug'))
138 # helper function: find last occurrence of element in list
139 def rfind(l
, elt
, offs
= -1):
140 for i
in range(len(l
)+offs
, 0, -1):
143 raise ValueError, "element not found"
145 # helper function: compare dotted version numbers.
146 # E.g., compare_version('1.3.25', '1.4.1')
147 # returns -1, 0, 1 if v1 is <, ==, > v2
148 def compare_versions(v1
, v2
):
149 # Convert dotted strings to lists
150 v1
= map(int, v1
.split('.'))
151 v2
= map(int, v2
.split('.'))
152 # Compare corresponding elements of lists
153 for n1
,n2
in zip(v1
, v2
):
154 if n1
< n2
: return -1
156 # all corresponding values are equal... see if one has extra values
157 if len(v1
) < len(v2
): return -1
158 if len(v1
) > len(v2
): return 1
161 # Each target must have 'build' in the interior of the path; the
162 # directory below this will determine the build parameters. For
163 # example, for target 'foo/bar/build/ALPHA_SE/arch/alpha/blah.do' we
164 # recognize that ALPHA_SE specifies the configuration because it
165 # follow 'build' in the bulid path.
167 # Generate absolute paths to targets so we can see where the build dir is
168 if COMMAND_LINE_TARGETS
:
169 # Ask SCons which directory it was invoked from
170 launch_dir
= GetLaunchDir()
171 # Make targets relative to invocation directory
172 abs_targets
= map(lambda x
: os
.path
.normpath(joinpath(launch_dir
, str(x
))),
173 COMMAND_LINE_TARGETS
)
175 # Default targets are relative to root of tree
176 abs_targets
= map(lambda x
: os
.path
.normpath(joinpath(ROOT
, str(x
))),
180 # Generate a list of the unique build roots and configs that the
181 # collected targets reference.
184 for t
in abs_targets
:
185 path_dirs
= t
.split('/')
187 build_top
= rfind(path_dirs
, 'build', -2)
189 print "Error: no non-leaf 'build' dir found on target path", t
191 this_build_root
= joinpath('/',*path_dirs
[:build_top
+1])
193 build_root
= this_build_root
195 if this_build_root
!= build_root
:
196 print "Error: build targets not under same build root\n"\
197 " %s\n %s" % (build_root
, this_build_root
)
199 build_path
= joinpath('/',*path_dirs
[:build_top
+2])
200 if build_path
not in build_paths
:
201 build_paths
.append(build_path
)
203 ###################################################
205 # Set up the default build environment. This environment is copied
206 # and modified according to each selected configuration.
208 ###################################################
210 env
= Environment(ENV
= os
.environ
, # inherit user's environment vars
214 #Parse CC/CXX early so that we use the correct compiler for
215 # to test for dependencies/versions/libraries/includes
216 if ARGUMENTS
.get('CC', None):
217 env
['CC'] = ARGUMENTS
.get('CC')
219 if ARGUMENTS
.get('CXX', None):
220 env
['CXX'] = ARGUMENTS
.get('CXX')
224 env
.SConsignFile(joinpath(build_root
,"sconsign"))
226 # Default duplicate option is to use hard links, but this messes up
227 # when you use emacs to edit a file in the target dir, as emacs moves
228 # file to file~ then copies to file, breaking the link. Symbolic
229 # (soft) links work better.
230 env
.SetOption('duplicate', 'soft-copy')
232 # I waffle on this setting... it does avoid a few painful but
233 # unnecessary builds, but it also seems to make trivial builds take
236 env
.TargetSignatures('content')
238 # M5_PLY is used by isa_parser.py to find the PLY package.
239 env
.Append(ENV
= { 'M5_PLY' : Dir('ext/ply') })
243 env
['GCC'] = subprocess
.Popen(env
['CXX'] + ' --version', shell
=True,
244 stdout
=subprocess
.PIPE
, stderr
=subprocess
.STDOUT
,
245 close_fds
=True).communicate()[0].find('GCC') >= 0
246 env
['SUNCC'] = subprocess
.Popen(env
['CXX'] + ' -V', shell
=True,
247 stdout
=subprocess
.PIPE
, stderr
=subprocess
.STDOUT
,
248 close_fds
=True).communicate()[0].find('Sun C++') >= 0
249 env
['ICC'] = subprocess
.Popen(env
['CXX'] + ' -V', shell
=True,
250 stdout
=subprocess
.PIPE
, stderr
=subprocess
.STDOUT
,
251 close_fds
=True).communicate()[0].find('Intel') >= 0
252 if env
['GCC'] + env
['SUNCC'] + env
['ICC'] > 1:
253 print 'Error: How can we have two at the same time?'
257 # Set up default C++ compiler flags
259 env
.Append(CCFLAGS
='-pipe')
260 env
.Append(CCFLAGS
='-fno-strict-aliasing')
261 env
.Append(CCFLAGS
=Split('-Wall -Wno-sign-compare -Werror -Wundef'))
263 pass #Fix me... add warning flags once we clean up icc warnings
265 env
.Append(CCFLAGS
='-Qoption ccfe')
266 env
.Append(CCFLAGS
='-features=gcc')
267 env
.Append(CCFLAGS
='-features=extensions')
268 env
.Append(CCFLAGS
='-library=stlport4')
269 env
.Append(CCFLAGS
='-xar')
270 # env.Append(CCFLAGS='-instances=semiexplicit')
272 print 'Error: Don\'t know what compiler options to use for your compiler.'
273 print ' Please fix SConstruct and src/SConscript and try again.'
276 if sys
.platform
== 'cygwin':
277 # cygwin has some header file issues...
278 env
.Append(CCFLAGS
=Split("-Wno-uninitialized"))
279 env
.Append(CPPPATH
=[Dir('ext/dnet')])
282 if not env
.has_key('SWIG'):
283 print 'Error: SWIG utility not found.'
284 print ' Please install (see http://www.swig.org) and retry.'
287 # Check for appropriate SWIG version
288 swig_version
= os
.popen('swig -version').read().split()
289 # First 3 words should be "SWIG Version x.y.z"
290 if len(swig_version
) < 3 or \
291 swig_version
[0] != 'SWIG' or swig_version
[1] != 'Version':
292 print 'Error determining SWIG version.'
295 min_swig_version
= '1.3.28'
296 if compare_versions(swig_version
[2], min_swig_version
) < 0:
297 print 'Error: SWIG version', min_swig_version
, 'or newer required.'
298 print ' Installed version:', swig_version
[2]
301 # Set up SWIG flags & scanner
302 swig_flags
=Split('-c++ -python -modern -templatereduce $_CPPINCFLAGS')
303 env
.Append(SWIGFLAGS
=swig_flags
)
305 # filter out all existing swig scanners, they mess up the dependency
306 # stuff for some reason
308 for scanner
in env
['SCANNERS']:
309 skeys
= scanner
.skeys
313 if isinstance(skeys
, (list, tuple)) and '.i' in skeys
:
316 scanners
.append(scanner
)
318 # add the new swig scanner that we like better
319 from SCons
.Scanner
import ClassicCPP
as CPPScanner
320 swig_inc_re
= '^[ \t]*[%,#][ \t]*(?:include|import)[ \t]*(<|")([^>"]+)(>|")'
321 scanners
.append(CPPScanner("SwigScan", [ ".i" ], "CPPPATH", swig_inc_re
))
323 # replace the scanners list that has what we want
324 env
['SCANNERS'] = scanners
326 # Platform-specific configuration. Note again that we assume that all
327 # builds under a given build root run on the same host platform.
328 conf
= Configure(env
,
329 conf_dir
= joinpath(build_root
, '.scons_config'),
330 log_file
= joinpath(build_root
, 'scons_config.log'))
332 # Find Python include and library directories for embedding the
333 # interpreter. For consistency, we will use the same Python
334 # installation used to run scons (and thus this script). If you want
335 # to link in an alternate version, see above for instructions on how
336 # to invoke scons with a different copy of the Python interpreter.
338 # Get brief Python version name (e.g., "python2.4") for locating
339 # include & library files
340 py_version_name
= 'python' + sys
.version
[:3]
342 # include path, e.g. /usr/local/include/python2.4
343 py_header_path
= joinpath(sys
.exec_prefix
, 'include', py_version_name
)
344 env
.Append(CPPPATH
= py_header_path
)
345 # verify that it works
346 if not conf
.CheckHeader('Python.h', '<>'):
347 print "Error: can't find Python.h header in", py_header_path
350 # add library path too if it's not in the default place
352 if sys
.exec_prefix
!= '/usr':
353 py_lib_path
= joinpath(sys
.exec_prefix
, 'lib')
354 elif sys
.platform
== 'cygwin':
355 # cygwin puts the .dll in /bin for some reason
358 env
.Append(LIBPATH
= py_lib_path
)
359 print 'Adding', py_lib_path
, 'to LIBPATH for', py_version_name
360 if not conf
.CheckLib(py_version_name
):
361 print "Error: can't find Python library", py_version_name
364 # On Solaris you need to use libsocket for socket ops
365 if not conf
.CheckLibWithHeader(None, 'sys/socket.h', 'C++', 'accept(0,0,0);'):
366 if not conf
.CheckLibWithHeader('socket', 'sys/socket.h', 'C++', 'accept(0,0,0);'):
367 print "Can't find library with socket calls (e.g. accept())"
370 # Check for zlib. If the check passes, libz will be automatically
371 # added to the LIBS environment variable.
372 if not conf
.CheckLibWithHeader('z', 'zlib.h', 'C++','zlibVersion();'):
373 print 'Error: did not find needed zlib compression library '\
374 'and/or zlib.h header file.'
375 print ' Please install zlib and try again.'
378 # Check for <fenv.h> (C99 FP environment control)
379 have_fenv
= conf
.CheckHeader('fenv.h', '<>')
381 print "Warning: Header file <fenv.h> not found."
382 print " This host has no IEEE FP rounding mode control."
385 mysql_config
= WhereIs('mysql_config')
386 have_mysql
= mysql_config
!= None
388 # Check MySQL version.
390 mysql_version
= os
.popen(mysql_config
+ ' --version').read()
391 min_mysql_version
= '4.1'
392 if compare_versions(mysql_version
, min_mysql_version
) < 0:
393 print 'Warning: MySQL', min_mysql_version
, 'or newer required.'
394 print ' Version', mysql_version
, 'detected.'
397 # Set up mysql_config commands.
399 mysql_config_include
= mysql_config
+ ' --include'
400 if os
.system(mysql_config_include
+ ' > /dev/null') != 0:
401 # older mysql_config versions don't support --include, use
403 mysql_config_include
= mysql_config
+ ' --cflags | sed s/\\\'//g'
404 # This seems to work in all versions
405 mysql_config_libs
= mysql_config
+ ' --libs'
409 # Define the universe of supported ISAs
411 Export('all_isa_list')
413 # Define the universe of supported CPU models
416 Export('all_cpu_list', 'default_cpus')
418 # Sticky options get saved in the options file so they persist from
419 # one invocation to the next (unless overridden, in which case the new
420 # value becomes sticky).
421 sticky_opts
= Options(args
=ARGUMENTS
)
422 Export('sticky_opts')
424 # Non-sticky options only apply to the current build.
425 nonsticky_opts
= Options(args
=ARGUMENTS
)
426 Export('nonsticky_opts')
428 # Walk the tree and execute all SConsopts scripts that wil add to the
430 for root
, dirs
, files
in os
.walk('.'):
431 if 'SConsopts' in files
:
432 SConscript(os
.path
.join(root
, 'SConsopts'))
438 def ExtraPathValidator(key
, val
, env
):
441 paths
= val
.split(':')
443 path
= os
.path
.expanduser(path
)
445 raise AttributeError, "Invalid path: '%s'" % path
447 sticky_opts
.AddOptions(
448 EnumOption('TARGET_ISA', 'Target ISA', 'alpha', all_isa_list
),
449 BoolOption('FULL_SYSTEM', 'Full-system support', False),
450 # There's a bug in scons 0.96.1 that causes ListOptions with list
451 # values (more than one value) not to be able to be restored from
452 # a saved option file. If this causes trouble then upgrade to
453 # scons 0.96.90 or later.
454 ListOption('CPU_MODELS', 'CPU models', default_cpus
, all_cpu_list
),
455 BoolOption('NO_FAST_ALLOC', 'Disable fast object allocator', False),
456 BoolOption('EFENCE', 'Link with Electric Fence malloc debugger',
458 BoolOption('SS_COMPATIBLE_FP',
459 'Make floating-point results compatible with SimpleScalar',
461 BoolOption('USE_SSE2',
462 'Compile for SSE2 (-msse2) to get IEEE FP on x86 hosts',
464 BoolOption('USE_MYSQL', 'Use MySQL for stats output', have_mysql
),
465 BoolOption('USE_FENV', 'Use <fenv.h> IEEE mode control', have_fenv
),
466 BoolOption('USE_CHECKER', 'Use checker for detailed CPU models', False),
467 ('CC', 'C compiler', os
.environ
.get('CC', env
['CC'])),
468 ('CXX', 'C++ compiler', os
.environ
.get('CXX', env
['CXX'])),
469 BoolOption('BATCH', 'Use batch pool for build and tests', False),
470 ('BATCH_CMD', 'Batch pool submission command name', 'qdo'),
472 'Override the default PYTHONHOME for this system (use with caution)',
473 '%s:%s' % (sys
.prefix
, sys
.exec_prefix
)),
474 ('EXTRAS', 'Add Extra directories to the compilation', '',
478 nonsticky_opts
.AddOptions(
479 BoolOption('update_ref', 'Update test reference outputs', False)
482 # These options get exported to #defines in config/*.hh (see src/SConscript).
483 env
.ExportOptions
= ['FULL_SYSTEM', 'ALPHA_TLASER', 'USE_FENV', \
484 'USE_MYSQL', 'NO_FAST_ALLOC', 'SS_COMPATIBLE_FP', \
485 'USE_CHECKER', 'PYTHONHOME', 'TARGET_ISA']
487 # Define a handy 'no-op' action
488 def no_action(target
, source
, env
):
491 env
.NoAction
= Action(no_action
, None)
493 ###################################################
495 # Define a SCons builder for configuration flag headers.
497 ###################################################
499 # This function generates a config header file that #defines the
500 # option symbol to the current option setting (0 or 1). The source
501 # operands are the name of the option and a Value node containing the
502 # value of the option.
503 def build_config_file(target
, source
, env
):
504 (option
, value
) = [s
.get_contents() for s
in source
]
505 f
= file(str(target
[0]), 'w')
506 print >> f
, '#define', option
, value
510 # Generate the message to be printed when building the config file.
511 def build_config_file_string(target
, source
, env
):
512 (option
, value
) = [s
.get_contents() for s
in source
]
513 return "Defining %s as %s in %s." % (option
, value
, target
[0])
515 # Combine the two functions into a scons Action object.
516 config_action
= Action(build_config_file
, build_config_file_string
)
518 # The emitter munges the source & target node lists to reflect what
519 # we're really doing.
520 def config_emitter(target
, source
, env
):
521 # extract option name from Builder arg
522 option
= str(target
[0])
523 # True target is config header file
524 target
= joinpath('config', option
.lower() + '.hh')
526 if isinstance(val
, bool):
529 elif isinstance(val
, str):
530 val
= '"' + val
+ '"'
532 # Sources are option name & value (packaged in SCons Value nodes)
533 return ([target
], [Value(option
), Value(val
)])
535 config_builder
= Builder(emitter
= config_emitter
, action
= config_action
)
537 env
.Append(BUILDERS
= { 'ConfigFile' : config_builder
})
539 ###################################################
541 # Define a SCons builder for copying files. This is used by the
542 # Python zipfile code in src/python/SConscript, but is placed up here
543 # since it's potentially more generally applicable.
545 ###################################################
547 copy_builder
= Builder(action
= Copy("$TARGET", "$SOURCE"))
549 env
.Append(BUILDERS
= { 'CopyFile' : copy_builder
})
551 ###################################################
553 # Define a simple SCons builder to concatenate files.
555 # Used to append the Python zip archive to the executable.
557 ###################################################
559 concat_builder
= Builder(action
= Action(['cat $SOURCES > $TARGET',
560 'chmod +x $TARGET']))
562 env
.Append(BUILDERS
= { 'Concat' : concat_builder
})
567 Usage: scons [scons options] [build options] [target(s)]
571 # libelf build is shared across all configs in the build root.
572 env
.SConscript('ext/libelf/SConscript',
573 build_dir
= joinpath(build_root
, 'libelf'),
576 ###################################################
578 # This function is used to set up a directory with switching headers
580 ###################################################
582 env
['ALL_ISA_LIST'] = all_isa_list
583 def make_switching_dir(dirname
, switch_headers
, env
):
584 # Generate the header. target[0] is the full path of the output
585 # header to generate. 'source' is a dummy variable, since we get the
586 # list of ISAs from env['ALL_ISA_LIST'].
587 def gen_switch_hdr(target
, source
, env
):
588 fname
= str(target
[0])
589 basename
= os
.path
.basename(fname
)
591 f
.write('#include "arch/isa_specific.hh"\n')
593 for isa
in all_isa_list
:
594 f
.write('%s THE_ISA == %s_ISA\n#include "%s/%s/%s"\n'
595 % (cond
, isa
.upper(), dirname
, isa
, basename
))
597 f
.write('#else\n#error "THE_ISA not set"\n#endif\n')
601 # String to print when generating header
602 def gen_switch_hdr_string(target
, source
, env
):
603 return "Generating switch header " + str(target
[0])
605 # Build SCons Action object. 'varlist' specifies env vars that this
606 # action depends on; when env['ALL_ISA_LIST'] changes these actions
607 # should get re-executed.
608 switch_hdr_action
= Action(gen_switch_hdr
, gen_switch_hdr_string
,
609 varlist
=['ALL_ISA_LIST'])
611 # Instantiate actions for each header
612 for hdr
in switch_headers
:
613 env
.Command(hdr
, [], switch_hdr_action
)
614 Export('make_switching_dir')
616 ###################################################
618 # Define build environments for selected configurations.
620 ###################################################
625 for build_path
in build_paths
:
626 print "Building in", build_path
627 env
['BUILDDIR'] = build_path
629 # build_dir is the tail component of build path, and is used to
630 # determine the build parameters (e.g., 'ALPHA_SE')
631 (build_root
, build_dir
) = os
.path
.split(build_path
)
632 # Make a copy of the build-root environment to use for this config.
633 env
= base_env
.Copy()
635 # Set env options according to the build directory config.
636 sticky_opts
.files
= []
637 # Options for $BUILD_ROOT/$BUILD_DIR are stored in
638 # $BUILD_ROOT/options/$BUILD_DIR so you can nuke
639 # $BUILD_ROOT/$BUILD_DIR without losing your options settings.
640 current_opts_file
= joinpath(build_root
, 'options', build_dir
)
641 if os
.path
.isfile(current_opts_file
):
642 sticky_opts
.files
.append(current_opts_file
)
643 print "Using saved options file %s" % current_opts_file
645 # Build dir-specific options file doesn't exist.
647 # Make sure the directory is there so we can create it later
648 opt_dir
= os
.path
.dirname(current_opts_file
)
649 if not os
.path
.isdir(opt_dir
):
652 # Get default build options from source tree. Options are
653 # normally determined by name of $BUILD_DIR, but can be
654 # overriden by 'default=' arg on command line.
655 default_opts_file
= joinpath('build_opts',
656 ARGUMENTS
.get('default', build_dir
))
657 if os
.path
.isfile(default_opts_file
):
658 sticky_opts
.files
.append(default_opts_file
)
659 print "Options file %s not found,\n using defaults in %s" \
660 % (current_opts_file
, default_opts_file
)
662 print "Error: cannot find options file %s or %s" \
663 % (current_opts_file
, default_opts_file
)
666 # Apply current option settings to env
667 sticky_opts
.Update(env
)
668 nonsticky_opts
.Update(env
)
670 help_text
+= "Sticky options for %s:\n" % build_dir \
671 + sticky_opts
.GenerateHelpText(env
) \
672 + "\nNon-sticky options for %s:\n" % build_dir \
673 + nonsticky_opts
.GenerateHelpText(env
)
675 # Process option settings.
677 if not have_fenv
and env
['USE_FENV']:
678 print "Warning: <fenv.h> not available; " \
679 "forcing USE_FENV to False in", build_dir
+ "."
680 env
['USE_FENV'] = False
682 if not env
['USE_FENV']:
683 print "Warning: No IEEE FP rounding mode control in", build_dir
+ "."
684 print " FP results may deviate slightly from other platforms."
687 env
.Append(LIBS
=['efence'])
691 print "Warning: MySQL not available; " \
692 "forcing USE_MYSQL to False in", build_dir
+ "."
693 env
['USE_MYSQL'] = False
695 print "Compiling in", build_dir
, "with MySQL support."
696 env
.ParseConfig(mysql_config_libs
)
697 env
.ParseConfig(mysql_config_include
)
699 # Save sticky option settings back to current options file
700 sticky_opts
.Save(current_opts_file
, env
)
702 # Do this after we save setting back, or else we'll tack on an
703 # extra 'qdo' every time we run scons.
705 env
['CC'] = env
['BATCH_CMD'] + ' ' + env
['CC']
706 env
['CXX'] = env
['BATCH_CMD'] + ' ' + env
['CXX']
709 env
.Append(CCFLAGS
='-msse2')
711 # The src/SConscript file sets up the build rules in 'env' according
712 # to the configured options. It returns a list of environments,
713 # one for each variant build (debug, opt, etc.)
714 envList
= SConscript('src/SConscript', build_dir
= build_path
,
717 # Set up the regression tests for each build.
719 SConscript('tests/SConscript',
720 build_dir
= joinpath(build_path
, 'tests', e
.Label
),
721 exports
= { 'env' : e
}, duplicate
= False)
726 ###################################################
728 # Let SCons do its thing. At this point SCons will use the defined
729 # build environments to build the requested targets.
731 ###################################################