SConstruct revision 4120:3e09b5d32c45
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 66# Python library imports 67import sys 68import os 69import subprocess 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 194env.SConsignFile(joinpath(build_root,"sconsign")) 195 196# Default duplicate option is to use hard links, but this messes up 197# when you use emacs to edit a file in the target dir, as emacs moves 198# file to file~ then copies to file, breaking the link. Symbolic 199# (soft) links work better. 200env.SetOption('duplicate', 'soft-copy') 201 202# I waffle on this setting... it does avoid a few painful but 203# unnecessary builds, but it also seems to make trivial builds take 204# noticeably longer. 205if False: 206 env.TargetSignatures('content') 207 208# M5_PLY is used by isa_parser.py to find the PLY package. 209env.Append(ENV = { 'M5_PLY' : Dir('ext/ply') }) 210env['GCC'] = False 211env['SUNCC'] = False 212env['ICC'] = False 213env['GCC'] = subprocess.Popen(env['CXX'] + ' --version', shell=True, 214 stdout=subprocess.PIPE, stderr=subprocess.STDOUT, 215 close_fds=True).communicate()[0].find('GCC') >= 0 216env['SUNCC'] = subprocess.Popen(env['CXX'] + ' -V', shell=True, 217 stdout=subprocess.PIPE, stderr=subprocess.STDOUT, 218 close_fds=True).communicate()[0].find('Sun C++') >= 0 219env['ICC'] = subprocess.Popen(env['CXX'] + ' -V', shell=True, 220 stdout=subprocess.PIPE, stderr=subprocess.STDOUT, 221 close_fds=True).communicate()[0].find('Intel') >= 0 222if env['GCC'] + env['SUNCC'] + env['ICC'] > 1: 223 print 'Error: How can we have two at the same time?' 224 Exit(1) 225 226 227# Set up default C++ compiler flags 228if env['GCC']: 229 env.Append(CCFLAGS='-pipe') 230 env.Append(CCFLAGS='-fno-strict-aliasing') 231 env.Append(CCFLAGS=Split('-Wall -Wno-sign-compare -Werror -Wundef')) 232elif env['ICC']: 233 pass #Fix me... add warning flags once we clean up icc warnings 234elif env['SUNCC']: 235 env.Append(CCFLAGS='-Qoption ccfe') 236 env.Append(CCFLAGS='-features=gcc') 237 env.Append(CCFLAGS='-features=extensions') 238 env.Append(CCFLAGS='-library=stlport4') 239 env.Append(CCFLAGS='-xar') 240# env.Append(CCFLAGS='-instances=semiexplicit') 241else: 242 print 'Error: Don\'t know what compiler options to use for your compiler.' 243 print ' Please fix SConstruct and src/SConscript and try again.' 244 Exit(1) 245 246if sys.platform == 'cygwin': 247 # cygwin has some header file issues... 248 env.Append(CCFLAGS=Split("-Wno-uninitialized")) 249env.Append(CPPPATH=[Dir('ext/dnet')]) 250 251# Check for SWIG 252if not env.has_key('SWIG'): 253 print 'Error: SWIG utility not found.' 254 print ' Please install (see http://www.swig.org) and retry.' 255 Exit(1) 256 257# Check for appropriate SWIG version 258swig_version = os.popen('swig -version').read().split() 259# First 3 words should be "SWIG Version x.y.z" 260if swig_version[0] != 'SWIG' or swig_version[1] != 'Version': 261 print 'Error determining SWIG version.' 262 Exit(1) 263 264min_swig_version = '1.3.28' 265if compare_versions(swig_version[2], min_swig_version) < 0: 266 print 'Error: SWIG version', min_swig_version, 'or newer required.' 267 print ' Installed version:', swig_version[2] 268 Exit(1) 269 270# Set up SWIG flags & scanner 271env.Append(SWIGFLAGS=Split('-c++ -python -modern $_CPPINCFLAGS')) 272 273import SCons.Scanner 274 275swig_inc_re = '^[ \t]*[%,#][ \t]*(?:include|import)[ \t]*(<|")([^>"]+)(>|")' 276 277swig_scanner = SCons.Scanner.ClassicCPP("SwigScan", ".i", "CPPPATH", 278 swig_inc_re) 279 280env.Append(SCANNERS = swig_scanner) 281 282# Platform-specific configuration. Note again that we assume that all 283# builds under a given build root run on the same host platform. 284conf = Configure(env, 285 conf_dir = joinpath(build_root, '.scons_config'), 286 log_file = joinpath(build_root, 'scons_config.log')) 287 288# Find Python include and library directories for embedding the 289# interpreter. For consistency, we will use the same Python 290# installation used to run scons (and thus this script). If you want 291# to link in an alternate version, see above for instructions on how 292# to invoke scons with a different copy of the Python interpreter. 293 294# Get brief Python version name (e.g., "python2.4") for locating 295# include & library files 296py_version_name = 'python' + sys.version[:3] 297 298# include path, e.g. /usr/local/include/python2.4 299py_header_path = joinpath(sys.exec_prefix, 'include', py_version_name) 300env.Append(CPPPATH = py_header_path) 301# verify that it works 302if not conf.CheckHeader('Python.h', '<>'): 303 print "Error: can't find Python.h header in", py_header_path 304 Exit(1) 305 306# add library path too if it's not in the default place 307py_lib_path = None 308if sys.exec_prefix != '/usr': 309 py_lib_path = joinpath(sys.exec_prefix, 'lib') 310elif sys.platform == 'cygwin': 311 # cygwin puts the .dll in /bin for some reason 312 py_lib_path = '/bin' 313if py_lib_path: 314 env.Append(LIBPATH = py_lib_path) 315 print 'Adding', py_lib_path, 'to LIBPATH for', py_version_name 316if not conf.CheckLib(py_version_name): 317 print "Error: can't find Python library", py_version_name 318 Exit(1) 319 320# On Solaris you need to use libsocket for socket ops 321if not conf.CheckLibWithHeader(None, 'sys/socket.h', 'C++', 'accept(0,0,0);'): 322 if not conf.CheckLibWithHeader('socket', 'sys/socket.h', 'C++', 'accept(0,0,0);'): 323 print "Can't find library with socket calls (e.g. accept())" 324 Exit(1) 325 326# Check for zlib. If the check passes, libz will be automatically 327# added to the LIBS environment variable. 328if not conf.CheckLibWithHeader('z', 'zlib.h', 'C++','zlibVersion();'): 329 print 'Error: did not find needed zlib compression library '\ 330 'and/or zlib.h header file.' 331 print ' Please install zlib and try again.' 332 Exit(1) 333 334# Check for <fenv.h> (C99 FP environment control) 335have_fenv = conf.CheckHeader('fenv.h', '<>') 336if not have_fenv: 337 print "Warning: Header file <fenv.h> not found." 338 print " This host has no IEEE FP rounding mode control." 339 340# Check for mysql. 341mysql_config = WhereIs('mysql_config') 342have_mysql = mysql_config != None 343 344# Check MySQL version. 345if have_mysql: 346 mysql_version = os.popen(mysql_config + ' --version').read() 347 min_mysql_version = '4.1' 348 if compare_versions(mysql_version, min_mysql_version) < 0: 349 print 'Warning: MySQL', min_mysql_version, 'or newer required.' 350 print ' Version', mysql_version, 'detected.' 351 have_mysql = False 352 353# Set up mysql_config commands. 354if have_mysql: 355 mysql_config_include = mysql_config + ' --include' 356 if os.system(mysql_config_include + ' > /dev/null') != 0: 357 # older mysql_config versions don't support --include, use 358 # --cflags instead 359 mysql_config_include = mysql_config + ' --cflags | sed s/\\\'//g' 360 # This seems to work in all versions 361 mysql_config_libs = mysql_config + ' --libs' 362 363env = conf.Finish() 364 365# Define the universe of supported ISAs 366env['ALL_ISA_LIST'] = ['alpha', 'sparc', 'mips', 'x86'] 367 368# Define the universe of supported CPU models 369env['ALL_CPU_LIST'] = ['AtomicSimpleCPU', 'TimingSimpleCPU', 370 'O3CPU', 'OzoneCPU'] 371 372if os.path.isdir(joinpath(SRCDIR, 'encumbered/cpu/full')): 373 env['ALL_CPU_LIST'] += ['FullCPU'] 374 375# Sticky options get saved in the options file so they persist from 376# one invocation to the next (unless overridden, in which case the new 377# value becomes sticky). 378sticky_opts = Options(args=ARGUMENTS) 379sticky_opts.AddOptions( 380 EnumOption('TARGET_ISA', 'Target ISA', 'alpha', env['ALL_ISA_LIST']), 381 BoolOption('FULL_SYSTEM', 'Full-system support', False), 382 # There's a bug in scons 0.96.1 that causes ListOptions with list 383 # values (more than one value) not to be able to be restored from 384 # a saved option file. If this causes trouble then upgrade to 385 # scons 0.96.90 or later. 386 ListOption('CPU_MODELS', 'CPU models', 'AtomicSimpleCPU,TimingSimpleCPU,O3CPU', 387 env['ALL_CPU_LIST']), 388 BoolOption('ALPHA_TLASER', 389 'Model Alpha TurboLaser platform (vs. Tsunami)', False), 390 BoolOption('NO_FAST_ALLOC', 'Disable fast object allocator', False), 391 BoolOption('EFENCE', 'Link with Electric Fence malloc debugger', 392 False), 393 BoolOption('SS_COMPATIBLE_FP', 394 'Make floating-point results compatible with SimpleScalar', 395 False), 396 BoolOption('USE_SSE2', 397 'Compile for SSE2 (-msse2) to get IEEE FP on x86 hosts', 398 False), 399 BoolOption('USE_MYSQL', 'Use MySQL for stats output', have_mysql), 400 BoolOption('USE_FENV', 'Use <fenv.h> IEEE mode control', have_fenv), 401 BoolOption('USE_CHECKER', 'Use checker for detailed CPU models', False), 402 ('CC', 'C compiler', os.environ.get('CC', env['CC'])), 403 ('CXX', 'C++ compiler', os.environ.get('CXX', env['CXX'])), 404 BoolOption('BATCH', 'Use batch pool for build and tests', False), 405 ('BATCH_CMD', 'Batch pool submission command name', 'qdo'), 406 ('PYTHONHOME', 407 'Override the default PYTHONHOME for this system (use with caution)', 408 '%s:%s' % (sys.prefix, sys.exec_prefix)) 409 ) 410 411# Non-sticky options only apply to the current build. 412nonsticky_opts = Options(args=ARGUMENTS) 413nonsticky_opts.AddOptions( 414 BoolOption('update_ref', 'Update test reference outputs', False) 415 ) 416 417# These options get exported to #defines in config/*.hh (see src/SConscript). 418env.ExportOptions = ['FULL_SYSTEM', 'ALPHA_TLASER', 'USE_FENV', \ 419 'USE_MYSQL', 'NO_FAST_ALLOC', 'SS_COMPATIBLE_FP', \ 420 'USE_CHECKER', 'PYTHONHOME', 'TARGET_ISA'] 421 422# Define a handy 'no-op' action 423def no_action(target, source, env): 424 return 0 425 426env.NoAction = Action(no_action, None) 427 428################################################### 429# 430# Define a SCons builder for configuration flag headers. 431# 432################################################### 433 434# This function generates a config header file that #defines the 435# option symbol to the current option setting (0 or 1). The source 436# operands are the name of the option and a Value node containing the 437# value of the option. 438def build_config_file(target, source, env): 439 (option, value) = [s.get_contents() for s in source] 440 f = file(str(target[0]), 'w') 441 print >> f, '#define', option, value 442 f.close() 443 return None 444 445# Generate the message to be printed when building the config file. 446def build_config_file_string(target, source, env): 447 (option, value) = [s.get_contents() for s in source] 448 return "Defining %s as %s in %s." % (option, value, target[0]) 449 450# Combine the two functions into a scons Action object. 451config_action = Action(build_config_file, build_config_file_string) 452 453# The emitter munges the source & target node lists to reflect what 454# we're really doing. 455def config_emitter(target, source, env): 456 # extract option name from Builder arg 457 option = str(target[0]) 458 # True target is config header file 459 target = joinpath('config', option.lower() + '.hh') 460 val = env[option] 461 if isinstance(val, bool): 462 # Force value to 0/1 463 val = int(val) 464 elif isinstance(val, str): 465 val = '"' + val + '"' 466 467 # Sources are option name & value (packaged in SCons Value nodes) 468 return ([target], [Value(option), Value(val)]) 469 470config_builder = Builder(emitter = config_emitter, action = config_action) 471 472env.Append(BUILDERS = { 'ConfigFile' : config_builder }) 473 474################################################### 475# 476# Define a SCons builder for copying files. This is used by the 477# Python zipfile code in src/python/SConscript, but is placed up here 478# since it's potentially more generally applicable. 479# 480################################################### 481 482copy_builder = Builder(action = Copy("$TARGET", "$SOURCE")) 483 484env.Append(BUILDERS = { 'CopyFile' : copy_builder }) 485 486################################################### 487# 488# Define a simple SCons builder to concatenate files. 489# 490# Used to append the Python zip archive to the executable. 491# 492################################################### 493 494concat_builder = Builder(action = Action(['cat $SOURCES > $TARGET', 495 'chmod +x $TARGET'])) 496 497env.Append(BUILDERS = { 'Concat' : concat_builder }) 498 499 500# base help text 501help_text = ''' 502Usage: scons [scons options] [build options] [target(s)] 503 504''' 505 506# libelf build is shared across all configs in the build root. 507env.SConscript('ext/libelf/SConscript', 508 build_dir = joinpath(build_root, 'libelf'), 509 exports = 'env') 510 511################################################### 512# 513# This function is used to set up a directory with switching headers 514# 515################################################### 516 517def make_switching_dir(dirname, switch_headers, env): 518 # Generate the header. target[0] is the full path of the output 519 # header to generate. 'source' is a dummy variable, since we get the 520 # list of ISAs from env['ALL_ISA_LIST']. 521 def gen_switch_hdr(target, source, env): 522 fname = str(target[0]) 523 basename = os.path.basename(fname) 524 f = open(fname, 'w') 525 f.write('#include "arch/isa_specific.hh"\n') 526 cond = '#if' 527 for isa in env['ALL_ISA_LIST']: 528 f.write('%s THE_ISA == %s_ISA\n#include "%s/%s/%s"\n' 529 % (cond, isa.upper(), dirname, isa, basename)) 530 cond = '#elif' 531 f.write('#else\n#error "THE_ISA not set"\n#endif\n') 532 f.close() 533 return 0 534 535 # String to print when generating header 536 def gen_switch_hdr_string(target, source, env): 537 return "Generating switch header " + str(target[0]) 538 539 # Build SCons Action object. 'varlist' specifies env vars that this 540 # action depends on; when env['ALL_ISA_LIST'] changes these actions 541 # should get re-executed. 542 switch_hdr_action = Action(gen_switch_hdr, gen_switch_hdr_string, 543 varlist=['ALL_ISA_LIST']) 544 545 # Instantiate actions for each header 546 for hdr in switch_headers: 547 env.Command(hdr, [], switch_hdr_action) 548 549env.make_switching_dir = make_switching_dir 550 551################################################### 552# 553# Define build environments for selected configurations. 554# 555################################################### 556 557# rename base env 558base_env = env 559 560for build_path in build_paths: 561 print "Building in", build_path 562 # build_dir is the tail component of build path, and is used to 563 # determine the build parameters (e.g., 'ALPHA_SE') 564 (build_root, build_dir) = os.path.split(build_path) 565 # Make a copy of the build-root environment to use for this config. 566 env = base_env.Copy() 567 568 # Set env options according to the build directory config. 569 sticky_opts.files = [] 570 # Options for $BUILD_ROOT/$BUILD_DIR are stored in 571 # $BUILD_ROOT/options/$BUILD_DIR so you can nuke 572 # $BUILD_ROOT/$BUILD_DIR without losing your options settings. 573 current_opts_file = joinpath(build_root, 'options', build_dir) 574 if os.path.isfile(current_opts_file): 575 sticky_opts.files.append(current_opts_file) 576 print "Using saved options file %s" % current_opts_file 577 else: 578 # Build dir-specific options file doesn't exist. 579 580 # Make sure the directory is there so we can create it later 581 opt_dir = os.path.dirname(current_opts_file) 582 if not os.path.isdir(opt_dir): 583 os.mkdir(opt_dir) 584 585 # Get default build options from source tree. Options are 586 # normally determined by name of $BUILD_DIR, but can be 587 # overriden by 'default=' arg on command line. 588 default_opts_file = joinpath('build_opts', 589 ARGUMENTS.get('default', build_dir)) 590 if os.path.isfile(default_opts_file): 591 sticky_opts.files.append(default_opts_file) 592 print "Options file %s not found,\n using defaults in %s" \ 593 % (current_opts_file, default_opts_file) 594 else: 595 print "Error: cannot find options file %s or %s" \ 596 % (current_opts_file, default_opts_file) 597 Exit(1) 598 599 # Apply current option settings to env 600 sticky_opts.Update(env) 601 nonsticky_opts.Update(env) 602 603 help_text += "Sticky options for %s:\n" % build_dir \ 604 + sticky_opts.GenerateHelpText(env) \ 605 + "\nNon-sticky options for %s:\n" % build_dir \ 606 + nonsticky_opts.GenerateHelpText(env) 607 608 # Process option settings. 609 610 if not have_fenv and env['USE_FENV']: 611 print "Warning: <fenv.h> not available; " \ 612 "forcing USE_FENV to False in", build_dir + "." 613 env['USE_FENV'] = False 614 615 if not env['USE_FENV']: 616 print "Warning: No IEEE FP rounding mode control in", build_dir + "." 617 print " FP results may deviate slightly from other platforms." 618 619 if env['EFENCE']: 620 env.Append(LIBS=['efence']) 621 622 if env['USE_MYSQL']: 623 if not have_mysql: 624 print "Warning: MySQL not available; " \ 625 "forcing USE_MYSQL to False in", build_dir + "." 626 env['USE_MYSQL'] = False 627 else: 628 print "Compiling in", build_dir, "with MySQL support." 629 env.ParseConfig(mysql_config_libs) 630 env.ParseConfig(mysql_config_include) 631 632 # Save sticky option settings back to current options file 633 sticky_opts.Save(current_opts_file, env) 634 635 # Do this after we save setting back, or else we'll tack on an 636 # extra 'qdo' every time we run scons. 637 if env['BATCH']: 638 env['CC'] = env['BATCH_CMD'] + ' ' + env['CC'] 639 env['CXX'] = env['BATCH_CMD'] + ' ' + env['CXX'] 640 641 if env['USE_SSE2']: 642 env.Append(CCFLAGS='-msse2') 643 644 # The src/SConscript file sets up the build rules in 'env' according 645 # to the configured options. It returns a list of environments, 646 # one for each variant build (debug, opt, etc.) 647 envList = SConscript('src/SConscript', build_dir = build_path, 648 exports = 'env') 649 650 # Set up the regression tests for each build. 651 for e in envList: 652 SConscript('tests/SConscript', 653 build_dir = joinpath(build_path, 'tests', e.Label), 654 exports = { 'env' : e }, duplicate = False) 655 656Help(help_text) 657 658 659################################################### 660# 661# Let SCons do its thing. At this point SCons will use the defined 662# build environments to build the requested targets. 663# 664################################################### 665 666