SConstruct revision 2155
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# To build M5, you need a directory with three things: 34955SN/A# 1. A copy of this file (named SConstruct). 352632Sstever@eecs.umich.edu# 2. A link named 'm5' to the top of the M5 simulator source tree. 362632Sstever@eecs.umich.edu# 3. A link named 'ext' to the top of the M5 external source tree. 372632Sstever@eecs.umich.edu# 382632Sstever@eecs.umich.edu# Then type 'scons' to build the default configuration (see below), or 39955SN/A# 'scons <CONFIG>/<binary>' to build some other configuration (e.g., 402632Sstever@eecs.umich.edu# 'ALPHA_FS/m5.opt' for the optimized full-system version). 412632Sstever@eecs.umich.edu# 422761Sstever@eecs.umich.edu################################################### 432632Sstever@eecs.umich.edu 442632Sstever@eecs.umich.edu# Python library imports 452632Sstever@eecs.umich.eduimport sys 462761Sstever@eecs.umich.eduimport os 472761Sstever@eecs.umich.edu 482761Sstever@eecs.umich.edu# Check for recent-enough Python and SCons versions 492632Sstever@eecs.umich.eduEnsurePythonVersion(2,3) 502632Sstever@eecs.umich.eduEnsureSConsVersion(0,96) 512761Sstever@eecs.umich.edu 522761Sstever@eecs.umich.edu# The absolute path to the current directory (where this file lives). 532761Sstever@eecs.umich.eduROOT = Dir('.').abspath 542761Sstever@eecs.umich.edu 552761Sstever@eecs.umich.edu# Paths to the M5 and external source trees (local symlinks). 562632Sstever@eecs.umich.eduSRCDIR = os.path.join(ROOT, 'm5') 572632Sstever@eecs.umich.eduEXT_SRCDIR = os.path.join(ROOT, 'ext') 582632Sstever@eecs.umich.edu 592632Sstever@eecs.umich.edu# Check for 'm5' and 'ext' links, die if they don't exist. 602632Sstever@eecs.umich.eduif not os.path.isdir(SRCDIR): 612632Sstever@eecs.umich.edu print "Error: '%s' must be a link to the M5 source tree." % SRCDIR 622632Sstever@eecs.umich.edu Exit(1) 63955SN/A 64955SN/Aif not os.path.isdir('ext'): 65955SN/A print "Error: '%s' must be a link to the M5 external source tree." \ 66955SN/A % EXT_SRCDIR 67955SN/A Exit(1) 683918Ssaidi@eecs.umich.edu 694202Sbinkertn@umich.edu# tell python where to find m5 python code 703716Sstever@eecs.umich.edusys.path.append(os.path.join(SRCDIR, 'python')) 71955SN/A 722656Sstever@eecs.umich.edu################################################### 732656Sstever@eecs.umich.edu# 742656Sstever@eecs.umich.edu# Figure out which configurations to set up. 752656Sstever@eecs.umich.edu# 762656Sstever@eecs.umich.edu# 772656Sstever@eecs.umich.edu# It's prohibitive to do all the combinations of base configurations 782656Sstever@eecs.umich.edu# and options, so we have to infer which ones the user wants. 792653Sstever@eecs.umich.edu# 802653Sstever@eecs.umich.edu# 1. If there are command-line targets, the configuration(s) are inferred 812653Sstever@eecs.umich.edu# from the directories of those targets. If scons was invoked from a 822653Sstever@eecs.umich.edu# subdirectory (using 'scons -u'), those targets have to be 832653Sstever@eecs.umich.edu# interpreted relative to that subdirectory. 842653Sstever@eecs.umich.edu# 852653Sstever@eecs.umich.edu# 2. If there are no command-line targets, and scons was invoked from a 862653Sstever@eecs.umich.edu# subdirectory (using 'scons -u'), the configuration is inferred from 872653Sstever@eecs.umich.edu# the name of the subdirectory. 882653Sstever@eecs.umich.edu# 892653Sstever@eecs.umich.edu# 3. If there are no command-line targets and scons was invoked from 901852SN/A# the root build directory, a default configuration is used. The 91955SN/A# built-in default is ALPHA_SE, but this can be overridden by setting the 92955SN/A# M5_DEFAULT_CONFIG shell environment veriable. 93955SN/A# 943717Sstever@eecs.umich.edu# In cases 2 & 3, the specific file target defaults to 'm5.debug', but 953716Sstever@eecs.umich.edu# this can be overridden by setting the M5_DEFAULT_BINARY shell 96955SN/A# environment veriable. 971533SN/A# 983716Sstever@eecs.umich.edu################################################### 991533SN/A 100955SN/A# Find default configuration & binary. 101955SN/Adefault_config = os.environ.get('M5_DEFAULT_CONFIG', 'ALPHA_SE') 1022632Sstever@eecs.umich.edudefault_binary = os.environ.get('M5_DEFAULT_BINARY', 'm5.debug') 1032632Sstever@eecs.umich.edu 104955SN/A# Ask SCons which directory it was invoked from. If you invoke SCons 105955SN/A# from a subdirectory you must use the '-u' flag. 106955SN/Alaunch_dir = GetLaunchDir() 107955SN/A 1082632Sstever@eecs.umich.edu# Build a list 'my_targets' of all the targets relative to ROOT. 109955SN/Aif launch_dir == ROOT: 1102632Sstever@eecs.umich.edu # invoked from root build dir 1112632Sstever@eecs.umich.edu if len(COMMAND_LINE_TARGETS) != 0: 1122632Sstever@eecs.umich.edu # easy: use specified targets as is 1132632Sstever@eecs.umich.edu my_targets = COMMAND_LINE_TARGETS 1142632Sstever@eecs.umich.edu else: 1152632Sstever@eecs.umich.edu # default target (ALPHA_SE/m5.debug, unless overridden) 1162632Sstever@eecs.umich.edu target = os.path.join(default_config, default_binary) 1173053Sstever@eecs.umich.edu my_targets = [target] 1183053Sstever@eecs.umich.edu Default(target) 1193053Sstever@eecs.umich.eduelse: 1203053Sstever@eecs.umich.edu # invoked from subdirectory 1213053Sstever@eecs.umich.edu if not launch_dir.startswith(ROOT): 1223053Sstever@eecs.umich.edu print "Error: launch dir (%s) not a subdirectory of ROOT (%s)!" \ 1233053Sstever@eecs.umich.edu (launch_dir, ROOT) 1243053Sstever@eecs.umich.edu Exit(1) 1253053Sstever@eecs.umich.edu # make launch_dir relative to ROOT (strip ROOT plus slash off front) 1263053Sstever@eecs.umich.edu launch_dir = launch_dir[len(ROOT)+1:] 1273053Sstever@eecs.umich.edu if len(COMMAND_LINE_TARGETS) != 0: 1283053Sstever@eecs.umich.edu # make specified targets relative to ROOT 1293053Sstever@eecs.umich.edu my_targets = map(lambda x: os.path.join(launch_dir, x), 1303053Sstever@eecs.umich.edu COMMAND_LINE_TARGETS) 1313053Sstever@eecs.umich.edu else: 1323053Sstever@eecs.umich.edu # build default binary (m5.debug, unless overridden) using the 1332632Sstever@eecs.umich.edu # config inferred by the invocation directory (the first 1342632Sstever@eecs.umich.edu # subdirectory after ROOT) 1352632Sstever@eecs.umich.edu target = os.path.join(launch_dir.split('/')[0], default_binary) 1362632Sstever@eecs.umich.edu my_targets = [target] 1372632Sstever@eecs.umich.edu Default(target) 1382632Sstever@eecs.umich.edu 1393718Sstever@eecs.umich.edu# Normalize target paths (gets rid of '..' in the middle, etc.) 1403718Sstever@eecs.umich.edumy_targets = map(os.path.normpath, my_targets) 1413718Sstever@eecs.umich.edu 1423718Sstever@eecs.umich.edu# Generate a list of the unique configs that the collected targets reference. 1433718Sstever@eecs.umich.edubuild_dirs = [] 1443718Sstever@eecs.umich.edufor t in my_targets: 1453718Sstever@eecs.umich.edu dir = t.split('/')[0] 1463718Sstever@eecs.umich.edu if dir not in build_dirs: 1473718Sstever@eecs.umich.edu build_dirs.append(dir) 1483718Sstever@eecs.umich.edu 1493718Sstever@eecs.umich.edu################################################### 1503718Sstever@eecs.umich.edu# 1513718Sstever@eecs.umich.edu# Set up the default build environment. This environment is copied 1522634Sstever@eecs.umich.edu# and modified according to each selected configuration. 1532634Sstever@eecs.umich.edu# 1542632Sstever@eecs.umich.edu################################################### 1552638Sstever@eecs.umich.edu 1562632Sstever@eecs.umich.eduenv = Environment(ENV = os.environ, # inherit user's environment vars 1572632Sstever@eecs.umich.edu ROOT = ROOT, 1582632Sstever@eecs.umich.edu SRCDIR = SRCDIR, 1592632Sstever@eecs.umich.edu EXT_SRCDIR = EXT_SRCDIR) 1602632Sstever@eecs.umich.edu 1612632Sstever@eecs.umich.eduenv.SConsignFile("sconsign") 1621858SN/A 1633716Sstever@eecs.umich.edu# I waffle on this setting... it does avoid a few painful but 1642638Sstever@eecs.umich.edu# unnecessary builds, but it also seems to make trivial builds take 1652638Sstever@eecs.umich.edu# noticeably longer. 1662638Sstever@eecs.umich.eduif False: 1672638Sstever@eecs.umich.edu env.TargetSignatures('content') 1682638Sstever@eecs.umich.edu 1692638Sstever@eecs.umich.edu# M5_EXT is used by isa_parser.py to find the PLY package. 1702638Sstever@eecs.umich.eduenv.Append(ENV = { 'M5_EXT' : EXT_SRCDIR }) 1713716Sstever@eecs.umich.edu 1722634Sstever@eecs.umich.edu# Set up default C++ compiler flags 1732634Sstever@eecs.umich.eduenv.Append(CCFLAGS='-pipe') 174955SN/Aenv.Append(CCFLAGS='-fno-strict-aliasing') 175955SN/Aenv.Append(CCFLAGS=Split('-Wall -Wno-sign-compare -Werror -Wundef')) 176955SN/Aif sys.platform == 'cygwin': 177955SN/A # cygwin has some header file issues... 178955SN/A env.Append(CCFLAGS=Split("-Wno-uninitialized")) 179955SN/Aenv.Append(CPPPATH=[os.path.join(EXT_SRCDIR + '/dnet')]) 180955SN/A 181955SN/A# Default libraries 1821858SN/Aenv.Append(LIBS=['z']) 1831858SN/A 1842632Sstever@eecs.umich.edu# Platform-specific configuration 1854202Sbinkertn@umich.educonf = Configure(env) 186955SN/A 1873643Ssaidi@eecs.umich.edu# Check for <fenv.h> (C99 FP environment control) 1883643Ssaidi@eecs.umich.eduhave_fenv = conf.CheckHeader('fenv.h', '<>') 1893643Ssaidi@eecs.umich.eduif not have_fenv: 1903643Ssaidi@eecs.umich.edu print "Warning: Header file <fenv.h> not found." 1913643Ssaidi@eecs.umich.edu print " This host has no IEEE FP rounding mode control." 1923643Ssaidi@eecs.umich.edu 1933643Ssaidi@eecs.umich.edu# Check for mysql. 1943643Ssaidi@eecs.umich.edumysql_config = WhereIs('mysql_config') 1953716Sstever@eecs.umich.eduhave_mysql = mysql_config != None 1961105SN/A 1972667Sstever@eecs.umich.edu# Check MySQL version. 1982667Sstever@eecs.umich.eduif have_mysql: 1992667Sstever@eecs.umich.edu mysql_version = os.popen(mysql_config + ' --version').read() 2002667Sstever@eecs.umich.edu mysql_version = mysql_version.split('.') 2012667Sstever@eecs.umich.edu mysql_major = int(mysql_version[0]) 2022667Sstever@eecs.umich.edu mysql_minor = int(mysql_version[1]) 2031869SN/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 2081065SN/A 2092632Sstever@eecs.umich.edu# Set up mysql_config commands. 2102632Sstever@eecs.umich.eduif have_mysql: 2113918Ssaidi@eecs.umich.edu mysql_config_include = mysql_config + ' --include' 2123918Ssaidi@eecs.umich.edu if os.system(mysql_config_include + ' > /dev/null') != 0: 2133940Ssaidi@eecs.umich.edu # older mysql_config versions don't support --include, use 2143918Ssaidi@eecs.umich.edu # --cflags instead 2153918Ssaidi@eecs.umich.edu mysql_config_include = mysql_config + ' --cflags | sed s/\\\'//g' 2163918Ssaidi@eecs.umich.edu # This seems to work in all versions 2173918Ssaidi@eecs.umich.edu mysql_config_libs = mysql_config + ' --libs' 2183918Ssaidi@eecs.umich.edu 2193918Ssaidi@eecs.umich.eduenv = conf.Finish() 2203940Ssaidi@eecs.umich.edu 2213940Ssaidi@eecs.umich.edu# Define the universe of supported ISAs 2223940Ssaidi@eecs.umich.eduenv['ALL_ISA_LIST'] = ['alpha', 'sparc', 'mips'] 2233942Ssaidi@eecs.umich.edu 2243940Ssaidi@eecs.umich.edu# Define the universe of supported CPU models 2253918Ssaidi@eecs.umich.eduenv['ALL_CPU_LIST'] = ['SimpleCPU', 'FastCPU', 'FullCPU', 'AlphaFullCPU'] 2263918Ssaidi@eecs.umich.edu 227955SN/A# Sticky options get saved in the options file so they persist from 2281858SN/A# one invocation to the next (unless overridden, in which case the new 2293918Ssaidi@eecs.umich.edu# value becomes sticky). 2303918Ssaidi@eecs.umich.edusticky_opts = Options(args=ARGUMENTS) 2313918Ssaidi@eecs.umich.edusticky_opts.AddOptions( 2323918Ssaidi@eecs.umich.edu EnumOption('TARGET_ISA', 'Target ISA', 'alpha', env['ALL_ISA_LIST']), 2333940Ssaidi@eecs.umich.edu BoolOption('FULL_SYSTEM', 'Full-system support', False), 2343940Ssaidi@eecs.umich.edu BoolOption('ALPHA_TLASER', 2353918Ssaidi@eecs.umich.edu 'Model Alpha TurboLaser platform (vs. Tsunami)', False), 2363918Ssaidi@eecs.umich.edu BoolOption('NO_FAST_ALLOC', 'Disable fast object allocator', False), 2373918Ssaidi@eecs.umich.edu BoolOption('EFENCE', 'Link with Electric Fence malloc debugger', 2383918Ssaidi@eecs.umich.edu False), 2393918Ssaidi@eecs.umich.edu BoolOption('SS_COMPATIBLE_FP', 2403918Ssaidi@eecs.umich.edu 'Make floating-point results compatible with SimpleScalar', 2413918Ssaidi@eecs.umich.edu False), 2423918Ssaidi@eecs.umich.edu BoolOption('USE_SSE2', 2433918Ssaidi@eecs.umich.edu 'Compile for SSE2 (-msse2) to get IEEE FP on x86 hosts', 2443940Ssaidi@eecs.umich.edu False), 2453918Ssaidi@eecs.umich.edu BoolOption('STATS_BINNING', 'Bin statistics by CPU mode', have_mysql), 2463918Ssaidi@eecs.umich.edu BoolOption('USE_MYSQL', 'Use MySQL for stats output', have_mysql), 2471851SN/A BoolOption('USE_FENV', 'Use <fenv.h> IEEE mode control', have_fenv), 2481851SN/A ('CC', 'C compiler', os.environ.get('CC', env['CC'])), 2491858SN/A ('CXX', 'C++ compiler', os.environ.get('CXX', env['CXX'])), 2502632Sstever@eecs.umich.edu BoolOption('BATCH', 'Use batch pool for build and tests', False), 251955SN/A ('BATCH_CMD', 'Batch pool submission command name', 'qdo') 2523053Sstever@eecs.umich.edu ) 2533053Sstever@eecs.umich.edu 2543053Sstever@eecs.umich.edu# Non-sticky options only apply to the current build. 2553053Sstever@eecs.umich.edunonsticky_opts = Options(args=ARGUMENTS) 2563053Sstever@eecs.umich.edunonsticky_opts.AddOptions( 2573053Sstever@eecs.umich.edu # This really should be a sticky option, but there's a bug in 2583053Sstever@eecs.umich.edu # scons 0.96.1 that causes ListOptions not to be able to be 2593053Sstever@eecs.umich.edu # restored from a saved option file. It looks like this is fixed 2603053Sstever@eecs.umich.edu # in 0.96.9, but there's a different bug in that version that means we 2613053Sstever@eecs.umich.edu # can't just upgrade. 2623053Sstever@eecs.umich.edu ListOption('CPU_MODELS', 'CPU models', 'all', env['ALL_CPU_LIST']), 2633053Sstever@eecs.umich.edu BoolOption('update_ref', 'Update test reference outputs', False) 2643053Sstever@eecs.umich.edu ) 2653053Sstever@eecs.umich.edu 2663053Sstever@eecs.umich.edu# These options get exported to #defines in config/*.hh (see m5/SConscript). 2673053Sstever@eecs.umich.eduenv.ExportOptions = ['FULL_SYSTEM', 'ALPHA_TLASER', 'USE_FENV', \ 2683053Sstever@eecs.umich.edu 'USE_MYSQL', 'NO_FAST_ALLOC', 'SS_COMPATIBLE_FP', \ 2693053Sstever@eecs.umich.edu 'STATS_BINNING'] 2703053Sstever@eecs.umich.edu 2712667Sstever@eecs.umich.edu# Define a handy 'no-op' action 2722667Sstever@eecs.umich.edudef no_action(target, source, env): 2732667Sstever@eecs.umich.edu return 0 2742667Sstever@eecs.umich.edu 2752667Sstever@eecs.umich.eduenv.NoAction = Action(no_action, None) 2762667Sstever@eecs.umich.edu 2772667Sstever@eecs.umich.edu# libelf build is described in its own SConscript file. 2782667Sstever@eecs.umich.edu# SConscript-global is the build in build/libelf shared among all 2792667Sstever@eecs.umich.edu# configs. 2802667Sstever@eecs.umich.eduenv.SConscript('m5/libelf/SConscript-global', exports = 'env') 2812667Sstever@eecs.umich.edu 2822667Sstever@eecs.umich.edu################################################### 2832638Sstever@eecs.umich.edu# 2842638Sstever@eecs.umich.edu# Define a SCons builder for configuration flag headers. 2852638Sstever@eecs.umich.edu# 2863716Sstever@eecs.umich.edu################################################### 2873716Sstever@eecs.umich.edu 2881858SN/A# This function generates a config header file that #defines the 2893118Sstever@eecs.umich.edu# option symbol to the current option setting (0 or 1). The source 2903118Sstever@eecs.umich.edu# operands are the name of the option and a Value node containing the 2913118Sstever@eecs.umich.edu# value of the option. 2923118Sstever@eecs.umich.edudef build_config_file(target, source, env): 2933118Sstever@eecs.umich.edu (option, value) = [s.get_contents() for s in source] 2943118Sstever@eecs.umich.edu f = file(str(target[0]), 'w') 2953118Sstever@eecs.umich.edu print >> f, '#define', option, value 2963118Sstever@eecs.umich.edu f.close() 2973118Sstever@eecs.umich.edu return None 2983118Sstever@eecs.umich.edu 2993118Sstever@eecs.umich.edu# Generate the message to be printed when building the config file. 3003716Sstever@eecs.umich.edudef build_config_file_string(target, source, env): 3013118Sstever@eecs.umich.edu (option, value) = [s.get_contents() for s in source] 3023118Sstever@eecs.umich.edu return "Defining %s as %s in %s." % (option, value, target[0]) 3033118Sstever@eecs.umich.edu 3043118Sstever@eecs.umich.edu# Combine the two functions into a scons Action object. 3053118Sstever@eecs.umich.educonfig_action = Action(build_config_file, build_config_file_string) 3063118Sstever@eecs.umich.edu 3073118Sstever@eecs.umich.edu# The emitter munges the source & target node lists to reflect what 3083118Sstever@eecs.umich.edu# we're really doing. 3093118Sstever@eecs.umich.edudef config_emitter(target, source, env): 3103716Sstever@eecs.umich.edu # extract option name from Builder arg 3113118Sstever@eecs.umich.edu option = str(target[0]) 3123118Sstever@eecs.umich.edu # True target is config header file 3133118Sstever@eecs.umich.edu target = os.path.join('config', option.lower() + '.hh') 3143118Sstever@eecs.umich.edu # Force value to 0/1 even if it's a Python bool 3153118Sstever@eecs.umich.edu val = int(eval(str(env[option]))) 3163118Sstever@eecs.umich.edu # Sources are option name & value (packaged in SCons Value nodes) 3173118Sstever@eecs.umich.edu return ([target], [Value(option), Value(val)]) 3183118Sstever@eecs.umich.edu 3193118Sstever@eecs.umich.educonfig_builder = Builder(emitter = config_emitter, action = config_action) 3203118Sstever@eecs.umich.edu 3213483Ssaidi@eecs.umich.eduenv.Append(BUILDERS = { 'ConfigFile' : config_builder }) 3223494Ssaidi@eecs.umich.edu 3233494Ssaidi@eecs.umich.edu################################################### 3243483Ssaidi@eecs.umich.edu# 3253483Ssaidi@eecs.umich.edu# Define build environments for selected configurations. 3263483Ssaidi@eecs.umich.edu# 3273053Sstever@eecs.umich.edu################################################### 3283053Sstever@eecs.umich.edu 3293918Ssaidi@eecs.umich.edu# rename base env 3303053Sstever@eecs.umich.edubase_env = env 3313053Sstever@eecs.umich.edu 3323053Sstever@eecs.umich.edufor build_dir in build_dirs: 3333053Sstever@eecs.umich.edu # Make a copy of the default environment to use for this config. 3343053Sstever@eecs.umich.edu env = base_env.Copy() 3351858SN/A 3361858SN/A # Record what build_dir was in the environment 3371858SN/A env.Append(BUILD_DIR=build_dir); 3381858SN/A 3391858SN/A # Set env according to the build directory config. 3401858SN/A 3411859SN/A sticky_opts.files = [] 3421858SN/A # Name of default options file is taken from 'default=' on command 3431858SN/A # line if set, otherwise name of build dir. 3441858SN/A default_options_file = os.path.join('build_options', 'default', 3451859SN/A ARGUMENTS.get('default', build_dir)) 3461859SN/A if os.path.isfile(default_options_file): 3471862SN/A sticky_opts.files.append(default_options_file) 3483053Sstever@eecs.umich.edu current_options_file = os.path.join('build_options', 'current', build_dir) 3493053Sstever@eecs.umich.edu if os.path.isfile(current_options_file): 3503053Sstever@eecs.umich.edu sticky_opts.files.append(current_options_file) 3513053Sstever@eecs.umich.edu else: 3521859SN/A # if file doesn't exist, make sure at least the directory is there 3531859SN/A # so we can create it later 3541859SN/A opt_dir = os.path.dirname(current_options_file) 3551859SN/A if not os.path.isdir(opt_dir): 3561859SN/A os.mkdir(opt_dir) 3571859SN/A if not sticky_opts.files: 3581859SN/A print "%s: No options file found in build_options, using defaults." \ 3591859SN/A % build_dir 3601862SN/A 3611859SN/A # Apply current option settings to env 3621859SN/A sticky_opts.Update(env) 3631859SN/A nonsticky_opts.Update(env) 3641858SN/A 3651858SN/A # Process option settings. 3662139SN/A 3674202Sbinkertn@umich.edu if not have_fenv and env['USE_FENV']: 3684202Sbinkertn@umich.edu print "Warning: <fenv.h> not available; " \ 3692139SN/A "forcing USE_FENV to False in", build_dir + "." 3702155SN/A env['USE_FENV'] = False 3714202Sbinkertn@umich.edu 3724202Sbinkertn@umich.edu if not env['USE_FENV']: 3734202Sbinkertn@umich.edu print "Warning: No IEEE FP rounding mode control in", build_dir + "." 3742155SN/A print " FP results may deviate slightly from other platforms." 3751869SN/A 3761869SN/A if env['EFENCE']: 3771869SN/A env.Append(LIBS=['efence']) 3781869SN/A 3794202Sbinkertn@umich.edu if env['USE_MYSQL']: 3804202Sbinkertn@umich.edu if not have_mysql: 3814202Sbinkertn@umich.edu print "Warning: MySQL not available; " \ 3824202Sbinkertn@umich.edu "forcing USE_MYSQL to False in", build_dir + "." 3834202Sbinkertn@umich.edu env['USE_MYSQL'] = False 3844202Sbinkertn@umich.edu else: 3854202Sbinkertn@umich.edu print "Compiling in", build_dir, "with MySQL support." 3864202Sbinkertn@umich.edu env.ParseConfig(mysql_config_libs) 3874202Sbinkertn@umich.edu env.ParseConfig(mysql_config_include) 3884202Sbinkertn@umich.edu 3894202Sbinkertn@umich.edu # Save sticky option settings back to current options file 3904202Sbinkertn@umich.edu sticky_opts.Save(current_options_file, env) 3914202Sbinkertn@umich.edu 3924202Sbinkertn@umich.edu # Do this after we save setting back, or else we'll tack on an 3934202Sbinkertn@umich.edu # extra 'qdo' every time we run scons. 3944202Sbinkertn@umich.edu if env['BATCH']: 3951869SN/A env['CC'] = env['BATCH_CMD'] + ' ' + env['CC'] 3964202Sbinkertn@umich.edu env['CXX'] = env['BATCH_CMD'] + ' ' + env['CXX'] 3971869SN/A 3982508SN/A if env['USE_SSE2']: 3992508SN/A env.Append(CCFLAGS='-msse2') 4002508SN/A 4012508SN/A # The m5/SConscript file sets up the build rules in 'env' according 4024202Sbinkertn@umich.edu # to the configured options. It returns a list of environments, 4031869SN/A # one for each variant build (debug, opt, etc.) 4041869SN/A envList = SConscript('m5/SConscript', build_dir = build_dir, 4051869SN/A exports = 'env', duplicate = False) 4061869SN/A 4071869SN/A # Set up the regression tests for each build. 4081869SN/A for e in envList: 4091965SN/A SConscript('m5-test/SConscript', 4101965SN/A build_dir = os.path.join(build_dir, 'test', e.Label), 4111965SN/A exports = { 'env' : e }, duplicate = False) 4121869SN/A 4131869SN/A################################################### 4142733Sktlim@umich.edu# 4151869SN/A# Let SCons do its thing. At this point SCons will use the defined 4161884SN/A# build environments to build the requested targets. 4171884SN/A# 4183356Sbinkertn@umich.edu################################################### 4193356Sbinkertn@umich.edu 4203356Sbinkertn@umich.edu