SConstruct revision 4554
1# -*- mode:python -*- 2 3# Copyright (c) 2004-2005 The Regents of The University of Michigan 4# All rights reserved. 5# 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. 16# 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. 28# 29# Authors: Steve Reinhardt 30 31################################################### 32# 33# SCons top-level build description (SConstruct) file. 34# 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). 39# 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. 44# 45# Examples: 46# 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 51# 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 55# file. 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 58# 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 62# options as well. 63# 64################################################### 65 66import sys 67import os 68import subprocess 69 70from os.path import join as joinpath 71 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]". 78EnsurePythonVersion(2,4) 79 80# Ironically, SCons 0.96 dies if you give EnsureSconsVersion a 81# 3-element version number. 82min_scons_version = (0,96,91) 83try: 84 EnsureSConsVersion(*min_scons_version) 85except: 86 print "Error checking current SCons version." 87 print "SCons", ".".join(map(str,min_scons_version)), "or greater required." 88 Exit(2) 89 90 91# The absolute path to the current directory (where this file lives). 92ROOT = Dir('.').abspath 93 94# Path to the M5 source tree. 95SRCDIR = joinpath(ROOT, 'src') 96 97# tell python where to find m5 python code 98sys.path.append(joinpath(ROOT, 'src/python')) 99 100################################################### 101# 102# Figure out which configurations to set up based on the path(s) of 103# the target(s). 104# 105################################################### 106 107# Find default configuration & binary. 108Default(os.environ.get('M5_DEFAULT_BINARY', 'build/ALPHA_SE/m5.debug')) 109 110# helper function: find last occurrence of element in list 111def rfind(l, elt, offs = -1): 112 for i in range(len(l)+offs, 0, -1): 113 if l[i] == elt: 114 return i 115 raise ValueError, "element not found" 116 117# helper function: compare dotted version numbers. 118# E.g., compare_version('1.3.25', '1.4.1') 119# returns -1, 0, 1 if v1 is <, ==, > v2 120def compare_versions(v1, v2): 121 # Convert dotted strings to lists 122 v1 = map(int, v1.split('.')) 123 v2 = map(int, v2.split('.')) 124 # Compare corresponding elements of lists 125 for n1,n2 in zip(v1, v2): 126 if n1 < n2: return -1 127 if n1 > n2: return 1 128 # all corresponding values are equal... see if one has extra values 129 if len(v1) < len(v2): return -1 130 if len(v1) > len(v2): return 1 131 return 0 132 133# Each target must have 'build' in the interior of the path; the 134# directory below this will determine the build parameters. For 135# example, for target 'foo/bar/build/ALPHA_SE/arch/alpha/blah.do' we 136# recognize that ALPHA_SE specifies the configuration because it 137# follow 'build' in the bulid path. 138 139# Generate absolute paths to targets so we can see where the build dir is 140if COMMAND_LINE_TARGETS: 141 # Ask SCons which directory it was invoked from 142 launch_dir = GetLaunchDir() 143 # Make targets relative to invocation directory 144 abs_targets = map(lambda x: os.path.normpath(joinpath(launch_dir, str(x))), 145 COMMAND_LINE_TARGETS) 146else: 147 # Default targets are relative to root of tree 148 abs_targets = map(lambda x: os.path.normpath(joinpath(ROOT, str(x))), 149 DEFAULT_TARGETS) 150 151 152# Generate a list of the unique build roots and configs that the 153# collected targets reference. 154build_paths = [] 155build_root = None 156for t in abs_targets: 157 path_dirs = t.split('/') 158 try: 159 build_top = rfind(path_dirs, 'build', -2) 160 except: 161 print "Error: no non-leaf 'build' dir found on target path", t 162 Exit(1) 163 this_build_root = joinpath('/',*path_dirs[:build_top+1]) 164 if not build_root: 165 build_root = this_build_root 166 else: 167 if this_build_root != build_root: 168 print "Error: build targets not under same build root\n"\ 169 " %s\n %s" % (build_root, this_build_root) 170 Exit(1) 171 build_path = joinpath('/',*path_dirs[:build_top+2]) 172 if build_path not in build_paths: 173 build_paths.append(build_path) 174 175################################################### 176# 177# Set up the default build environment. This environment is copied 178# and modified according to each selected configuration. 179# 180################################################### 181 182env = Environment(ENV = os.environ, # inherit user's environment vars 183 ROOT = ROOT, 184 SRCDIR = SRCDIR) 185 186#Parse CC/CXX early so that we use the correct compiler for 187# to test for dependencies/versions/libraries/includes 188if ARGUMENTS.get('CC', None): 189 env['CC'] = ARGUMENTS.get('CC') 190 191if ARGUMENTS.get('CXX', None): 192 env['CXX'] = ARGUMENTS.get('CXX') 193 194Export('env') 195 196env.SConsignFile(joinpath(build_root,"sconsign")) 197 198# Default duplicate option is to use hard links, but this messes up 199# when you use emacs to edit a file in the target dir, as emacs moves 200# file to file~ then copies to file, breaking the link. Symbolic 201# (soft) links work better. 202env.SetOption('duplicate', 'soft-copy') 203 204# I waffle on this setting... it does avoid a few painful but 205# unnecessary builds, but it also seems to make trivial builds take 206# noticeably longer. 207if False: 208 env.TargetSignatures('content') 209 210# M5_PLY is used by isa_parser.py to find the PLY package. 211env.Append(ENV = { 'M5_PLY' : Dir('ext/ply') }) 212env['GCC'] = False 213env['SUNCC'] = False 214env['ICC'] = False 215env['GCC'] = subprocess.Popen(env['CXX'] + ' --version', shell=True, 216 stdout=subprocess.PIPE, stderr=subprocess.STDOUT, 217 close_fds=True).communicate()[0].find('GCC') >= 0 218env['SUNCC'] = subprocess.Popen(env['CXX'] + ' -V', shell=True, 219 stdout=subprocess.PIPE, stderr=subprocess.STDOUT, 220 close_fds=True).communicate()[0].find('Sun C++') >= 0 221env['ICC'] = subprocess.Popen(env['CXX'] + ' -V', shell=True, 222 stdout=subprocess.PIPE, stderr=subprocess.STDOUT, 223 close_fds=True).communicate()[0].find('Intel') >= 0 224if env['GCC'] + env['SUNCC'] + env['ICC'] > 1: 225 print 'Error: How can we have two at the same time?' 226 Exit(1) 227 228 229# Set up default C++ compiler flags 230if env['GCC']: 231 env.Append(CCFLAGS='-pipe') 232 env.Append(CCFLAGS='-fno-strict-aliasing') 233 env.Append(CCFLAGS=Split('-Wall -Wno-sign-compare -Werror -Wundef')) 234elif env['ICC']: 235 pass #Fix me... add warning flags once we clean up icc warnings 236elif env['SUNCC']: 237 env.Append(CCFLAGS='-Qoption ccfe') 238 env.Append(CCFLAGS='-features=gcc') 239 env.Append(CCFLAGS='-features=extensions') 240 env.Append(CCFLAGS='-library=stlport4') 241 env.Append(CCFLAGS='-xar') 242# env.Append(CCFLAGS='-instances=semiexplicit') 243else: 244 print 'Error: Don\'t know what compiler options to use for your compiler.' 245 print ' Please fix SConstruct and src/SConscript and try again.' 246 Exit(1) 247 248if sys.platform == 'cygwin': 249 # cygwin has some header file issues... 250 env.Append(CCFLAGS=Split("-Wno-uninitialized")) 251env.Append(CPPPATH=[Dir('ext/dnet')]) 252 253# Check for SWIG 254if not env.has_key('SWIG'): 255 print 'Error: SWIG utility not found.' 256 print ' Please install (see http://www.swig.org) and retry.' 257 Exit(1) 258 259# Check for appropriate SWIG version 260swig_version = os.popen('swig -version').read().split() 261# First 3 words should be "SWIG Version x.y.z" 262if swig_version[0] != 'SWIG' or swig_version[1] != 'Version': 263 print 'Error determining SWIG version.' 264 Exit(1) 265 266min_swig_version = '1.3.28' 267if compare_versions(swig_version[2], min_swig_version) < 0: 268 print 'Error: SWIG version', min_swig_version, 'or newer required.' 269 print ' Installed version:', swig_version[2] 270 Exit(1) 271 272# Set up SWIG flags & scanner 273swig_flags=Split('-c++ -python -modern -templatereduce $_CPPINCFLAGS') 274env.Append(SWIGFLAGS=swig_flags) 275 276# filter out all existing swig scanners, they mess up the dependency 277# stuff for some reason 278scanners = [] 279for scanner in env['SCANNERS']: 280 skeys = scanner.skeys 281 if skeys == '.i': 282 continue 283 284 if isinstance(skeys, (list, tuple)) and '.i' in skeys: 285 continue 286 287 scanners.append(scanner) 288 289# add the new swig scanner that we like better 290from SCons.Scanner import ClassicCPP as CPPScanner 291swig_inc_re = '^[ \t]*[%,#][ \t]*(?:include|import)[ \t]*(<|")([^>"]+)(>|")' 292scanners.append(CPPScanner("SwigScan", [ ".i" ], "CPPPATH", swig_inc_re)) 293 294# replace the scanners list that has what we want 295env['SCANNERS'] = scanners 296 297# Platform-specific configuration. Note again that we assume that all 298# builds under a given build root run on the same host platform. 299conf = Configure(env, 300 conf_dir = joinpath(build_root, '.scons_config'), 301 log_file = joinpath(build_root, 'scons_config.log')) 302 303# Find Python include and library directories for embedding the 304# interpreter. For consistency, we will use the same Python 305# installation used to run scons (and thus this script). If you want 306# to link in an alternate version, see above for instructions on how 307# to invoke scons with a different copy of the Python interpreter. 308 309# Get brief Python version name (e.g., "python2.4") for locating 310# include & library files 311py_version_name = 'python' + sys.version[:3] 312 313# include path, e.g. /usr/local/include/python2.4 314py_header_path = joinpath(sys.exec_prefix, 'include', py_version_name) 315env.Append(CPPPATH = py_header_path) 316# verify that it works 317if not conf.CheckHeader('Python.h', '<>'): 318 print "Error: can't find Python.h header in", py_header_path 319 Exit(1) 320 321# add library path too if it's not in the default place 322py_lib_path = None 323if sys.exec_prefix != '/usr': 324 py_lib_path = joinpath(sys.exec_prefix, 'lib') 325elif sys.platform == 'cygwin': 326 # cygwin puts the .dll in /bin for some reason 327 py_lib_path = '/bin' 328if py_lib_path: 329 env.Append(LIBPATH = py_lib_path) 330 print 'Adding', py_lib_path, 'to LIBPATH for', py_version_name 331if not conf.CheckLib(py_version_name): 332 print "Error: can't find Python library", py_version_name 333 Exit(1) 334 335# On Solaris you need to use libsocket for socket ops 336if not conf.CheckLibWithHeader(None, 'sys/socket.h', 'C++', 'accept(0,0,0);'): 337 if not conf.CheckLibWithHeader('socket', 'sys/socket.h', 'C++', 'accept(0,0,0);'): 338 print "Can't find library with socket calls (e.g. accept())" 339 Exit(1) 340 341# Check for zlib. If the check passes, libz will be automatically 342# added to the LIBS environment variable. 343if not conf.CheckLibWithHeader('z', 'zlib.h', 'C++','zlibVersion();'): 344 print 'Error: did not find needed zlib compression library '\ 345 'and/or zlib.h header file.' 346 print ' Please install zlib and try again.' 347 Exit(1) 348 349# Check for <fenv.h> (C99 FP environment control) 350have_fenv = conf.CheckHeader('fenv.h', '<>') 351if not have_fenv: 352 print "Warning: Header file <fenv.h> not found." 353 print " This host has no IEEE FP rounding mode control." 354 355# Check for mysql. 356mysql_config = WhereIs('mysql_config') 357have_mysql = mysql_config != None 358 359# Check MySQL version. 360if have_mysql: 361 mysql_version = os.popen(mysql_config + ' --version').read() 362 min_mysql_version = '4.1' 363 if compare_versions(mysql_version, min_mysql_version) < 0: 364 print 'Warning: MySQL', min_mysql_version, 'or newer required.' 365 print ' Version', mysql_version, 'detected.' 366 have_mysql = False 367 368# Set up mysql_config commands. 369if have_mysql: 370 mysql_config_include = mysql_config + ' --include' 371 if os.system(mysql_config_include + ' > /dev/null') != 0: 372 # older mysql_config versions don't support --include, use 373 # --cflags instead 374 mysql_config_include = mysql_config + ' --cflags | sed s/\\\'//g' 375 # This seems to work in all versions 376 mysql_config_libs = mysql_config + ' --libs' 377 378env = conf.Finish() 379 380# Define the universe of supported ISAs 381all_isa_list = [ ] 382Export('all_isa_list') 383 384# Define the universe of supported CPU models 385all_cpu_list = [ ] 386default_cpus = [ ] 387Export('all_cpu_list', 'default_cpus') 388 389# Sticky options get saved in the options file so they persist from 390# one invocation to the next (unless overridden, in which case the new 391# value becomes sticky). 392sticky_opts = Options(args=ARGUMENTS) 393Export('sticky_opts') 394 395# Non-sticky options only apply to the current build. 396nonsticky_opts = Options(args=ARGUMENTS) 397Export('nonsticky_opts') 398 399# Walk the tree and execute all SConsopts scripts that wil add to the 400# above options 401for root, dirs, files in os.walk('.'): 402 if 'SConsopts' in files: 403 SConscript(os.path.join(root, 'SConsopts')) 404 405all_isa_list.sort() 406all_cpu_list.sort() 407default_cpus.sort() 408 409sticky_opts.AddOptions( 410 EnumOption('TARGET_ISA', 'Target ISA', 'alpha', all_isa_list), 411 BoolOption('FULL_SYSTEM', 'Full-system support', False), 412 # There's a bug in scons 0.96.1 that causes ListOptions with list 413 # values (more than one value) not to be able to be restored from 414 # a saved option file. If this causes trouble then upgrade to 415 # scons 0.96.90 or later. 416 ListOption('CPU_MODELS', 'CPU models', default_cpus, all_cpu_list), 417 BoolOption('NO_FAST_ALLOC', 'Disable fast object allocator', False), 418 BoolOption('EFENCE', 'Link with Electric Fence malloc debugger', 419 False), 420 BoolOption('SS_COMPATIBLE_FP', 421 'Make floating-point results compatible with SimpleScalar', 422 False), 423 BoolOption('USE_SSE2', 424 'Compile for SSE2 (-msse2) to get IEEE FP on x86 hosts', 425 False), 426 BoolOption('USE_MYSQL', 'Use MySQL for stats output', have_mysql), 427 BoolOption('USE_FENV', 'Use <fenv.h> IEEE mode control', have_fenv), 428 BoolOption('USE_CHECKER', 'Use checker for detailed CPU models', False), 429 ('CC', 'C compiler', os.environ.get('CC', env['CC'])), 430 ('CXX', 'C++ compiler', os.environ.get('CXX', env['CXX'])), 431 BoolOption('BATCH', 'Use batch pool for build and tests', False), 432 ('BATCH_CMD', 'Batch pool submission command name', 'qdo'), 433 ('PYTHONHOME', 434 'Override the default PYTHONHOME for this system (use with caution)', 435 '%s:%s' % (sys.prefix, sys.exec_prefix)) 436 ) 437 438nonsticky_opts.AddOptions( 439 BoolOption('update_ref', 'Update test reference outputs', False) 440 ) 441 442# These options get exported to #defines in config/*.hh (see src/SConscript). 443env.ExportOptions = ['FULL_SYSTEM', 'ALPHA_TLASER', 'USE_FENV', \ 444 'USE_MYSQL', 'NO_FAST_ALLOC', 'SS_COMPATIBLE_FP', \ 445 'USE_CHECKER', 'PYTHONHOME', 'TARGET_ISA'] 446 447# Define a handy 'no-op' action 448def no_action(target, source, env): 449 return 0 450 451env.NoAction = Action(no_action, None) 452 453################################################### 454# 455# Define a SCons builder for configuration flag headers. 456# 457################################################### 458 459# This function generates a config header file that #defines the 460# option symbol to the current option setting (0 or 1). The source 461# operands are the name of the option and a Value node containing the 462# value of the option. 463def build_config_file(target, source, env): 464 (option, value) = [s.get_contents() for s in source] 465 f = file(str(target[0]), 'w') 466 print >> f, '#define', option, value 467 f.close() 468 return None 469 470# Generate the message to be printed when building the config file. 471def build_config_file_string(target, source, env): 472 (option, value) = [s.get_contents() for s in source] 473 return "Defining %s as %s in %s." % (option, value, target[0]) 474 475# Combine the two functions into a scons Action object. 476config_action = Action(build_config_file, build_config_file_string) 477 478# The emitter munges the source & target node lists to reflect what 479# we're really doing. 480def config_emitter(target, source, env): 481 # extract option name from Builder arg 482 option = str(target[0]) 483 # True target is config header file 484 target = joinpath('config', option.lower() + '.hh') 485 val = env[option] 486 if isinstance(val, bool): 487 # Force value to 0/1 488 val = int(val) 489 elif isinstance(val, str): 490 val = '"' + val + '"' 491 492 # Sources are option name & value (packaged in SCons Value nodes) 493 return ([target], [Value(option), Value(val)]) 494 495config_builder = Builder(emitter = config_emitter, action = config_action) 496 497env.Append(BUILDERS = { 'ConfigFile' : config_builder }) 498 499################################################### 500# 501# Define a SCons builder for copying files. This is used by the 502# Python zipfile code in src/python/SConscript, but is placed up here 503# since it's potentially more generally applicable. 504# 505################################################### 506 507copy_builder = Builder(action = Copy("$TARGET", "$SOURCE")) 508 509env.Append(BUILDERS = { 'CopyFile' : copy_builder }) 510 511################################################### 512# 513# Define a simple SCons builder to concatenate files. 514# 515# Used to append the Python zip archive to the executable. 516# 517################################################### 518 519concat_builder = Builder(action = Action(['cat $SOURCES > $TARGET', 520 'chmod +x $TARGET'])) 521 522env.Append(BUILDERS = { 'Concat' : concat_builder }) 523 524 525# base help text 526help_text = ''' 527Usage: scons [scons options] [build options] [target(s)] 528 529''' 530 531# libelf build is shared across all configs in the build root. 532env.SConscript('ext/libelf/SConscript', 533 build_dir = joinpath(build_root, 'libelf'), 534 exports = 'env') 535 536################################################### 537# 538# This function is used to set up a directory with switching headers 539# 540################################################### 541 542env['ALL_ISA_LIST'] = all_isa_list 543def make_switching_dir(dirname, switch_headers, env): 544 # Generate the header. target[0] is the full path of the output 545 # header to generate. 'source' is a dummy variable, since we get the 546 # list of ISAs from env['ALL_ISA_LIST']. 547 def gen_switch_hdr(target, source, env): 548 fname = str(target[0]) 549 basename = os.path.basename(fname) 550 f = open(fname, 'w') 551 f.write('#include "arch/isa_specific.hh"\n') 552 cond = '#if' 553 for isa in all_isa_list: 554 f.write('%s THE_ISA == %s_ISA\n#include "%s/%s/%s"\n' 555 % (cond, isa.upper(), dirname, isa, basename)) 556 cond = '#elif' 557 f.write('#else\n#error "THE_ISA not set"\n#endif\n') 558 f.close() 559 return 0 560 561 # String to print when generating header 562 def gen_switch_hdr_string(target, source, env): 563 return "Generating switch header " + str(target[0]) 564 565 # Build SCons Action object. 'varlist' specifies env vars that this 566 # action depends on; when env['ALL_ISA_LIST'] changes these actions 567 # should get re-executed. 568 switch_hdr_action = Action(gen_switch_hdr, gen_switch_hdr_string, 569 varlist=['ALL_ISA_LIST']) 570 571 # Instantiate actions for each header 572 for hdr in switch_headers: 573 env.Command(hdr, [], switch_hdr_action) 574Export('make_switching_dir') 575 576################################################### 577# 578# Define build environments for selected configurations. 579# 580################################################### 581 582# rename base env 583base_env = env 584 585for build_path in build_paths: 586 print "Building in", build_path 587 # build_dir is the tail component of build path, and is used to 588 # determine the build parameters (e.g., 'ALPHA_SE') 589 (build_root, build_dir) = os.path.split(build_path) 590 # Make a copy of the build-root environment to use for this config. 591 env = base_env.Copy() 592 593 # Set env options according to the build directory config. 594 sticky_opts.files = [] 595 # Options for $BUILD_ROOT/$BUILD_DIR are stored in 596 # $BUILD_ROOT/options/$BUILD_DIR so you can nuke 597 # $BUILD_ROOT/$BUILD_DIR without losing your options settings. 598 current_opts_file = joinpath(build_root, 'options', build_dir) 599 if os.path.isfile(current_opts_file): 600 sticky_opts.files.append(current_opts_file) 601 print "Using saved options file %s" % current_opts_file 602 else: 603 # Build dir-specific options file doesn't exist. 604 605 # Make sure the directory is there so we can create it later 606 opt_dir = os.path.dirname(current_opts_file) 607 if not os.path.isdir(opt_dir): 608 os.mkdir(opt_dir) 609 610 # Get default build options from source tree. Options are 611 # normally determined by name of $BUILD_DIR, but can be 612 # overriden by 'default=' arg on command line. 613 default_opts_file = joinpath('build_opts', 614 ARGUMENTS.get('default', build_dir)) 615 if os.path.isfile(default_opts_file): 616 sticky_opts.files.append(default_opts_file) 617 print "Options file %s not found,\n using defaults in %s" \ 618 % (current_opts_file, default_opts_file) 619 else: 620 print "Error: cannot find options file %s or %s" \ 621 % (current_opts_file, default_opts_file) 622 Exit(1) 623 624 # Apply current option settings to env 625 sticky_opts.Update(env) 626 nonsticky_opts.Update(env) 627 628 help_text += "Sticky options for %s:\n" % build_dir \ 629 + sticky_opts.GenerateHelpText(env) \ 630 + "\nNon-sticky options for %s:\n" % build_dir \ 631 + nonsticky_opts.GenerateHelpText(env) 632 633 # Process option settings. 634 635 if not have_fenv and env['USE_FENV']: 636 print "Warning: <fenv.h> not available; " \ 637 "forcing USE_FENV to False in", build_dir + "." 638 env['USE_FENV'] = False 639 640 if not env['USE_FENV']: 641 print "Warning: No IEEE FP rounding mode control in", build_dir + "." 642 print " FP results may deviate slightly from other platforms." 643 644 if env['EFENCE']: 645 env.Append(LIBS=['efence']) 646 647 if env['USE_MYSQL']: 648 if not have_mysql: 649 print "Warning: MySQL not available; " \ 650 "forcing USE_MYSQL to False in", build_dir + "." 651 env['USE_MYSQL'] = False 652 else: 653 print "Compiling in", build_dir, "with MySQL support." 654 env.ParseConfig(mysql_config_libs) 655 env.ParseConfig(mysql_config_include) 656 657 # Save sticky option settings back to current options file 658 sticky_opts.Save(current_opts_file, env) 659 660 # Do this after we save setting back, or else we'll tack on an 661 # extra 'qdo' every time we run scons. 662 if env['BATCH']: 663 env['CC'] = env['BATCH_CMD'] + ' ' + env['CC'] 664 env['CXX'] = env['BATCH_CMD'] + ' ' + env['CXX'] 665 666 if env['USE_SSE2']: 667 env.Append(CCFLAGS='-msse2') 668 669 # The src/SConscript file sets up the build rules in 'env' according 670 # to the configured options. It returns a list of environments, 671 # one for each variant build (debug, opt, etc.) 672 envList = SConscript('src/SConscript', build_dir = build_path, 673 exports = 'env') 674 675 # Set up the regression tests for each build. 676 for e in envList: 677 SConscript('tests/SConscript', 678 build_dir = joinpath(build_path, 'tests', e.Label), 679 exports = { 'env' : e }, duplicate = False) 680 681Help(help_text) 682 683 684################################################### 685# 686# Let SCons do its thing. At this point SCons will use the defined 687# build environments to build the requested targets. 688# 689################################################### 690 691