SConstruct revision 2155
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# 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 39955SN/A# 'scons <CONFIG>/<binary>' to build some other configuration (e.g., 40955SN/A# 'ALPHA_FS/m5.opt' for the optimized full-system version). 41955SN/A# 422665Ssaidi@eecs.umich.edu################################################### 432665Ssaidi@eecs.umich.edu 445863Snate@binkert.org# Python library imports 45955SN/Aimport sys 46955SN/Aimport os 47955SN/A 48955SN/A# Check for recent-enough Python and SCons versions 49955SN/AEnsurePythonVersion(2,3) 508878Ssteve.reinhardt@amd.comEnsureSConsVersion(0,96) 512632Sstever@eecs.umich.edu 528878Ssteve.reinhardt@amd.com# The absolute path to the current directory (where this file lives). 532632Sstever@eecs.umich.eduROOT = Dir('.').abspath 54955SN/A 558878Ssteve.reinhardt@amd.com# Paths to the M5 and external source trees (local symlinks). 562632Sstever@eecs.umich.eduSRCDIR = os.path.join(ROOT, 'm5') 572761Sstever@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): 612761Sstever@eecs.umich.edu print "Error: '%s' must be a link to the M5 source tree." % SRCDIR 622761Sstever@eecs.umich.edu Exit(1) 632761Sstever@eecs.umich.edu 648878Ssteve.reinhardt@amd.comif not os.path.isdir('ext'): 658878Ssteve.reinhardt@amd.com print "Error: '%s' must be a link to the M5 external source tree." \ 662761Sstever@eecs.umich.edu % EXT_SRCDIR 672761Sstever@eecs.umich.edu Exit(1) 682761Sstever@eecs.umich.edu 692761Sstever@eecs.umich.edu# tell python where to find m5 python code 702761Sstever@eecs.umich.edusys.path.append(os.path.join(SRCDIR, 'python')) 718878Ssteve.reinhardt@amd.com 728878Ssteve.reinhardt@amd.com################################################### 732632Sstever@eecs.umich.edu# 742632Sstever@eecs.umich.edu# Figure out which configurations to set up. 758878Ssteve.reinhardt@amd.com# 768878Ssteve.reinhardt@amd.com# 772632Sstever@eecs.umich.edu# It's prohibitive to do all the combinations of base configurations 78955SN/A# and options, so we have to infer which ones the user wants. 79955SN/A# 80955SN/A# 1. If there are command-line targets, the configuration(s) are inferred 815863Snate@binkert.org# from the directories of those targets. If scons was invoked from a 825863Snate@binkert.org# subdirectory (using 'scons -u'), those targets have to be 835863Snate@binkert.org# interpreted relative to that subdirectory. 845863Snate@binkert.org# 855863Snate@binkert.org# 2. If there are no command-line targets, and scons was invoked from a 865863Snate@binkert.org# subdirectory (using 'scons -u'), the configuration is inferred from 875863Snate@binkert.org# the name of the subdirectory. 885863Snate@binkert.org# 895863Snate@binkert.org# 3. If there are no command-line targets and scons was invoked from 905863Snate@binkert.org# the root build directory, a default configuration is used. The 915863Snate@binkert.org# built-in default is ALPHA_SE, but this can be overridden by setting the 928878Ssteve.reinhardt@amd.com# M5_DEFAULT_CONFIG shell environment veriable. 935863Snate@binkert.org# 945863Snate@binkert.org# In cases 2 & 3, the specific file target defaults to 'm5.debug', but 955863Snate@binkert.org# this can be overridden by setting the M5_DEFAULT_BINARY shell 969812Sandreas.hansson@arm.com# environment veriable. 979812Sandreas.hansson@arm.com# 985863Snate@binkert.org################################################### 999812Sandreas.hansson@arm.com 1005863Snate@binkert.org# Find default configuration & binary. 1015863Snate@binkert.orgdefault_config = os.environ.get('M5_DEFAULT_CONFIG', 'ALPHA_SE') 1025863Snate@binkert.orgdefault_binary = os.environ.get('M5_DEFAULT_BINARY', 'm5.debug') 1039812Sandreas.hansson@arm.com 1049812Sandreas.hansson@arm.com# Ask SCons which directory it was invoked from. If you invoke SCons 1055863Snate@binkert.org# from a subdirectory you must use the '-u' flag. 1065863Snate@binkert.orglaunch_dir = GetLaunchDir() 1078878Ssteve.reinhardt@amd.com 1085863Snate@binkert.org# Build a list 'my_targets' of all the targets relative to ROOT. 1095863Snate@binkert.orgif launch_dir == ROOT: 1105863Snate@binkert.org # invoked from root build dir 1116654Snate@binkert.org if len(COMMAND_LINE_TARGETS) != 0: 11210196SCurtis.Dunham@arm.com # easy: use specified targets as is 113955SN/A my_targets = COMMAND_LINE_TARGETS 1145396Ssaidi@eecs.umich.edu else: 11511401Sandreas.sandberg@arm.com # default target (ALPHA_SE/m5.debug, unless overridden) 1165863Snate@binkert.org target = os.path.join(default_config, default_binary) 1175863Snate@binkert.org my_targets = [target] 1184202Sbinkertn@umich.edu Default(target) 1195863Snate@binkert.orgelse: 1205863Snate@binkert.org # invoked from subdirectory 1215863Snate@binkert.org if not launch_dir.startswith(ROOT): 1225863Snate@binkert.org print "Error: launch dir (%s) not a subdirectory of ROOT (%s)!" \ 123955SN/A (launch_dir, ROOT) 1246654Snate@binkert.org Exit(1) 1255273Sstever@gmail.com # make launch_dir relative to ROOT (strip ROOT plus slash off front) 1265871Snate@binkert.org launch_dir = launch_dir[len(ROOT)+1:] 1275273Sstever@gmail.com if len(COMMAND_LINE_TARGETS) != 0: 1286655Snate@binkert.org # make specified targets relative to ROOT 1298878Ssteve.reinhardt@amd.com my_targets = map(lambda x: os.path.join(launch_dir, x), 1306655Snate@binkert.org COMMAND_LINE_TARGETS) 1316655Snate@binkert.org else: 1329219Spower.jg@gmail.com # build default binary (m5.debug, unless overridden) using the 1336655Snate@binkert.org # config inferred by the invocation directory (the first 1345871Snate@binkert.org # subdirectory after ROOT) 1356654Snate@binkert.org target = os.path.join(launch_dir.split('/')[0], default_binary) 1368947Sandreas.hansson@arm.com my_targets = [target] 1375396Ssaidi@eecs.umich.edu Default(target) 1388120Sgblack@eecs.umich.edu 1398120Sgblack@eecs.umich.edu# Normalize target paths (gets rid of '..' in the middle, etc.) 1408120Sgblack@eecs.umich.edumy_targets = map(os.path.normpath, my_targets) 1418120Sgblack@eecs.umich.edu 1428120Sgblack@eecs.umich.edu# Generate a list of the unique configs that the collected targets reference. 1438120Sgblack@eecs.umich.edubuild_dirs = [] 1448120Sgblack@eecs.umich.edufor t in my_targets: 1458120Sgblack@eecs.umich.edu dir = t.split('/')[0] 1468879Ssteve.reinhardt@amd.com if dir not in build_dirs: 1478879Ssteve.reinhardt@amd.com build_dirs.append(dir) 1488879Ssteve.reinhardt@amd.com 1498879Ssteve.reinhardt@amd.com################################################### 1508879Ssteve.reinhardt@amd.com# 1518879Ssteve.reinhardt@amd.com# Set up the default build environment. This environment is copied 1528879Ssteve.reinhardt@amd.com# and modified according to each selected configuration. 1538879Ssteve.reinhardt@amd.com# 1548879Ssteve.reinhardt@amd.com################################################### 1558879Ssteve.reinhardt@amd.com 1568879Ssteve.reinhardt@amd.comenv = Environment(ENV = os.environ, # inherit user's environment vars 1578879Ssteve.reinhardt@amd.com ROOT = ROOT, 1588879Ssteve.reinhardt@amd.com SRCDIR = SRCDIR, 1598120Sgblack@eecs.umich.edu EXT_SRCDIR = EXT_SRCDIR) 1608120Sgblack@eecs.umich.edu 1618120Sgblack@eecs.umich.eduenv.SConsignFile("sconsign") 1628120Sgblack@eecs.umich.edu 1638120Sgblack@eecs.umich.edu# I waffle on this setting... it does avoid a few painful but 1648120Sgblack@eecs.umich.edu# unnecessary builds, but it also seems to make trivial builds take 1658120Sgblack@eecs.umich.edu# noticeably longer. 1668120Sgblack@eecs.umich.eduif False: 1678120Sgblack@eecs.umich.edu env.TargetSignatures('content') 1688120Sgblack@eecs.umich.edu 1698120Sgblack@eecs.umich.edu# M5_EXT is used by isa_parser.py to find the PLY package. 1708120Sgblack@eecs.umich.eduenv.Append(ENV = { 'M5_EXT' : EXT_SRCDIR }) 1718120Sgblack@eecs.umich.edu 1728120Sgblack@eecs.umich.edu# Set up default C++ compiler flags 1738879Ssteve.reinhardt@amd.comenv.Append(CCFLAGS='-pipe') 1748879Ssteve.reinhardt@amd.comenv.Append(CCFLAGS='-fno-strict-aliasing') 1758879Ssteve.reinhardt@amd.comenv.Append(CCFLAGS=Split('-Wall -Wno-sign-compare -Werror -Wundef')) 1768879Ssteve.reinhardt@amd.comif sys.platform == 'cygwin': 17710458Sandreas.hansson@arm.com # cygwin has some header file issues... 17810458Sandreas.hansson@arm.com env.Append(CCFLAGS=Split("-Wno-uninitialized")) 17910458Sandreas.hansson@arm.comenv.Append(CPPPATH=[os.path.join(EXT_SRCDIR + '/dnet')]) 1808879Ssteve.reinhardt@amd.com 1818879Ssteve.reinhardt@amd.com# Default libraries 1828879Ssteve.reinhardt@amd.comenv.Append(LIBS=['z']) 1838879Ssteve.reinhardt@amd.com 1849227Sandreas.hansson@arm.com# Platform-specific configuration 1859227Sandreas.hansson@arm.comconf = Configure(env) 18612063Sgabeblack@google.com 18712063Sgabeblack@google.com# Check for <fenv.h> (C99 FP environment control) 18812063Sgabeblack@google.comhave_fenv = conf.CheckHeader('fenv.h', '<>') 1898879Ssteve.reinhardt@amd.comif not have_fenv: 1908879Ssteve.reinhardt@amd.com print "Warning: Header file <fenv.h> not found." 1918879Ssteve.reinhardt@amd.com print " This host has no IEEE FP rounding mode control." 1928879Ssteve.reinhardt@amd.com 19310453SAndrew.Bardsley@arm.com# Check for mysql. 19410453SAndrew.Bardsley@arm.commysql_config = WhereIs('mysql_config') 19510453SAndrew.Bardsley@arm.comhave_mysql = mysql_config != None 19610456SCurtis.Dunham@arm.com 19710456SCurtis.Dunham@arm.com# Check MySQL version. 19810456SCurtis.Dunham@arm.comif have_mysql: 19910457Sandreas.hansson@arm.com mysql_version = os.popen(mysql_config + ' --version').read() 20010457Sandreas.hansson@arm.com mysql_version = mysql_version.split('.') 20111342Sandreas.hansson@arm.com mysql_major = int(mysql_version[0]) 20211342Sandreas.hansson@arm.com mysql_minor = int(mysql_version[1]) 2038120Sgblack@eecs.umich.edu # This version check is probably overly conservative, but it deals 20412063Sgabeblack@google.com # with the versions we have installed. 20512063Sgabeblack@google.com if mysql_major < 4 or (mysql_major == 4 and mysql_minor < 1): 20612063Sgabeblack@google.com print "Warning: MySQL v4.1 or newer required." 20712063Sgabeblack@google.com have_mysql = False 2088947Sandreas.hansson@arm.com 2097816Ssteve.reinhardt@amd.com# Set up mysql_config commands. 2105871Snate@binkert.orgif have_mysql: 2115871Snate@binkert.org mysql_config_include = mysql_config + ' --include' 2126121Snate@binkert.org if os.system(mysql_config_include + ' > /dev/null') != 0: 2135871Snate@binkert.org # older mysql_config versions don't support --include, use 2145871Snate@binkert.org # --cflags instead 2159926Sstan.czerniawski@arm.com mysql_config_include = mysql_config + ' --cflags | sed s/\\\'//g' 2169926Sstan.czerniawski@arm.com # This seems to work in all versions 2179119Sandreas.hansson@arm.com mysql_config_libs = mysql_config + ' --libs' 21810068Sandreas.hansson@arm.com 21911989Sandreas.sandberg@arm.comenv = conf.Finish() 220955SN/A 2219416SAndreas.Sandberg@ARM.com# Define the universe of supported ISAs 22211342Sandreas.hansson@arm.comenv['ALL_ISA_LIST'] = ['alpha', 'sparc', 'mips'] 22311212Sjoseph.gross@amd.com 22411212Sjoseph.gross@amd.com# Define the universe of supported CPU models 22511212Sjoseph.gross@amd.comenv['ALL_CPU_LIST'] = ['SimpleCPU', 'FastCPU', 'FullCPU', 'AlphaFullCPU'] 22611212Sjoseph.gross@amd.com 22711212Sjoseph.gross@amd.com# Sticky options get saved in the options file so they persist from 2289416SAndreas.Sandberg@ARM.com# one invocation to the next (unless overridden, in which case the new 2299416SAndreas.Sandberg@ARM.com# value becomes sticky). 2305871Snate@binkert.orgsticky_opts = Options(args=ARGUMENTS) 23110584Sandreas.hansson@arm.comsticky_opts.AddOptions( 2329416SAndreas.Sandberg@ARM.com EnumOption('TARGET_ISA', 'Target ISA', 'alpha', env['ALL_ISA_LIST']), 2339416SAndreas.Sandberg@ARM.com BoolOption('FULL_SYSTEM', 'Full-system support', False), 2345871Snate@binkert.org BoolOption('ALPHA_TLASER', 235955SN/A 'Model Alpha TurboLaser platform (vs. Tsunami)', False), 23610671Sandreas.hansson@arm.com BoolOption('NO_FAST_ALLOC', 'Disable fast object allocator', False), 23710671Sandreas.hansson@arm.com BoolOption('EFENCE', 'Link with Electric Fence malloc debugger', 23810671Sandreas.hansson@arm.com False), 23910671Sandreas.hansson@arm.com BoolOption('SS_COMPATIBLE_FP', 2408881Smarc.orr@gmail.com 'Make floating-point results compatible with SimpleScalar', 2416121Snate@binkert.org False), 2426121Snate@binkert.org BoolOption('USE_SSE2', 2431533SN/A 'Compile for SSE2 (-msse2) to get IEEE FP on x86 hosts', 2449239Sandreas.hansson@arm.com False), 2459239Sandreas.hansson@arm.com BoolOption('STATS_BINNING', 'Bin statistics by CPU mode', have_mysql), 2469239Sandreas.hansson@arm.com BoolOption('USE_MYSQL', 'Use MySQL for stats output', have_mysql), 2479239Sandreas.hansson@arm.com BoolOption('USE_FENV', 'Use <fenv.h> IEEE mode control', have_fenv), 2489239Sandreas.hansson@arm.com ('CC', 'C compiler', os.environ.get('CC', env['CC'])), 2499239Sandreas.hansson@arm.com ('CXX', 'C++ compiler', os.environ.get('CXX', env['CXX'])), 2509239Sandreas.hansson@arm.com BoolOption('BATCH', 'Use batch pool for build and tests', False), 2516655Snate@binkert.org ('BATCH_CMD', 'Batch pool submission command name', 'qdo') 2526655Snate@binkert.org ) 2536655Snate@binkert.org 2546655Snate@binkert.org# Non-sticky options only apply to the current build. 2555871Snate@binkert.orgnonsticky_opts = Options(args=ARGUMENTS) 2565871Snate@binkert.orgnonsticky_opts.AddOptions( 2575863Snate@binkert.org # This really should be a sticky option, but there's a bug in 2585871Snate@binkert.org # scons 0.96.1 that causes ListOptions not to be able to be 2598878Ssteve.reinhardt@amd.com # restored from a saved option file. It looks like this is fixed 2605871Snate@binkert.org # in 0.96.9, but there's a different bug in that version that means we 2615871Snate@binkert.org # can't just upgrade. 2625871Snate@binkert.org ListOption('CPU_MODELS', 'CPU models', 'all', env['ALL_CPU_LIST']), 2635863Snate@binkert.org BoolOption('update_ref', 'Update test reference outputs', False) 2646121Snate@binkert.org ) 2655863Snate@binkert.org 26611408Sandreas.sandberg@arm.com# These options get exported to #defines in config/*.hh (see m5/SConscript). 26711408Sandreas.sandberg@arm.comenv.ExportOptions = ['FULL_SYSTEM', 'ALPHA_TLASER', 'USE_FENV', \ 2688336Ssteve.reinhardt@amd.com 'USE_MYSQL', 'NO_FAST_ALLOC', 'SS_COMPATIBLE_FP', \ 26911469SCurtis.Dunham@arm.com 'STATS_BINNING'] 27011469SCurtis.Dunham@arm.com 2718336Ssteve.reinhardt@amd.com# Define a handy 'no-op' action 2724678Snate@binkert.orgdef no_action(target, source, env): 27311887Sandreas.sandberg@arm.com return 0 27411887Sandreas.sandberg@arm.com 27511887Sandreas.sandberg@arm.comenv.NoAction = Action(no_action, None) 27611887Sandreas.sandberg@arm.com 27711887Sandreas.sandberg@arm.com# libelf build is described in its own SConscript file. 27811887Sandreas.sandberg@arm.com# SConscript-global is the build in build/libelf shared among all 27911887Sandreas.sandberg@arm.com# configs. 28011887Sandreas.sandberg@arm.comenv.SConscript('m5/libelf/SConscript-global', exports = 'env') 28111887Sandreas.sandberg@arm.com 28211887Sandreas.sandberg@arm.com################################################### 28311887Sandreas.sandberg@arm.com# 28411408Sandreas.sandberg@arm.com# Define a SCons builder for configuration flag headers. 28511401Sandreas.sandberg@arm.com# 28611401Sandreas.sandberg@arm.com################################################### 28711401Sandreas.sandberg@arm.com 28811401Sandreas.sandberg@arm.com# This function generates a config header file that #defines the 28911401Sandreas.sandberg@arm.com# option symbol to the current option setting (0 or 1). The source 29011401Sandreas.sandberg@arm.com# operands are the name of the option and a Value node containing the 2918336Ssteve.reinhardt@amd.com# value of the option. 2928336Ssteve.reinhardt@amd.comdef build_config_file(target, source, env): 2938336Ssteve.reinhardt@amd.com (option, value) = [s.get_contents() for s in source] 2944678Snate@binkert.org f = file(str(target[0]), 'w') 29511401Sandreas.sandberg@arm.com print >> f, '#define', option, value 2964678Snate@binkert.org f.close() 2974678Snate@binkert.org return None 29811401Sandreas.sandberg@arm.com 29911401Sandreas.sandberg@arm.com# Generate the message to be printed when building the config file. 3008336Ssteve.reinhardt@amd.comdef build_config_file_string(target, source, env): 3014678Snate@binkert.org (option, value) = [s.get_contents() for s in source] 3028336Ssteve.reinhardt@amd.com return "Defining %s as %s in %s." % (option, value, target[0]) 3038336Ssteve.reinhardt@amd.com 3048336Ssteve.reinhardt@amd.com# Combine the two functions into a scons Action object. 3058336Ssteve.reinhardt@amd.comconfig_action = Action(build_config_file, build_config_file_string) 3068336Ssteve.reinhardt@amd.com 3078336Ssteve.reinhardt@amd.com# The emitter munges the source & target node lists to reflect what 3085871Snate@binkert.org# we're really doing. 3095871Snate@binkert.orgdef config_emitter(target, source, env): 3108336Ssteve.reinhardt@amd.com # extract option name from Builder arg 31111408Sandreas.sandberg@arm.com option = str(target[0]) 31211408Sandreas.sandberg@arm.com # True target is config header file 31311408Sandreas.sandberg@arm.com target = os.path.join('config', option.lower() + '.hh') 31411408Sandreas.sandberg@arm.com # Force value to 0/1 even if it's a Python bool 31511408Sandreas.sandberg@arm.com val = int(eval(str(env[option]))) 31611408Sandreas.sandberg@arm.com # Sources are option name & value (packaged in SCons Value nodes) 31711408Sandreas.sandberg@arm.com return ([target], [Value(option), Value(val)]) 3188336Ssteve.reinhardt@amd.com 31911401Sandreas.sandberg@arm.comconfig_builder = Builder(emitter = config_emitter, action = config_action) 32011401Sandreas.sandberg@arm.com 32111401Sandreas.sandberg@arm.comenv.Append(BUILDERS = { 'ConfigFile' : config_builder }) 3225871Snate@binkert.org 3238336Ssteve.reinhardt@amd.com################################################### 3248336Ssteve.reinhardt@amd.com# 32511401Sandreas.sandberg@arm.com# Define build environments for selected configurations. 32611401Sandreas.sandberg@arm.com# 32711401Sandreas.sandberg@arm.com################################################### 32811401Sandreas.sandberg@arm.com 32911401Sandreas.sandberg@arm.com# rename base env 3304678Snate@binkert.orgbase_env = env 3315871Snate@binkert.org 3324678Snate@binkert.orgfor build_dir in build_dirs: 33311401Sandreas.sandberg@arm.com # Make a copy of the default environment to use for this config. 33411401Sandreas.sandberg@arm.com env = base_env.Copy() 33511401Sandreas.sandberg@arm.com 33611401Sandreas.sandberg@arm.com # Record what build_dir was in the environment 33711401Sandreas.sandberg@arm.com env.Append(BUILD_DIR=build_dir); 33811401Sandreas.sandberg@arm.com 33911401Sandreas.sandberg@arm.com # Set env according to the build directory config. 34011401Sandreas.sandberg@arm.com 34111401Sandreas.sandberg@arm.com sticky_opts.files = [] 34211401Sandreas.sandberg@arm.com # Name of default options file is taken from 'default=' on command 34311401Sandreas.sandberg@arm.com # line if set, otherwise name of build dir. 34411401Sandreas.sandberg@arm.com default_options_file = os.path.join('build_options', 'default', 34511450Sandreas.sandberg@arm.com ARGUMENTS.get('default', build_dir)) 34611450Sandreas.sandberg@arm.com if os.path.isfile(default_options_file): 34711450Sandreas.sandberg@arm.com sticky_opts.files.append(default_options_file) 34811450Sandreas.sandberg@arm.com current_options_file = os.path.join('build_options', 'current', build_dir) 34911450Sandreas.sandberg@arm.com if os.path.isfile(current_options_file): 35011450Sandreas.sandberg@arm.com sticky_opts.files.append(current_options_file) 35111450Sandreas.sandberg@arm.com else: 35211450Sandreas.sandberg@arm.com # if file doesn't exist, make sure at least the directory is there 35311450Sandreas.sandberg@arm.com # so we can create it later 35411450Sandreas.sandberg@arm.com opt_dir = os.path.dirname(current_options_file) 35511450Sandreas.sandberg@arm.com if not os.path.isdir(opt_dir): 35611401Sandreas.sandberg@arm.com os.mkdir(opt_dir) 35711450Sandreas.sandberg@arm.com if not sticky_opts.files: 35811450Sandreas.sandberg@arm.com print "%s: No options file found in build_options, using defaults." \ 35911450Sandreas.sandberg@arm.com % build_dir 36011401Sandreas.sandberg@arm.com 36111450Sandreas.sandberg@arm.com # Apply current option settings to env 36211401Sandreas.sandberg@arm.com sticky_opts.Update(env) 3638336Ssteve.reinhardt@amd.com nonsticky_opts.Update(env) 3648336Ssteve.reinhardt@amd.com 3658336Ssteve.reinhardt@amd.com # Process option settings. 3668336Ssteve.reinhardt@amd.com 3678336Ssteve.reinhardt@amd.com if not have_fenv and env['USE_FENV']: 3688336Ssteve.reinhardt@amd.com print "Warning: <fenv.h> not available; " \ 3698336Ssteve.reinhardt@amd.com "forcing USE_FENV to False in", build_dir + "." 3708336Ssteve.reinhardt@amd.com env['USE_FENV'] = False 3718336Ssteve.reinhardt@amd.com 3728336Ssteve.reinhardt@amd.com if not env['USE_FENV']: 37311401Sandreas.sandberg@arm.com print "Warning: No IEEE FP rounding mode control in", build_dir + "." 37411401Sandreas.sandberg@arm.com print " FP results may deviate slightly from other platforms." 3758336Ssteve.reinhardt@amd.com 3768336Ssteve.reinhardt@amd.com if env['EFENCE']: 3778336Ssteve.reinhardt@amd.com env.Append(LIBS=['efence']) 3785871Snate@binkert.org 37911476Sandreas.sandberg@arm.com if env['USE_MYSQL']: 38011476Sandreas.sandberg@arm.com if not have_mysql: 38111476Sandreas.sandberg@arm.com print "Warning: MySQL not available; " \ 38211476Sandreas.sandberg@arm.com "forcing USE_MYSQL to False in", build_dir + "." 38311476Sandreas.sandberg@arm.com env['USE_MYSQL'] = False 38411476Sandreas.sandberg@arm.com else: 38511476Sandreas.sandberg@arm.com print "Compiling in", build_dir, "with MySQL support." 38611476Sandreas.sandberg@arm.com env.ParseConfig(mysql_config_libs) 38711476Sandreas.sandberg@arm.com env.ParseConfig(mysql_config_include) 38811887Sandreas.sandberg@arm.com 38911887Sandreas.sandberg@arm.com # Save sticky option settings back to current options file 39011887Sandreas.sandberg@arm.com sticky_opts.Save(current_options_file, env) 39111408Sandreas.sandberg@arm.com 39211887Sandreas.sandberg@arm.com # Do this after we save setting back, or else we'll tack on an 39311887Sandreas.sandberg@arm.com # extra 'qdo' every time we run scons. 39411887Sandreas.sandberg@arm.com if env['BATCH']: 39511887Sandreas.sandberg@arm.com env['CC'] = env['BATCH_CMD'] + ' ' + env['CC'] 39611887Sandreas.sandberg@arm.com env['CXX'] = env['BATCH_CMD'] + ' ' + env['CXX'] 39711887Sandreas.sandberg@arm.com 39811926Sgabeblack@google.com if env['USE_SSE2']: 39911926Sgabeblack@google.com env.Append(CCFLAGS='-msse2') 40011926Sgabeblack@google.com 40111926Sgabeblack@google.com # The m5/SConscript file sets up the build rules in 'env' according 40211887Sandreas.sandberg@arm.com # to the configured options. It returns a list of environments, 40311887Sandreas.sandberg@arm.com # one for each variant build (debug, opt, etc.) 40411944Sandreas.sandberg@arm.com envList = SConscript('m5/SConscript', build_dir = build_dir, 40511887Sandreas.sandberg@arm.com exports = 'env', duplicate = False) 40611927Sgabeblack@google.com 40711927Sgabeblack@google.com # Set up the regression tests for each build. 40811927Sgabeblack@google.com for e in envList: 40911927Sgabeblack@google.com SConscript('m5-test/SConscript', 41011927Sgabeblack@google.com build_dir = os.path.join(build_dir, 'test', e.Label), 41111927Sgabeblack@google.com exports = { 'env' : e }, duplicate = False) 41211887Sandreas.sandberg@arm.com 41311928Sgabeblack@google.com################################################### 41411928Sgabeblack@google.com# 41511887Sandreas.sandberg@arm.com# Let SCons do its thing. At this point SCons will use the defined 41611887Sandreas.sandberg@arm.com# build environments to build the requested targets. 41711887Sandreas.sandberg@arm.com# 41811887Sandreas.sandberg@arm.com################################################### 41911887Sandreas.sandberg@arm.com 42011887Sandreas.sandberg@arm.com