SConstruct revision 2665
1360SN/A# -*- mode:python -*-
21458SN/A
3360SN/A# Copyright (c) 2004-2005 The Regents of The University of Michigan
4360SN/A# All rights reserved.
5360SN/A#
6360SN/A# Redistribution and use in source and binary forms, with or without
7360SN/A# modification, are permitted provided that the following conditions are
8360SN/A# met: redistributions of source code must retain the above copyright
9360SN/A# notice, this list of conditions and the following disclaimer;
10360SN/A# redistributions in binary form must reproduce the above copyright
11360SN/A# notice, this list of conditions and the following disclaimer in the
12360SN/A# documentation and/or other materials provided with the distribution;
13360SN/A# neither the name of the copyright holders nor the names of its
14360SN/A# contributors may be used to endorse or promote products derived from
15360SN/A# this software without specific prior written permission.
16360SN/A#
17360SN/A# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18360SN/A# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19360SN/A# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20360SN/A# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21360SN/A# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22360SN/A# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23360SN/A# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24360SN/A# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25360SN/A# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26360SN/A# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
272665Ssaidi@eecs.umich.edu# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
282665Ssaidi@eecs.umich.edu#
292665Ssaidi@eecs.umich.edu# Authors: Steve Reinhardt
30360SN/A
31360SN/A###################################################
321354SN/A#
331354SN/A# SCons top-level build description (SConstruct) file.
34360SN/A#
352764Sstever@eecs.umich.edu# While in this directory ('m5'), just type 'scons' to build the default
362764Sstever@eecs.umich.edu# configuration (see below), or type 'scons build/<CONFIG>/<binary>'
372064SN/A# to build some other configuration (e.g., 'build/ALPHA_FS/m5.opt' for
38360SN/A# the optimized full-system version).
39360SN/A#
40360SN/A# You can build M5 in a different directory as long as there is a
41360SN/A# 'build/<CONFIG>' somewhere along the target path.  The build system
42360SN/A# expdects that all configs under the same build directory are being
43360SN/A# built for the same host system.
441809SN/A#
455543Ssaidi@eecs.umich.edu# Examples:
461809SN/A#   These two commands are equivalent.  The '-u' option tells scons to
473113Sgblack@eecs.umich.edu#   search up the directory tree for this SConstruct file.
488229Snate@binkert.org#   % cd <path-to-src>/m5 ; scons build/ALPHA_FS/m5.debug
498229Snate@binkert.org#   % cd <path-to-src>/m5/build/ALPHA_FS; scons -u m5.debug
503113Sgblack@eecs.umich.edu#   These two commands are equivalent and demonstrate building in a
517075Snate@binkert.org#   directory outside of the source tree.  The '-C' option tells scons
528229Snate@binkert.org#   to chdir to the specified directory to find this SConstruct file.
537075Snate@binkert.org#   % cd <path-to-src>/m5 ; scons /local/foo/build/ALPHA_FS/m5.debug
54360SN/A#   % cd /local/foo/build/ALPHA_FS; scons -C <path-to-src>/m5 m5.debug
552474SN/A#
565543Ssaidi@eecs.umich.edu# You can use 'scons -H' to print scons options.  If you're in this
572462SN/A# 'm5' directory (or use -u or -C to tell scons where to find this
581354SN/A# file), you can use 'scons -h' to print all the M5-specific build
596216Snate@binkert.org# options as well.
606658Snate@binkert.org#
612474SN/A###################################################
622680Sktlim@umich.edu
638232Snate@binkert.org# Python library imports
648229Snate@binkert.orgimport sys
658706Sandreas.hansson@arm.comimport os
667678Sgblack@eecs.umich.edu
678229Snate@binkert.org# Check for recent-enough Python and SCons versions.  If your system's
688766Sgblack@eecs.umich.edu# default installation of Python is not recent enough, you can use a
696640Svince@csl.cornell.edu# non-default installation of the Python interpreter by either (1)
70360SN/A# rearranging your PATH so that scons finds the non-default 'python'
71360SN/A# first or (2) explicitly invoking an alternative interpreter on the
72360SN/A# scons script, e.g., "/usr/local/bin/python2.4 `which scons` [args]".
73360SN/AEnsurePythonVersion(2,4)
74360SN/A
75360SN/A# Ironically, SCons 0.96 dies if you give EnsureSconsVersion a
76360SN/A# 3-element version number.
77360SN/Amin_scons_version = (0,96,91)
78378SN/Atry:
791450SN/A    EnsureSConsVersion(*min_scons_version)
803114Sgblack@eecs.umich.eduexcept:
81360SN/A    print "Error checking current SCons version."
825543Ssaidi@eecs.umich.edu    print "SCons", ".".join(map(str,min_scons_version)), "or greater required."
835543Ssaidi@eecs.umich.edu    Exit(2)
845543Ssaidi@eecs.umich.edu    
85360SN/A
86360SN/A# The absolute path to the current directory (where this file lives).
87360SN/AROOT = Dir('.').abspath
88360SN/A
89360SN/A# Paths to the M5 and external source trees.
902680Sktlim@umich.eduSRCDIR = os.path.join(ROOT, 'src')
91360SN/A
92360SN/A# tell python where to find m5 python code
93360SN/Asys.path.append(os.path.join(ROOT, 'src/python'))
94360SN/A
95360SN/A###################################################
96360SN/A#
97360SN/A# Figure out which configurations to set up based on the path(s) of
98360SN/A# the target(s).
99360SN/A#
100360SN/A###################################################
101360SN/A
1023114Sgblack@eecs.umich.edu# Find default configuration & binary.
103360SN/ADefault(os.environ.get('M5_DEFAULT_BINARY', 'build/ALPHA_SE/m5.debug'))
104360SN/A
105360SN/A# Ask SCons which directory it was invoked from.
106360SN/Alaunch_dir = GetLaunchDir()
107360SN/A
108360SN/A# Make targets relative to invocation directory
109360SN/Aabs_targets = map(lambda x: os.path.normpath(os.path.join(launch_dir, str(x))),
110360SN/A                  BUILD_TARGETS)
111360SN/A
112360SN/A# helper function: find last occurrence of element in list
113360SN/Adef rfind(l, elt, offs = -1):
114360SN/A    for i in range(len(l)+offs, 0, -1):
115360SN/A        if l[i] == elt:
116360SN/A            return i
117360SN/A    raise ValueError, "element not found"
118360SN/A
119360SN/A# Each target must have 'build' in the interior of the path; the
120360SN/A# directory below this will determine the build parameters.  For
121360SN/A# example, for target 'foo/bar/build/ALPHA_SE/arch/alpha/blah.do' we
122360SN/A# recognize that ALPHA_SE specifies the configuration because it
123360SN/A# follow 'build' in the bulid path.
1248852Sandreas.hansson@arm.com
125360SN/A# Generate a list of the unique build roots and configs that the
1268852Sandreas.hansson@arm.com# collected targets reference.
1275543Ssaidi@eecs.umich.edubuild_paths = []
128360SN/Abuild_root = None
129360SN/Afor t in abs_targets:
130360SN/A    path_dirs = t.split('/')
131360SN/A    try:
132360SN/A        build_top = rfind(path_dirs, 'build', -2)
1338852Sandreas.hansson@arm.com    except:
134360SN/A        print "Error: no non-leaf 'build' dir found on target path", t
1358852Sandreas.hansson@arm.com        Exit(1)
1365543Ssaidi@eecs.umich.edu    this_build_root = os.path.join('/',*path_dirs[:build_top+1])
137360SN/A    if not build_root:
138360SN/A        build_root = this_build_root
139360SN/A    else:
140360SN/A        if this_build_root != build_root:
141360SN/A            print "Error: build targets not under same build root\n"\
142360SN/A                  "  %s\n  %s" % (build_root, this_build_root)
143360SN/A            Exit(1)
144360SN/A    build_path = os.path.join('/',*path_dirs[:build_top+2])
145360SN/A    if build_path not in build_paths:
146360SN/A        build_paths.append(build_path)
147360SN/A
148360SN/A###################################################
149360SN/A#
1505543Ssaidi@eecs.umich.edu# Set up the default build environment.  This environment is copied
151360SN/A# and modified according to each selected configuration.
152360SN/A#
153360SN/A###################################################
154360SN/A
155360SN/Aenv = Environment(ENV = os.environ,  # inherit user's environment vars
156360SN/A                  ROOT = ROOT,
157360SN/A                  SRCDIR = SRCDIR)
158360SN/A
159360SN/Aenv.SConsignFile("sconsign")
160360SN/A
161360SN/A# I waffle on this setting... it does avoid a few painful but
162360SN/A# unnecessary builds, but it also seems to make trivial builds take
163360SN/A# noticeably longer.
164360SN/Aif False:
165360SN/A    env.TargetSignatures('content')
166360SN/A
167360SN/A# M5_PLY is used by isa_parser.py to find the PLY package.
1685543Ssaidi@eecs.umich.eduenv.Append(ENV = { 'M5_PLY' : Dir('ext/ply') })
1695543Ssaidi@eecs.umich.edu
170502SN/A# Set up default C++ compiler flags
171360SN/Aenv.Append(CCFLAGS='-pipe')
172360SN/Aenv.Append(CCFLAGS='-fno-strict-aliasing')
173360SN/Aenv.Append(CCFLAGS=Split('-Wall -Wno-sign-compare -Werror -Wundef'))
174360SN/Aif sys.platform == 'cygwin':
175360SN/A    # cygwin has some header file issues...
176360SN/A    env.Append(CCFLAGS=Split("-Wno-uninitialized"))
177360SN/Aenv.Append(CPPPATH=[Dir('ext/dnet')])
178360SN/A
179360SN/A# Find Python include and library directories for embedding the
180360SN/A# interpreter.  For consistency, we will use the same Python
181360SN/A# installation used to run scons (and thus this script).  If you want
182378SN/A# to link in an alternate version, see above for instructions on how
1831706SN/A# to invoke scons with a different copy of the Python interpreter.
1843114Sgblack@eecs.umich.edu
185378SN/A# Get brief Python version name (e.g., "python2.4") for locating
186378SN/A# include & library files
187378SN/Apy_version_name = 'python' + sys.version[:3]
188378SN/A
189378SN/A# include path, e.g. /usr/local/include/python2.4
1901706SN/Aenv.Append(CPPPATH = os.path.join(sys.exec_prefix, 'include', py_version_name))
1913114Sgblack@eecs.umich.eduenv.Append(LIBS = py_version_name)
1928149SChris.Emmons@ARM.com# add library path too if it's not in the default place
1938149SChris.Emmons@ARM.comif sys.exec_prefix != '/usr':
194360SN/A    env.Append(LIBPATH = os.path.join(sys.exec_prefix, 'lib'))
1956109Ssanchezd@stanford.edu
1961706SN/A# Other default libraries
1973114Sgblack@eecs.umich.eduenv.Append(LIBS=['z'])
198378SN/A
1996109Ssanchezd@stanford.edu# Platform-specific configuration.  Note again that we assume that all
2006109Ssanchezd@stanford.edu# builds under a given build root run on the same host platform.
2016109Ssanchezd@stanford.educonf = Configure(env,
2026109Ssanchezd@stanford.edu                 conf_dir = os.path.join(build_root, '.scons_config'),
203378SN/A                 log_file = os.path.join(build_root, 'scons_config.log'))
2041706SN/A
2053114Sgblack@eecs.umich.edu# Check for <fenv.h> (C99 FP environment control)
206378SN/Ahave_fenv = conf.CheckHeader('fenv.h', '<>')
2075748SSteve.Reinhardt@amd.comif not have_fenv:
2085748SSteve.Reinhardt@amd.com    print "Warning: Header file <fenv.h> not found."
2095748SSteve.Reinhardt@amd.com    print "         This host has no IEEE FP rounding mode control."
210378SN/A
211378SN/A# Check for mysql.
2121706SN/Amysql_config = WhereIs('mysql_config')
2133114Sgblack@eecs.umich.eduhave_mysql = mysql_config != None
214378SN/A
215378SN/A# Check MySQL version.
2161706SN/Aif have_mysql:
2173114Sgblack@eecs.umich.edu    mysql_version = os.popen(mysql_config + ' --version').read()
218378SN/A    mysql_version = mysql_version.split('.')
219378SN/A    mysql_major = int(mysql_version[0])
2201706SN/A    mysql_minor = int(mysql_version[1])
2213114Sgblack@eecs.umich.edu    # This version check is probably overly conservative, but it deals
222378SN/A    # with the versions we have installed.
223378SN/A    if mysql_major < 4 or (mysql_major == 4 and mysql_minor < 1):
2241706SN/A        print "Warning: MySQL v4.1 or newer required."
2253114Sgblack@eecs.umich.edu        have_mysql = False
226378SN/A
2274118Sgblack@eecs.umich.edu# Set up mysql_config commands.
2284118Sgblack@eecs.umich.eduif have_mysql:
2294118Sgblack@eecs.umich.edu    mysql_config_include = mysql_config + ' --include'
2304118Sgblack@eecs.umich.edu    if os.system(mysql_config_include + ' > /dev/null') != 0:
231378SN/A        # older mysql_config versions don't support --include, use
2321706SN/A        # --cflags instead
2333114Sgblack@eecs.umich.edu        mysql_config_include = mysql_config + ' --cflags | sed s/\\\'//g'
234378SN/A    # This seems to work in all versions
235378SN/A    mysql_config_libs = mysql_config + ' --libs'
2361706SN/A
2373114Sgblack@eecs.umich.eduenv = conf.Finish()
238360SN/A
2395513SMichael.Adler@intel.com# Define the universe of supported ISAs
2405513SMichael.Adler@intel.comenv['ALL_ISA_LIST'] = ['alpha', 'sparc', 'mips']
2415513SMichael.Adler@intel.com
2425513SMichael.Adler@intel.com# Define the universe of supported CPU models
2435513SMichael.Adler@intel.comenv['ALL_CPU_LIST'] = ['AtomicSimpleCPU', 'TimingSimpleCPU',
2445513SMichael.Adler@intel.com                       'FullCPU', 'AlphaFullCPU']
2455513SMichael.Adler@intel.com
2465513SMichael.Adler@intel.com# Sticky options get saved in the options file so they persist from
247511SN/A# one invocation to the next (unless overridden, in which case the new
2481706SN/A# value becomes sticky).
2493114Sgblack@eecs.umich.edusticky_opts = Options(args=ARGUMENTS)
250511SN/Asticky_opts.AddOptions(
2515513SMichael.Adler@intel.com    EnumOption('TARGET_ISA', 'Target ISA', 'alpha', env['ALL_ISA_LIST']),
2525513SMichael.Adler@intel.com    BoolOption('FULL_SYSTEM', 'Full-system support', False),
2535513SMichael.Adler@intel.com    # There's a bug in scons 0.96.1 that causes ListOptions with list
2545513SMichael.Adler@intel.com    # values (more than one value) not to be able to be restored from
255511SN/A    # a saved option file.  If this causes trouble then upgrade to
2561706SN/A    # scons 0.96.90 or later.
2573114Sgblack@eecs.umich.edu    ListOption('CPU_MODELS', 'CPU models', 'AtomicSimpleCPU,TimingSimpleCPU',
2581706SN/A               env['ALL_CPU_LIST']),
2591706SN/A    BoolOption('ALPHA_TLASER',
2601706SN/A               'Model Alpha TurboLaser platform (vs. Tsunami)', False),
2611706SN/A    BoolOption('NO_FAST_ALLOC', 'Disable fast object allocator', False),
2623114Sgblack@eecs.umich.edu    BoolOption('EFENCE', 'Link with Electric Fence malloc debugger',
2631706SN/A               False),
2641706SN/A    BoolOption('SS_COMPATIBLE_FP',
2651706SN/A               'Make floating-point results compatible with SimpleScalar',
2661706SN/A               False),
2673114Sgblack@eecs.umich.edu    BoolOption('USE_SSE2',
2681706SN/A               'Compile for SSE2 (-msse2) to get IEEE FP on x86 hosts',
269511SN/A               False),
2706703Svince@csl.cornell.edu    BoolOption('STATS_BINNING', 'Bin statistics by CPU mode', have_mysql),
2716703Svince@csl.cornell.edu    BoolOption('USE_MYSQL', 'Use MySQL for stats output', have_mysql),
2726703Svince@csl.cornell.edu    BoolOption('USE_FENV', 'Use <fenv.h> IEEE mode control', have_fenv),
2736703Svince@csl.cornell.edu    ('CC', 'C compiler', os.environ.get('CC', env['CC'])),
2746685Stjones1@inf.ed.ac.uk    ('CXX', 'C++ compiler', os.environ.get('CXX', env['CXX'])),
2756685Stjones1@inf.ed.ac.uk    BoolOption('BATCH', 'Use batch pool for build and tests', False),
2766685Stjones1@inf.ed.ac.uk    ('BATCH_CMD', 'Batch pool submission command name', 'qdo')
2776685Stjones1@inf.ed.ac.uk    )
2786685Stjones1@inf.ed.ac.uk
2795513SMichael.Adler@intel.com# Non-sticky options only apply to the current build.
2805513SMichael.Adler@intel.comnonsticky_opts = Options(args=ARGUMENTS)
2815513SMichael.Adler@intel.comnonsticky_opts.AddOptions(
2825513SMichael.Adler@intel.com    BoolOption('update_ref', 'Update test reference outputs', False)
2835513SMichael.Adler@intel.com    )
2841999SN/A
2851999SN/A# These options get exported to #defines in config/*.hh (see m5/SConscript).
2863114Sgblack@eecs.umich.eduenv.ExportOptions = ['FULL_SYSTEM', 'ALPHA_TLASER', 'USE_FENV', \
2871999SN/A                     'USE_MYSQL', 'NO_FAST_ALLOC', 'SS_COMPATIBLE_FP', \
2881999SN/A                     'STATS_BINNING']
2891999SN/A
2901999SN/A# Define a handy 'no-op' action
2913114Sgblack@eecs.umich.edudef no_action(target, source, env):
2921999SN/A    return 0
2933079Sstever@eecs.umich.edu
2943079Sstever@eecs.umich.eduenv.NoAction = Action(no_action, None)
2953114Sgblack@eecs.umich.edu
2963079Sstever@eecs.umich.edu###################################################
2972093SN/A#
2982093SN/A# Define a SCons builder for configuration flag headers.
2993114Sgblack@eecs.umich.edu#
3002093SN/A###################################################
3012687Sksewell@umich.edu
3022687Sksewell@umich.edu# This function generates a config header file that #defines the
3033114Sgblack@eecs.umich.edu# option symbol to the current option setting (0 or 1).  The source
3042687Sksewell@umich.edu# operands are the name of the option and a Value node containing the
3052238SN/A# value of the option.
3062238SN/Adef build_config_file(target, source, env):
3073114Sgblack@eecs.umich.edu    (option, value) = [s.get_contents() for s in source]
3082238SN/A    f = file(str(target[0]), 'w')
3092238SN/A    print >> f, '#define', option, value
3102238SN/A    f.close()
3113114Sgblack@eecs.umich.edu    return None
3122238SN/A
3132238SN/A# Generate the message to be printed when building the config file.
3142238SN/Adef build_config_file_string(target, source, env):
3153114Sgblack@eecs.umich.edu    (option, value) = [s.get_contents() for s in source]
3162238SN/A    return "Defining %s as %s in %s." % (option, value, target[0])
3172238SN/A
3182238SN/A# Combine the two functions into a scons Action object.
3193114Sgblack@eecs.umich.educonfig_action = Action(build_config_file, build_config_file_string)
3202238SN/A
3212238SN/A# The emitter munges the source & target node lists to reflect what
3222238SN/A# we're really doing.
3233114Sgblack@eecs.umich.edudef config_emitter(target, source, env):
3242238SN/A    # extract option name from Builder arg
3252238SN/A    option = str(target[0])
3262238SN/A    # True target is config header file
3273114Sgblack@eecs.umich.edu    target = os.path.join('config', option.lower() + '.hh')
3282238SN/A    # Force value to 0/1 even if it's a Python bool
3292238SN/A    val = int(eval(str(env[option])))
3302238SN/A    # Sources are option name & value (packaged in SCons Value nodes)
3313114Sgblack@eecs.umich.edu    return ([target], [Value(option), Value(val)])
3322238SN/A
3336109Ssanchezd@stanford.educonfig_builder = Builder(emitter = config_emitter, action = config_action)
3346109Ssanchezd@stanford.edu
3356109Ssanchezd@stanford.eduenv.Append(BUILDERS = { 'ConfigFile' : config_builder })
3362238SN/A
3372238SN/A###################################################
3382238SN/A#
3392238SN/A# Define a SCons builder for copying files.  This is used by the
3402238SN/A# Python zipfile code in src/python/SConscript, but is placed up here
3413114Sgblack@eecs.umich.edu# since it's potentially more generally applicable.
3422238SN/A#
3432238SN/A###################################################
3442238SN/A
3453114Sgblack@eecs.umich.educopy_builder = Builder(action = Copy("$TARGET", "$SOURCE"))
3462238SN/A
3472238SN/Aenv.Append(BUILDERS = { 'CopyFile' : copy_builder })
3482238SN/A
3493114Sgblack@eecs.umich.edu###################################################
3502238SN/A#
3512238SN/A# Define a simple SCons builder to concatenate files.
3522238SN/A#
3533114Sgblack@eecs.umich.edu# Used to append the Python zip archive to the executable.
3542238SN/A#
3552238SN/A###################################################
3561354SN/A
3571354SN/Aconcat_builder = Builder(action = Action(['cat $SOURCES > $TARGET',
3581354SN/A                                          'chmod +x $TARGET']))
3591354SN/A
3601354SN/Aenv.Append(BUILDERS = { 'Concat' : concat_builder })
3611354SN/A
3621354SN/A
3631354SN/A# base help text
3641354SN/Ahelp_text = '''
3651354SN/AUsage: scons [scons options] [build options] [target(s)]
3661354SN/A
3671354SN/A'''
3681354SN/A
3691354SN/A# libelf build is shared across all configs in the build root.
3707823Ssteve.reinhardt@amd.comenv.SConscript('ext/libelf/SConscript',
3711354SN/A               build_dir = os.path.join(build_root, 'libelf'),
3721354SN/A               exports = 'env')
3731354SN/A
3741354SN/A###################################################
375360SN/A#
376360SN/A# Define build environments for selected configurations.
377360SN/A#
378360SN/A###################################################
379360SN/A
380360SN/A# rename base env
381360SN/Abase_env = env
3823113Sgblack@eecs.umich.edu
3833113Sgblack@eecs.umich.edufor build_path in build_paths:
3843113Sgblack@eecs.umich.edu    print "Building in", build_path
3853113Sgblack@eecs.umich.edu    # build_dir is the tail component of build path, and is used to
3863113Sgblack@eecs.umich.edu    # determine the build parameters (e.g., 'ALPHA_SE')
3873113Sgblack@eecs.umich.edu    (build_root, build_dir) = os.path.split(build_path)
3883113Sgblack@eecs.umich.edu    # Make a copy of the build-root environment to use for this config.
3893113Sgblack@eecs.umich.edu    env = base_env.Copy()
3903113Sgblack@eecs.umich.edu
3913113Sgblack@eecs.umich.edu    # Set env options according to the build directory config.
3923113Sgblack@eecs.umich.edu    sticky_opts.files = []
3933113Sgblack@eecs.umich.edu    # Options for $BUILD_ROOT/$BUILD_DIR are stored in
3943113Sgblack@eecs.umich.edu    # $BUILD_ROOT/options/$BUILD_DIR so you can nuke
3953113Sgblack@eecs.umich.edu    # $BUILD_ROOT/$BUILD_DIR without losing your options settings.
3963113Sgblack@eecs.umich.edu    current_opts_file = os.path.join(build_root, 'options', build_dir)
3973113Sgblack@eecs.umich.edu    if os.path.isfile(current_opts_file):
3984189Sgblack@eecs.umich.edu        sticky_opts.files.append(current_opts_file)
3994189Sgblack@eecs.umich.edu        print "Using saved options file %s" % current_opts_file
4003113Sgblack@eecs.umich.edu    else:
4013113Sgblack@eecs.umich.edu        # Build dir-specific options file doesn't exist.
4023113Sgblack@eecs.umich.edu
4033113Sgblack@eecs.umich.edu        # Make sure the directory is there so we can create it later
4048737Skoansin.tan@gmail.com        opt_dir = os.path.dirname(current_opts_file)
4053113Sgblack@eecs.umich.edu        if not os.path.isdir(opt_dir):
4068737Skoansin.tan@gmail.com            os.mkdir(opt_dir)
4073277Sgblack@eecs.umich.edu
4085515SMichael.Adler@intel.com        # Get default build options from source tree.  Options are
4095515SMichael.Adler@intel.com        # normally determined by name of $BUILD_DIR, but can be
4105515SMichael.Adler@intel.com        # overriden by 'default=' arg on command line.
4115515SMichael.Adler@intel.com        default_opts_file = os.path.join('build_opts',
4125515SMichael.Adler@intel.com                                         ARGUMENTS.get('default', build_dir))
4138737Skoansin.tan@gmail.com        if os.path.isfile(default_opts_file):
4143277Sgblack@eecs.umich.edu            sticky_opts.files.append(default_opts_file)
4158737Skoansin.tan@gmail.com            print "Options file %s not found,\n  using defaults in %s" \
4163277Sgblack@eecs.umich.edu                  % (current_opts_file, default_opts_file)
4178737Skoansin.tan@gmail.com        else:
4183277Sgblack@eecs.umich.edu            print "Error: cannot find options file %s or %s" \
4198737Skoansin.tan@gmail.com                  % (current_opts_file, default_opts_file)
4203113Sgblack@eecs.umich.edu            Exit(1)
4213113Sgblack@eecs.umich.edu
4223113Sgblack@eecs.umich.edu    # Apply current option settings to env
4233113Sgblack@eecs.umich.edu    sticky_opts.Update(env)
4248737Skoansin.tan@gmail.com    nonsticky_opts.Update(env)
4253113Sgblack@eecs.umich.edu
4268737Skoansin.tan@gmail.com    help_text += "Sticky options for %s:\n" % build_dir \
4273114Sgblack@eecs.umich.edu                 + sticky_opts.GenerateHelpText(env) \
4288737Skoansin.tan@gmail.com                 + "\nNon-sticky options for %s:\n" % build_dir \
4293114Sgblack@eecs.umich.edu                 + nonsticky_opts.GenerateHelpText(env)
4308737Skoansin.tan@gmail.com
4313114Sgblack@eecs.umich.edu    # Process option settings.
4328737Skoansin.tan@gmail.com
4334061Sgblack@eecs.umich.edu    if not have_fenv and env['USE_FENV']:
4344061Sgblack@eecs.umich.edu        print "Warning: <fenv.h> not available; " \
4354061Sgblack@eecs.umich.edu              "forcing USE_FENV to False in", build_dir + "."
4368737Skoansin.tan@gmail.com        env['USE_FENV'] = False
4373113Sgblack@eecs.umich.edu
4388737Skoansin.tan@gmail.com    if not env['USE_FENV']:
4393113Sgblack@eecs.umich.edu        print "Warning: No IEEE FP rounding mode control in", build_dir + "."
4403113Sgblack@eecs.umich.edu        print "         FP results may deviate slightly from other platforms."
4413113Sgblack@eecs.umich.edu
4423113Sgblack@eecs.umich.edu    if env['EFENCE']:
4433113Sgblack@eecs.umich.edu        env.Append(LIBS=['efence'])
4443113Sgblack@eecs.umich.edu
4453113Sgblack@eecs.umich.edu    if env['USE_MYSQL']:
4463113Sgblack@eecs.umich.edu        if not have_mysql:
4474189Sgblack@eecs.umich.edu            print "Warning: MySQL not available; " \
4484189Sgblack@eecs.umich.edu                  "forcing USE_MYSQL to False in", build_dir + "."
4493113Sgblack@eecs.umich.edu            env['USE_MYSQL'] = False
4503113Sgblack@eecs.umich.edu        else:
4513113Sgblack@eecs.umich.edu            print "Compiling in", build_dir, "with MySQL support."
4528737Skoansin.tan@gmail.com            env.ParseConfig(mysql_config_libs)
4533113Sgblack@eecs.umich.edu            env.ParseConfig(mysql_config_include)
4548737Skoansin.tan@gmail.com
4553113Sgblack@eecs.umich.edu    # Save sticky option settings back to current options file
4568737Skoansin.tan@gmail.com    sticky_opts.Save(current_opts_file, env)
4573113Sgblack@eecs.umich.edu
4583113Sgblack@eecs.umich.edu    # Do this after we save setting back, or else we'll tack on an
4593113Sgblack@eecs.umich.edu    # extra 'qdo' every time we run scons.
4603113Sgblack@eecs.umich.edu    if env['BATCH']:
4613113Sgblack@eecs.umich.edu        env['CC']  = env['BATCH_CMD'] + ' ' + env['CC']
4623113Sgblack@eecs.umich.edu        env['CXX'] = env['BATCH_CMD'] + ' ' + env['CXX']
4633113Sgblack@eecs.umich.edu
4643113Sgblack@eecs.umich.edu    if env['USE_SSE2']:
4653113Sgblack@eecs.umich.edu        env.Append(CCFLAGS='-msse2')
4663113Sgblack@eecs.umich.edu
4678852Sandreas.hansson@arm.com    # The m5/SConscript file sets up the build rules in 'env' according
4683113Sgblack@eecs.umich.edu    # to the configured options.  It returns a list of environments,
4693113Sgblack@eecs.umich.edu    # one for each variant build (debug, opt, etc.)
4703113Sgblack@eecs.umich.edu    envList = SConscript('src/SConscript', build_dir = build_path,
4713113Sgblack@eecs.umich.edu                         exports = 'env', duplicate = False)
4723113Sgblack@eecs.umich.edu
4733113Sgblack@eecs.umich.edu    # Set up the regression tests for each build.
4743113Sgblack@eecs.umich.edu#    for e in envList:
4753113Sgblack@eecs.umich.edu#        SConscript('m5-test/SConscript',
4763113Sgblack@eecs.umich.edu#                   build_dir = os.path.join(build_dir, 'test', e.Label),
4773113Sgblack@eecs.umich.edu#                   exports = { 'env' : e }, duplicate = False)
4788852Sandreas.hansson@arm.com
4793113Sgblack@eecs.umich.eduHelp(help_text)
4803113Sgblack@eecs.umich.edu
4813113Sgblack@eecs.umich.edu###################################################
4823113Sgblack@eecs.umich.edu#
4836686Stjones1@inf.ed.ac.uk# Let SCons do its thing.  At this point SCons will use the defined
4843113Sgblack@eecs.umich.edu# build environments to build the requested targets.
4853113Sgblack@eecs.umich.edu#
4863113Sgblack@eecs.umich.edu###################################################
487378SN/A
488378SN/A