1# -*- mode:python -*- 2 3# Copyright (c) 2004-2005 The Regents of The University of Michigan 4# All rights reserved. 5# 6# Redistribution and use in source and binary forms, with or without 7# modification, are permitted provided that the following conditions are 8# met: redistributions of source code must retain the above copyright 9# notice, this list of conditions and the following disclaimer; 10# redistributions in binary form must reproduce the above copyright 11# notice, this list of conditions and the following disclaimer in the 12# documentation and/or other materials provided with the distribution; 13# neither the name of the copyright holders nor the names of its 14# contributors may be used to endorse or promote products derived from 15# this software without specific prior written permission. 16# 17# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28# 29# Authors: Steve Reinhardt 30 31################################################### 32# 33# SCons top-level build description (SConstruct) file. 34# 35# While in this directory ('m5'), just type 'scons' to build the default 36# configuration (see below), or type 'scons build/<CONFIG>/<binary>' 37# to build some other configuration (e.g., 'build/ALPHA_FS/m5.opt' for 38# the optimized full-system version). 39# 40# You can build M5 in a different directory as long as there is a 41# 'build/<CONFIG>' somewhere along the target path. The build system
| 1# -*- mode:python -*- 2 3# Copyright (c) 2004-2005 The Regents of The University of Michigan 4# All rights reserved. 5# 6# Redistribution and use in source and binary forms, with or without 7# modification, are permitted provided that the following conditions are 8# met: redistributions of source code must retain the above copyright 9# notice, this list of conditions and the following disclaimer; 10# redistributions in binary form must reproduce the above copyright 11# notice, this list of conditions and the following disclaimer in the 12# documentation and/or other materials provided with the distribution; 13# neither the name of the copyright holders nor the names of its 14# contributors may be used to endorse or promote products derived from 15# this software without specific prior written permission. 16# 17# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28# 29# Authors: Steve Reinhardt 30 31################################################### 32# 33# SCons top-level build description (SConstruct) file. 34# 35# While in this directory ('m5'), just type 'scons' to build the default 36# configuration (see below), or type 'scons build/<CONFIG>/<binary>' 37# to build some other configuration (e.g., 'build/ALPHA_FS/m5.opt' for 38# the optimized full-system version). 39# 40# You can build M5 in a different directory as long as there is a 41# 'build/<CONFIG>' somewhere along the target path. The build system
|
42# expdects that all configs under the same build directory are being
| 42# expects that all configs under the same build directory are being
|
43# built for the same host system. 44# 45# Examples:
| 43# built for the same host system. 44# 45# Examples:
|
46# These two commands are equivalent. The '-u' option tells scons to 47# search up the directory tree for this SConstruct file.
| 46# 47# The following two commands are equivalent. The '-u' option tells 48# scons to search up the directory tree for this SConstruct file.
|
48# % cd <path-to-src>/m5 ; scons build/ALPHA_FS/m5.debug 49# % cd <path-to-src>/m5/build/ALPHA_FS; scons -u m5.debug
| 49# % cd <path-to-src>/m5 ; scons build/ALPHA_FS/m5.debug 50# % cd <path-to-src>/m5/build/ALPHA_FS; scons -u m5.debug
|
50# These two commands are equivalent and demonstrate building in a 51# directory outside of the source tree. The '-C' option tells scons 52# to chdir to the specified directory to find this SConstruct file.
| 51# 52# The following two commands are equivalent and demonstrate building 53# in a directory outside of the source tree. The '-C' option tells 54# scons to chdir to the specified directory to find this SConstruct 55# file.
|
53# % cd <path-to-src>/m5 ; scons /local/foo/build/ALPHA_FS/m5.debug 54# % cd /local/foo/build/ALPHA_FS; scons -C <path-to-src>/m5 m5.debug 55# 56# You can use 'scons -H' to print scons options. If you're in this 57# 'm5' directory (or use -u or -C to tell scons where to find this 58# file), you can use 'scons -h' to print all the M5-specific build 59# options as well. 60# 61################################################### 62 63# Python library imports 64import sys 65import os 66 67# Check for recent-enough Python and SCons versions. If your system's 68# default installation of Python is not recent enough, you can use a 69# non-default installation of the Python interpreter by either (1) 70# rearranging your PATH so that scons finds the non-default 'python' 71# first or (2) explicitly invoking an alternative interpreter on the 72# scons script, e.g., "/usr/local/bin/python2.4 `which scons` [args]". 73EnsurePythonVersion(2,4) 74 75# Ironically, SCons 0.96 dies if you give EnsureSconsVersion a 76# 3-element version number. 77min_scons_version = (0,96,91) 78try: 79 EnsureSConsVersion(*min_scons_version) 80except: 81 print "Error checking current SCons version." 82 print "SCons", ".".join(map(str,min_scons_version)), "or greater required." 83 Exit(2) 84 85 86# The absolute path to the current directory (where this file lives). 87ROOT = Dir('.').abspath 88 89# Paths to the M5 and external source trees. 90SRCDIR = os.path.join(ROOT, 'src') 91 92# tell python where to find m5 python code 93sys.path.append(os.path.join(ROOT, 'src/python')) 94 95################################################### 96# 97# Figure out which configurations to set up based on the path(s) of 98# the target(s). 99# 100################################################### 101 102# Find default configuration & binary. 103Default(os.environ.get('M5_DEFAULT_BINARY', 'build/ALPHA_SE/m5.debug')) 104 105# Ask SCons which directory it was invoked from. 106launch_dir = GetLaunchDir() 107 108# Make targets relative to invocation directory 109abs_targets = map(lambda x: os.path.normpath(os.path.join(launch_dir, str(x))), 110 BUILD_TARGETS) 111 112# helper function: find last occurrence of element in list 113def rfind(l, elt, offs = -1): 114 for i in range(len(l)+offs, 0, -1): 115 if l[i] == elt: 116 return i 117 raise ValueError, "element not found" 118 119# Each target must have 'build' in the interior of the path; the 120# directory below this will determine the build parameters. For 121# example, for target 'foo/bar/build/ALPHA_SE/arch/alpha/blah.do' we 122# recognize that ALPHA_SE specifies the configuration because it 123# follow 'build' in the bulid path. 124 125# Generate a list of the unique build roots and configs that the 126# collected targets reference. 127build_paths = [] 128build_root = None 129for t in abs_targets: 130 path_dirs = t.split('/') 131 try: 132 build_top = rfind(path_dirs, 'build', -2) 133 except: 134 print "Error: no non-leaf 'build' dir found on target path", t 135 Exit(1) 136 this_build_root = os.path.join('/',*path_dirs[:build_top+1]) 137 if not build_root: 138 build_root = this_build_root 139 else: 140 if this_build_root != build_root: 141 print "Error: build targets not under same build root\n"\ 142 " %s\n %s" % (build_root, this_build_root) 143 Exit(1) 144 build_path = os.path.join('/',*path_dirs[:build_top+2]) 145 if build_path not in build_paths: 146 build_paths.append(build_path) 147 148################################################### 149# 150# Set up the default build environment. This environment is copied 151# and modified according to each selected configuration. 152# 153################################################### 154 155env = Environment(ENV = os.environ, # inherit user's environment vars 156 ROOT = ROOT, 157 SRCDIR = SRCDIR) 158
| 56# % cd <path-to-src>/m5 ; scons /local/foo/build/ALPHA_FS/m5.debug 57# % cd /local/foo/build/ALPHA_FS; scons -C <path-to-src>/m5 m5.debug 58# 59# You can use 'scons -H' to print scons options. If you're in this 60# 'm5' directory (or use -u or -C to tell scons where to find this 61# file), you can use 'scons -h' to print all the M5-specific build 62# options as well. 63# 64################################################### 65 66# Python library imports 67import sys 68import os 69 70# Check for recent-enough Python and SCons versions. If your system's 71# default installation of Python is not recent enough, you can use a 72# non-default installation of the Python interpreter by either (1) 73# rearranging your PATH so that scons finds the non-default 'python' 74# first or (2) explicitly invoking an alternative interpreter on the 75# scons script, e.g., "/usr/local/bin/python2.4 `which scons` [args]". 76EnsurePythonVersion(2,4) 77 78# Ironically, SCons 0.96 dies if you give EnsureSconsVersion a 79# 3-element version number. 80min_scons_version = (0,96,91) 81try: 82 EnsureSConsVersion(*min_scons_version) 83except: 84 print "Error checking current SCons version." 85 print "SCons", ".".join(map(str,min_scons_version)), "or greater required." 86 Exit(2) 87 88 89# The absolute path to the current directory (where this file lives). 90ROOT = Dir('.').abspath 91 92# Paths to the M5 and external source trees. 93SRCDIR = os.path.join(ROOT, 'src') 94 95# tell python where to find m5 python code 96sys.path.append(os.path.join(ROOT, 'src/python')) 97 98################################################### 99# 100# Figure out which configurations to set up based on the path(s) of 101# the target(s). 102# 103################################################### 104 105# Find default configuration & binary. 106Default(os.environ.get('M5_DEFAULT_BINARY', 'build/ALPHA_SE/m5.debug')) 107 108# Ask SCons which directory it was invoked from. 109launch_dir = GetLaunchDir() 110 111# Make targets relative to invocation directory 112abs_targets = map(lambda x: os.path.normpath(os.path.join(launch_dir, str(x))), 113 BUILD_TARGETS) 114 115# helper function: find last occurrence of element in list 116def rfind(l, elt, offs = -1): 117 for i in range(len(l)+offs, 0, -1): 118 if l[i] == elt: 119 return i 120 raise ValueError, "element not found" 121 122# Each target must have 'build' in the interior of the path; the 123# directory below this will determine the build parameters. For 124# example, for target 'foo/bar/build/ALPHA_SE/arch/alpha/blah.do' we 125# recognize that ALPHA_SE specifies the configuration because it 126# follow 'build' in the bulid path. 127 128# Generate a list of the unique build roots and configs that the 129# collected targets reference. 130build_paths = [] 131build_root = None 132for t in abs_targets: 133 path_dirs = t.split('/') 134 try: 135 build_top = rfind(path_dirs, 'build', -2) 136 except: 137 print "Error: no non-leaf 'build' dir found on target path", t 138 Exit(1) 139 this_build_root = os.path.join('/',*path_dirs[:build_top+1]) 140 if not build_root: 141 build_root = this_build_root 142 else: 143 if this_build_root != build_root: 144 print "Error: build targets not under same build root\n"\ 145 " %s\n %s" % (build_root, this_build_root) 146 Exit(1) 147 build_path = os.path.join('/',*path_dirs[:build_top+2]) 148 if build_path not in build_paths: 149 build_paths.append(build_path) 150 151################################################### 152# 153# Set up the default build environment. This environment is copied 154# and modified according to each selected configuration. 155# 156################################################### 157 158env = Environment(ENV = os.environ, # inherit user's environment vars 159 ROOT = ROOT, 160 SRCDIR = SRCDIR) 161
|
159env.SConsignFile("sconsign")
| 162env.SConsignFile(os.path.join(build_root,"sconsign"))
|
160 161# Default duplicate option is to use hard links, but this messes up 162# when you use emacs to edit a file in the target dir, as emacs moves 163# file to file~ then copies to file, breaking the link. Symbolic 164# (soft) links work better. 165env.SetOption('duplicate', 'soft-copy') 166 167# I waffle on this setting... it does avoid a few painful but 168# unnecessary builds, but it also seems to make trivial builds take 169# noticeably longer. 170if False: 171 env.TargetSignatures('content') 172 173# M5_PLY is used by isa_parser.py to find the PLY package. 174env.Append(ENV = { 'M5_PLY' : Dir('ext/ply') }) 175 176# Set up default C++ compiler flags 177env.Append(CCFLAGS='-pipe') 178env.Append(CCFLAGS='-fno-strict-aliasing') 179env.Append(CCFLAGS=Split('-Wall -Wno-sign-compare -Werror -Wundef')) 180if sys.platform == 'cygwin': 181 # cygwin has some header file issues... 182 env.Append(CCFLAGS=Split("-Wno-uninitialized")) 183env.Append(CPPPATH=[Dir('ext/dnet')]) 184 185# Find Python include and library directories for embedding the 186# interpreter. For consistency, we will use the same Python 187# installation used to run scons (and thus this script). If you want 188# to link in an alternate version, see above for instructions on how 189# to invoke scons with a different copy of the Python interpreter. 190 191# Get brief Python version name (e.g., "python2.4") for locating 192# include & library files 193py_version_name = 'python' + sys.version[:3] 194 195# include path, e.g. /usr/local/include/python2.4 196env.Append(CPPPATH = os.path.join(sys.exec_prefix, 'include', py_version_name)) 197env.Append(LIBS = py_version_name) 198# add library path too if it's not in the default place 199if sys.exec_prefix != '/usr': 200 env.Append(LIBPATH = os.path.join(sys.exec_prefix, 'lib')) 201 202# Set up SWIG flags & scanner 203 204env.Append(SWIGFLAGS=Split('-c++ -python -modern $_CPPINCFLAGS')) 205 206import SCons.Scanner 207 208swig_inc_re = '^[ \t]*[%,#][ \t]*(?:include|import)[ \t]*(<|")([^>"]+)(>|")' 209 210swig_scanner = SCons.Scanner.ClassicCPP("SwigScan", ".i", "CPPPATH", 211 swig_inc_re) 212 213env.Append(SCANNERS = swig_scanner) 214 215# Other default libraries 216env.Append(LIBS=['z']) 217 218# Platform-specific configuration. Note again that we assume that all 219# builds under a given build root run on the same host platform. 220conf = Configure(env, 221 conf_dir = os.path.join(build_root, '.scons_config'), 222 log_file = os.path.join(build_root, 'scons_config.log')) 223 224# Check for <fenv.h> (C99 FP environment control) 225have_fenv = conf.CheckHeader('fenv.h', '<>') 226if not have_fenv: 227 print "Warning: Header file <fenv.h> not found." 228 print " This host has no IEEE FP rounding mode control." 229 230# Check for mysql. 231mysql_config = WhereIs('mysql_config') 232have_mysql = mysql_config != None 233 234# Check MySQL version. 235if have_mysql: 236 mysql_version = os.popen(mysql_config + ' --version').read() 237 mysql_version = mysql_version.split('.') 238 mysql_major = int(mysql_version[0]) 239 mysql_minor = int(mysql_version[1]) 240 # This version check is probably overly conservative, but it deals 241 # with the versions we have installed. 242 if mysql_major < 4 or (mysql_major == 4 and mysql_minor < 1): 243 print "Warning: MySQL v4.1 or newer required." 244 have_mysql = False 245 246# Set up mysql_config commands. 247if have_mysql: 248 mysql_config_include = mysql_config + ' --include' 249 if os.system(mysql_config_include + ' > /dev/null') != 0: 250 # older mysql_config versions don't support --include, use 251 # --cflags instead 252 mysql_config_include = mysql_config + ' --cflags | sed s/\\\'//g' 253 # This seems to work in all versions 254 mysql_config_libs = mysql_config + ' --libs' 255 256env = conf.Finish() 257 258# Define the universe of supported ISAs 259env['ALL_ISA_LIST'] = ['alpha', 'sparc', 'mips'] 260 261# Define the universe of supported CPU models 262env['ALL_CPU_LIST'] = ['AtomicSimpleCPU', 'TimingSimpleCPU', 263 'FullCPU', 'AlphaO3CPU', 264 'OzoneSimpleCPU', 'OzoneCPU'] 265 266# Sticky options get saved in the options file so they persist from 267# one invocation to the next (unless overridden, in which case the new 268# value becomes sticky). 269sticky_opts = Options(args=ARGUMENTS) 270sticky_opts.AddOptions( 271 EnumOption('TARGET_ISA', 'Target ISA', 'alpha', env['ALL_ISA_LIST']), 272 BoolOption('FULL_SYSTEM', 'Full-system support', False), 273 # There's a bug in scons 0.96.1 that causes ListOptions with list 274 # values (more than one value) not to be able to be restored from 275 # a saved option file. If this causes trouble then upgrade to 276 # scons 0.96.90 or later. 277 ListOption('CPU_MODELS', 'CPU models', 'AtomicSimpleCPU,TimingSimpleCPU', 278 env['ALL_CPU_LIST']), 279 BoolOption('ALPHA_TLASER', 280 'Model Alpha TurboLaser platform (vs. Tsunami)', False), 281 BoolOption('NO_FAST_ALLOC', 'Disable fast object allocator', False), 282 BoolOption('EFENCE', 'Link with Electric Fence malloc debugger', 283 False), 284 BoolOption('SS_COMPATIBLE_FP', 285 'Make floating-point results compatible with SimpleScalar', 286 False), 287 BoolOption('USE_SSE2', 288 'Compile for SSE2 (-msse2) to get IEEE FP on x86 hosts', 289 False), 290 BoolOption('USE_MYSQL', 'Use MySQL for stats output', have_mysql), 291 BoolOption('USE_FENV', 'Use <fenv.h> IEEE mode control', have_fenv), 292 BoolOption('USE_CHECKER', 'Use checker for detailed CPU models', False), 293 ('CC', 'C compiler', os.environ.get('CC', env['CC'])), 294 ('CXX', 'C++ compiler', os.environ.get('CXX', env['CXX'])), 295 BoolOption('BATCH', 'Use batch pool for build and tests', False), 296 ('BATCH_CMD', 'Batch pool submission command name', 'qdo') 297 ) 298 299# Non-sticky options only apply to the current build. 300nonsticky_opts = Options(args=ARGUMENTS) 301nonsticky_opts.AddOptions( 302 BoolOption('update_ref', 'Update test reference outputs', False) 303 ) 304
| 163 164# Default duplicate option is to use hard links, but this messes up 165# when you use emacs to edit a file in the target dir, as emacs moves 166# file to file~ then copies to file, breaking the link. Symbolic 167# (soft) links work better. 168env.SetOption('duplicate', 'soft-copy') 169 170# I waffle on this setting... it does avoid a few painful but 171# unnecessary builds, but it also seems to make trivial builds take 172# noticeably longer. 173if False: 174 env.TargetSignatures('content') 175 176# M5_PLY is used by isa_parser.py to find the PLY package. 177env.Append(ENV = { 'M5_PLY' : Dir('ext/ply') }) 178 179# Set up default C++ compiler flags 180env.Append(CCFLAGS='-pipe') 181env.Append(CCFLAGS='-fno-strict-aliasing') 182env.Append(CCFLAGS=Split('-Wall -Wno-sign-compare -Werror -Wundef')) 183if sys.platform == 'cygwin': 184 # cygwin has some header file issues... 185 env.Append(CCFLAGS=Split("-Wno-uninitialized")) 186env.Append(CPPPATH=[Dir('ext/dnet')]) 187 188# Find Python include and library directories for embedding the 189# interpreter. For consistency, we will use the same Python 190# installation used to run scons (and thus this script). If you want 191# to link in an alternate version, see above for instructions on how 192# to invoke scons with a different copy of the Python interpreter. 193 194# Get brief Python version name (e.g., "python2.4") for locating 195# include & library files 196py_version_name = 'python' + sys.version[:3] 197 198# include path, e.g. /usr/local/include/python2.4 199env.Append(CPPPATH = os.path.join(sys.exec_prefix, 'include', py_version_name)) 200env.Append(LIBS = py_version_name) 201# add library path too if it's not in the default place 202if sys.exec_prefix != '/usr': 203 env.Append(LIBPATH = os.path.join(sys.exec_prefix, 'lib')) 204 205# Set up SWIG flags & scanner 206 207env.Append(SWIGFLAGS=Split('-c++ -python -modern $_CPPINCFLAGS')) 208 209import SCons.Scanner 210 211swig_inc_re = '^[ \t]*[%,#][ \t]*(?:include|import)[ \t]*(<|")([^>"]+)(>|")' 212 213swig_scanner = SCons.Scanner.ClassicCPP("SwigScan", ".i", "CPPPATH", 214 swig_inc_re) 215 216env.Append(SCANNERS = swig_scanner) 217 218# Other default libraries 219env.Append(LIBS=['z']) 220 221# Platform-specific configuration. Note again that we assume that all 222# builds under a given build root run on the same host platform. 223conf = Configure(env, 224 conf_dir = os.path.join(build_root, '.scons_config'), 225 log_file = os.path.join(build_root, 'scons_config.log')) 226 227# Check for <fenv.h> (C99 FP environment control) 228have_fenv = conf.CheckHeader('fenv.h', '<>') 229if not have_fenv: 230 print "Warning: Header file <fenv.h> not found." 231 print " This host has no IEEE FP rounding mode control." 232 233# Check for mysql. 234mysql_config = WhereIs('mysql_config') 235have_mysql = mysql_config != None 236 237# Check MySQL version. 238if have_mysql: 239 mysql_version = os.popen(mysql_config + ' --version').read() 240 mysql_version = mysql_version.split('.') 241 mysql_major = int(mysql_version[0]) 242 mysql_minor = int(mysql_version[1]) 243 # This version check is probably overly conservative, but it deals 244 # with the versions we have installed. 245 if mysql_major < 4 or (mysql_major == 4 and mysql_minor < 1): 246 print "Warning: MySQL v4.1 or newer required." 247 have_mysql = False 248 249# Set up mysql_config commands. 250if have_mysql: 251 mysql_config_include = mysql_config + ' --include' 252 if os.system(mysql_config_include + ' > /dev/null') != 0: 253 # older mysql_config versions don't support --include, use 254 # --cflags instead 255 mysql_config_include = mysql_config + ' --cflags | sed s/\\\'//g' 256 # This seems to work in all versions 257 mysql_config_libs = mysql_config + ' --libs' 258 259env = conf.Finish() 260 261# Define the universe of supported ISAs 262env['ALL_ISA_LIST'] = ['alpha', 'sparc', 'mips'] 263 264# Define the universe of supported CPU models 265env['ALL_CPU_LIST'] = ['AtomicSimpleCPU', 'TimingSimpleCPU', 266 'FullCPU', 'AlphaO3CPU', 267 'OzoneSimpleCPU', 'OzoneCPU'] 268 269# Sticky options get saved in the options file so they persist from 270# one invocation to the next (unless overridden, in which case the new 271# value becomes sticky). 272sticky_opts = Options(args=ARGUMENTS) 273sticky_opts.AddOptions( 274 EnumOption('TARGET_ISA', 'Target ISA', 'alpha', env['ALL_ISA_LIST']), 275 BoolOption('FULL_SYSTEM', 'Full-system support', False), 276 # There's a bug in scons 0.96.1 that causes ListOptions with list 277 # values (more than one value) not to be able to be restored from 278 # a saved option file. If this causes trouble then upgrade to 279 # scons 0.96.90 or later. 280 ListOption('CPU_MODELS', 'CPU models', 'AtomicSimpleCPU,TimingSimpleCPU', 281 env['ALL_CPU_LIST']), 282 BoolOption('ALPHA_TLASER', 283 'Model Alpha TurboLaser platform (vs. Tsunami)', False), 284 BoolOption('NO_FAST_ALLOC', 'Disable fast object allocator', False), 285 BoolOption('EFENCE', 'Link with Electric Fence malloc debugger', 286 False), 287 BoolOption('SS_COMPATIBLE_FP', 288 'Make floating-point results compatible with SimpleScalar', 289 False), 290 BoolOption('USE_SSE2', 291 'Compile for SSE2 (-msse2) to get IEEE FP on x86 hosts', 292 False), 293 BoolOption('USE_MYSQL', 'Use MySQL for stats output', have_mysql), 294 BoolOption('USE_FENV', 'Use <fenv.h> IEEE mode control', have_fenv), 295 BoolOption('USE_CHECKER', 'Use checker for detailed CPU models', False), 296 ('CC', 'C compiler', os.environ.get('CC', env['CC'])), 297 ('CXX', 'C++ compiler', os.environ.get('CXX', env['CXX'])), 298 BoolOption('BATCH', 'Use batch pool for build and tests', False), 299 ('BATCH_CMD', 'Batch pool submission command name', 'qdo') 300 ) 301 302# Non-sticky options only apply to the current build. 303nonsticky_opts = Options(args=ARGUMENTS) 304nonsticky_opts.AddOptions( 305 BoolOption('update_ref', 'Update test reference outputs', False) 306 ) 307
|
305# These options get exported to #defines in config/*.hh (see m5/SConscript).
| 308# These options get exported to #defines in config/*.hh (see src/SConscript).
|
306env.ExportOptions = ['FULL_SYSTEM', 'ALPHA_TLASER', 'USE_FENV', \ 307 'USE_MYSQL', 'NO_FAST_ALLOC', 'SS_COMPATIBLE_FP', \ 308 'USE_CHECKER'] 309 310# Define a handy 'no-op' action 311def no_action(target, source, env): 312 return 0 313 314env.NoAction = Action(no_action, None) 315 316################################################### 317# 318# Define a SCons builder for configuration flag headers. 319# 320################################################### 321 322# This function generates a config header file that #defines the 323# option symbol to the current option setting (0 or 1). The source 324# operands are the name of the option and a Value node containing the 325# value of the option. 326def build_config_file(target, source, env): 327 (option, value) = [s.get_contents() for s in source] 328 f = file(str(target[0]), 'w') 329 print >> f, '#define', option, value 330 f.close() 331 return None 332 333# Generate the message to be printed when building the config file. 334def build_config_file_string(target, source, env): 335 (option, value) = [s.get_contents() for s in source] 336 return "Defining %s as %s in %s." % (option, value, target[0]) 337 338# Combine the two functions into a scons Action object. 339config_action = Action(build_config_file, build_config_file_string) 340 341# The emitter munges the source & target node lists to reflect what 342# we're really doing. 343def config_emitter(target, source, env): 344 # extract option name from Builder arg 345 option = str(target[0]) 346 # True target is config header file 347 target = os.path.join('config', option.lower() + '.hh') 348 # Force value to 0/1 even if it's a Python bool 349 val = int(eval(str(env[option]))) 350 # Sources are option name & value (packaged in SCons Value nodes) 351 return ([target], [Value(option), Value(val)]) 352 353config_builder = Builder(emitter = config_emitter, action = config_action) 354 355env.Append(BUILDERS = { 'ConfigFile' : config_builder }) 356 357################################################### 358# 359# Define a SCons builder for copying files. This is used by the 360# Python zipfile code in src/python/SConscript, but is placed up here 361# since it's potentially more generally applicable. 362# 363################################################### 364 365copy_builder = Builder(action = Copy("$TARGET", "$SOURCE")) 366 367env.Append(BUILDERS = { 'CopyFile' : copy_builder }) 368 369################################################### 370# 371# Define a simple SCons builder to concatenate files. 372# 373# Used to append the Python zip archive to the executable. 374# 375################################################### 376 377concat_builder = Builder(action = Action(['cat $SOURCES > $TARGET', 378 'chmod +x $TARGET'])) 379 380env.Append(BUILDERS = { 'Concat' : concat_builder }) 381 382 383# base help text 384help_text = ''' 385Usage: scons [scons options] [build options] [target(s)] 386 387''' 388 389# libelf build is shared across all configs in the build root. 390env.SConscript('ext/libelf/SConscript', 391 build_dir = os.path.join(build_root, 'libelf'), 392 exports = 'env') 393 394################################################### 395# 396# Define build environments for selected configurations. 397# 398################################################### 399 400# rename base env 401base_env = env 402 403for build_path in build_paths: 404 print "Building in", build_path 405 # build_dir is the tail component of build path, and is used to 406 # determine the build parameters (e.g., 'ALPHA_SE') 407 (build_root, build_dir) = os.path.split(build_path) 408 # Make a copy of the build-root environment to use for this config. 409 env = base_env.Copy() 410 411 # Set env options according to the build directory config. 412 sticky_opts.files = [] 413 # Options for $BUILD_ROOT/$BUILD_DIR are stored in 414 # $BUILD_ROOT/options/$BUILD_DIR so you can nuke 415 # $BUILD_ROOT/$BUILD_DIR without losing your options settings. 416 current_opts_file = os.path.join(build_root, 'options', build_dir) 417 if os.path.isfile(current_opts_file): 418 sticky_opts.files.append(current_opts_file) 419 print "Using saved options file %s" % current_opts_file 420 else: 421 # Build dir-specific options file doesn't exist. 422 423 # Make sure the directory is there so we can create it later 424 opt_dir = os.path.dirname(current_opts_file) 425 if not os.path.isdir(opt_dir): 426 os.mkdir(opt_dir) 427 428 # Get default build options from source tree. Options are 429 # normally determined by name of $BUILD_DIR, but can be 430 # overriden by 'default=' arg on command line. 431 default_opts_file = os.path.join('build_opts', 432 ARGUMENTS.get('default', build_dir)) 433 if os.path.isfile(default_opts_file): 434 sticky_opts.files.append(default_opts_file) 435 print "Options file %s not found,\n using defaults in %s" \ 436 % (current_opts_file, default_opts_file) 437 else: 438 print "Error: cannot find options file %s or %s" \ 439 % (current_opts_file, default_opts_file) 440 Exit(1) 441 442 # Apply current option settings to env 443 sticky_opts.Update(env) 444 nonsticky_opts.Update(env) 445 446 help_text += "Sticky options for %s:\n" % build_dir \ 447 + sticky_opts.GenerateHelpText(env) \ 448 + "\nNon-sticky options for %s:\n" % build_dir \ 449 + nonsticky_opts.GenerateHelpText(env) 450 451 # Process option settings. 452 453 if not have_fenv and env['USE_FENV']: 454 print "Warning: <fenv.h> not available; " \ 455 "forcing USE_FENV to False in", build_dir + "." 456 env['USE_FENV'] = False 457 458 if not env['USE_FENV']: 459 print "Warning: No IEEE FP rounding mode control in", build_dir + "." 460 print " FP results may deviate slightly from other platforms." 461 462 if env['EFENCE']: 463 env.Append(LIBS=['efence']) 464 465 if env['USE_MYSQL']: 466 if not have_mysql: 467 print "Warning: MySQL not available; " \ 468 "forcing USE_MYSQL to False in", build_dir + "." 469 env['USE_MYSQL'] = False 470 else: 471 print "Compiling in", build_dir, "with MySQL support." 472 env.ParseConfig(mysql_config_libs) 473 env.ParseConfig(mysql_config_include) 474
| 309env.ExportOptions = ['FULL_SYSTEM', 'ALPHA_TLASER', 'USE_FENV', \ 310 'USE_MYSQL', 'NO_FAST_ALLOC', 'SS_COMPATIBLE_FP', \ 311 'USE_CHECKER'] 312 313# Define a handy 'no-op' action 314def no_action(target, source, env): 315 return 0 316 317env.NoAction = Action(no_action, None) 318 319################################################### 320# 321# Define a SCons builder for configuration flag headers. 322# 323################################################### 324 325# This function generates a config header file that #defines the 326# option symbol to the current option setting (0 or 1). The source 327# operands are the name of the option and a Value node containing the 328# value of the option. 329def build_config_file(target, source, env): 330 (option, value) = [s.get_contents() for s in source] 331 f = file(str(target[0]), 'w') 332 print >> f, '#define', option, value 333 f.close() 334 return None 335 336# Generate the message to be printed when building the config file. 337def build_config_file_string(target, source, env): 338 (option, value) = [s.get_contents() for s in source] 339 return "Defining %s as %s in %s." % (option, value, target[0]) 340 341# Combine the two functions into a scons Action object. 342config_action = Action(build_config_file, build_config_file_string) 343 344# The emitter munges the source & target node lists to reflect what 345# we're really doing. 346def config_emitter(target, source, env): 347 # extract option name from Builder arg 348 option = str(target[0]) 349 # True target is config header file 350 target = os.path.join('config', option.lower() + '.hh') 351 # Force value to 0/1 even if it's a Python bool 352 val = int(eval(str(env[option]))) 353 # Sources are option name & value (packaged in SCons Value nodes) 354 return ([target], [Value(option), Value(val)]) 355 356config_builder = Builder(emitter = config_emitter, action = config_action) 357 358env.Append(BUILDERS = { 'ConfigFile' : config_builder }) 359 360################################################### 361# 362# Define a SCons builder for copying files. This is used by the 363# Python zipfile code in src/python/SConscript, but is placed up here 364# since it's potentially more generally applicable. 365# 366################################################### 367 368copy_builder = Builder(action = Copy("$TARGET", "$SOURCE")) 369 370env.Append(BUILDERS = { 'CopyFile' : copy_builder }) 371 372################################################### 373# 374# Define a simple SCons builder to concatenate files. 375# 376# Used to append the Python zip archive to the executable. 377# 378################################################### 379 380concat_builder = Builder(action = Action(['cat $SOURCES > $TARGET', 381 'chmod +x $TARGET'])) 382 383env.Append(BUILDERS = { 'Concat' : concat_builder }) 384 385 386# base help text 387help_text = ''' 388Usage: scons [scons options] [build options] [target(s)] 389 390''' 391 392# libelf build is shared across all configs in the build root. 393env.SConscript('ext/libelf/SConscript', 394 build_dir = os.path.join(build_root, 'libelf'), 395 exports = 'env') 396 397################################################### 398# 399# Define build environments for selected configurations. 400# 401################################################### 402 403# rename base env 404base_env = env 405 406for build_path in build_paths: 407 print "Building in", build_path 408 # build_dir is the tail component of build path, and is used to 409 # determine the build parameters (e.g., 'ALPHA_SE') 410 (build_root, build_dir) = os.path.split(build_path) 411 # Make a copy of the build-root environment to use for this config. 412 env = base_env.Copy() 413 414 # Set env options according to the build directory config. 415 sticky_opts.files = [] 416 # Options for $BUILD_ROOT/$BUILD_DIR are stored in 417 # $BUILD_ROOT/options/$BUILD_DIR so you can nuke 418 # $BUILD_ROOT/$BUILD_DIR without losing your options settings. 419 current_opts_file = os.path.join(build_root, 'options', build_dir) 420 if os.path.isfile(current_opts_file): 421 sticky_opts.files.append(current_opts_file) 422 print "Using saved options file %s" % current_opts_file 423 else: 424 # Build dir-specific options file doesn't exist. 425 426 # Make sure the directory is there so we can create it later 427 opt_dir = os.path.dirname(current_opts_file) 428 if not os.path.isdir(opt_dir): 429 os.mkdir(opt_dir) 430 431 # Get default build options from source tree. Options are 432 # normally determined by name of $BUILD_DIR, but can be 433 # overriden by 'default=' arg on command line. 434 default_opts_file = os.path.join('build_opts', 435 ARGUMENTS.get('default', build_dir)) 436 if os.path.isfile(default_opts_file): 437 sticky_opts.files.append(default_opts_file) 438 print "Options file %s not found,\n using defaults in %s" \ 439 % (current_opts_file, default_opts_file) 440 else: 441 print "Error: cannot find options file %s or %s" \ 442 % (current_opts_file, default_opts_file) 443 Exit(1) 444 445 # Apply current option settings to env 446 sticky_opts.Update(env) 447 nonsticky_opts.Update(env) 448 449 help_text += "Sticky options for %s:\n" % build_dir \ 450 + sticky_opts.GenerateHelpText(env) \ 451 + "\nNon-sticky options for %s:\n" % build_dir \ 452 + nonsticky_opts.GenerateHelpText(env) 453 454 # Process option settings. 455 456 if not have_fenv and env['USE_FENV']: 457 print "Warning: <fenv.h> not available; " \ 458 "forcing USE_FENV to False in", build_dir + "." 459 env['USE_FENV'] = False 460 461 if not env['USE_FENV']: 462 print "Warning: No IEEE FP rounding mode control in", build_dir + "." 463 print " FP results may deviate slightly from other platforms." 464 465 if env['EFENCE']: 466 env.Append(LIBS=['efence']) 467 468 if env['USE_MYSQL']: 469 if not have_mysql: 470 print "Warning: MySQL not available; " \ 471 "forcing USE_MYSQL to False in", build_dir + "." 472 env['USE_MYSQL'] = False 473 else: 474 print "Compiling in", build_dir, "with MySQL support." 475 env.ParseConfig(mysql_config_libs) 476 env.ParseConfig(mysql_config_include) 477
|
| 478 # Check if the Checker is being used. If so append it to env['CPU_MODELS'] 479 if env['USE_CHECKER']: 480 env['CPU_MODELS'].append('CheckerCPU') 481
|
475 # Save sticky option settings back to current options file 476 sticky_opts.Save(current_opts_file, env) 477 478 # Do this after we save setting back, or else we'll tack on an 479 # extra 'qdo' every time we run scons. 480 if env['BATCH']: 481 env['CC'] = env['BATCH_CMD'] + ' ' + env['CC'] 482 env['CXX'] = env['BATCH_CMD'] + ' ' + env['CXX'] 483 484 if env['USE_SSE2']: 485 env.Append(CCFLAGS='-msse2') 486
| 482 # Save sticky option settings back to current options file 483 sticky_opts.Save(current_opts_file, env) 484 485 # Do this after we save setting back, or else we'll tack on an 486 # extra 'qdo' every time we run scons. 487 if env['BATCH']: 488 env['CC'] = env['BATCH_CMD'] + ' ' + env['CC'] 489 env['CXX'] = env['BATCH_CMD'] + ' ' + env['CXX'] 490 491 if env['USE_SSE2']: 492 env.Append(CCFLAGS='-msse2') 493
|
487 # The m5/SConscript file sets up the build rules in 'env' according
| 494 # The src/SConscript file sets up the build rules in 'env' according
|
488 # to the configured options. It returns a list of environments, 489 # one for each variant build (debug, opt, etc.) 490 envList = SConscript('src/SConscript', build_dir = build_path, 491 exports = 'env') 492 493 # Set up the regression tests for each build. 494# for e in envList: 495# SConscript('m5-test/SConscript', 496# build_dir = os.path.join(build_dir, 'test', e.Label), 497# exports = { 'env' : e }, duplicate = False) 498 499Help(help_text) 500 501################################################### 502# 503# Let SCons do its thing. At this point SCons will use the defined 504# build environments to build the requested targets. 505# 506################################################### 507
| 495 # to the configured options. It returns a list of environments, 496 # one for each variant build (debug, opt, etc.) 497 envList = SConscript('src/SConscript', build_dir = build_path, 498 exports = 'env') 499 500 # Set up the regression tests for each build. 501# for e in envList: 502# SConscript('m5-test/SConscript', 503# build_dir = os.path.join(build_dir, 'test', e.Label), 504# exports = { 'env' : e }, duplicate = False) 505 506Help(help_text) 507 508################################################### 509# 510# Let SCons do its thing. At this point SCons will use the defined 511# build environments to build the requested targets. 512# 513################################################### 514
|