SConstruct revision 2653
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.
282665Ssaidi@eecs.umich.edu
292665Ssaidi@eecs.umich.edu###################################################
30955SN/A#
31955SN/A# SCons top-level build description (SConstruct) file.
32955SN/A#
33955SN/A# While in this directory ('m5'), just type 'scons' to build the default
34955SN/A# 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).
372632Sstever@eecs.umich.edu#
382632Sstever@eecs.umich.edu# You can build M5 in a different directory as long as there is a
39955SN/A# '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.
422761Sstever@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.
462761Sstever@eecs.umich.edu#   % cd <path-to-src>/m5 ; scons build/ALPHA_FS/m5.debug
472761Sstever@eecs.umich.edu#   % cd <path-to-src>/m5/build/ALPHA_FS; scons -u m5.debug
482761Sstever@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.
512761Sstever@eecs.umich.edu#   % cd <path-to-src>/m5 ; scons /local/foo/build/ALPHA_FS/m5.debug
522761Sstever@eecs.umich.edu#   % cd /local/foo/build/ALPHA_FS; scons -C <path-to-src>/m5 m5.debug
532761Sstever@eecs.umich.edu#
542761Sstever@eecs.umich.edu# You can use 'scons -H' to print scons options.  If you're in this
552761Sstever@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.
582632Sstever@eecs.umich.edu#
592632Sstever@eecs.umich.edu###################################################
602632Sstever@eecs.umich.edu
612632Sstever@eecs.umich.edu# Python library imports
622632Sstever@eecs.umich.eduimport sys
63955SN/Aimport os
64955SN/A
65955SN/A# Check for recent-enough Python and SCons versions
66955SN/AEnsurePythonVersion(2,3)
67955SN/A
68955SN/A# Ironically, SCons 0.96 dies if you give EnsureSconsVersion a
69955SN/A# 3-element version number.
702656Sstever@eecs.umich.edumin_scons_version = (0,96,91)
712656Sstever@eecs.umich.edutry:
722656Sstever@eecs.umich.edu    EnsureSConsVersion(*min_scons_version)
732656Sstever@eecs.umich.eduexcept:
742656Sstever@eecs.umich.edu    print "Error checking current SCons version."
752656Sstever@eecs.umich.edu    print "SCons", ".".join(map(str,min_scons_version)), "or greater required."
762656Sstever@eecs.umich.edu    Exit(2)
772653Sstever@eecs.umich.edu    
782653Sstever@eecs.umich.edu
792653Sstever@eecs.umich.edu# The absolute path to the current directory (where this file lives).
802653Sstever@eecs.umich.eduROOT = Dir('.').abspath
812653Sstever@eecs.umich.edu
822653Sstever@eecs.umich.edu# Paths to the M5 and external source trees.
832653Sstever@eecs.umich.eduSRCDIR = os.path.join(ROOT, 'src')
842653Sstever@eecs.umich.edu
852653Sstever@eecs.umich.edu# tell python where to find m5 python code
862653Sstever@eecs.umich.edusys.path.append(os.path.join(ROOT, 'src/python'))
872653Sstever@eecs.umich.edu
881852SN/A###################################################
89955SN/A#
90955SN/A# Figure out which configurations to set up based on the path(s) of
91955SN/A# the target(s).
922632Sstever@eecs.umich.edu#
932632Sstever@eecs.umich.edu###################################################
94955SN/A
951533SN/A# Find default configuration & binary.
962632Sstever@eecs.umich.eduDefault(os.environ.get('M5_DEFAULT_BINARY', 'build/ALPHA_SE/m5.debug'))
971533SN/A
98955SN/A# Ask SCons which directory it was invoked from.
99955SN/Alaunch_dir = GetLaunchDir()
1002632Sstever@eecs.umich.edu
1012632Sstever@eecs.umich.edu# Make targets relative to invocation directory
102955SN/Aabs_targets = map(lambda x: os.path.normpath(os.path.join(launch_dir, str(x))),
103955SN/A                  BUILD_TARGETS)
104955SN/A
105955SN/A# helper function: find last occurrence of element in list
1062632Sstever@eecs.umich.edudef rfind(l, elt, offs = -1):
107955SN/A    for i in range(len(l)+offs, 0, -1):
1082632Sstever@eecs.umich.edu        if l[i] == elt:
109955SN/A            return i
110955SN/A    raise ValueError, "element not found"
1112632Sstever@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
1182632Sstever@eecs.umich.edu# Generate a list of the unique build roots and configs that the
1192632Sstever@eecs.umich.edu# collected targets reference.
1202632Sstever@eecs.umich.edubuild_paths = []
1212632Sstever@eecs.umich.edubuild_root = None
1222632Sstever@eecs.umich.edufor t in abs_targets:
1232632Sstever@eecs.umich.edu    path_dirs = t.split('/')
1242632Sstever@eecs.umich.edu    try:
1252632Sstever@eecs.umich.edu        build_top = rfind(path_dirs, 'build', -2)
1262632Sstever@eecs.umich.edu    except:
1272632Sstever@eecs.umich.edu        print "Error: no non-leaf 'build' dir found on target path", t
1282634Sstever@eecs.umich.edu        Exit(1)
1292634Sstever@eecs.umich.edu    this_build_root = os.path.join('/',*path_dirs[:build_top+1])
1302632Sstever@eecs.umich.edu    if not build_root:
1312638Sstever@eecs.umich.edu        build_root = this_build_root
1322632Sstever@eecs.umich.edu    else:
1332632Sstever@eecs.umich.edu        if this_build_root != build_root:
1342632Sstever@eecs.umich.edu            print "Error: build targets not under same build root\n"\
1352632Sstever@eecs.umich.edu                  "  %s\n  %s" % (build_root, this_build_root)
1362632Sstever@eecs.umich.edu            Exit(1)
1372632Sstever@eecs.umich.edu    build_path = os.path.join('/',*path_dirs[:build_top+2])
1381858SN/A    if build_path not in build_paths:
1392638Sstever@eecs.umich.edu        build_paths.append(build_path)
1402638Sstever@eecs.umich.edu
1412638Sstever@eecs.umich.edu###################################################
1422638Sstever@eecs.umich.edu#
1432638Sstever@eecs.umich.edu# Set up the default build environment.  This environment is copied
1442638Sstever@eecs.umich.edu# and modified according to each selected configuration.
1452638Sstever@eecs.umich.edu#
1462638Sstever@eecs.umich.edu###################################################
1472634Sstever@eecs.umich.edu
1482634Sstever@eecs.umich.eduenv = Environment(ENV = os.environ,  # inherit user's environment vars
1492634Sstever@eecs.umich.edu                  ROOT = ROOT,
150955SN/A                  SRCDIR = SRCDIR)
151955SN/A
152955SN/Aenv.SConsignFile("sconsign")
153955SN/A
154955SN/A# I waffle on this setting... it does avoid a few painful but
155955SN/A# unnecessary builds, but it also seems to make trivial builds take
156955SN/A# noticeably longer.
157955SN/Aif False:
1581858SN/A    env.TargetSignatures('content')
1591858SN/A
1602632Sstever@eecs.umich.edu# M5_PLY is used by isa_parser.py to find the PLY package.
161955SN/Aenv.Append(ENV = { 'M5_PLY' : Dir('ext/ply') })
1622776Sstever@eecs.umich.edu
1631105SN/A# Set up default C++ compiler flags
1642667Sstever@eecs.umich.eduenv.Append(CCFLAGS='-pipe')
1652667Sstever@eecs.umich.eduenv.Append(CCFLAGS='-fno-strict-aliasing')
1662667Sstever@eecs.umich.eduenv.Append(CCFLAGS=Split('-Wall -Wno-sign-compare -Werror -Wundef'))
1672667Sstever@eecs.umich.eduif sys.platform == 'cygwin':
1682667Sstever@eecs.umich.edu    # cygwin has some header file issues...
1692667Sstever@eecs.umich.edu    env.Append(CCFLAGS=Split("-Wno-uninitialized"))
1701869SN/Aenv.Append(CPPPATH=[Dir('ext/dnet')])
1711869SN/A
1721869SN/A# Default libraries
1731869SN/Aenv.Append(LIBS=['z'])
1741869SN/A
1751065SN/A# Platform-specific configuration.  Note again that we assume that all
1762632Sstever@eecs.umich.edu# builds under a given build root run on the same host platform.
1772632Sstever@eecs.umich.educonf = Configure(env,
178955SN/A                 conf_dir = os.path.join(build_root, '.scons_config'),
1791858SN/A                 log_file = os.path.join(build_root, 'scons_config.log'))
1801858SN/A
1811858SN/A# Check for <fenv.h> (C99 FP environment control)
1821858SN/Ahave_fenv = conf.CheckHeader('fenv.h', '<>')
1831851SN/Aif not have_fenv:
1841851SN/A    print "Warning: Header file <fenv.h> not found."
1851858SN/A    print "         This host has no IEEE FP rounding mode control."
1862632Sstever@eecs.umich.edu
187955SN/A# Check for mysql.
1882656Sstever@eecs.umich.edumysql_config = WhereIs('mysql_config')
1892656Sstever@eecs.umich.eduhave_mysql = mysql_config != None
1902656Sstever@eecs.umich.edu
1912656Sstever@eecs.umich.edu# Check MySQL version.
1922656Sstever@eecs.umich.eduif have_mysql:
1932656Sstever@eecs.umich.edu    mysql_version = os.popen(mysql_config + ' --version').read()
1942656Sstever@eecs.umich.edu    mysql_version = mysql_version.split('.')
1952656Sstever@eecs.umich.edu    mysql_major = int(mysql_version[0])
1962656Sstever@eecs.umich.edu    mysql_minor = int(mysql_version[1])
1972656Sstever@eecs.umich.edu    # This version check is probably overly conservative, but it deals
1982656Sstever@eecs.umich.edu    # with the versions we have installed.
1992656Sstever@eecs.umich.edu    if mysql_major < 4 or (mysql_major == 4 and mysql_minor < 1):
2002656Sstever@eecs.umich.edu        print "Warning: MySQL v4.1 or newer required."
2012656Sstever@eecs.umich.edu        have_mysql = False
2022656Sstever@eecs.umich.edu
2032656Sstever@eecs.umich.edu# Set up mysql_config commands.
2042655Sstever@eecs.umich.eduif have_mysql:
2052667Sstever@eecs.umich.edu    mysql_config_include = mysql_config + ' --include'
2062667Sstever@eecs.umich.edu    if os.system(mysql_config_include + ' > /dev/null') != 0:
2072667Sstever@eecs.umich.edu        # older mysql_config versions don't support --include, use
2082667Sstever@eecs.umich.edu        # --cflags instead
2092667Sstever@eecs.umich.edu        mysql_config_include = mysql_config + ' --cflags | sed s/\\\'//g'
2102667Sstever@eecs.umich.edu    # This seems to work in all versions
2112667Sstever@eecs.umich.edu    mysql_config_libs = mysql_config + ' --libs'
2122667Sstever@eecs.umich.edu
2132667Sstever@eecs.umich.eduenv = conf.Finish()
2142667Sstever@eecs.umich.edu
2152667Sstever@eecs.umich.edu# Define the universe of supported ISAs
2162667Sstever@eecs.umich.eduenv['ALL_ISA_LIST'] = ['alpha', 'sparc', 'mips']
2172667Sstever@eecs.umich.edu
2182655Sstever@eecs.umich.edu# Define the universe of supported CPU models
2191858SN/Aenv['ALL_CPU_LIST'] = ['AtomicSimpleCPU', 'TimingSimpleCPU',
2201858SN/A                       'FullCPU', 'AlphaFullCPU']
2212638Sstever@eecs.umich.edu
2222638Sstever@eecs.umich.edu# Sticky options get saved in the options file so they persist from
2232638Sstever@eecs.umich.edu# one invocation to the next (unless overridden, in which case the new
2242638Sstever@eecs.umich.edu# value becomes sticky).
2252638Sstever@eecs.umich.edusticky_opts = Options(args=ARGUMENTS)
2261858SN/Asticky_opts.AddOptions(
2271858SN/A    EnumOption('TARGET_ISA', 'Target ISA', 'alpha', env['ALL_ISA_LIST']),
2281858SN/A    BoolOption('FULL_SYSTEM', 'Full-system support', False),
2291858SN/A    # There's a bug in scons 0.96.1 that causes ListOptions with list
2301858SN/A    # values (more than one value) not to be able to be restored from
2311858SN/A    # a saved option file.  If this causes trouble then upgrade to
2321858SN/A    # scons 0.96.90 or later.
2331859SN/A    ListOption('CPU_MODELS', 'CPU models', 'AtomicSimpleCPU,TimingSimpleCPU',
2341858SN/A               env['ALL_CPU_LIST']),
2351858SN/A    BoolOption('ALPHA_TLASER',
2361858SN/A               'Model Alpha TurboLaser platform (vs. Tsunami)', False),
2371859SN/A    BoolOption('NO_FAST_ALLOC', 'Disable fast object allocator', False),
2381859SN/A    BoolOption('EFENCE', 'Link with Electric Fence malloc debugger',
2391862SN/A               False),
2401862SN/A    BoolOption('SS_COMPATIBLE_FP',
2411862SN/A               'Make floating-point results compatible with SimpleScalar',
2421862SN/A               False),
2431859SN/A    BoolOption('USE_SSE2',
2441859SN/A               'Compile for SSE2 (-msse2) to get IEEE FP on x86 hosts',
2451963SN/A               False),
2461963SN/A    BoolOption('STATS_BINNING', 'Bin statistics by CPU mode', have_mysql),
2471859SN/A    BoolOption('USE_MYSQL', 'Use MySQL for stats output', have_mysql),
2481859SN/A    BoolOption('USE_FENV', 'Use <fenv.h> IEEE mode control', have_fenv),
2491859SN/A    ('CC', 'C compiler', os.environ.get('CC', env['CC'])),
2501859SN/A    ('CXX', 'C++ compiler', os.environ.get('CXX', env['CXX'])),
2511859SN/A    BoolOption('BATCH', 'Use batch pool for build and tests', False),
2521859SN/A    ('BATCH_CMD', 'Batch pool submission command name', 'qdo')
2531859SN/A    )
2541859SN/A
2551862SN/A# Non-sticky options only apply to the current build.
2561859SN/Anonsticky_opts = Options(args=ARGUMENTS)
2571859SN/Anonsticky_opts.AddOptions(
2581859SN/A    BoolOption('update_ref', 'Update test reference outputs', False)
2591858SN/A    )
2601858SN/A
2612139SN/A# These options get exported to #defines in config/*.hh (see m5/SConscript).
2622139SN/Aenv.ExportOptions = ['FULL_SYSTEM', 'ALPHA_TLASER', 'USE_FENV', \
2632139SN/A                     'USE_MYSQL', 'NO_FAST_ALLOC', 'SS_COMPATIBLE_FP', \
2642155SN/A                     'STATS_BINNING']
2652623SN/A
2662817Sksewell@umich.edu# Define a handy 'no-op' action
2672792Sktlim@umich.edudef no_action(target, source, env):
2682155SN/A    return 0
2691869SN/A
2701869SN/Aenv.NoAction = Action(no_action, None)
2711869SN/A
2721869SN/A###################################################
2731869SN/A#
2742139SN/A# Define a SCons builder for configuration flag headers.
2751869SN/A#
2762508SN/A###################################################
2772508SN/A
2782508SN/A# This function generates a config header file that #defines the
2792508SN/A# option symbol to the current option setting (0 or 1).  The source
2802635Sstever@eecs.umich.edu# operands are the name of the option and a Value node containing the
2812635Sstever@eecs.umich.edu# value of the option.
2821869SN/Adef build_config_file(target, source, env):
2831869SN/A    (option, value) = [s.get_contents() for s in source]
2841869SN/A    f = file(str(target[0]), 'w')
2851869SN/A    print >> f, '#define', option, value
2861869SN/A    f.close()
2871869SN/A    return None
2881869SN/A
2891869SN/A# Generate the message to be printed when building the config file.
2901965SN/Adef build_config_file_string(target, source, env):
2911965SN/A    (option, value) = [s.get_contents() for s in source]
2921965SN/A    return "Defining %s as %s in %s." % (option, value, target[0])
2931869SN/A
2941869SN/A# Combine the two functions into a scons Action object.
2952733Sktlim@umich.educonfig_action = Action(build_config_file, build_config_file_string)
2961869SN/A
2971884SN/A# The emitter munges the source & target node lists to reflect what
2981884SN/A# we're really doing.
2991884SN/Adef config_emitter(target, source, env):
3001869SN/A    # extract option name from Builder arg
3011858SN/A    option = str(target[0])
3021869SN/A    # True target is config header file
3031869SN/A    target = os.path.join('config', option.lower() + '.hh')
3041869SN/A    # Force value to 0/1 even if it's a Python bool
3052953Sktlim@umich.edu    val = int(eval(str(env[option])))
3062953Sktlim@umich.edu    # Sources are option name & value (packaged in SCons Value nodes)
3071869SN/A    return ([target], [Value(option), Value(val)])
3081869SN/A
3091858SN/Aconfig_builder = Builder(emitter = config_emitter, action = config_action)
3102761Sstever@eecs.umich.edu
3111869SN/Aenv.Append(BUILDERS = { 'ConfigFile' : config_builder })
3122733Sktlim@umich.edu
3132733Sktlim@umich.edu# base help text
3141869SN/Ahelp_text = '''
3151869SN/AUsage: scons [scons options] [build options] [target(s)]
3161869SN/A
3171869SN/A'''
3181869SN/A
3191869SN/A# libelf build is shared across all configs in the build root.
3201858SN/Aenv.SConscript('ext/libelf/SConscript',
321955SN/A               build_dir = os.path.join(build_root, 'libelf'),
322955SN/A               exports = 'env')
3231869SN/A
3241869SN/A###################################################
3251869SN/A#
3261869SN/A# Define build environments for selected configurations.
3271869SN/A#
3281869SN/A###################################################
3291869SN/A
3301869SN/A# rename base env
3311869SN/Abase_env = env
3321869SN/A
3331869SN/Afor build_path in build_paths:
3341869SN/A    print "Building in", build_path
3351869SN/A    # build_dir is the tail component of build path, and is used to
3361869SN/A    # determine the build parameters (e.g., 'ALPHA_SE')
3371869SN/A    (build_root, build_dir) = os.path.split(build_path)
3381869SN/A    # Make a copy of the build-root environment to use for this config.
3391869SN/A    env = base_env.Copy()
3401869SN/A
3411869SN/A    # Set env options according to the build directory config.
3421869SN/A    sticky_opts.files = []
3431869SN/A    # Options for $BUILD_ROOT/$BUILD_DIR are stored in
3441869SN/A    # $BUILD_ROOT/options/$BUILD_DIR so you can nuke
3451869SN/A    # $BUILD_ROOT/$BUILD_DIR without losing your options settings.
3461869SN/A    current_opts_file = os.path.join(build_root, 'options', build_dir)
3471869SN/A    if os.path.isfile(current_opts_file):
3481869SN/A        sticky_opts.files.append(current_opts_file)
3491869SN/A        print "Using saved options file %s" % current_opts_file
3501869SN/A    else:
3511869SN/A        # Build dir-specific options file doesn't exist.
3521869SN/A
3531869SN/A        # Make sure the directory is there so we can create it later
3541869SN/A        opt_dir = os.path.dirname(current_opts_file)
3551869SN/A        if not os.path.isdir(opt_dir):
3561869SN/A            os.mkdir(opt_dir)
3571869SN/A
3581869SN/A        # Get default build options from source tree.  Options are
3591869SN/A        # normally determined by name of $BUILD_DIR, but can be
3601869SN/A        # overriden by 'default=' arg on command line.
3611869SN/A        default_opts_file = os.path.join('build_opts',
3622655Sstever@eecs.umich.edu                                         ARGUMENTS.get('default', build_dir))
3632655Sstever@eecs.umich.edu        if os.path.isfile(default_opts_file):
3642655Sstever@eecs.umich.edu            sticky_opts.files.append(default_opts_file)
3652655Sstever@eecs.umich.edu            print "Options file %s not found,\n  using defaults in %s" \
3662655Sstever@eecs.umich.edu                  % (current_opts_file, default_opts_file)
3672655Sstever@eecs.umich.edu        else:
3682655Sstever@eecs.umich.edu            print "Error: cannot find options file %s or %s" \
3692655Sstever@eecs.umich.edu                  % (current_opts_file, default_opts_file)
3702655Sstever@eecs.umich.edu            Exit(1)
3712655Sstever@eecs.umich.edu
3722655Sstever@eecs.umich.edu    # Apply current option settings to env
3732655Sstever@eecs.umich.edu    sticky_opts.Update(env)
3742655Sstever@eecs.umich.edu    nonsticky_opts.Update(env)
3752655Sstever@eecs.umich.edu
3762655Sstever@eecs.umich.edu    help_text += "Sticky options for %s:\n" % build_dir \
3772655Sstever@eecs.umich.edu                 + sticky_opts.GenerateHelpText(env) \
3782655Sstever@eecs.umich.edu                 + "\nNon-sticky options for %s:\n" % build_dir \
3792655Sstever@eecs.umich.edu                 + nonsticky_opts.GenerateHelpText(env)
3802655Sstever@eecs.umich.edu
3812655Sstever@eecs.umich.edu    # Process option settings.
3822655Sstever@eecs.umich.edu
3832655Sstever@eecs.umich.edu    if not have_fenv and env['USE_FENV']:
3842655Sstever@eecs.umich.edu        print "Warning: <fenv.h> not available; " \
3852655Sstever@eecs.umich.edu              "forcing USE_FENV to False in", build_dir + "."
3862655Sstever@eecs.umich.edu        env['USE_FENV'] = False
3872655Sstever@eecs.umich.edu
3882634Sstever@eecs.umich.edu    if not env['USE_FENV']:
3892634Sstever@eecs.umich.edu        print "Warning: No IEEE FP rounding mode control in", build_dir + "."
3902634Sstever@eecs.umich.edu        print "         FP results may deviate slightly from other platforms."
3912634Sstever@eecs.umich.edu
3922634Sstever@eecs.umich.edu    if env['EFENCE']:
3932634Sstever@eecs.umich.edu        env.Append(LIBS=['efence'])
3942638Sstever@eecs.umich.edu
3952638Sstever@eecs.umich.edu    if env['USE_MYSQL']:
3962638Sstever@eecs.umich.edu        if not have_mysql:
3972638Sstever@eecs.umich.edu            print "Warning: MySQL not available; " \
3982638Sstever@eecs.umich.edu                  "forcing USE_MYSQL to False in", build_dir + "."
3991869SN/A            env['USE_MYSQL'] = False
4001869SN/A        else:
401955SN/A            print "Compiling in", build_dir, "with MySQL support."
402955SN/A            env.ParseConfig(mysql_config_libs)
403955SN/A            env.ParseConfig(mysql_config_include)
404955SN/A
4051858SN/A    # Save sticky option settings back to current options file
4061858SN/A    sticky_opts.Save(current_opts_file, env)
4071858SN/A
4082632Sstever@eecs.umich.edu    # Do this after we save setting back, or else we'll tack on an
4092632Sstever@eecs.umich.edu    # extra 'qdo' every time we run scons.
4102632Sstever@eecs.umich.edu    if env['BATCH']:
4112632Sstever@eecs.umich.edu        env['CC']  = env['BATCH_CMD'] + ' ' + env['CC']
4122632Sstever@eecs.umich.edu        env['CXX'] = env['BATCH_CMD'] + ' ' + env['CXX']
4132634Sstever@eecs.umich.edu
4142638Sstever@eecs.umich.edu    if env['USE_SSE2']:
4152023SN/A        env.Append(CCFLAGS='-msse2')
4162632Sstever@eecs.umich.edu
4172632Sstever@eecs.umich.edu    # The m5/SConscript file sets up the build rules in 'env' according
4182632Sstever@eecs.umich.edu    # to the configured options.  It returns a list of environments,
4192632Sstever@eecs.umich.edu    # one for each variant build (debug, opt, etc.)
4202632Sstever@eecs.umich.edu    envList = SConscript('src/SConscript', build_dir = build_path,
4212632Sstever@eecs.umich.edu                         exports = 'env', duplicate = False)
4222632Sstever@eecs.umich.edu
4232632Sstever@eecs.umich.edu    # Set up the regression tests for each build.
4242632Sstever@eecs.umich.edu#    for e in envList:
4252632Sstever@eecs.umich.edu#        SConscript('m5-test/SConscript',
4262632Sstever@eecs.umich.edu#                   build_dir = os.path.join(build_dir, 'test', e.Label),
4272023SN/A#                   exports = { 'env' : e }, duplicate = False)
4282632Sstever@eecs.umich.edu
4292632Sstever@eecs.umich.eduHelp(help_text)
4301889SN/A
4311889SN/A###################################################
4322632Sstever@eecs.umich.edu#
4332632Sstever@eecs.umich.edu# Let SCons do its thing.  At this point SCons will use the defined
4342632Sstever@eecs.umich.edu# build environments to build the requested targets.
4352632Sstever@eecs.umich.edu#
4362632Sstever@eecs.umich.edu###################################################
4372632Sstever@eecs.umich.edu
4382632Sstever@eecs.umich.edu