SConstruct revision 2023
1955SN/A# -*- mode:python -*-
2955SN/A
313576Sciro.santilli@arm.com# Copyright (c) 2004-2005 The Regents of The University of Michigan
413576Sciro.santilli@arm.com# All rights reserved.
513576Sciro.santilli@arm.com#
613576Sciro.santilli@arm.com# Redistribution and use in source and binary forms, with or without
713576Sciro.santilli@arm.com# modification, are permitted provided that the following conditions are
813576Sciro.santilli@arm.com# met: redistributions of source code must retain the above copyright
913576Sciro.santilli@arm.com# notice, this list of conditions and the following disclaimer;
1013576Sciro.santilli@arm.com# redistributions in binary form must reproduce the above copyright
1113576Sciro.santilli@arm.com# notice, this list of conditions and the following disclaimer in the
1213576Sciro.santilli@arm.com# documentation and/or other materials provided with the distribution;
1313576Sciro.santilli@arm.com# neither the name of the copyright holders nor the names of its
141762SN/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#
33955SN/A# To build M5, you need a directory with three things:
34955SN/A# 1. A copy of this file (named SConstruct).
35955SN/A# 2. A link named 'm5' to the top of the M5 simulator source tree.
36955SN/A# 3. A link named 'ext' to the top of the M5 external source tree.
37955SN/A#
38955SN/A# Then type 'scons' to build the default configuration (see below), or
392665Ssaidi@eecs.umich.edu# 'scons <CONFIG>/<binary>' to build some other configuration (e.g.,
404762Snate@binkert.org# 'ALPHA_FS/m5.opt' for the optimized full-system version).
41955SN/A#
4212563Sgabeblack@google.com###################################################
4312563Sgabeblack@google.com
445522Snate@binkert.org# Python library imports
456143Snate@binkert.orgimport sys
4612371Sgabeblack@google.comimport os
474762Snate@binkert.org
485522Snate@binkert.org# Check for recent-enough Python and SCons versions
49955SN/AEnsurePythonVersion(2,3)
505522Snate@binkert.orgEnsureSConsVersion(0,96)
5111974Sgabeblack@google.com
52955SN/A# The absolute path to the current directory (where this file lives).
535522Snate@binkert.orgROOT = Dir('.').abspath
544202Sbinkertn@umich.edu
555742Snate@binkert.org# Paths to the M5 and external source trees (local symlinks).
56955SN/ASRCDIR = os.path.join(ROOT, 'm5')
574381Sbinkertn@umich.eduEXT_SRCDIR = os.path.join(ROOT, 'ext')
584381Sbinkertn@umich.edu
5912246Sgabeblack@google.com# Check for 'm5' and 'ext' links, die if they don't exist.
6012246Sgabeblack@google.comif not os.path.isdir(SRCDIR):
618334Snate@binkert.org    print "Error: '%s' must be a link to the M5 source tree." % SRCDIR
62955SN/A    Exit(1)
63955SN/A
644202Sbinkertn@umich.eduif not os.path.isdir('ext'):
65955SN/A    print "Error: '%s' must be a link to the M5 external source tree." \
664382Sbinkertn@umich.edu          % EXT_SRCDIR
674382Sbinkertn@umich.edu    Exit(1)
684382Sbinkertn@umich.edu
696654Snate@binkert.org# tell python where to find m5 python code
705517Snate@binkert.orgsys.path.append(os.path.join(SRCDIR, 'python'))
718614Sgblack@eecs.umich.edu
727674Snate@binkert.org###################################################
736143Snate@binkert.org#
746143Snate@binkert.org# Figure out which configurations to set up.
756143Snate@binkert.org#
7612302Sgabeblack@google.com#
7712302Sgabeblack@google.com# It's prohibitive to do all the combinations of base configurations
7812302Sgabeblack@google.com# and options, so we have to infer which ones the user wants.
7912371Sgabeblack@google.com#
8012371Sgabeblack@google.com# 1. If there are command-line targets, the configuration(s) are inferred
8112371Sgabeblack@google.com#    from the directories of those targets.  If scons was invoked from a
8212371Sgabeblack@google.com#    subdirectory (using 'scons -u'), those targets have to be
8312371Sgabeblack@google.com#    interpreted relative to that subdirectory.
8412371Sgabeblack@google.com#
8512371Sgabeblack@google.com# 2. If there are no command-line targets, and scons was invoked from a
8612371Sgabeblack@google.com#    subdirectory (using 'scons -u'), the configuration is inferred from
8712371Sgabeblack@google.com#    the name of the subdirectory.
8812371Sgabeblack@google.com#
8912371Sgabeblack@google.com# 3. If there are no command-line targets and scons was invoked from
9012371Sgabeblack@google.com#    the root build directory, a default configuration is used.  The
9112371Sgabeblack@google.com#    built-in default is ALPHA_SE, but this can be overridden by setting the
9212371Sgabeblack@google.com#    M5_DEFAULT_CONFIG shell environment veriable.
9312371Sgabeblack@google.com#
9412371Sgabeblack@google.com# In cases 2 & 3, the specific file target defaults to 'm5.debug', but
9512371Sgabeblack@google.com# this can be overridden by setting the M5_DEFAULT_BINARY shell
9612371Sgabeblack@google.com# environment veriable.
9712371Sgabeblack@google.com#
9812371Sgabeblack@google.com###################################################
9912371Sgabeblack@google.com
10012371Sgabeblack@google.com# Find default configuration & binary.
10112371Sgabeblack@google.comdefault_config = os.environ.get('M5_DEFAULT_CONFIG', 'ALPHA_SE')
10212371Sgabeblack@google.comdefault_binary = os.environ.get('M5_DEFAULT_BINARY', 'm5.debug')
10312371Sgabeblack@google.com
10412371Sgabeblack@google.com# Ask SCons which directory it was invoked from.  If you invoke SCons
10512371Sgabeblack@google.com# from a subdirectory you must use the '-u' flag.
10612371Sgabeblack@google.comlaunch_dir = GetLaunchDir()
10712371Sgabeblack@google.com
10812371Sgabeblack@google.com# Build a list 'my_targets' of all the targets relative to ROOT.
10912371Sgabeblack@google.comif launch_dir == ROOT:
11012371Sgabeblack@google.com    # invoked from root build dir
11112371Sgabeblack@google.com    if len(COMMAND_LINE_TARGETS) != 0:
11212371Sgabeblack@google.com        # easy: use specified targets as is
11312371Sgabeblack@google.com        my_targets = COMMAND_LINE_TARGETS
11412371Sgabeblack@google.com    else:
11512371Sgabeblack@google.com        # default target (ALPHA_SE/m5.debug, unless overridden)
11612371Sgabeblack@google.com        target = os.path.join(default_config, default_binary)
11712371Sgabeblack@google.com        my_targets = [target]
11812371Sgabeblack@google.com        Default(target)
11912371Sgabeblack@google.comelse:
12012371Sgabeblack@google.com    # invoked from subdirectory
12112371Sgabeblack@google.com    if not launch_dir.startswith(ROOT):
12212371Sgabeblack@google.com        print "Error: launch dir (%s) not a subdirectory of ROOT (%s)!" \
12312371Sgabeblack@google.com              (launch_dir, ROOT)
12412371Sgabeblack@google.com        Exit(1)
12512371Sgabeblack@google.com    # make launch_dir relative to ROOT (strip ROOT plus slash off front)
12612302Sgabeblack@google.com    launch_dir = launch_dir[len(ROOT)+1:]
12712371Sgabeblack@google.com    if len(COMMAND_LINE_TARGETS) != 0:
12812302Sgabeblack@google.com        # make specified targets relative to ROOT
12912371Sgabeblack@google.com        my_targets = map(lambda x: os.path.join(launch_dir, x),
13012302Sgabeblack@google.com                         COMMAND_LINE_TARGETS)
13112302Sgabeblack@google.com    else:
13212371Sgabeblack@google.com        # build default binary (m5.debug, unless overridden) using the
13312371Sgabeblack@google.com        # config inferred by the invocation directory (the first
13412371Sgabeblack@google.com        # subdirectory after ROOT)
13512371Sgabeblack@google.com        target = os.path.join(launch_dir.split('/')[0], default_binary)
13612302Sgabeblack@google.com        my_targets = [target]
13712371Sgabeblack@google.com        Default(target)
13812371Sgabeblack@google.com
13912371Sgabeblack@google.com# Normalize target paths (gets rid of '..' in the middle, etc.)
14012371Sgabeblack@google.commy_targets = map(os.path.normpath, my_targets)
14111983Sgabeblack@google.com
1426143Snate@binkert.org# Generate a list of the unique configs that the collected targets reference.
1438233Snate@binkert.orgbuild_dirs = []
14412302Sgabeblack@google.comfor t in my_targets:
1456143Snate@binkert.org    dir = t.split('/')[0]
1466143Snate@binkert.org    if dir not in build_dirs:
14712302Sgabeblack@google.com        build_dirs.append(dir)
1484762Snate@binkert.org
1496143Snate@binkert.org###################################################
1508233Snate@binkert.org#
1518233Snate@binkert.org# Set up the default build environment.  This environment is copied
15212302Sgabeblack@google.com# and modified according to each selected configuration.
15312302Sgabeblack@google.com#
1546143Snate@binkert.org###################################################
15512362Sgabeblack@google.com
15612362Sgabeblack@google.comenv = Environment(ENV = os.environ,  # inherit user's environment vars
15712362Sgabeblack@google.com                  ROOT = ROOT,
15812362Sgabeblack@google.com                  SRCDIR = SRCDIR,
15912302Sgabeblack@google.com                  EXT_SRCDIR = EXT_SRCDIR)
16012302Sgabeblack@google.com
16112302Sgabeblack@google.comenv.SConsignFile("sconsign")
16212302Sgabeblack@google.com
16312302Sgabeblack@google.com# I waffle on this setting... it does avoid a few painful but
16412363Sgabeblack@google.com# unnecessary builds, but it also seems to make trivial builds take
16512363Sgabeblack@google.com# noticeably longer.
16612363Sgabeblack@google.comif False:
16712363Sgabeblack@google.com    env.TargetSignatures('content')
16812302Sgabeblack@google.com
16912363Sgabeblack@google.com# M5_EXT is used by isa_parser.py to find the PLY package.
17012363Sgabeblack@google.comenv.Append(ENV = { 'M5_EXT' : EXT_SRCDIR })
17112363Sgabeblack@google.com
17212363Sgabeblack@google.com# Set up default C++ compiler flags
17312363Sgabeblack@google.comenv.Append(CCFLAGS='-pipe')
1748233Snate@binkert.orgenv.Append(CCFLAGS='-fno-strict-aliasing')
1756143Snate@binkert.orgenv.Append(CCFLAGS=Split('-Wall -Wno-sign-compare -Werror -Wundef'))
1766143Snate@binkert.orgif sys.platform == 'cygwin':
1776143Snate@binkert.org    # cygwin has some header file issues...
1786143Snate@binkert.org    env.Append(CCFLAGS=Split("-Wno-uninitialized"))
1796143Snate@binkert.orgenv.Append(CPPPATH=[os.path.join(EXT_SRCDIR + '/dnet')])
1806143Snate@binkert.org
1816143Snate@binkert.org# Default libraries
1826143Snate@binkert.orgenv.Append(LIBS=['z'])
1836143Snate@binkert.org
1847065Snate@binkert.org# Platform-specific configuration
1856143Snate@binkert.orgconf = Configure(env)
18612362Sgabeblack@google.com
18712362Sgabeblack@google.com# Check for <fenv.h> (C99 FP environment control)
18812362Sgabeblack@google.comhave_fenv = conf.CheckHeader('fenv.h', '<>')
18912362Sgabeblack@google.comif not have_fenv:
19012362Sgabeblack@google.com    print "Warning: Header file <fenv.h> not found."
19112362Sgabeblack@google.com    print "         This host has no IEEE FP rounding mode control."
19212362Sgabeblack@google.com
19312362Sgabeblack@google.com# Check for mysql.
19412362Sgabeblack@google.commysql_config = WhereIs('mysql_config')
19512362Sgabeblack@google.comhave_mysql = mysql_config != None
19612362Sgabeblack@google.com
19712362Sgabeblack@google.com# Check MySQL version.
1988233Snate@binkert.orgif have_mysql:
1998233Snate@binkert.org    mysql_version = os.popen(mysql_config + ' --version').read()
2008233Snate@binkert.org    mysql_version = mysql_version.split('.')
2018233Snate@binkert.org    mysql_major = int(mysql_version[0])
2028233Snate@binkert.org    mysql_minor = int(mysql_version[1])
2038233Snate@binkert.org    # This version check is probably overly conservative, but it deals
2048233Snate@binkert.org    # with the versions we have installed.
2058233Snate@binkert.org    if mysql_major < 4 or (mysql_major == 4 and mysql_minor < 1):
2068233Snate@binkert.org        print "Warning: MySQL v4.1 or newer required."
2078233Snate@binkert.org        have_mysql = False
2088233Snate@binkert.org
2098233Snate@binkert.org# Set up mysql_config commands.
2108233Snate@binkert.orgif have_mysql:
2118233Snate@binkert.org    mysql_config_include = mysql_config + ' --include'
2128233Snate@binkert.org    if os.system(mysql_config_include + ' > /dev/null') != 0:
2138233Snate@binkert.org        # older mysql_config versions don't support --include, use
2148233Snate@binkert.org        # --cflags instead
2158233Snate@binkert.org        mysql_config_include = mysql_config + ' --cflags | sed s/\\\'//g'
2168233Snate@binkert.org    # This seems to work in all versions
2178233Snate@binkert.org    mysql_config_libs = mysql_config + ' --libs'
2188233Snate@binkert.org
2196143Snate@binkert.orgenv = conf.Finish()
2206143Snate@binkert.org
2216143Snate@binkert.org# Sticky options get saved in the options file so they persist from
2226143Snate@binkert.org# one invocation to the next (unless overridden, in which case the new
2236143Snate@binkert.org# value becomes sticky).
2246143Snate@binkert.orgsticky_opts = Options(args=ARGUMENTS)
2259982Satgutier@umich.edusticky_opts.AddOptions(
22613576Sciro.santilli@arm.com    EnumOption('TARGET_ISA', 'Target ISA', 'alpha', ('alpha', 'sparc')),
22713576Sciro.santilli@arm.com    BoolOption('FULL_SYSTEM', 'Full-system support', False),
22813576Sciro.santilli@arm.com    BoolOption('ALPHA_TLASER',
22913576Sciro.santilli@arm.com               'Model Alpha TurboLaser platform (vs. Tsunami)', False),
23013576Sciro.santilli@arm.com    BoolOption('NO_FAST_ALLOC', 'Disable fast object allocator', False),
23113576Sciro.santilli@arm.com    BoolOption('EFENCE', 'Link with Electric Fence malloc debugger',
23213576Sciro.santilli@arm.com               False),
23313576Sciro.santilli@arm.com    BoolOption('SS_COMPATIBLE_FP',
23413576Sciro.santilli@arm.com               'Make floating-point results compatible with SimpleScalar',
23513576Sciro.santilli@arm.com               False),
23613576Sciro.santilli@arm.com    BoolOption('USE_SSE2',
23713576Sciro.santilli@arm.com               'Compile for SSE2 (-msse2) to get IEEE FP on x86 hosts',
23813576Sciro.santilli@arm.com               False),
23913576Sciro.santilli@arm.com    BoolOption('STATS_BINNING', 'Bin statistics by CPU mode', have_mysql),
24013576Sciro.santilli@arm.com    BoolOption('USE_MYSQL', 'Use MySQL for stats output', have_mysql),
24113576Sciro.santilli@arm.com    BoolOption('USE_FENV', 'Use <fenv.h> IEEE mode control', have_fenv),
24213576Sciro.santilli@arm.com    ('CC', 'C compiler', os.environ.get('CC', env['CC'])),
24313576Sciro.santilli@arm.com    ('CXX', 'C++ compiler', os.environ.get('CXX', env['CXX'])),
24413576Sciro.santilli@arm.com    BoolOption('BATCH', 'Use batch pool for build and tests', False),
24513576Sciro.santilli@arm.com    ('BATCH_CMD', 'Batch pool submission command name', 'qdo')
24613576Sciro.santilli@arm.com    )
24713576Sciro.santilli@arm.com
24813576Sciro.santilli@arm.com# Non-sticky options only apply to the current build.
24913576Sciro.santilli@arm.comnonsticky_opts = Options(args=ARGUMENTS)
25013576Sciro.santilli@arm.comnonsticky_opts.AddOptions(
25113576Sciro.santilli@arm.com    BoolOption('update_ref', 'Update test reference outputs', False)
25213576Sciro.santilli@arm.com    )
25313576Sciro.santilli@arm.com
25413576Sciro.santilli@arm.com# These options get exported to #defines in config/*.hh (see m5/SConscript).
25513576Sciro.santilli@arm.comenv.ExportOptions = ['FULL_SYSTEM', 'ALPHA_TLASER', 'USE_FENV', \
25613576Sciro.santilli@arm.com                     'USE_MYSQL', 'NO_FAST_ALLOC', 'SS_COMPATIBLE_FP', \
25713576Sciro.santilli@arm.com                     'STATS_BINNING']
25813630Sciro.santilli@arm.com
25913630Sciro.santilli@arm.com# Define a handy 'no-op' action
26013576Sciro.santilli@arm.comdef no_action(target, source, env):
26113576Sciro.santilli@arm.com    return 0
26213576Sciro.santilli@arm.com
26313576Sciro.santilli@arm.comenv.NoAction = Action(no_action, None)
26413576Sciro.santilli@arm.com
26513576Sciro.santilli@arm.com# libelf build is described in its own SConscript file.
26613576Sciro.santilli@arm.com# SConscript-global is the build in build/libelf shared among all
26713576Sciro.santilli@arm.com# configs.
26813576Sciro.santilli@arm.comenv.SConscript('m5/libelf/SConscript-global', exports = 'env')
26913576Sciro.santilli@arm.com
27013576Sciro.santilli@arm.com###################################################
27113576Sciro.santilli@arm.com#
27213576Sciro.santilli@arm.com# Define a SCons builder for configuration flag headers.
27313576Sciro.santilli@arm.com#
27413576Sciro.santilli@arm.com###################################################
27513576Sciro.santilli@arm.com
27613576Sciro.santilli@arm.com# This function generates a config header file that #defines the
27713576Sciro.santilli@arm.com# option symbol to the current option setting (0 or 1).  The source
27813576Sciro.santilli@arm.com# operands are the name of the option and a Value node containing the
27913576Sciro.santilli@arm.com# value of the option.
28013576Sciro.santilli@arm.comdef build_config_file(target, source, env):
28113576Sciro.santilli@arm.com    (option, value) = [s.get_contents() for s in source]
28213576Sciro.santilli@arm.com    f = file(str(target[0]), 'w')
28313576Sciro.santilli@arm.com    print >> f, '#define', option, value
28413576Sciro.santilli@arm.com    f.close()
28513576Sciro.santilli@arm.com    return None
28613576Sciro.santilli@arm.com
28713576Sciro.santilli@arm.com# Generate the message to be printed when building the config file.
28813576Sciro.santilli@arm.comdef build_config_file_string(target, source, env):
28913576Sciro.santilli@arm.com    (option, value) = [s.get_contents() for s in source]
29013576Sciro.santilli@arm.com    return "Defining %s as %s in %s." % (option, value, target[0])
29113576Sciro.santilli@arm.com
29213576Sciro.santilli@arm.com# Combine the two functions into a scons Action object.
29313576Sciro.santilli@arm.comconfig_action = Action(build_config_file, build_config_file_string)
29413576Sciro.santilli@arm.com
29513576Sciro.santilli@arm.com# The emitter munges the source & target node lists to reflect what
29613576Sciro.santilli@arm.com# we're really doing.
29713577Sciro.santilli@arm.comdef config_emitter(target, source, env):
29813577Sciro.santilli@arm.com    # extract option name from Builder arg
29913577Sciro.santilli@arm.com    option = str(target[0])
3006143Snate@binkert.org    # True target is config header file
30112302Sgabeblack@google.com    target = os.path.join('config', option.lower() + '.hh')
30212302Sgabeblack@google.com    # Force value to 0/1 even if it's a Python bool
30312302Sgabeblack@google.com    val = int(eval(str(env[option])))
30412302Sgabeblack@google.com    # Sources are option name & value (packaged in SCons Value nodes)
30512302Sgabeblack@google.com    return ([target], [Value(option), Value(val)])
30612302Sgabeblack@google.com
30712302Sgabeblack@google.comconfig_builder = Builder(emitter = config_emitter, action = config_action)
30812302Sgabeblack@google.com
30911983Sgabeblack@google.comenv.Append(BUILDERS = { 'ConfigFile' : config_builder })
31011983Sgabeblack@google.com
31111983Sgabeblack@google.com###################################################
31212302Sgabeblack@google.com#
31312302Sgabeblack@google.com# Define build environments for selected configurations.
31412302Sgabeblack@google.com#
31512302Sgabeblack@google.com###################################################
31612302Sgabeblack@google.com
31712302Sgabeblack@google.com# rename base env
31811983Sgabeblack@google.combase_env = env
3196143Snate@binkert.org
32012305Sgabeblack@google.comfor build_dir in build_dirs:
32112302Sgabeblack@google.com    # Make a copy of the default environment to use for this config.
32212302Sgabeblack@google.com    env = base_env.Copy()
32312302Sgabeblack@google.com
3246143Snate@binkert.org    # Record what build_dir was in the environment
3256143Snate@binkert.org    env.Append(BUILD_DIR=build_dir);
3266143Snate@binkert.org
3275522Snate@binkert.org    # Set env according to the build directory config.
3286143Snate@binkert.org
3296143Snate@binkert.org    sticky_opts.files = []
3306143Snate@binkert.org    # Name of default options file is taken from 'default=' on command
3319982Satgutier@umich.edu    # line if set, otherwise name of build dir.
33212302Sgabeblack@google.com    default_options_file = os.path.join('build_options', 'default',
33312302Sgabeblack@google.com                                        ARGUMENTS.get('default', build_dir))
33412302Sgabeblack@google.com    if os.path.isfile(default_options_file):
3356143Snate@binkert.org        sticky_opts.files.append(default_options_file)
3366143Snate@binkert.org    current_options_file = os.path.join('build_options', 'current', build_dir)
3376143Snate@binkert.org    if os.path.isfile(current_options_file):
3386143Snate@binkert.org        sticky_opts.files.append(current_options_file)
3395522Snate@binkert.org    else:
3405522Snate@binkert.org        # if file doesn't exist, make sure at least the directory is there
3415522Snate@binkert.org        # so we can create it later
3425522Snate@binkert.org        opt_dir = os.path.dirname(current_options_file)
3435604Snate@binkert.org        if not os.path.isdir(opt_dir):
3445604Snate@binkert.org            os.mkdir(opt_dir)
3456143Snate@binkert.org    if not sticky_opts.files:
3466143Snate@binkert.org        print "%s: No options file found in build_options, using defaults." \
3474762Snate@binkert.org              % build_dir
3484762Snate@binkert.org
3496143Snate@binkert.org    # Apply current option settings to env
3506727Ssteve.reinhardt@amd.com    sticky_opts.Update(env)
3516727Ssteve.reinhardt@amd.com    nonsticky_opts.Update(env)
3526727Ssteve.reinhardt@amd.com
3534762Snate@binkert.org    # Process option settings.
3546143Snate@binkert.org
3556143Snate@binkert.org    if not have_fenv and env['USE_FENV']:
3566143Snate@binkert.org        print "Warning: <fenv.h> not available; " \
3576143Snate@binkert.org              "forcing USE_FENV to False in", build_dir + "."
3586727Ssteve.reinhardt@amd.com        env['USE_FENV'] = False
3596143Snate@binkert.org
3607674Snate@binkert.org    if not env['USE_FENV']:
3617674Snate@binkert.org        print "Warning: No IEEE FP rounding mode control in", build_dir + "."
3625604Snate@binkert.org        print "         FP results may deviate slightly from other platforms."
3636143Snate@binkert.org
3646143Snate@binkert.org    if env['EFENCE']:
3656143Snate@binkert.org        env.Append(LIBS=['efence'])
3664762Snate@binkert.org
3676143Snate@binkert.org    if env['USE_MYSQL']:
3684762Snate@binkert.org        if not have_mysql:
3694762Snate@binkert.org            print "Warning: MySQL not available; " \
3704762Snate@binkert.org                  "forcing USE_MYSQL to False in", build_dir + "."
3716143Snate@binkert.org            env['USE_MYSQL'] = False
3726143Snate@binkert.org        else:
3734762Snate@binkert.org            print "Compiling in", build_dir, "with MySQL support."
37412302Sgabeblack@google.com            env.ParseConfig(mysql_config_libs)
37512302Sgabeblack@google.com            env.ParseConfig(mysql_config_include)
3768233Snate@binkert.org
37712302Sgabeblack@google.com    # Save sticky option settings back to current options file
3786143Snate@binkert.org    sticky_opts.Save(current_options_file, env)
3796143Snate@binkert.org
3804762Snate@binkert.org    # Do this after we save setting back, or else we'll tack on an
3816143Snate@binkert.org    # extra 'qdo' every time we run scons.
3824762Snate@binkert.org    if env['BATCH']:
3839396Sandreas.hansson@arm.com        env['CC']  = env['BATCH_CMD'] + ' ' + env['CC']
3849396Sandreas.hansson@arm.com        env['CXX'] = env['BATCH_CMD'] + ' ' + env['CXX']
3859396Sandreas.hansson@arm.com
38612302Sgabeblack@google.com    if env['USE_SSE2']:
38712302Sgabeblack@google.com        env.Append(CCFLAGS='-msse2')
38812302Sgabeblack@google.com
3899396Sandreas.hansson@arm.com    # The m5/SConscript file sets up the build rules in 'env' according
3909396Sandreas.hansson@arm.com    # to the configured options.  It returns a list of environments,
3919396Sandreas.hansson@arm.com    # one for each variant build (debug, opt, etc.)
3929396Sandreas.hansson@arm.com    envList = SConscript('m5/SConscript', build_dir = build_dir,
3939396Sandreas.hansson@arm.com                         exports = 'env', duplicate = False)
3949396Sandreas.hansson@arm.com
3959396Sandreas.hansson@arm.com    # Set up the regression tests for each build.
3969930Sandreas.hansson@arm.com    for e in envList:
3979930Sandreas.hansson@arm.com        SConscript('m5-test/SConscript',
3989396Sandreas.hansson@arm.com                   build_dir = os.path.join(build_dir, 'test', e.Label),
3996143Snate@binkert.org                   exports = { 'env' : e }, duplicate = False)
40012797Sgabeblack@google.com
40112797Sgabeblack@google.com###################################################
40212797Sgabeblack@google.com#
4038235Snate@binkert.org# Let SCons do its thing.  At this point SCons will use the defined
40412797Sgabeblack@google.com# build environments to build the requested targets.
40512797Sgabeblack@google.com#
40612797Sgabeblack@google.com###################################################
40712797Sgabeblack@google.com
40812797Sgabeblack@google.com