SConstruct revision 2634
1955SN/A# -*- mode:python -*- 2955SN/A 311408Sandreas.sandberg@arm.com# Copyright (c) 2004-2005 The Regents of The University of Michigan 49812Sandreas.hansson@arm.com# All rights reserved. 59812Sandreas.hansson@arm.com# 69812Sandreas.hansson@arm.com# Redistribution and use in source and binary forms, with or without 79812Sandreas.hansson@arm.com# modification, are permitted provided that the following conditions are 89812Sandreas.hansson@arm.com# met: redistributions of source code must retain the above copyright 99812Sandreas.hansson@arm.com# notice, this list of conditions and the following disclaimer; 109812Sandreas.hansson@arm.com# redistributions in binary form must reproduce the above copyright 119812Sandreas.hansson@arm.com# notice, this list of conditions and the following disclaimer in the 129812Sandreas.hansson@arm.com# documentation and/or other materials provided with the distribution; 139812Sandreas.hansson@arm.com# neither the name of the copyright holders nor the names of its 149812Sandreas.hansson@arm.com# contributors may be used to endorse or promote products derived from 157816Ssteve.reinhardt@amd.com# this software without specific prior written permission. 165871Snate@binkert.org# 171762SN/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# While in this directory ('m5'), just type 'scons' to build the default 34955SN/A# configuration (see below), or type 'scons build/<CONFIG>/<binary>' 35955SN/A# to build some other configuration (e.g., 'build/ALPHA_FS/m5.opt' for 36955SN/A# the optimized full-system version). 37955SN/A# 38955SN/A# 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 40955SN/A# expdects that all configs under the same build directory are being 41955SN/A# built for the same host system. 422665Ssaidi@eecs.umich.edu# 432665Ssaidi@eecs.umich.edu# Examples: 445863Snate@binkert.org# These two commands are equivalent. The '-u' option tells scons to 45955SN/A# search up the directory tree for this SConstruct file. 46955SN/A# % cd <path-to-src>/m5 ; scons build/ALPHA_FS/m5.debug 47955SN/A# % cd <path-to-src>/m5/build/ALPHA_FS; scons -u m5.debug 48955SN/A# These two commands are equivalent and demonstrate building in a 49955SN/A# directory outside of the source tree. The '-C' option tells scons 508878Ssteve.reinhardt@amd.com# to chdir to the specified directory to find this SConstruct file. 512632Sstever@eecs.umich.edu# % cd <path-to-src>/m5 ; scons /local/foo/build/ALPHA_FS/m5.debug 528878Ssteve.reinhardt@amd.com# % cd /local/foo/build/ALPHA_FS; scons -C <path-to-src>/m5 m5.debug 532632Sstever@eecs.umich.edu# 54955SN/A# You can use 'scons -H' to print scons options. If you're in this 558878Ssteve.reinhardt@amd.com# '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 572761Sstever@eecs.umich.edu# options as well. 582632Sstever@eecs.umich.edu# 592632Sstever@eecs.umich.edu################################################### 602632Sstever@eecs.umich.edu 612761Sstever@eecs.umich.edu# Python library imports 622761Sstever@eecs.umich.eduimport sys 632761Sstever@eecs.umich.eduimport os 648878Ssteve.reinhardt@amd.com 658878Ssteve.reinhardt@amd.com# Check for recent-enough Python and SCons versions 662761Sstever@eecs.umich.eduEnsurePythonVersion(2,3) 672761Sstever@eecs.umich.eduEnsureSConsVersion(0,96,91) 682761Sstever@eecs.umich.edu 692761Sstever@eecs.umich.edu# The absolute path to the current directory (where this file lives). 702761Sstever@eecs.umich.eduROOT = Dir('.').abspath 718878Ssteve.reinhardt@amd.com 728878Ssteve.reinhardt@amd.com# Paths to the M5 and external source trees. 732632Sstever@eecs.umich.eduSRCDIR = os.path.join(ROOT, 'src') 742632Sstever@eecs.umich.edu 758878Ssteve.reinhardt@amd.com# tell python where to find m5 python code 768878Ssteve.reinhardt@amd.comsys.path.append(os.path.join(ROOT, 'src/python')) 772632Sstever@eecs.umich.edu 78955SN/A################################################### 79955SN/A# 80955SN/A# Figure out which configurations to set up based on the path(s) of 815863Snate@binkert.org# the target(s). 825863Snate@binkert.org# 835863Snate@binkert.org################################################### 845863Snate@binkert.org 855863Snate@binkert.org# Find default configuration & binary. 865863Snate@binkert.orgDefault(os.environ.get('M5_DEFAULT_BINARY', 'build/ALPHA_SE/m5.debug')) 875863Snate@binkert.org 885863Snate@binkert.org# Ask SCons which directory it was invoked from. 895863Snate@binkert.orglaunch_dir = GetLaunchDir() 905863Snate@binkert.org 915863Snate@binkert.org# Make targets relative to invocation directory 928878Ssteve.reinhardt@amd.comabs_targets = map(lambda x: os.path.normpath(os.path.join(launch_dir, str(x))), 935863Snate@binkert.org BUILD_TARGETS) 945863Snate@binkert.org 955863Snate@binkert.org# helper function: find last occurrence of element in list 969812Sandreas.hansson@arm.comdef rfind(l, elt, offs = -1): 979812Sandreas.hansson@arm.com for i in range(len(l)+offs, 0, -1): 985863Snate@binkert.org if l[i] == elt: 999812Sandreas.hansson@arm.com return i 1005863Snate@binkert.org raise ValueError, "element not found" 1015863Snate@binkert.org 1025863Snate@binkert.org# Each target must have 'build' in the interior of the path; the 1039812Sandreas.hansson@arm.com# directory below this will determine the build parameters. For 1049812Sandreas.hansson@arm.com# example, for target 'foo/bar/build/ALPHA_SE/arch/alpha/blah.do' we 1055863Snate@binkert.org# recognize that ALPHA_SE specifies the configuration because it 1065863Snate@binkert.org# follow 'build' in the bulid path. 1078878Ssteve.reinhardt@amd.com 1085863Snate@binkert.org# Generate a list of the unique build roots and configs that the 1095863Snate@binkert.org# collected targets reference. 1105863Snate@binkert.orgbuild_paths = [] 1116654Snate@binkert.orgbuild_roots = [] 11210196SCurtis.Dunham@arm.comfor t in abs_targets: 113955SN/A path_dirs = t.split('/') 1145396Ssaidi@eecs.umich.edu try: 11511401Sandreas.sandberg@arm.com build_top = rfind(path_dirs, 'build', -2) 1165863Snate@binkert.org except: 1175863Snate@binkert.org print "Error: no non-leaf 'build' dir found on target path", t 1184202Sbinkertn@umich.edu Exit(1) 1195863Snate@binkert.org build_root = os.path.join('/',*path_dirs[:build_top+1]) 1205863Snate@binkert.org if build_root not in build_roots: 1215863Snate@binkert.org build_roots.append(build_root) 1225863Snate@binkert.org build_path = os.path.join('/',*path_dirs[:build_top+2]) 123955SN/A if build_path not in build_paths: 1246654Snate@binkert.org build_paths.append(build_path) 1255273Sstever@gmail.com 1265871Snate@binkert.org################################################### 1275273Sstever@gmail.com# 1286655Snate@binkert.org# Set up the default build environment. This environment is copied 1298878Ssteve.reinhardt@amd.com# and modified according to each selected configuration. 1306655Snate@binkert.org# 1316655Snate@binkert.org################################################### 1329219Spower.jg@gmail.com 1336655Snate@binkert.orgenv = Environment(ENV = os.environ, # inherit user's environment vars 1345871Snate@binkert.org ROOT = ROOT, 1356654Snate@binkert.org SRCDIR = SRCDIR) 1368947Sandreas.hansson@arm.com 1375396Ssaidi@eecs.umich.eduenv.SConsignFile("sconsign") 1388120Sgblack@eecs.umich.edu 1398120Sgblack@eecs.umich.edu# I waffle on this setting... it does avoid a few painful but 1408120Sgblack@eecs.umich.edu# unnecessary builds, but it also seems to make trivial builds take 1418120Sgblack@eecs.umich.edu# noticeably longer. 1428120Sgblack@eecs.umich.eduif False: 1438120Sgblack@eecs.umich.edu env.TargetSignatures('content') 1448120Sgblack@eecs.umich.edu 1458120Sgblack@eecs.umich.edu# M5_PLY is used by isa_parser.py to find the PLY package. 1468879Ssteve.reinhardt@amd.comenv.Append(ENV = { 'M5_PLY' : Dir('ext/ply') }) 1478879Ssteve.reinhardt@amd.com 1488879Ssteve.reinhardt@amd.com# Set up default C++ compiler flags 1498879Ssteve.reinhardt@amd.comenv.Append(CCFLAGS='-pipe') 1508879Ssteve.reinhardt@amd.comenv.Append(CCFLAGS='-fno-strict-aliasing') 1518879Ssteve.reinhardt@amd.comenv.Append(CCFLAGS=Split('-Wall -Wno-sign-compare -Werror -Wundef')) 1528879Ssteve.reinhardt@amd.comif sys.platform == 'cygwin': 1538879Ssteve.reinhardt@amd.com # cygwin has some header file issues... 1548879Ssteve.reinhardt@amd.com env.Append(CCFLAGS=Split("-Wno-uninitialized")) 1558879Ssteve.reinhardt@amd.comenv.Append(CPPPATH=[Dir('ext/dnet')]) 1568879Ssteve.reinhardt@amd.com 1578879Ssteve.reinhardt@amd.com# Default libraries 1588879Ssteve.reinhardt@amd.comenv.Append(LIBS=['z']) 1598120Sgblack@eecs.umich.edu 1608120Sgblack@eecs.umich.edu# Platform-specific configuration 1618120Sgblack@eecs.umich.educonf = Configure(env) 1628120Sgblack@eecs.umich.edu 1638120Sgblack@eecs.umich.edu# Check for <fenv.h> (C99 FP environment control) 1648120Sgblack@eecs.umich.eduhave_fenv = conf.CheckHeader('fenv.h', '<>') 1658120Sgblack@eecs.umich.eduif not have_fenv: 1668120Sgblack@eecs.umich.edu print "Warning: Header file <fenv.h> not found." 1678120Sgblack@eecs.umich.edu print " This host has no IEEE FP rounding mode control." 1688120Sgblack@eecs.umich.edu 1698120Sgblack@eecs.umich.edu# Check for mysql. 1708120Sgblack@eecs.umich.edumysql_config = WhereIs('mysql_config') 1718120Sgblack@eecs.umich.eduhave_mysql = mysql_config != None 1728120Sgblack@eecs.umich.edu 1738879Ssteve.reinhardt@amd.com# Check MySQL version. 1748879Ssteve.reinhardt@amd.comif have_mysql: 1758879Ssteve.reinhardt@amd.com mysql_version = os.popen(mysql_config + ' --version').read() 1768879Ssteve.reinhardt@amd.com mysql_version = mysql_version.split('.') 17710458Sandreas.hansson@arm.com mysql_major = int(mysql_version[0]) 17810458Sandreas.hansson@arm.com mysql_minor = int(mysql_version[1]) 17910458Sandreas.hansson@arm.com # This version check is probably overly conservative, but it deals 1808879Ssteve.reinhardt@amd.com # with the versions we have installed. 1818879Ssteve.reinhardt@amd.com if mysql_major < 4 or (mysql_major == 4 and mysql_minor < 1): 1828879Ssteve.reinhardt@amd.com print "Warning: MySQL v4.1 or newer required." 1838879Ssteve.reinhardt@amd.com have_mysql = False 1849227Sandreas.hansson@arm.com 1859227Sandreas.hansson@arm.com# Set up mysql_config commands. 18612063Sgabeblack@google.comif have_mysql: 18712063Sgabeblack@google.com mysql_config_include = mysql_config + ' --include' 18812063Sgabeblack@google.com if os.system(mysql_config_include + ' > /dev/null') != 0: 1898879Ssteve.reinhardt@amd.com # older mysql_config versions don't support --include, use 1908879Ssteve.reinhardt@amd.com # --cflags instead 1918879Ssteve.reinhardt@amd.com mysql_config_include = mysql_config + ' --cflags | sed s/\\\'//g' 1928879Ssteve.reinhardt@amd.com # This seems to work in all versions 19310453SAndrew.Bardsley@arm.com mysql_config_libs = mysql_config + ' --libs' 19410453SAndrew.Bardsley@arm.com 19510453SAndrew.Bardsley@arm.comenv = conf.Finish() 19610456SCurtis.Dunham@arm.com 19710456SCurtis.Dunham@arm.com# Define the universe of supported ISAs 19810456SCurtis.Dunham@arm.comenv['ALL_ISA_LIST'] = ['alpha', 'sparc', 'mips'] 19910457Sandreas.hansson@arm.com 20010457Sandreas.hansson@arm.com# Define the universe of supported CPU models 20111342Sandreas.hansson@arm.comenv['ALL_CPU_LIST'] = ['AtomicSimpleCPU', 'TimingSimpleCPU', 20211342Sandreas.hansson@arm.com 'FastCPU', 'FullCPU', 'AlphaFullCPU'] 2038120Sgblack@eecs.umich.edu 20412063Sgabeblack@google.com# Sticky options get saved in the options file so they persist from 20512063Sgabeblack@google.com# one invocation to the next (unless overridden, in which case the new 20612063Sgabeblack@google.com# value becomes sticky). 20712063Sgabeblack@google.comsticky_opts = Options(args=ARGUMENTS) 2088947Sandreas.hansson@arm.comsticky_opts.AddOptions( 2097816Ssteve.reinhardt@amd.com EnumOption('TARGET_ISA', 'Target ISA', 'alpha', env['ALL_ISA_LIST']), 2105871Snate@binkert.org BoolOption('FULL_SYSTEM', 'Full-system support', False), 2115871Snate@binkert.org # There's a bug in scons 0.96.1 that causes ListOptions with list 2126121Snate@binkert.org # values (more than one value) not to be able to be restored from 2135871Snate@binkert.org # a saved option file. If this causes trouble then upgrade to 2145871Snate@binkert.org # scons 0.96.90 or later. 2159926Sstan.czerniawski@arm.com ListOption('CPU_MODELS', 'CPU models', 'all', env['ALL_CPU_LIST']), 2169926Sstan.czerniawski@arm.com BoolOption('ALPHA_TLASER', 2179119Sandreas.hansson@arm.com 'Model Alpha TurboLaser platform (vs. Tsunami)', False), 21810068Sandreas.hansson@arm.com BoolOption('NO_FAST_ALLOC', 'Disable fast object allocator', False), 21911989Sandreas.sandberg@arm.com BoolOption('EFENCE', 'Link with Electric Fence malloc debugger', 220955SN/A False), 2219416SAndreas.Sandberg@ARM.com BoolOption('SS_COMPATIBLE_FP', 22211342Sandreas.hansson@arm.com 'Make floating-point results compatible with SimpleScalar', 22311212Sjoseph.gross@amd.com False), 22411212Sjoseph.gross@amd.com BoolOption('USE_SSE2', 22511212Sjoseph.gross@amd.com 'Compile for SSE2 (-msse2) to get IEEE FP on x86 hosts', 22611212Sjoseph.gross@amd.com False), 22711212Sjoseph.gross@amd.com BoolOption('STATS_BINNING', 'Bin statistics by CPU mode', have_mysql), 2289416SAndreas.Sandberg@ARM.com BoolOption('USE_MYSQL', 'Use MySQL for stats output', have_mysql), 2299416SAndreas.Sandberg@ARM.com BoolOption('USE_FENV', 'Use <fenv.h> IEEE mode control', have_fenv), 2305871Snate@binkert.org ('CC', 'C compiler', os.environ.get('CC', env['CC'])), 23110584Sandreas.hansson@arm.com ('CXX', 'C++ compiler', os.environ.get('CXX', env['CXX'])), 2329416SAndreas.Sandberg@ARM.com BoolOption('BATCH', 'Use batch pool for build and tests', False), 2339416SAndreas.Sandberg@ARM.com ('BATCH_CMD', 'Batch pool submission command name', 'qdo') 2345871Snate@binkert.org ) 235955SN/A 23610671Sandreas.hansson@arm.com# Non-sticky options only apply to the current build. 23710671Sandreas.hansson@arm.comnonsticky_opts = Options(args=ARGUMENTS) 23810671Sandreas.hansson@arm.comnonsticky_opts.AddOptions( 23910671Sandreas.hansson@arm.com BoolOption('update_ref', 'Update test reference outputs', False) 2408881Smarc.orr@gmail.com ) 2416121Snate@binkert.org 2426121Snate@binkert.org# These options get exported to #defines in config/*.hh (see m5/SConscript). 2431533SN/Aenv.ExportOptions = ['FULL_SYSTEM', 'ALPHA_TLASER', 'USE_FENV', \ 2449239Sandreas.hansson@arm.com 'USE_MYSQL', 'NO_FAST_ALLOC', 'SS_COMPATIBLE_FP', \ 2459239Sandreas.hansson@arm.com 'STATS_BINNING'] 2469239Sandreas.hansson@arm.com 2479239Sandreas.hansson@arm.com# Define a handy 'no-op' action 2489239Sandreas.hansson@arm.comdef no_action(target, source, env): 2499239Sandreas.hansson@arm.com return 0 2509239Sandreas.hansson@arm.com 2516655Snate@binkert.orgenv.NoAction = Action(no_action, None) 2526655Snate@binkert.org 2536655Snate@binkert.org################################################### 2546655Snate@binkert.org# 2555871Snate@binkert.org# Define a SCons builder for configuration flag headers. 2565871Snate@binkert.org# 2575863Snate@binkert.org################################################### 2585871Snate@binkert.org 2598878Ssteve.reinhardt@amd.com# This function generates a config header file that #defines the 2605871Snate@binkert.org# option symbol to the current option setting (0 or 1). The source 2615871Snate@binkert.org# operands are the name of the option and a Value node containing the 2625871Snate@binkert.org# value of the option. 2635863Snate@binkert.orgdef build_config_file(target, source, env): 2646121Snate@binkert.org (option, value) = [s.get_contents() for s in source] 2655863Snate@binkert.org f = file(str(target[0]), 'w') 26611408Sandreas.sandberg@arm.com print >> f, '#define', option, value 26711408Sandreas.sandberg@arm.com f.close() 2688336Ssteve.reinhardt@amd.com return None 26911469SCurtis.Dunham@arm.com 27011469SCurtis.Dunham@arm.com# Generate the message to be printed when building the config file. 2718336Ssteve.reinhardt@amd.comdef build_config_file_string(target, source, env): 2724678Snate@binkert.org (option, value) = [s.get_contents() for s in source] 27311887Sandreas.sandberg@arm.com return "Defining %s as %s in %s." % (option, value, target[0]) 27411887Sandreas.sandberg@arm.com 27511887Sandreas.sandberg@arm.com# Combine the two functions into a scons Action object. 27611887Sandreas.sandberg@arm.comconfig_action = Action(build_config_file, build_config_file_string) 27711887Sandreas.sandberg@arm.com 27811887Sandreas.sandberg@arm.com# The emitter munges the source & target node lists to reflect what 27911887Sandreas.sandberg@arm.com# we're really doing. 28011887Sandreas.sandberg@arm.comdef config_emitter(target, source, env): 28111887Sandreas.sandberg@arm.com # extract option name from Builder arg 28211887Sandreas.sandberg@arm.com option = str(target[0]) 28311887Sandreas.sandberg@arm.com # True target is config header file 28411408Sandreas.sandberg@arm.com target = os.path.join('config', option.lower() + '.hh') 28511401Sandreas.sandberg@arm.com # Force value to 0/1 even if it's a Python bool 28611401Sandreas.sandberg@arm.com val = int(eval(str(env[option]))) 28711401Sandreas.sandberg@arm.com # Sources are option name & value (packaged in SCons Value nodes) 28811401Sandreas.sandberg@arm.com return ([target], [Value(option), Value(val)]) 28911401Sandreas.sandberg@arm.com 29011401Sandreas.sandberg@arm.comconfig_builder = Builder(emitter = config_emitter, action = config_action) 2918336Ssteve.reinhardt@amd.com 2928336Ssteve.reinhardt@amd.comenv.Append(BUILDERS = { 'ConfigFile' : config_builder }) 2938336Ssteve.reinhardt@amd.com 2944678Snate@binkert.org# base help text 29511401Sandreas.sandberg@arm.comhelp_text = ''' 2964678Snate@binkert.orgUsage: scons [scons options] [build options] [target(s)] 2974678Snate@binkert.org 29811401Sandreas.sandberg@arm.com''' 29911401Sandreas.sandberg@arm.com 3008336Ssteve.reinhardt@amd.com################################################### 3014678Snate@binkert.org# 3028336Ssteve.reinhardt@amd.com# Define build environments for selected configurations. 3038336Ssteve.reinhardt@amd.com# 3048336Ssteve.reinhardt@amd.com################################################### 3058336Ssteve.reinhardt@amd.com 3068336Ssteve.reinhardt@amd.com# rename base env 3078336Ssteve.reinhardt@amd.combase_env = env 3085871Snate@binkert.org 3095871Snate@binkert.org# Spme things (just libelf currently) are shared across all configs in 3108336Ssteve.reinhardt@amd.com# a "build root". Need to define how to build these just once for 31111408Sandreas.sandberg@arm.com# each referenced root. 31211408Sandreas.sandberg@arm.combuild_root_env = {} 31311408Sandreas.sandberg@arm.comfor build_root in build_roots: 31411408Sandreas.sandberg@arm.com env = base_env.Copy() 31511408Sandreas.sandberg@arm.com env.SConscript('ext/libelf/SConscript', 31611408Sandreas.sandberg@arm.com build_dir = os.path.join(build_root, 'libelf'), 31711408Sandreas.sandberg@arm.com exports = 'env') 3188336Ssteve.reinhardt@amd.com build_root_env[build_root] = env 31911401Sandreas.sandberg@arm.com 32011401Sandreas.sandberg@arm.comfor build_path in build_paths: 32111401Sandreas.sandberg@arm.com print "Building in", build_path 3225871Snate@binkert.org # build_dir is the tail component of build path, and is used to 3238336Ssteve.reinhardt@amd.com # determine the build parameters (e.g., 'ALPHA_SE') 3248336Ssteve.reinhardt@amd.com (build_root, build_dir) = os.path.split(build_path) 32511401Sandreas.sandberg@arm.com # Make a copy of the build-root environment to use for this config. 32611401Sandreas.sandberg@arm.com env = build_root_env[build_root].Copy() 32711401Sandreas.sandberg@arm.com 32811401Sandreas.sandberg@arm.com # Set env options according to the build directory config. 32911401Sandreas.sandberg@arm.com sticky_opts.files = [] 3304678Snate@binkert.org # Options for $BUILD_ROOT/$BUILD_DIR are stored in 3315871Snate@binkert.org # $BUILD_ROOT/options/$BUILD_DIR so you can nuke 3324678Snate@binkert.org # $BUILD_ROOT/$BUILD_DIR without losing your options settings. 33311401Sandreas.sandberg@arm.com current_opts_file = os.path.join(build_root, 'options', build_dir) 33411401Sandreas.sandberg@arm.com if os.path.isfile(current_opts_file): 33511401Sandreas.sandberg@arm.com sticky_opts.files.append(current_opts_file) 33611401Sandreas.sandberg@arm.com print "Using saved options file %s" % current_opts_file 33711401Sandreas.sandberg@arm.com else: 33811401Sandreas.sandberg@arm.com # Build dir-specific options file doesn't exist. 33911401Sandreas.sandberg@arm.com 34011401Sandreas.sandberg@arm.com # Make sure the directory is there so we can create it later 34111401Sandreas.sandberg@arm.com opt_dir = os.path.dirname(current_opts_file) 34211401Sandreas.sandberg@arm.com if not os.path.isdir(opt_dir): 34311401Sandreas.sandberg@arm.com os.mkdir(opt_dir) 34411401Sandreas.sandberg@arm.com 34511450Sandreas.sandberg@arm.com # Get default build options from source tree. Options are 34611450Sandreas.sandberg@arm.com # normally determined by name of $BUILD_DIR, but can be 34711450Sandreas.sandberg@arm.com # overriden by 'default=' arg on command line. 34811450Sandreas.sandberg@arm.com default_opts_file = os.path.join('build_opts', 34911450Sandreas.sandberg@arm.com ARGUMENTS.get('default', build_dir)) 35011450Sandreas.sandberg@arm.com if os.path.isfile(default_opts_file): 35111450Sandreas.sandberg@arm.com sticky_opts.files.append(default_opts_file) 35211450Sandreas.sandberg@arm.com print "Options file %s not found,\n using defaults in %s" \ 35311450Sandreas.sandberg@arm.com % (current_opts_file, default_opts_file) 35411450Sandreas.sandberg@arm.com else: 35511450Sandreas.sandberg@arm.com print "Error: cannot find options file %s or %s" \ 35611401Sandreas.sandberg@arm.com % (current_opts_file, default_opts_file) 35711450Sandreas.sandberg@arm.com Exit(1) 35811450Sandreas.sandberg@arm.com 35911450Sandreas.sandberg@arm.com # Apply current option settings to env 36011401Sandreas.sandberg@arm.com sticky_opts.Update(env) 36111450Sandreas.sandberg@arm.com nonsticky_opts.Update(env) 36211401Sandreas.sandberg@arm.com 3638336Ssteve.reinhardt@amd.com help_text += "Sticky options for %s:\n" % build_dir \ 3648336Ssteve.reinhardt@amd.com + sticky_opts.GenerateHelpText(env) \ 3658336Ssteve.reinhardt@amd.com + "\nNon-sticky options for %s:\n" % build_dir \ 3668336Ssteve.reinhardt@amd.com + nonsticky_opts.GenerateHelpText(env) 3678336Ssteve.reinhardt@amd.com 3688336Ssteve.reinhardt@amd.com # Process option settings. 3698336Ssteve.reinhardt@amd.com 3708336Ssteve.reinhardt@amd.com if not have_fenv and env['USE_FENV']: 3718336Ssteve.reinhardt@amd.com print "Warning: <fenv.h> not available; " \ 3728336Ssteve.reinhardt@amd.com "forcing USE_FENV to False in", build_dir + "." 37311401Sandreas.sandberg@arm.com env['USE_FENV'] = False 37411401Sandreas.sandberg@arm.com 3758336Ssteve.reinhardt@amd.com if not env['USE_FENV']: 3768336Ssteve.reinhardt@amd.com print "Warning: No IEEE FP rounding mode control in", build_dir + "." 3778336Ssteve.reinhardt@amd.com print " FP results may deviate slightly from other platforms." 3785871Snate@binkert.org 37911476Sandreas.sandberg@arm.com if env['EFENCE']: 38011476Sandreas.sandberg@arm.com env.Append(LIBS=['efence']) 38111476Sandreas.sandberg@arm.com 38211476Sandreas.sandberg@arm.com if env['USE_MYSQL']: 38311476Sandreas.sandberg@arm.com if not have_mysql: 38411476Sandreas.sandberg@arm.com print "Warning: MySQL not available; " \ 38511476Sandreas.sandberg@arm.com "forcing USE_MYSQL to False in", build_dir + "." 38611476Sandreas.sandberg@arm.com env['USE_MYSQL'] = False 38711476Sandreas.sandberg@arm.com else: 38811887Sandreas.sandberg@arm.com print "Compiling in", build_dir, "with MySQL support." 38911887Sandreas.sandberg@arm.com env.ParseConfig(mysql_config_libs) 39011887Sandreas.sandberg@arm.com env.ParseConfig(mysql_config_include) 39111408Sandreas.sandberg@arm.com 39211887Sandreas.sandberg@arm.com # Save sticky option settings back to current options file 39311887Sandreas.sandberg@arm.com sticky_opts.Save(current_opts_file, env) 39411887Sandreas.sandberg@arm.com 39511887Sandreas.sandberg@arm.com # Do this after we save setting back, or else we'll tack on an 39611887Sandreas.sandberg@arm.com # extra 'qdo' every time we run scons. 39711887Sandreas.sandberg@arm.com if env['BATCH']: 39811926Sgabeblack@google.com env['CC'] = env['BATCH_CMD'] + ' ' + env['CC'] 39911926Sgabeblack@google.com env['CXX'] = env['BATCH_CMD'] + ' ' + env['CXX'] 40011926Sgabeblack@google.com 40111926Sgabeblack@google.com if env['USE_SSE2']: 40211887Sandreas.sandberg@arm.com env.Append(CCFLAGS='-msse2') 40311887Sandreas.sandberg@arm.com 40411944Sandreas.sandberg@arm.com # The m5/SConscript file sets up the build rules in 'env' according 40511887Sandreas.sandberg@arm.com # to the configured options. It returns a list of environments, 40611927Sgabeblack@google.com # one for each variant build (debug, opt, etc.) 40711927Sgabeblack@google.com envList = SConscript('src/SConscript', build_dir = build_path, 40811927Sgabeblack@google.com exports = 'env', duplicate = False) 40911927Sgabeblack@google.com 41011927Sgabeblack@google.com # Set up the regression tests for each build. 41111927Sgabeblack@google.com# for e in envList: 41211887Sandreas.sandberg@arm.com# SConscript('m5-test/SConscript', 41311928Sgabeblack@google.com# build_dir = os.path.join(build_dir, 'test', e.Label), 41411928Sgabeblack@google.com# exports = { 'env' : e }, duplicate = False) 41511887Sandreas.sandberg@arm.com 41611887Sandreas.sandberg@arm.comHelp(help_text) 41711887Sandreas.sandberg@arm.com 41811887Sandreas.sandberg@arm.com################################################### 41911887Sandreas.sandberg@arm.com# 42011887Sandreas.sandberg@arm.com# Let SCons do its thing. At this point SCons will use the defined 42111887Sandreas.sandberg@arm.com# build environments to build the requested targets. 42211887Sandreas.sandberg@arm.com# 42311887Sandreas.sandberg@arm.com################################################### 42411887Sandreas.sandberg@arm.com 42511476Sandreas.sandberg@arm.com