SConstruct revision 2655
1955SN/A# -*- mode:python -*-
2955SN/A
31762SN/A# Copyright (c) 2004-2005 The Regents of The University of Michigan
4955SN/A# All rights reserved.
5955SN/A#
6955SN/A# Redistribution and use in source and binary forms, with or without
7955SN/A# modification, are permitted provided that the following conditions are
8955SN/A# met: redistributions of source code must retain the above copyright
9955SN/A# notice, this list of conditions and the following disclaimer;
10955SN/A# redistributions in binary form must reproduce the above copyright
11955SN/A# notice, this list of conditions and the following disclaimer in the
12955SN/A# documentation and/or other materials provided with the distribution;
13955SN/A# neither the name of the copyright holders nor the names of its
14955SN/A# contributors may be used to endorse or promote products derived from
15955SN/A# this software without specific prior written permission.
16955SN/A#
17955SN/A# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18955SN/A# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19955SN/A# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20955SN/A# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21955SN/A# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22955SN/A# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23955SN/A# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24955SN/A# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25955SN/A# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26955SN/A# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27955SN/A# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28955SN/A
29955SN/A###################################################
30955SN/A#
31955SN/A# SCons top-level build description (SConstruct) file.
32955SN/A#
332632Sstever@eecs.umich.edu# While in this directory ('m5'), just type 'scons' to build the default
342632Sstever@eecs.umich.edu# configuration (see below), or type 'scons build/<CONFIG>/<binary>'
352632Sstever@eecs.umich.edu# to build some other configuration (e.g., 'build/ALPHA_FS/m5.opt' for
362632Sstever@eecs.umich.edu# the optimized full-system version).
37955SN/A#
382632Sstever@eecs.umich.edu# You can build M5 in a different directory as long as there is a
392632Sstever@eecs.umich.edu# 'build/<CONFIG>' somewhere along the target path.  The build system
402632Sstever@eecs.umich.edu# expdects that all configs under the same build directory are being
412632Sstever@eecs.umich.edu# built for the same host system.
422632Sstever@eecs.umich.edu#
432632Sstever@eecs.umich.edu# Examples:
442632Sstever@eecs.umich.edu#   These two commands are equivalent.  The '-u' option tells scons to
452632Sstever@eecs.umich.edu#   search up the directory tree for this SConstruct file.
462632Sstever@eecs.umich.edu#   % cd <path-to-src>/m5 ; scons build/ALPHA_FS/m5.debug
472632Sstever@eecs.umich.edu#   % cd <path-to-src>/m5/build/ALPHA_FS; scons -u m5.debug
482632Sstever@eecs.umich.edu#   These two commands are equivalent and demonstrate building in a
492632Sstever@eecs.umich.edu#   directory outside of the source tree.  The '-C' option tells scons
502632Sstever@eecs.umich.edu#   to chdir to the specified directory to find this SConstruct file.
512632Sstever@eecs.umich.edu#   % cd <path-to-src>/m5 ; scons /local/foo/build/ALPHA_FS/m5.debug
522632Sstever@eecs.umich.edu#   % cd /local/foo/build/ALPHA_FS; scons -C <path-to-src>/m5 m5.debug
532632Sstever@eecs.umich.edu#
542632Sstever@eecs.umich.edu# You can use 'scons -H' to print scons options.  If you're in this
552632Sstever@eecs.umich.edu# 'm5' directory (or use -u or -C to tell scons where to find this
562632Sstever@eecs.umich.edu# file), you can use 'scons -h' to print all the M5-specific build
572632Sstever@eecs.umich.edu# options as well.
58955SN/A#
59955SN/A###################################################
60955SN/A
61955SN/A# Python library imports
62955SN/Aimport sys
63955SN/Aimport os
64955SN/A
651858SN/A# Check for recent-enough Python and SCons versions
661858SN/AEnsurePythonVersion(2,3)
672632Sstever@eecs.umich.edu
681852SN/A# Ironically, SCons 0.96 dies if you give EnsureSconsVersion a
69955SN/A# 3-element version number.
70955SN/Amin_scons_version = (0,96,91)
71955SN/Atry:
722632Sstever@eecs.umich.edu    EnsureSConsVersion(*min_scons_version)
732632Sstever@eecs.umich.eduexcept:
74955SN/A    print "Error checking current SCons version."
751533SN/A    print "SCons", ".".join(map(str,min_scons_version)), "or greater required."
762632Sstever@eecs.umich.edu    Exit(2)
771533SN/A    
78955SN/A
79955SN/A# The absolute path to the current directory (where this file lives).
802632Sstever@eecs.umich.eduROOT = Dir('.').abspath
812632Sstever@eecs.umich.edu
82955SN/A# Paths to the M5 and external source trees.
83955SN/ASRCDIR = os.path.join(ROOT, 'src')
84955SN/A
85955SN/A# tell python where to find m5 python code
862632Sstever@eecs.umich.edusys.path.append(os.path.join(ROOT, 'src/python'))
87955SN/A
882632Sstever@eecs.umich.edu###################################################
89955SN/A#
90955SN/A# Figure out which configurations to set up based on the path(s) of
912632Sstever@eecs.umich.edu# the target(s).
922632Sstever@eecs.umich.edu#
932632Sstever@eecs.umich.edu###################################################
942632Sstever@eecs.umich.edu
952632Sstever@eecs.umich.edu# Find default configuration & binary.
962632Sstever@eecs.umich.eduDefault(os.environ.get('M5_DEFAULT_BINARY', 'build/ALPHA_SE/m5.debug'))
972632Sstever@eecs.umich.edu
982632Sstever@eecs.umich.edu# Ask SCons which directory it was invoked from.
992632Sstever@eecs.umich.edulaunch_dir = GetLaunchDir()
1002632Sstever@eecs.umich.edu
1012632Sstever@eecs.umich.edu# Make targets relative to invocation directory
1022632Sstever@eecs.umich.eduabs_targets = map(lambda x: os.path.normpath(os.path.join(launch_dir, str(x))),
1032632Sstever@eecs.umich.edu                  BUILD_TARGETS)
1042632Sstever@eecs.umich.edu
1052632Sstever@eecs.umich.edu# helper function: find last occurrence of element in list
1062632Sstever@eecs.umich.edudef rfind(l, elt, offs = -1):
1072632Sstever@eecs.umich.edu    for i in range(len(l)+offs, 0, -1):
1082634Sstever@eecs.umich.edu        if l[i] == elt:
1092634Sstever@eecs.umich.edu            return i
1102632Sstever@eecs.umich.edu    raise ValueError, "element not found"
1112634Sstever@eecs.umich.edu
1122632Sstever@eecs.umich.edu# Each target must have 'build' in the interior of the path; the
1132632Sstever@eecs.umich.edu# directory below this will determine the build parameters.  For
1142632Sstever@eecs.umich.edu# example, for target 'foo/bar/build/ALPHA_SE/arch/alpha/blah.do' we
1152632Sstever@eecs.umich.edu# recognize that ALPHA_SE specifies the configuration because it
1162632Sstever@eecs.umich.edu# follow 'build' in the bulid path.
1172632Sstever@eecs.umich.edu
1181858SN/A# Generate a list of the unique build roots and configs that the
1192634Sstever@eecs.umich.edu# collected targets reference.
1202634Sstever@eecs.umich.edubuild_paths = []
1212634Sstever@eecs.umich.edubuild_root = None
1222634Sstever@eecs.umich.edufor t in abs_targets:
1232634Sstever@eecs.umich.edu    path_dirs = t.split('/')
1242634Sstever@eecs.umich.edu    try:
125955SN/A        build_top = rfind(path_dirs, 'build', -2)
126955SN/A    except:
127955SN/A        print "Error: no non-leaf 'build' dir found on target path", t
128955SN/A        Exit(1)
129955SN/A    this_build_root = os.path.join('/',*path_dirs[:build_top+1])
130955SN/A    if not build_root:
131955SN/A        build_root = this_build_root
132955SN/A    else:
1331858SN/A        if this_build_root != build_root:
1341858SN/A            print "Error: build targets not under same build root\n"\
1352632Sstever@eecs.umich.edu                  "  %s\n  %s" % (build_root, this_build_root)
136955SN/A            Exit(1)
1371858SN/A    build_path = os.path.join('/',*path_dirs[:build_top+2])
1381105SN/A    if build_path not in build_paths:
1391869SN/A        build_paths.append(build_path)
1401869SN/A
1411869SN/A###################################################
1421869SN/A#
1431869SN/A# Set up the default build environment.  This environment is copied
1441065SN/A# and modified according to each selected configuration.
1452632Sstever@eecs.umich.edu#
1462632Sstever@eecs.umich.edu###################################################
147955SN/A
1481858SN/Aenv = Environment(ENV = os.environ,  # inherit user's environment vars
1491858SN/A                  ROOT = ROOT,
1501858SN/A                  SRCDIR = SRCDIR)
1511858SN/A
1521851SN/Aenv.SConsignFile("sconsign")
1531851SN/A
1541858SN/A# I waffle on this setting... it does avoid a few painful but
1552632Sstever@eecs.umich.edu# unnecessary builds, but it also seems to make trivial builds take
156955SN/A# noticeably longer.
1571858SN/Aif False:
1581858SN/A    env.TargetSignatures('content')
1591858SN/A
1601858SN/A# M5_PLY is used by isa_parser.py to find the PLY package.
1611858SN/Aenv.Append(ENV = { 'M5_PLY' : Dir('ext/ply') })
1621858SN/A
1631858SN/A# Set up default C++ compiler flags
1641858SN/Aenv.Append(CCFLAGS='-pipe')
1651858SN/Aenv.Append(CCFLAGS='-fno-strict-aliasing')
1661858SN/Aenv.Append(CCFLAGS=Split('-Wall -Wno-sign-compare -Werror -Wundef'))
1671858SN/Aif sys.platform == 'cygwin':
1681858SN/A    # cygwin has some header file issues...
1691859SN/A    env.Append(CCFLAGS=Split("-Wno-uninitialized"))
1701858SN/Aenv.Append(CPPPATH=[Dir('ext/dnet')])
1711858SN/A
1721858SN/A# Environment args for linking in Python interpreter.
1731859SN/A# Should really have an option for setting the version instead of
1741859SN/A# having 2.4 hardwired in here...
1751862SN/Aenv.Append(CPPPATH='/usr/include/python2.4')
1761862SN/Aenv.Append(LIBS='python2.4')
1771862SN/A
1781862SN/A# Other default libraries
1791859SN/Aenv.Append(LIBS=['z'])
1801859SN/A
1811963SN/A# Platform-specific configuration.  Note again that we assume that all
1821963SN/A# builds under a given build root run on the same host platform.
1831859SN/Aconf = Configure(env,
1841859SN/A                 conf_dir = os.path.join(build_root, '.scons_config'),
1851859SN/A                 log_file = os.path.join(build_root, 'scons_config.log'))
1861859SN/A
1871859SN/A# Check for <fenv.h> (C99 FP environment control)
1881859SN/Ahave_fenv = conf.CheckHeader('fenv.h', '<>')
1891859SN/Aif not have_fenv:
1901859SN/A    print "Warning: Header file <fenv.h> not found."
1911862SN/A    print "         This host has no IEEE FP rounding mode control."
1921859SN/A
1931859SN/A# Check for mysql.
1941859SN/Amysql_config = WhereIs('mysql_config')
1951858SN/Ahave_mysql = mysql_config != None
1961858SN/A
1972139SN/A# Check MySQL version.
1982139SN/Aif have_mysql:
1992139SN/A    mysql_version = os.popen(mysql_config + ' --version').read()
2002155SN/A    mysql_version = mysql_version.split('.')
2012623SN/A    mysql_major = int(mysql_version[0])
2022623SN/A    mysql_minor = int(mysql_version[1])
2032155SN/A    # This version check is probably overly conservative, but it deals
2041869SN/A    # with the versions we have installed.
2051869SN/A    if mysql_major < 4 or (mysql_major == 4 and mysql_minor < 1):
2061869SN/A        print "Warning: MySQL v4.1 or newer required."
2071869SN/A        have_mysql = False
2081869SN/A
2092139SN/A# Set up mysql_config commands.
2101869SN/Aif have_mysql:
2112508SN/A    mysql_config_include = mysql_config + ' --include'
2122508SN/A    if os.system(mysql_config_include + ' > /dev/null') != 0:
2132508SN/A        # older mysql_config versions don't support --include, use
2142508SN/A        # --cflags instead
2152635Sstever@eecs.umich.edu        mysql_config_include = mysql_config + ' --cflags | sed s/\\\'//g'
2162635Sstever@eecs.umich.edu    # This seems to work in all versions
2171869SN/A    mysql_config_libs = mysql_config + ' --libs'
2181869SN/A
2191869SN/Aenv = conf.Finish()
2201869SN/A
2211869SN/A# Define the universe of supported ISAs
2221869SN/Aenv['ALL_ISA_LIST'] = ['alpha', 'sparc', 'mips']
2231869SN/A
2241869SN/A# Define the universe of supported CPU models
2251965SN/Aenv['ALL_CPU_LIST'] = ['AtomicSimpleCPU', 'TimingSimpleCPU',
2261965SN/A                       'FullCPU', 'AlphaFullCPU']
2271965SN/A
2281869SN/A# Sticky options get saved in the options file so they persist from
2291869SN/A# one invocation to the next (unless overridden, in which case the new
2301869SN/A# value becomes sticky).
2311869SN/Asticky_opts = Options(args=ARGUMENTS)
2321884SN/Asticky_opts.AddOptions(
2331884SN/A    EnumOption('TARGET_ISA', 'Target ISA', 'alpha', env['ALL_ISA_LIST']),
2341884SN/A    BoolOption('FULL_SYSTEM', 'Full-system support', False),
2351869SN/A    # There's a bug in scons 0.96.1 that causes ListOptions with list
2361858SN/A    # values (more than one value) not to be able to be restored from
2371869SN/A    # a saved option file.  If this causes trouble then upgrade to
2381869SN/A    # scons 0.96.90 or later.
2391869SN/A    ListOption('CPU_MODELS', 'CPU models', 'AtomicSimpleCPU,TimingSimpleCPU',
2401869SN/A               env['ALL_CPU_LIST']),
2411869SN/A    BoolOption('ALPHA_TLASER',
2421858SN/A               'Model Alpha TurboLaser platform (vs. Tsunami)', False),
2431869SN/A    BoolOption('NO_FAST_ALLOC', 'Disable fast object allocator', False),
2441869SN/A    BoolOption('EFENCE', 'Link with Electric Fence malloc debugger',
2451869SN/A               False),
2461869SN/A    BoolOption('SS_COMPATIBLE_FP',
2471869SN/A               'Make floating-point results compatible with SimpleScalar',
2481869SN/A               False),
2491869SN/A    BoolOption('USE_SSE2',
2501869SN/A               'Compile for SSE2 (-msse2) to get IEEE FP on x86 hosts',
2511869SN/A               False),
2521869SN/A    BoolOption('STATS_BINNING', 'Bin statistics by CPU mode', have_mysql),
2531858SN/A    BoolOption('USE_MYSQL', 'Use MySQL for stats output', have_mysql),
254955SN/A    BoolOption('USE_FENV', 'Use <fenv.h> IEEE mode control', have_fenv),
255955SN/A    ('CC', 'C compiler', os.environ.get('CC', env['CC'])),
2561869SN/A    ('CXX', 'C++ compiler', os.environ.get('CXX', env['CXX'])),
2571869SN/A    BoolOption('BATCH', 'Use batch pool for build and tests', False),
2581869SN/A    ('BATCH_CMD', 'Batch pool submission command name', 'qdo')
2591869SN/A    )
2601869SN/A
2611869SN/A# Non-sticky options only apply to the current build.
2621869SN/Anonsticky_opts = Options(args=ARGUMENTS)
2631869SN/Anonsticky_opts.AddOptions(
2641869SN/A    BoolOption('update_ref', 'Update test reference outputs', False)
2651869SN/A    )
2661869SN/A
2671869SN/A# These options get exported to #defines in config/*.hh (see m5/SConscript).
2681869SN/Aenv.ExportOptions = ['FULL_SYSTEM', 'ALPHA_TLASER', 'USE_FENV', \
2691869SN/A                     'USE_MYSQL', 'NO_FAST_ALLOC', 'SS_COMPATIBLE_FP', \
2701869SN/A                     'STATS_BINNING']
2711869SN/A
2721869SN/A# Define a handy 'no-op' action
2731869SN/Adef no_action(target, source, env):
2741869SN/A    return 0
2751869SN/A
2761869SN/Aenv.NoAction = Action(no_action, None)
2771869SN/A
2781869SN/A###################################################
2791869SN/A#
2801869SN/A# Define a SCons builder for configuration flag headers.
2811869SN/A#
2821869SN/A###################################################
2831869SN/A
2841869SN/A# This function generates a config header file that #defines the
2851869SN/A# option symbol to the current option setting (0 or 1).  The source
2861869SN/A# operands are the name of the option and a Value node containing the
2871869SN/A# value of the option.
2881869SN/Adef build_config_file(target, source, env):
2891869SN/A    (option, value) = [s.get_contents() for s in source]
2901869SN/A    f = file(str(target[0]), 'w')
2911869SN/A    print >> f, '#define', option, value
2921869SN/A    f.close()
2931869SN/A    return None
2941869SN/A
2952634Sstever@eecs.umich.edu# Generate the message to be printed when building the config file.
2962634Sstever@eecs.umich.edudef build_config_file_string(target, source, env):
2972634Sstever@eecs.umich.edu    (option, value) = [s.get_contents() for s in source]
2982634Sstever@eecs.umich.edu    return "Defining %s as %s in %s." % (option, value, target[0])
2992634Sstever@eecs.umich.edu
3002634Sstever@eecs.umich.edu# Combine the two functions into a scons Action object.
3011869SN/Aconfig_action = Action(build_config_file, build_config_file_string)
3021869SN/A
303955SN/A# The emitter munges the source & target node lists to reflect what
304955SN/A# we're really doing.
305955SN/Adef config_emitter(target, source, env):
306955SN/A    # extract option name from Builder arg
3071858SN/A    option = str(target[0])
3081858SN/A    # True target is config header file
3091858SN/A    target = os.path.join('config', option.lower() + '.hh')
3102634Sstever@eecs.umich.edu    # Force value to 0/1 even if it's a Python bool
3112634Sstever@eecs.umich.edu    val = int(eval(str(env[option])))
3122634Sstever@eecs.umich.edu    # Sources are option name & value (packaged in SCons Value nodes)
3132634Sstever@eecs.umich.edu    return ([target], [Value(option), Value(val)])
3142634Sstever@eecs.umich.edu
3152634Sstever@eecs.umich.educonfig_builder = Builder(emitter = config_emitter, action = config_action)
3162634Sstever@eecs.umich.edu
3172634Sstever@eecs.umich.eduenv.Append(BUILDERS = { 'ConfigFile' : config_builder })
3182634Sstever@eecs.umich.edu
3192634Sstever@eecs.umich.edu###################################################
3202598SN/A#
3212632Sstever@eecs.umich.edu# Define a SCons builder for copying files.  This is used by the
3222632Sstever@eecs.umich.edu# Python zipfile code in src/python/SConscript, but is placed up here
3232632Sstever@eecs.umich.edu# since it's potentially more generally applicable.
3242632Sstever@eecs.umich.edu#
3252632Sstever@eecs.umich.edu###################################################
3262634Sstever@eecs.umich.edu
3272634Sstever@eecs.umich.educopy_builder = Builder(action = Copy("$TARGET", "$SOURCE"))
3282023SN/A
3292632Sstever@eecs.umich.eduenv.Append(BUILDERS = { 'CopyFile' : copy_builder })
3302632Sstever@eecs.umich.edu
3312632Sstever@eecs.umich.edu###################################################
3322632Sstever@eecs.umich.edu#
3332632Sstever@eecs.umich.edu# Define a simple SCons builder to concatenate files.
3342632Sstever@eecs.umich.edu#
3352632Sstever@eecs.umich.edu# Used to append the Python zip archive to the executable.
3362632Sstever@eecs.umich.edu#
3372632Sstever@eecs.umich.edu###################################################
3382632Sstever@eecs.umich.edu
3392632Sstever@eecs.umich.educoncat_builder = Builder(action = Action(['cat $SOURCES > $TARGET',
3402023SN/A                                          'chmod +x $TARGET']))
3412632Sstever@eecs.umich.edu
3422632Sstever@eecs.umich.eduenv.Append(BUILDERS = { 'Concat' : concat_builder })
3431889SN/A
3441889SN/A
3452632Sstever@eecs.umich.edu# base help text
3462632Sstever@eecs.umich.eduhelp_text = '''
3472632Sstever@eecs.umich.eduUsage: scons [scons options] [build options] [target(s)]
3482632Sstever@eecs.umich.edu
3492632Sstever@eecs.umich.edu'''
3502632Sstever@eecs.umich.edu
3512632Sstever@eecs.umich.edu# libelf build is shared across all configs in the build root.
3522632Sstever@eecs.umich.eduenv.SConscript('ext/libelf/SConscript',
3532632Sstever@eecs.umich.edu               build_dir = os.path.join(build_root, 'libelf'),
3542632Sstever@eecs.umich.edu               exports = 'env')
3552632Sstever@eecs.umich.edu
3562632Sstever@eecs.umich.edu###################################################
3572632Sstever@eecs.umich.edu#
3582632Sstever@eecs.umich.edu# Define build environments for selected configurations.
3591888SN/A#
3601888SN/A###################################################
3611869SN/A
3621869SN/A# rename base env
3631858SN/Abase_env = env
3642598SN/A
3652598SN/Afor build_path in build_paths:
3662598SN/A    print "Building in", build_path
3672598SN/A    # build_dir is the tail component of build path, and is used to
3682598SN/A    # determine the build parameters (e.g., 'ALPHA_SE')
3691858SN/A    (build_root, build_dir) = os.path.split(build_path)
3701858SN/A    # Make a copy of the build-root environment to use for this config.
3711858SN/A    env = base_env.Copy()
3721858SN/A
3731858SN/A    # Set env options according to the build directory config.
3741858SN/A    sticky_opts.files = []
3751858SN/A    # Options for $BUILD_ROOT/$BUILD_DIR are stored in
3761858SN/A    # $BUILD_ROOT/options/$BUILD_DIR so you can nuke
3771858SN/A    # $BUILD_ROOT/$BUILD_DIR without losing your options settings.
3781871SN/A    current_opts_file = os.path.join(build_root, 'options', build_dir)
3791858SN/A    if os.path.isfile(current_opts_file):
3801858SN/A        sticky_opts.files.append(current_opts_file)
3811858SN/A        print "Using saved options file %s" % current_opts_file
3821858SN/A    else:
3831858SN/A        # Build dir-specific options file doesn't exist.
3841858SN/A
3851858SN/A        # Make sure the directory is there so we can create it later
3861858SN/A        opt_dir = os.path.dirname(current_opts_file)
3871858SN/A        if not os.path.isdir(opt_dir):
3881858SN/A            os.mkdir(opt_dir)
3891858SN/A
3901859SN/A        # Get default build options from source tree.  Options are
3911859SN/A        # normally determined by name of $BUILD_DIR, but can be
3921869SN/A        # overriden by 'default=' arg on command line.
3931888SN/A        default_opts_file = os.path.join('build_opts',
3942632Sstever@eecs.umich.edu                                         ARGUMENTS.get('default', build_dir))
3951869SN/A        if os.path.isfile(default_opts_file):
3961884SN/A            sticky_opts.files.append(default_opts_file)
3971884SN/A            print "Options file %s not found,\n  using defaults in %s" \
3981884SN/A                  % (current_opts_file, default_opts_file)
3991884SN/A        else:
4001884SN/A            print "Error: cannot find options file %s or %s" \
4011884SN/A                  % (current_opts_file, default_opts_file)
4021965SN/A            Exit(1)
4031965SN/A
4041965SN/A    # Apply current option settings to env
405955SN/A    sticky_opts.Update(env)
4061869SN/A    nonsticky_opts.Update(env)
4071869SN/A
4082632Sstever@eecs.umich.edu    help_text += "Sticky options for %s:\n" % build_dir \
4091869SN/A                 + sticky_opts.GenerateHelpText(env) \
4101869SN/A                 + "\nNon-sticky options for %s:\n" % build_dir \
4111869SN/A                 + nonsticky_opts.GenerateHelpText(env)
4122632Sstever@eecs.umich.edu
4132632Sstever@eecs.umich.edu    # Process option settings.
4142632Sstever@eecs.umich.edu
4152632Sstever@eecs.umich.edu    if not have_fenv and env['USE_FENV']:
416955SN/A        print "Warning: <fenv.h> not available; " \
4172598SN/A              "forcing USE_FENV to False in", build_dir + "."
4182598SN/A        env['USE_FENV'] = False
419955SN/A
420955SN/A    if not env['USE_FENV']:
421955SN/A        print "Warning: No IEEE FP rounding mode control in", build_dir + "."
4221530SN/A        print "         FP results may deviate slightly from other platforms."
423955SN/A
424955SN/A    if env['EFENCE']:
425955SN/A        env.Append(LIBS=['efence'])
426
427    if env['USE_MYSQL']:
428        if not have_mysql:
429            print "Warning: MySQL not available; " \
430                  "forcing USE_MYSQL to False in", build_dir + "."
431            env['USE_MYSQL'] = False
432        else:
433            print "Compiling in", build_dir, "with MySQL support."
434            env.ParseConfig(mysql_config_libs)
435            env.ParseConfig(mysql_config_include)
436
437    # Save sticky option settings back to current options file
438    sticky_opts.Save(current_opts_file, env)
439
440    # Do this after we save setting back, or else we'll tack on an
441    # extra 'qdo' every time we run scons.
442    if env['BATCH']:
443        env['CC']  = env['BATCH_CMD'] + ' ' + env['CC']
444        env['CXX'] = env['BATCH_CMD'] + ' ' + env['CXX']
445
446    if env['USE_SSE2']:
447        env.Append(CCFLAGS='-msse2')
448
449    # The m5/SConscript file sets up the build rules in 'env' according
450    # to the configured options.  It returns a list of environments,
451    # one for each variant build (debug, opt, etc.)
452    envList = SConscript('src/SConscript', build_dir = build_path,
453                         exports = 'env', duplicate = False)
454
455    # Set up the regression tests for each build.
456#    for e in envList:
457#        SConscript('m5-test/SConscript',
458#                   build_dir = os.path.join(build_dir, 'test', e.Label),
459#                   exports = { 'env' : e }, duplicate = False)
460
461Help(help_text)
462
463###################################################
464#
465# Let SCons do its thing.  At this point SCons will use the defined
466# build environments to build the requested targets.
467#
468###################################################
469
470