SConstruct revision 2668:1f891cd3d920
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. If your system's 662761Sstever@eecs.umich.edu# default installation of Python is not recent enough, you can use a 672761Sstever@eecs.umich.edu# non-default installation of the Python interpreter by either (1) 682761Sstever@eecs.umich.edu# rearranging your PATH so that scons finds the non-default 'python' 692761Sstever@eecs.umich.edu# first or (2) explicitly invoking an alternative interpreter on the 702761Sstever@eecs.umich.edu# scons script, e.g., "/usr/local/bin/python2.4 `which scons` [args]". 718878Ssteve.reinhardt@amd.comEnsurePythonVersion(2,4) 728878Ssteve.reinhardt@amd.com 732632Sstever@eecs.umich.edu# Ironically, SCons 0.96 dies if you give EnsureSconsVersion a 742632Sstever@eecs.umich.edu# 3-element version number. 758878Ssteve.reinhardt@amd.commin_scons_version = (0,96,91) 768878Ssteve.reinhardt@amd.comtry: 772632Sstever@eecs.umich.edu EnsureSConsVersion(*min_scons_version) 78955SN/Aexcept: 79955SN/A print "Error checking current SCons version." 80955SN/A print "SCons", ".".join(map(str,min_scons_version)), "or greater required." 815863Snate@binkert.org Exit(2) 825863Snate@binkert.org 835863Snate@binkert.org 845863Snate@binkert.org# The absolute path to the current directory (where this file lives). 855863Snate@binkert.orgROOT = Dir('.').abspath 865863Snate@binkert.org 875863Snate@binkert.org# Paths to the M5 and external source trees. 885863Snate@binkert.orgSRCDIR = os.path.join(ROOT, 'src') 895863Snate@binkert.org 905863Snate@binkert.org# tell python where to find m5 python code 915863Snate@binkert.orgsys.path.append(os.path.join(ROOT, 'src/python')) 928878Ssteve.reinhardt@amd.com 935863Snate@binkert.org################################################### 945863Snate@binkert.org# 955863Snate@binkert.org# Figure out which configurations to set up based on the path(s) of 969812Sandreas.hansson@arm.com# the target(s). 979812Sandreas.hansson@arm.com# 985863Snate@binkert.org################################################### 999812Sandreas.hansson@arm.com 1005863Snate@binkert.org# Find default configuration & binary. 1015863Snate@binkert.orgDefault(os.environ.get('M5_DEFAULT_BINARY', 'build/ALPHA_SE/m5.debug')) 1025863Snate@binkert.org 1039812Sandreas.hansson@arm.com# Ask SCons which directory it was invoked from. 1049812Sandreas.hansson@arm.comlaunch_dir = GetLaunchDir() 1055863Snate@binkert.org 1065863Snate@binkert.org# Make targets relative to invocation directory 1078878Ssteve.reinhardt@amd.comabs_targets = map(lambda x: os.path.normpath(os.path.join(launch_dir, str(x))), 1085863Snate@binkert.org BUILD_TARGETS) 1095863Snate@binkert.org 1105863Snate@binkert.org# helper function: find last occurrence of element in list 1116654Snate@binkert.orgdef rfind(l, elt, offs = -1): 11210196SCurtis.Dunham@arm.com for i in range(len(l)+offs, 0, -1): 113955SN/A if l[i] == elt: 1145396Ssaidi@eecs.umich.edu return i 11511401Sandreas.sandberg@arm.com raise ValueError, "element not found" 1165863Snate@binkert.org 1175863Snate@binkert.org# Each target must have 'build' in the interior of the path; the 1184202Sbinkertn@umich.edu# directory below this will determine the build parameters. For 1195863Snate@binkert.org# example, for target 'foo/bar/build/ALPHA_SE/arch/alpha/blah.do' we 1205863Snate@binkert.org# recognize that ALPHA_SE specifies the configuration because it 1215863Snate@binkert.org# follow 'build' in the bulid path. 1225863Snate@binkert.org 123955SN/A# Generate a list of the unique build roots and configs that the 1246654Snate@binkert.org# collected targets reference. 1255273Sstever@gmail.combuild_paths = [] 1265871Snate@binkert.orgbuild_root = None 1275273Sstever@gmail.comfor t in abs_targets: 1286655Snate@binkert.org path_dirs = t.split('/') 1298878Ssteve.reinhardt@amd.com try: 1306655Snate@binkert.org build_top = rfind(path_dirs, 'build', -2) 1316655Snate@binkert.org except: 1329219Spower.jg@gmail.com print "Error: no non-leaf 'build' dir found on target path", t 1336655Snate@binkert.org Exit(1) 1345871Snate@binkert.org this_build_root = os.path.join('/',*path_dirs[:build_top+1]) 1356654Snate@binkert.org if not build_root: 1368947Sandreas.hansson@arm.com build_root = this_build_root 1375396Ssaidi@eecs.umich.edu else: 1388120Sgblack@eecs.umich.edu if this_build_root != build_root: 1398120Sgblack@eecs.umich.edu print "Error: build targets not under same build root\n"\ 1408120Sgblack@eecs.umich.edu " %s\n %s" % (build_root, this_build_root) 1418120Sgblack@eecs.umich.edu Exit(1) 1428120Sgblack@eecs.umich.edu build_path = os.path.join('/',*path_dirs[:build_top+2]) 1438120Sgblack@eecs.umich.edu if build_path not in build_paths: 1448120Sgblack@eecs.umich.edu build_paths.append(build_path) 1458120Sgblack@eecs.umich.edu 1468879Ssteve.reinhardt@amd.com################################################### 1478879Ssteve.reinhardt@amd.com# 1488879Ssteve.reinhardt@amd.com# Set up the default build environment. This environment is copied 1498879Ssteve.reinhardt@amd.com# and modified according to each selected configuration. 1508879Ssteve.reinhardt@amd.com# 1518879Ssteve.reinhardt@amd.com################################################### 1528879Ssteve.reinhardt@amd.com 1538879Ssteve.reinhardt@amd.comenv = Environment(ENV = os.environ, # inherit user's environment vars 1548879Ssteve.reinhardt@amd.com ROOT = ROOT, 1558879Ssteve.reinhardt@amd.com SRCDIR = SRCDIR) 1568879Ssteve.reinhardt@amd.com 1578879Ssteve.reinhardt@amd.comenv.SConsignFile("sconsign") 1588879Ssteve.reinhardt@amd.com 1598120Sgblack@eecs.umich.edu# I waffle on this setting... it does avoid a few painful but 1608120Sgblack@eecs.umich.edu# unnecessary builds, but it also seems to make trivial builds take 1618120Sgblack@eecs.umich.edu# noticeably longer. 1628120Sgblack@eecs.umich.eduif False: 1638120Sgblack@eecs.umich.edu env.TargetSignatures('content') 1648120Sgblack@eecs.umich.edu 1658120Sgblack@eecs.umich.edu# M5_PLY is used by isa_parser.py to find the PLY package. 1668120Sgblack@eecs.umich.eduenv.Append(ENV = { 'M5_PLY' : Dir('ext/ply') }) 1678120Sgblack@eecs.umich.edu 1688120Sgblack@eecs.umich.edu# Set up default C++ compiler flags 1698120Sgblack@eecs.umich.eduenv.Append(CCFLAGS='-pipe') 1708120Sgblack@eecs.umich.eduenv.Append(CCFLAGS='-fno-strict-aliasing') 1718120Sgblack@eecs.umich.eduenv.Append(CCFLAGS=Split('-Wall -Wno-sign-compare -Werror -Wundef')) 1728120Sgblack@eecs.umich.eduif sys.platform == 'cygwin': 1738879Ssteve.reinhardt@amd.com # cygwin has some header file issues... 1748879Ssteve.reinhardt@amd.com env.Append(CCFLAGS=Split("-Wno-uninitialized")) 1758879Ssteve.reinhardt@amd.comenv.Append(CPPPATH=[Dir('ext/dnet')]) 1768879Ssteve.reinhardt@amd.com 17710458Sandreas.hansson@arm.com# Find Python include and library directories for embedding the 17810458Sandreas.hansson@arm.com# interpreter. For consistency, we will use the same Python 17910458Sandreas.hansson@arm.com# installation used to run scons (and thus this script). If you want 1808879Ssteve.reinhardt@amd.com# to link in an alternate version, see above for instructions on how 1818879Ssteve.reinhardt@amd.com# to invoke scons with a different copy of the Python interpreter. 1828879Ssteve.reinhardt@amd.com 1838879Ssteve.reinhardt@amd.com# Get brief Python version name (e.g., "python2.4") for locating 1849227Sandreas.hansson@arm.com# include & library files 1859227Sandreas.hansson@arm.compy_version_name = 'python' + sys.version[:3] 1868879Ssteve.reinhardt@amd.com 1878879Ssteve.reinhardt@amd.com# include path, e.g. /usr/local/include/python2.4 1888879Ssteve.reinhardt@amd.comenv.Append(CPPPATH = os.path.join(sys.exec_prefix, 'include', py_version_name)) 1898879Ssteve.reinhardt@amd.comenv.Append(LIBS = py_version_name) 19010453SAndrew.Bardsley@arm.com# add library path too if it's not in the default place 19110453SAndrew.Bardsley@arm.comif sys.exec_prefix != '/usr': 19210453SAndrew.Bardsley@arm.com env.Append(LIBPATH = os.path.join(sys.exec_prefix, 'lib')) 19310456SCurtis.Dunham@arm.com 19410456SCurtis.Dunham@arm.com# Other default libraries 19510456SCurtis.Dunham@arm.comenv.Append(LIBS=['z']) 19610457Sandreas.hansson@arm.com 19710457Sandreas.hansson@arm.com# Platform-specific configuration. Note again that we assume that all 19811342Sandreas.hansson@arm.com# builds under a given build root run on the same host platform. 19911342Sandreas.hansson@arm.comconf = Configure(env, 2008120Sgblack@eecs.umich.edu conf_dir = os.path.join(build_root, '.scons_config'), 2018947Sandreas.hansson@arm.com log_file = os.path.join(build_root, 'scons_config.log')) 2027816Ssteve.reinhardt@amd.com 2035871Snate@binkert.org# Check for <fenv.h> (C99 FP environment control) 2045871Snate@binkert.orghave_fenv = conf.CheckHeader('fenv.h', '<>') 2056121Snate@binkert.orgif not have_fenv: 2065871Snate@binkert.org print "Warning: Header file <fenv.h> not found." 2075871Snate@binkert.org print " This host has no IEEE FP rounding mode control." 2089926Sstan.czerniawski@arm.com 2099926Sstan.czerniawski@arm.com# Check for mysql. 2109119Sandreas.hansson@arm.commysql_config = WhereIs('mysql_config') 21110068Sandreas.hansson@arm.comhave_mysql = mysql_config != None 21210068Sandreas.hansson@arm.com 213955SN/A# Check MySQL version. 2149416SAndreas.Sandberg@ARM.comif have_mysql: 21511342Sandreas.hansson@arm.com mysql_version = os.popen(mysql_config + ' --version').read() 21611212Sjoseph.gross@amd.com mysql_version = mysql_version.split('.') 21711212Sjoseph.gross@amd.com mysql_major = int(mysql_version[0]) 21811212Sjoseph.gross@amd.com mysql_minor = int(mysql_version[1]) 21911212Sjoseph.gross@amd.com # This version check is probably overly conservative, but it deals 22011212Sjoseph.gross@amd.com # with the versions we have installed. 2219416SAndreas.Sandberg@ARM.com if mysql_major < 4 or (mysql_major == 4 and mysql_minor < 1): 2229416SAndreas.Sandberg@ARM.com print "Warning: MySQL v4.1 or newer required." 2235871Snate@binkert.org have_mysql = False 22410584Sandreas.hansson@arm.com 2259416SAndreas.Sandberg@ARM.com# Set up mysql_config commands. 2269416SAndreas.Sandberg@ARM.comif have_mysql: 2275871Snate@binkert.org mysql_config_include = mysql_config + ' --include' 228955SN/A if os.system(mysql_config_include + ' > /dev/null') != 0: 22910671Sandreas.hansson@arm.com # older mysql_config versions don't support --include, use 23010671Sandreas.hansson@arm.com # --cflags instead 23110671Sandreas.hansson@arm.com mysql_config_include = mysql_config + ' --cflags | sed s/\\\'//g' 23210671Sandreas.hansson@arm.com # This seems to work in all versions 2338881Smarc.orr@gmail.com mysql_config_libs = mysql_config + ' --libs' 2346121Snate@binkert.org 2356121Snate@binkert.orgenv = conf.Finish() 2361533SN/A 2379239Sandreas.hansson@arm.com# Define the universe of supported ISAs 2389239Sandreas.hansson@arm.comenv['ALL_ISA_LIST'] = ['alpha', 'sparc', 'mips'] 2399239Sandreas.hansson@arm.com 2409239Sandreas.hansson@arm.com# Define the universe of supported CPU models 2419239Sandreas.hansson@arm.comenv['ALL_CPU_LIST'] = ['AtomicSimpleCPU', 'TimingSimpleCPU', 2429239Sandreas.hansson@arm.com 'FullCPU', 'AlphaFullCPU', 2439239Sandreas.hansson@arm.com 'OzoneSimpleCPU', 'OzoneCPU', 'CheckerCPU'] 2449239Sandreas.hansson@arm.com 2459239Sandreas.hansson@arm.com# Sticky options get saved in the options file so they persist from 2469239Sandreas.hansson@arm.com# one invocation to the next (unless overridden, in which case the new 2479239Sandreas.hansson@arm.com# value becomes sticky). 2489239Sandreas.hansson@arm.comsticky_opts = Options(args=ARGUMENTS) 2496655Snate@binkert.orgsticky_opts.AddOptions( 2506655Snate@binkert.org EnumOption('TARGET_ISA', 'Target ISA', 'alpha', env['ALL_ISA_LIST']), 2516655Snate@binkert.org BoolOption('FULL_SYSTEM', 'Full-system support', False), 2526655Snate@binkert.org # There's a bug in scons 0.96.1 that causes ListOptions with list 2535871Snate@binkert.org # values (more than one value) not to be able to be restored from 2545871Snate@binkert.org # a saved option file. If this causes trouble then upgrade to 2555863Snate@binkert.org # scons 0.96.90 or later. 2565871Snate@binkert.org ListOption('CPU_MODELS', 'CPU models', 'AtomicSimpleCPU,TimingSimpleCPU', 2578878Ssteve.reinhardt@amd.com env['ALL_CPU_LIST']), 2585871Snate@binkert.org BoolOption('ALPHA_TLASER', 2595871Snate@binkert.org 'Model Alpha TurboLaser platform (vs. Tsunami)', False), 2605871Snate@binkert.org BoolOption('NO_FAST_ALLOC', 'Disable fast object allocator', False), 2615863Snate@binkert.org BoolOption('EFENCE', 'Link with Electric Fence malloc debugger', 2626121Snate@binkert.org False), 2635863Snate@binkert.org BoolOption('SS_COMPATIBLE_FP', 26411408Sandreas.sandberg@arm.com 'Make floating-point results compatible with SimpleScalar', 26511408Sandreas.sandberg@arm.com False), 2668336Ssteve.reinhardt@amd.com BoolOption('USE_SSE2', 26711469SCurtis.Dunham@arm.com 'Compile for SSE2 (-msse2) to get IEEE FP on x86 hosts', 26811469SCurtis.Dunham@arm.com False), 2698336Ssteve.reinhardt@amd.com BoolOption('STATS_BINNING', 'Bin statistics by CPU mode', have_mysql), 2704678Snate@binkert.org BoolOption('USE_MYSQL', 'Use MySQL for stats output', have_mysql), 27111887Sandreas.sandberg@arm.com BoolOption('USE_FENV', 'Use <fenv.h> IEEE mode control', have_fenv), 27211887Sandreas.sandberg@arm.com ('CC', 'C compiler', os.environ.get('CC', env['CC'])), 27311887Sandreas.sandberg@arm.com ('CXX', 'C++ compiler', os.environ.get('CXX', env['CXX'])), 27411887Sandreas.sandberg@arm.com BoolOption('BATCH', 'Use batch pool for build and tests', False), 27511887Sandreas.sandberg@arm.com ('BATCH_CMD', 'Batch pool submission command name', 'qdo') 27611887Sandreas.sandberg@arm.com ) 27711887Sandreas.sandberg@arm.com 27811887Sandreas.sandberg@arm.com# Non-sticky options only apply to the current build. 27911887Sandreas.sandberg@arm.comnonsticky_opts = Options(args=ARGUMENTS) 28011887Sandreas.sandberg@arm.comnonsticky_opts.AddOptions( 28111887Sandreas.sandberg@arm.com BoolOption('update_ref', 'Update test reference outputs', False) 28211408Sandreas.sandberg@arm.com ) 28311401Sandreas.sandberg@arm.com 28411401Sandreas.sandberg@arm.com# These options get exported to #defines in config/*.hh (see m5/SConscript). 28511401Sandreas.sandberg@arm.comenv.ExportOptions = ['FULL_SYSTEM', 'ALPHA_TLASER', 'USE_FENV', \ 28611401Sandreas.sandberg@arm.com 'USE_MYSQL', 'NO_FAST_ALLOC', 'SS_COMPATIBLE_FP', \ 28711401Sandreas.sandberg@arm.com 'STATS_BINNING'] 28811401Sandreas.sandberg@arm.com 2898336Ssteve.reinhardt@amd.com# Define a handy 'no-op' action 2908336Ssteve.reinhardt@amd.comdef no_action(target, source, env): 2918336Ssteve.reinhardt@amd.com return 0 2924678Snate@binkert.org 29311401Sandreas.sandberg@arm.comenv.NoAction = Action(no_action, None) 2944678Snate@binkert.org 2954678Snate@binkert.org################################################### 29611401Sandreas.sandberg@arm.com# 29711401Sandreas.sandberg@arm.com# Define a SCons builder for configuration flag headers. 2988336Ssteve.reinhardt@amd.com# 2994678Snate@binkert.org################################################### 3008336Ssteve.reinhardt@amd.com 3018336Ssteve.reinhardt@amd.com# This function generates a config header file that #defines the 3028336Ssteve.reinhardt@amd.com# option symbol to the current option setting (0 or 1). The source 3038336Ssteve.reinhardt@amd.com# operands are the name of the option and a Value node containing the 3048336Ssteve.reinhardt@amd.com# value of the option. 3058336Ssteve.reinhardt@amd.comdef build_config_file(target, source, env): 3065871Snate@binkert.org (option, value) = [s.get_contents() for s in source] 3075871Snate@binkert.org f = file(str(target[0]), 'w') 3088336Ssteve.reinhardt@amd.com print >> f, '#define', option, value 30911408Sandreas.sandberg@arm.com f.close() 31011408Sandreas.sandberg@arm.com return None 31111408Sandreas.sandberg@arm.com 31211408Sandreas.sandberg@arm.com# Generate the message to be printed when building the config file. 31311408Sandreas.sandberg@arm.comdef build_config_file_string(target, source, env): 31411408Sandreas.sandberg@arm.com (option, value) = [s.get_contents() for s in source] 31511408Sandreas.sandberg@arm.com return "Defining %s as %s in %s." % (option, value, target[0]) 3168336Ssteve.reinhardt@amd.com 31711401Sandreas.sandberg@arm.com# Combine the two functions into a scons Action object. 31811401Sandreas.sandberg@arm.comconfig_action = Action(build_config_file, build_config_file_string) 31911401Sandreas.sandberg@arm.com 3205871Snate@binkert.org# The emitter munges the source & target node lists to reflect what 3218336Ssteve.reinhardt@amd.com# we're really doing. 3228336Ssteve.reinhardt@amd.comdef config_emitter(target, source, env): 32311401Sandreas.sandberg@arm.com # extract option name from Builder arg 32411401Sandreas.sandberg@arm.com option = str(target[0]) 32511401Sandreas.sandberg@arm.com # True target is config header file 32611401Sandreas.sandberg@arm.com target = os.path.join('config', option.lower() + '.hh') 32711401Sandreas.sandberg@arm.com # Force value to 0/1 even if it's a Python bool 3284678Snate@binkert.org val = int(eval(str(env[option]))) 3295871Snate@binkert.org # Sources are option name & value (packaged in SCons Value nodes) 3304678Snate@binkert.org return ([target], [Value(option), Value(val)]) 33111401Sandreas.sandberg@arm.com 33211401Sandreas.sandberg@arm.comconfig_builder = Builder(emitter = config_emitter, action = config_action) 33311401Sandreas.sandberg@arm.com 33411401Sandreas.sandberg@arm.comenv.Append(BUILDERS = { 'ConfigFile' : config_builder }) 33511401Sandreas.sandberg@arm.com 33611401Sandreas.sandberg@arm.com################################################### 33711401Sandreas.sandberg@arm.com# 33811401Sandreas.sandberg@arm.com# Define a SCons builder for copying files. This is used by the 33911401Sandreas.sandberg@arm.com# Python zipfile code in src/python/SConscript, but is placed up here 34011401Sandreas.sandberg@arm.com# since it's potentially more generally applicable. 34111401Sandreas.sandberg@arm.com# 34211401Sandreas.sandberg@arm.com################################################### 34311450Sandreas.sandberg@arm.com 34411450Sandreas.sandberg@arm.comcopy_builder = Builder(action = Copy("$TARGET", "$SOURCE")) 34511450Sandreas.sandberg@arm.com 34611450Sandreas.sandberg@arm.comenv.Append(BUILDERS = { 'CopyFile' : copy_builder }) 34711450Sandreas.sandberg@arm.com 34811450Sandreas.sandberg@arm.com################################################### 34911450Sandreas.sandberg@arm.com# 35011450Sandreas.sandberg@arm.com# Define a simple SCons builder to concatenate files. 35111450Sandreas.sandberg@arm.com# 35211450Sandreas.sandberg@arm.com# Used to append the Python zip archive to the executable. 35311450Sandreas.sandberg@arm.com# 35411401Sandreas.sandberg@arm.com################################################### 35511450Sandreas.sandberg@arm.com 35611450Sandreas.sandberg@arm.comconcat_builder = Builder(action = Action(['cat $SOURCES > $TARGET', 35711450Sandreas.sandberg@arm.com 'chmod +x $TARGET'])) 35811401Sandreas.sandberg@arm.com 35911450Sandreas.sandberg@arm.comenv.Append(BUILDERS = { 'Concat' : concat_builder }) 36011401Sandreas.sandberg@arm.com 3618336Ssteve.reinhardt@amd.com 3628336Ssteve.reinhardt@amd.com# base help text 3638336Ssteve.reinhardt@amd.comhelp_text = ''' 3648336Ssteve.reinhardt@amd.comUsage: scons [scons options] [build options] [target(s)] 3658336Ssteve.reinhardt@amd.com 3668336Ssteve.reinhardt@amd.com''' 3678336Ssteve.reinhardt@amd.com 3688336Ssteve.reinhardt@amd.com# libelf build is shared across all configs in the build root. 3698336Ssteve.reinhardt@amd.comenv.SConscript('ext/libelf/SConscript', 3708336Ssteve.reinhardt@amd.com build_dir = os.path.join(build_root, 'libelf'), 37111401Sandreas.sandberg@arm.com exports = 'env') 37211401Sandreas.sandberg@arm.com 3738336Ssteve.reinhardt@amd.com################################################### 3748336Ssteve.reinhardt@amd.com# 3758336Ssteve.reinhardt@amd.com# Define build environments for selected configurations. 3765871Snate@binkert.org# 37711476Sandreas.sandberg@arm.com################################################### 37811476Sandreas.sandberg@arm.com 37911476Sandreas.sandberg@arm.com# rename base env 38011476Sandreas.sandberg@arm.combase_env = env 38111476Sandreas.sandberg@arm.com 38211476Sandreas.sandberg@arm.comfor build_path in build_paths: 38311476Sandreas.sandberg@arm.com print "Building in", build_path 38411476Sandreas.sandberg@arm.com # build_dir is the tail component of build path, and is used to 38511476Sandreas.sandberg@arm.com # determine the build parameters (e.g., 'ALPHA_SE') 38611887Sandreas.sandberg@arm.com (build_root, build_dir) = os.path.split(build_path) 38711887Sandreas.sandberg@arm.com # Make a copy of the build-root environment to use for this config. 38811887Sandreas.sandberg@arm.com env = base_env.Copy() 38911408Sandreas.sandberg@arm.com 39011887Sandreas.sandberg@arm.com # Set env options according to the build directory config. 39111887Sandreas.sandberg@arm.com sticky_opts.files = [] 39211887Sandreas.sandberg@arm.com # Options for $BUILD_ROOT/$BUILD_DIR are stored in 39311887Sandreas.sandberg@arm.com # $BUILD_ROOT/options/$BUILD_DIR so you can nuke 39411887Sandreas.sandberg@arm.com # $BUILD_ROOT/$BUILD_DIR without losing your options settings. 39511887Sandreas.sandberg@arm.com current_opts_file = os.path.join(build_root, 'options', build_dir) 39611926Sgabeblack@google.com if os.path.isfile(current_opts_file): 39711926Sgabeblack@google.com sticky_opts.files.append(current_opts_file) 39811926Sgabeblack@google.com print "Using saved options file %s" % current_opts_file 39911926Sgabeblack@google.com else: 40011887Sandreas.sandberg@arm.com # Build dir-specific options file doesn't exist. 40111887Sandreas.sandberg@arm.com 40211944Sandreas.sandberg@arm.com # Make sure the directory is there so we can create it later 40311887Sandreas.sandberg@arm.com opt_dir = os.path.dirname(current_opts_file) 40411927Sgabeblack@google.com if not os.path.isdir(opt_dir): 40511927Sgabeblack@google.com os.mkdir(opt_dir) 40611927Sgabeblack@google.com 40711927Sgabeblack@google.com # Get default build options from source tree. Options are 40811927Sgabeblack@google.com # normally determined by name of $BUILD_DIR, but can be 40911927Sgabeblack@google.com # overriden by 'default=' arg on command line. 41011887Sandreas.sandberg@arm.com default_opts_file = os.path.join('build_opts', 41111928Sgabeblack@google.com ARGUMENTS.get('default', build_dir)) 41211928Sgabeblack@google.com if os.path.isfile(default_opts_file): 41311887Sandreas.sandberg@arm.com sticky_opts.files.append(default_opts_file) 41411887Sandreas.sandberg@arm.com print "Options file %s not found,\n using defaults in %s" \ 41511887Sandreas.sandberg@arm.com % (current_opts_file, default_opts_file) 41611887Sandreas.sandberg@arm.com else: 41711887Sandreas.sandberg@arm.com print "Error: cannot find options file %s or %s" \ 41811887Sandreas.sandberg@arm.com % (current_opts_file, default_opts_file) 41911887Sandreas.sandberg@arm.com Exit(1) 42011887Sandreas.sandberg@arm.com 42111887Sandreas.sandberg@arm.com # Apply current option settings to env 42211887Sandreas.sandberg@arm.com sticky_opts.Update(env) 42311476Sandreas.sandberg@arm.com nonsticky_opts.Update(env) 42411476Sandreas.sandberg@arm.com 42511408Sandreas.sandberg@arm.com help_text += "Sticky options for %s:\n" % build_dir \ 42611408Sandreas.sandberg@arm.com + sticky_opts.GenerateHelpText(env) \ 42711408Sandreas.sandberg@arm.com + "\nNon-sticky options for %s:\n" % build_dir \ 42811408Sandreas.sandberg@arm.com + nonsticky_opts.GenerateHelpText(env) 42911408Sandreas.sandberg@arm.com 43011408Sandreas.sandberg@arm.com # Process option settings. 43111408Sandreas.sandberg@arm.com 43211887Sandreas.sandberg@arm.com if not have_fenv and env['USE_FENV']: 43311887Sandreas.sandberg@arm.com print "Warning: <fenv.h> not available; " \ 43411476Sandreas.sandberg@arm.com "forcing USE_FENV to False in", build_dir + "." 43511887Sandreas.sandberg@arm.com env['USE_FENV'] = False 43611887Sandreas.sandberg@arm.com 43711476Sandreas.sandberg@arm.com if not env['USE_FENV']: 43811476Sandreas.sandberg@arm.com print "Warning: No IEEE FP rounding mode control in", build_dir + "." 43911476Sandreas.sandberg@arm.com print " FP results may deviate slightly from other platforms." 44011476Sandreas.sandberg@arm.com 4416121Snate@binkert.org if env['EFENCE']: 442955SN/A env.Append(LIBS=['efence']) 443955SN/A 4442632Sstever@eecs.umich.edu if env['USE_MYSQL']: 4452632Sstever@eecs.umich.edu if not have_mysql: 446955SN/A print "Warning: MySQL not available; " \ 447955SN/A "forcing USE_MYSQL to False in", build_dir + "." 448955SN/A env['USE_MYSQL'] = False 449955SN/A else: 4508878Ssteve.reinhardt@amd.com print "Compiling in", build_dir, "with MySQL support." 451955SN/A env.ParseConfig(mysql_config_libs) 4522632Sstever@eecs.umich.edu env.ParseConfig(mysql_config_include) 4532632Sstever@eecs.umich.edu 4542632Sstever@eecs.umich.edu # Save sticky option settings back to current options file 4552632Sstever@eecs.umich.edu sticky_opts.Save(current_opts_file, env) 4562632Sstever@eecs.umich.edu 4572632Sstever@eecs.umich.edu # Do this after we save setting back, or else we'll tack on an 4582632Sstever@eecs.umich.edu # extra 'qdo' every time we run scons. 4598268Ssteve.reinhardt@amd.com if env['BATCH']: 4608268Ssteve.reinhardt@amd.com env['CC'] = env['BATCH_CMD'] + ' ' + env['CC'] 4618268Ssteve.reinhardt@amd.com env['CXX'] = env['BATCH_CMD'] + ' ' + env['CXX'] 4628268Ssteve.reinhardt@amd.com 4638268Ssteve.reinhardt@amd.com if env['USE_SSE2']: 4648268Ssteve.reinhardt@amd.com env.Append(CCFLAGS='-msse2') 4658268Ssteve.reinhardt@amd.com 4662632Sstever@eecs.umich.edu # The m5/SConscript file sets up the build rules in 'env' according 4672632Sstever@eecs.umich.edu # to the configured options. It returns a list of environments, 4682632Sstever@eecs.umich.edu # one for each variant build (debug, opt, etc.) 4692632Sstever@eecs.umich.edu envList = SConscript('src/SConscript', build_dir = build_path, 4708268Ssteve.reinhardt@amd.com exports = 'env', duplicate = False) 4712632Sstever@eecs.umich.edu 4728268Ssteve.reinhardt@amd.com # Set up the regression tests for each build. 4738268Ssteve.reinhardt@amd.com# for e in envList: 4748268Ssteve.reinhardt@amd.com# SConscript('m5-test/SConscript', 4758268Ssteve.reinhardt@amd.com# build_dir = os.path.join(build_dir, 'test', e.Label), 4763718Sstever@eecs.umich.edu# exports = { 'env' : e }, duplicate = False) 4772634Sstever@eecs.umich.edu 4782634Sstever@eecs.umich.eduHelp(help_text) 4795863Snate@binkert.org 4802638Sstever@eecs.umich.edu################################################### 4818268Ssteve.reinhardt@amd.com# 4822632Sstever@eecs.umich.edu# Let SCons do its thing. At this point SCons will use the defined 4832632Sstever@eecs.umich.edu# build environments to build the requested targets. 4842632Sstever@eecs.umich.edu# 4852632Sstever@eecs.umich.edu################################################### 4862632Sstever@eecs.umich.edu 4871858SN/A