SConstruct revision 2139
12221SN/A# -*- mode:python -*- 22221SN/A 32221SN/A# Copyright (c) 2004-2005 The Regents of The University of Michigan 42221SN/A# All rights reserved. 52221SN/A# 62221SN/A# Redistribution and use in source and binary forms, with or without 72221SN/A# modification, are permitted provided that the following conditions are 82221SN/A# met: redistributions of source code must retain the above copyright 92221SN/A# notice, this list of conditions and the following disclaimer; 102221SN/A# redistributions in binary form must reproduce the above copyright 112221SN/A# notice, this list of conditions and the following disclaimer in the 122221SN/A# documentation and/or other materials provided with the distribution; 132221SN/A# neither the name of the copyright holders nor the names of its 142221SN/A# contributors may be used to endorse or promote products derived from 152221SN/A# this software without specific prior written permission. 162221SN/A# 172221SN/A# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 182221SN/A# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 192221SN/A# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 202221SN/A# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 212221SN/A# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 222221SN/A# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 232221SN/A# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 242221SN/A# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 252221SN/A# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 262221SN/A# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 272665Ssaidi@eecs.umich.edu# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 282665Ssaidi@eecs.umich.edu 292665Ssaidi@eecs.umich.edu################################################### 302221SN/A# 312221SN/A# SCons top-level build description (SConstruct) file. 323415Sgblack@eecs.umich.edu# 333415Sgblack@eecs.umich.edu# To build M5, you need a directory with three things: 342223SN/A# 1. A copy of this file (named SConstruct). 353415Sgblack@eecs.umich.edu# 2. A link named 'm5' to the top of the M5 simulator source tree. 363578Sgblack@eecs.umich.edu# 3. A link named 'ext' to the top of the M5 external source tree. 373415Sgblack@eecs.umich.edu# 383415Sgblack@eecs.umich.edu# Then type 'scons' to build the default configuration (see below), or 393523Sgblack@eecs.umich.edu# 'scons <CONFIG>/<binary>' to build some other configuration (e.g., 403415Sgblack@eecs.umich.edu# 'ALPHA_FS/m5.opt' for the optimized full-system version). 412680Sktlim@umich.edu# 422800Ssaidi@eecs.umich.edu################################################### 433523Sgblack@eecs.umich.edu 443415Sgblack@eecs.umich.edu# Python library imports 452800Ssaidi@eecs.umich.eduimport sys 462800Ssaidi@eecs.umich.eduimport os 472221SN/A 483415Sgblack@eecs.umich.edu# Check for recent-enough Python and SCons versions 493415Sgblack@eecs.umich.eduEnsurePythonVersion(2,3) 502223SN/AEnsureSConsVersion(0,96) 512221SN/A 522221SN/A# The absolute path to the current directory (where this file lives). 533573Sgblack@eecs.umich.eduROOT = Dir('.').abspath 543576Sgblack@eecs.umich.edu 553576Sgblack@eecs.umich.edu# Paths to the M5 and external source trees (local symlinks). 562221SN/ASRCDIR = os.path.join(ROOT, 'm5') 573573Sgblack@eecs.umich.eduEXT_SRCDIR = os.path.join(ROOT, 'ext') 583576Sgblack@eecs.umich.edu 593576Sgblack@eecs.umich.edu# Check for 'm5' and 'ext' links, die if they don't exist. 602221SN/Aif not os.path.isdir(SRCDIR): 613573Sgblack@eecs.umich.edu print "Error: '%s' must be a link to the M5 source tree." % SRCDIR 623576Sgblack@eecs.umich.edu Exit(1) 633576Sgblack@eecs.umich.edu 642221SN/Aif not os.path.isdir('ext'): 653573Sgblack@eecs.umich.edu print "Error: '%s' must be a link to the M5 external source tree." \ 663576Sgblack@eecs.umich.edu % EXT_SRCDIR 673576Sgblack@eecs.umich.edu Exit(1) 682221SN/A 693573Sgblack@eecs.umich.edu# tell python where to find m5 python code 703576Sgblack@eecs.umich.edusys.path.append(os.path.join(SRCDIR, 'python')) 713576Sgblack@eecs.umich.edu 722221SN/A################################################### 733573Sgblack@eecs.umich.edu# 743576Sgblack@eecs.umich.edu# Figure out which configurations to set up. 753576Sgblack@eecs.umich.edu# 762221SN/A# 773573Sgblack@eecs.umich.edu# It's prohibitive to do all the combinations of base configurations 783576Sgblack@eecs.umich.edu# and options, so we have to infer which ones the user wants. 793576Sgblack@eecs.umich.edu# 803576Sgblack@eecs.umich.edu# 1. If there are command-line targets, the configuration(s) are inferred 813576Sgblack@eecs.umich.edu# from the directories of those targets. If scons was invoked from a 823576Sgblack@eecs.umich.edu# subdirectory (using 'scons -u'), those targets have to be 833576Sgblack@eecs.umich.edu# interpreted relative to that subdirectory. 843576Sgblack@eecs.umich.edu# 852221SN/A# 2. If there are no command-line targets, and scons was invoked from a 863573Sgblack@eecs.umich.edu# subdirectory (using 'scons -u'), the configuration is inferred from 873576Sgblack@eecs.umich.edu# the name of the subdirectory. 883576Sgblack@eecs.umich.edu# 892221SN/A# 3. If there are no command-line targets and scons was invoked from 903573Sgblack@eecs.umich.edu# the root build directory, a default configuration is used. The 913576Sgblack@eecs.umich.edu# built-in default is ALPHA_SE, but this can be overridden by setting the 923576Sgblack@eecs.umich.edu# M5_DEFAULT_CONFIG shell environment veriable. 932221SN/A# 943573Sgblack@eecs.umich.edu# In cases 2 & 3, the specific file target defaults to 'm5.debug', but 953576Sgblack@eecs.umich.edu# this can be overridden by setting the M5_DEFAULT_BINARY shell 963576Sgblack@eecs.umich.edu# environment veriable. 973576Sgblack@eecs.umich.edu# 983576Sgblack@eecs.umich.edu################################################### 993576Sgblack@eecs.umich.edu 1003576Sgblack@eecs.umich.edu# Find default configuration & binary. 1013576Sgblack@eecs.umich.edudefault_config = os.environ.get('M5_DEFAULT_CONFIG', 'ALPHA_SE') 1023576Sgblack@eecs.umich.edudefault_binary = os.environ.get('M5_DEFAULT_BINARY', 'm5.debug') 1033576Sgblack@eecs.umich.edu 1043576Sgblack@eecs.umich.edu# Ask SCons which directory it was invoked from. If you invoke SCons 1053576Sgblack@eecs.umich.edu# from a subdirectory you must use the '-u' flag. 1063576Sgblack@eecs.umich.edulaunch_dir = GetLaunchDir() 1072221SN/A 1083573Sgblack@eecs.umich.edu# Build a list 'my_targets' of all the targets relative to ROOT. 1093576Sgblack@eecs.umich.eduif launch_dir == ROOT: 1103576Sgblack@eecs.umich.edu # invoked from root build dir 1112221SN/A if len(COMMAND_LINE_TARGETS) != 0: 1123573Sgblack@eecs.umich.edu # easy: use specified targets as is 1133576Sgblack@eecs.umich.edu my_targets = COMMAND_LINE_TARGETS 1143576Sgblack@eecs.umich.edu else: 1152221SN/A # default target (ALPHA_SE/m5.debug, unless overridden) 1163573Sgblack@eecs.umich.edu target = os.path.join(default_config, default_binary) 1173576Sgblack@eecs.umich.edu my_targets = [target] 1183576Sgblack@eecs.umich.edu Default(target) 1192221SN/Aelse: 1203573Sgblack@eecs.umich.edu # invoked from subdirectory 1213576Sgblack@eecs.umich.edu if not launch_dir.startswith(ROOT): 1223576Sgblack@eecs.umich.edu print "Error: launch dir (%s) not a subdirectory of ROOT (%s)!" \ 1232221SN/A (launch_dir, ROOT) 1243573Sgblack@eecs.umich.edu Exit(1) 1253576Sgblack@eecs.umich.edu # make launch_dir relative to ROOT (strip ROOT plus slash off front) 1263576Sgblack@eecs.umich.edu launch_dir = launch_dir[len(ROOT)+1:] 1272221SN/A if len(COMMAND_LINE_TARGETS) != 0: 1283573Sgblack@eecs.umich.edu # make specified targets relative to ROOT 1293576Sgblack@eecs.umich.edu my_targets = map(lambda x: os.path.join(launch_dir, x), 1303576Sgblack@eecs.umich.edu COMMAND_LINE_TARGETS) 1312223SN/A else: 1323573Sgblack@eecs.umich.edu # build default binary (m5.debug, unless overridden) using the 1333576Sgblack@eecs.umich.edu # config inferred by the invocation directory (the first 1343576Sgblack@eecs.umich.edu # subdirectory after ROOT) 1352223SN/A target = os.path.join(launch_dir.split('/')[0], default_binary) 1363573Sgblack@eecs.umich.edu my_targets = [target] 1373576Sgblack@eecs.umich.edu Default(target) 1383576Sgblack@eecs.umich.edu 1392223SN/A# Normalize target paths (gets rid of '..' in the middle, etc.) 1403573Sgblack@eecs.umich.edumy_targets = map(os.path.normpath, my_targets) 1413576Sgblack@eecs.umich.edu 1423576Sgblack@eecs.umich.edu# Generate a list of the unique configs that the collected targets reference. 1432223SN/Abuild_dirs = [] 1443573Sgblack@eecs.umich.edufor t in my_targets: 1453576Sgblack@eecs.umich.edu dir = t.split('/')[0] 1463576Sgblack@eecs.umich.edu if dir not in build_dirs: 1473576Sgblack@eecs.umich.edu build_dirs.append(dir) 1483576Sgblack@eecs.umich.edu 1493576Sgblack@eecs.umich.edu################################################### 1503576Sgblack@eecs.umich.edu# 1513576Sgblack@eecs.umich.edu# Set up the default build environment. This environment is copied 1522223SN/A# and modified according to each selected configuration. 1533573Sgblack@eecs.umich.edu# 1543576Sgblack@eecs.umich.edu################################################### 1553576Sgblack@eecs.umich.edu 1562223SN/Aenv = Environment(ENV = os.environ, # inherit user's environment vars 1573573Sgblack@eecs.umich.edu ROOT = ROOT, 1583576Sgblack@eecs.umich.edu SRCDIR = SRCDIR, 1593576Sgblack@eecs.umich.edu EXT_SRCDIR = EXT_SRCDIR) 1602223SN/A 1613573Sgblack@eecs.umich.eduenv.SConsignFile("sconsign") 1623576Sgblack@eecs.umich.edu 1633576Sgblack@eecs.umich.edu# I waffle on this setting... it does avoid a few painful but 1642223SN/A# unnecessary builds, but it also seems to make trivial builds take 1653573Sgblack@eecs.umich.edu# noticeably longer. 1663576Sgblack@eecs.umich.eduif False: 1673576Sgblack@eecs.umich.edu env.TargetSignatures('content') 1682223SN/A 1693573Sgblack@eecs.umich.edu# M5_EXT is used by isa_parser.py to find the PLY package. 1703576Sgblack@eecs.umich.eduenv.Append(ENV = { 'M5_EXT' : EXT_SRCDIR }) 1713576Sgblack@eecs.umich.edu 1722223SN/A# Set up default C++ compiler flags 1733573Sgblack@eecs.umich.eduenv.Append(CCFLAGS='-pipe') 1743576Sgblack@eecs.umich.eduenv.Append(CCFLAGS='-fno-strict-aliasing') 1753576Sgblack@eecs.umich.eduenv.Append(CCFLAGS=Split('-Wall -Wno-sign-compare -Werror -Wundef')) 1762223SN/Aif sys.platform == 'cygwin': 1773573Sgblack@eecs.umich.edu # cygwin has some header file issues... 1783576Sgblack@eecs.umich.edu env.Append(CCFLAGS=Split("-Wno-uninitialized")) 1793576Sgblack@eecs.umich.eduenv.Append(CPPPATH=[os.path.join(EXT_SRCDIR + '/dnet')]) 1802223SN/A 1813573Sgblack@eecs.umich.edu# Default libraries 1823576Sgblack@eecs.umich.eduenv.Append(LIBS=['z']) 1833576Sgblack@eecs.umich.edu 1842223SN/A# Platform-specific configuration 1853573Sgblack@eecs.umich.educonf = Configure(env) 1863576Sgblack@eecs.umich.edu 1873576Sgblack@eecs.umich.edu# Check for <fenv.h> (C99 FP environment control) 1882223SN/Ahave_fenv = conf.CheckHeader('fenv.h', '<>') 1893573Sgblack@eecs.umich.eduif not have_fenv: 1903576Sgblack@eecs.umich.edu print "Warning: Header file <fenv.h> not found." 1913576Sgblack@eecs.umich.edu print " This host has no IEEE FP rounding mode control." 1922223SN/A 1933576Sgblack@eecs.umich.edu# Check for mysql. 1943576Sgblack@eecs.umich.edumysql_config = WhereIs('mysql_config') 1953576Sgblack@eecs.umich.eduhave_mysql = mysql_config != None 1963576Sgblack@eecs.umich.edu 1972527SN/A# Check MySQL version. 1983573Sgblack@eecs.umich.eduif have_mysql: 1993576Sgblack@eecs.umich.edu mysql_version = os.popen(mysql_config + ' --version').read() 2003890Ssaidi@eecs.umich.edu mysql_version = mysql_version.split('.') 2012223SN/A mysql_major = int(mysql_version[0]) 2023573Sgblack@eecs.umich.edu mysql_minor = int(mysql_version[1]) 2033576Sgblack@eecs.umich.edu # This version check is probably overly conservative, but it deals 2043576Sgblack@eecs.umich.edu # with the versions we have installed. 2052223SN/A if mysql_major < 4 or (mysql_major == 4 and mysql_minor < 1): 2063573Sgblack@eecs.umich.edu print "Warning: MySQL v4.1 or newer required." 2073576Sgblack@eecs.umich.edu have_mysql = False 2083576Sgblack@eecs.umich.edu 2092223SN/A# Set up mysql_config commands. 2103573Sgblack@eecs.umich.eduif have_mysql: 2114103Ssaidi@eecs.umich.edu mysql_config_include = mysql_config + ' --include' 2124103Ssaidi@eecs.umich.edu if os.system(mysql_config_include + ' > /dev/null') != 0: 2134103Ssaidi@eecs.umich.edu # older mysql_config versions don't support --include, use 2144103Ssaidi@eecs.umich.edu # --cflags instead 2153576Sgblack@eecs.umich.edu mysql_config_include = mysql_config + ' --cflags | sed s/\\\'//g' 2163576Sgblack@eecs.umich.edu # This seems to work in all versions 2172223SN/A mysql_config_libs = mysql_config + ' --libs' 2183573Sgblack@eecs.umich.edu 2193576Sgblack@eecs.umich.eduenv = conf.Finish() 2203576Sgblack@eecs.umich.edu 2212223SN/A# Define the universe of supported ISAs 2223573Sgblack@eecs.umich.eduenv['ALL_ISA_LIST'] = ['alpha', 'sparc', 'mips'] 2233576Sgblack@eecs.umich.edu 2243576Sgblack@eecs.umich.edu# Sticky options get saved in the options file so they persist from 2253576Sgblack@eecs.umich.edu# one invocation to the next (unless overridden, in which case the new 2263576Sgblack@eecs.umich.edu# value becomes sticky). 2273576Sgblack@eecs.umich.edusticky_opts = Options(args=ARGUMENTS) 2283576Sgblack@eecs.umich.edusticky_opts.AddOptions( 2293576Sgblack@eecs.umich.edu EnumOption('TARGET_ISA', 'Target ISA', 'alpha', env['ALL_ISA_LIST']), 2303576Sgblack@eecs.umich.edu BoolOption('FULL_SYSTEM', 'Full-system support', False), 2313576Sgblack@eecs.umich.edu BoolOption('ALPHA_TLASER', 2323576Sgblack@eecs.umich.edu 'Model Alpha TurboLaser platform (vs. Tsunami)', False), 2333576Sgblack@eecs.umich.edu BoolOption('NO_FAST_ALLOC', 'Disable fast object allocator', False), 2343576Sgblack@eecs.umich.edu BoolOption('EFENCE', 'Link with Electric Fence malloc debugger', 2353576Sgblack@eecs.umich.edu False), 2363576Sgblack@eecs.umich.edu BoolOption('SS_COMPATIBLE_FP', 2373576Sgblack@eecs.umich.edu 'Make floating-point results compatible with SimpleScalar', 2383576Sgblack@eecs.umich.edu False), 2393576Sgblack@eecs.umich.edu BoolOption('USE_SSE2', 2403576Sgblack@eecs.umich.edu 'Compile for SSE2 (-msse2) to get IEEE FP on x86 hosts', 2413576Sgblack@eecs.umich.edu False), 2423576Sgblack@eecs.umich.edu BoolOption('STATS_BINNING', 'Bin statistics by CPU mode', have_mysql), 2433576Sgblack@eecs.umich.edu BoolOption('USE_MYSQL', 'Use MySQL for stats output', have_mysql), 2443576Sgblack@eecs.umich.edu BoolOption('USE_FENV', 'Use <fenv.h> IEEE mode control', have_fenv), 2453576Sgblack@eecs.umich.edu ('CC', 'C compiler', os.environ.get('CC', env['CC'])), 2463576Sgblack@eecs.umich.edu ('CXX', 'C++ compiler', os.environ.get('CXX', env['CXX'])), 2473893Shsul@eecs.umich.edu BoolOption('BATCH', 'Use batch pool for build and tests', False), 2483576Sgblack@eecs.umich.edu ('BATCH_CMD', 'Batch pool submission command name', 'qdo') 2493576Sgblack@eecs.umich.edu ) 2503576Sgblack@eecs.umich.edu 2513576Sgblack@eecs.umich.edu# Non-sticky options only apply to the current build. 2523576Sgblack@eecs.umich.edunonsticky_opts = Options(args=ARGUMENTS) 2533576Sgblack@eecs.umich.edunonsticky_opts.AddOptions( 2543576Sgblack@eecs.umich.edu BoolOption('update_ref', 'Update test reference outputs', False) 2553576Sgblack@eecs.umich.edu ) 2563576Sgblack@eecs.umich.edu 2573576Sgblack@eecs.umich.edu# These options get exported to #defines in config/*.hh (see m5/SConscript). 2583576Sgblack@eecs.umich.eduenv.ExportOptions = ['FULL_SYSTEM', 'ALPHA_TLASER', 'USE_FENV', \ 2593576Sgblack@eecs.umich.edu 'USE_MYSQL', 'NO_FAST_ALLOC', 'SS_COMPATIBLE_FP', \ 2603576Sgblack@eecs.umich.edu 'STATS_BINNING'] 2613576Sgblack@eecs.umich.edu 2623576Sgblack@eecs.umich.edu# Define a handy 'no-op' action 2633576Sgblack@eecs.umich.edudef no_action(target, source, env): 2643576Sgblack@eecs.umich.edu return 0 2653576Sgblack@eecs.umich.edu 2663576Sgblack@eecs.umich.eduenv.NoAction = Action(no_action, None) 2673576Sgblack@eecs.umich.edu 2683576Sgblack@eecs.umich.edu# libelf build is described in its own SConscript file. 2692223SN/A# SConscript-global is the build in build/libelf shared among all 2702800Ssaidi@eecs.umich.edu# configs. 2713573Sgblack@eecs.umich.eduenv.SConscript('m5/libelf/SConscript-global', exports = 'env') 2723576Sgblack@eecs.umich.edu 2733576Sgblack@eecs.umich.edu################################################### 2742800Ssaidi@eecs.umich.edu# 2752800Ssaidi@eecs.umich.edu# Define a SCons builder for configuration flag headers. 2763415Sgblack@eecs.umich.edu# 2773578Sgblack@eecs.umich.edu################################################### 2783578Sgblack@eecs.umich.edu 2793415Sgblack@eecs.umich.edu# This function generates a config header file that #defines the 2803415Sgblack@eecs.umich.edu# option symbol to the current option setting (0 or 1). The source 2813578Sgblack@eecs.umich.edu# operands are the name of the option and a Value node containing the 2823415Sgblack@eecs.umich.edu# value of the option. 2833578Sgblack@eecs.umich.edudef build_config_file(target, source, env): 2843578Sgblack@eecs.umich.edu (option, value) = [s.get_contents() for s in source] 2854172Ssaidi@eecs.umich.edu f = file(str(target[0]), 'w') 2863578Sgblack@eecs.umich.edu print >> f, '#define', option, value 2873578Sgblack@eecs.umich.edu f.close() 2883578Sgblack@eecs.umich.edu return None 2893578Sgblack@eecs.umich.edu 2904172Ssaidi@eecs.umich.edu# Generate the message to be printed when building the config file. 2913746Sgblack@eecs.umich.edudef build_config_file_string(target, source, env): 2923746Sgblack@eecs.umich.edu (option, value) = [s.get_contents() for s in source] 2934172Ssaidi@eecs.umich.edu return "Defining %s as %s in %s." % (option, value, target[0]) 2943746Sgblack@eecs.umich.edu 2954172Ssaidi@eecs.umich.edu# Combine the two functions into a scons Action object. 2963578Sgblack@eecs.umich.educonfig_action = Action(build_config_file, build_config_file_string) 2973578Sgblack@eecs.umich.edu 2983578Sgblack@eecs.umich.edu# The emitter munges the source & target node lists to reflect what 2993578Sgblack@eecs.umich.edu# we're really doing. 3003578Sgblack@eecs.umich.edudef config_emitter(target, source, env): 3013578Sgblack@eecs.umich.edu # extract option name from Builder arg 3023578Sgblack@eecs.umich.edu option = str(target[0]) 3033578Sgblack@eecs.umich.edu # True target is config header file 3043578Sgblack@eecs.umich.edu target = os.path.join('config', option.lower() + '.hh') 3054172Ssaidi@eecs.umich.edu # Force value to 0/1 even if it's a Python bool 3064172Ssaidi@eecs.umich.edu val = int(eval(str(env[option]))) 3074172Ssaidi@eecs.umich.edu # Sources are option name & value (packaged in SCons Value nodes) 3084172Ssaidi@eecs.umich.edu return ([target], [Value(option), Value(val)]) 3094172Ssaidi@eecs.umich.edu 3103761Sgblack@eecs.umich.educonfig_builder = Builder(emitter = config_emitter, action = config_action) 3114172Ssaidi@eecs.umich.edu 3124172Ssaidi@eecs.umich.eduenv.Append(BUILDERS = { 'ConfigFile' : config_builder }) 3134172Ssaidi@eecs.umich.edu 3144172Ssaidi@eecs.umich.edu################################################### 3154172Ssaidi@eecs.umich.edu# 3163578Sgblack@eecs.umich.edu# Define build environments for selected configurations. 3173578Sgblack@eecs.umich.edu# 3183578Sgblack@eecs.umich.edu################################################### 3193578Sgblack@eecs.umich.edu 3203578Sgblack@eecs.umich.edu# rename base env 3213928Ssaidi@eecs.umich.edubase_env = env 3223928Ssaidi@eecs.umich.edu 3233928Ssaidi@eecs.umich.edufor build_dir in build_dirs: 3243928Ssaidi@eecs.umich.edu # Make a copy of the default environment to use for this config. 3253928Ssaidi@eecs.umich.edu env = base_env.Copy() 3263578Sgblack@eecs.umich.edu 3273578Sgblack@eecs.umich.edu # Record what build_dir was in the environment 3283578Sgblack@eecs.umich.edu env.Append(BUILD_DIR=build_dir); 3293578Sgblack@eecs.umich.edu 3303578Sgblack@eecs.umich.edu # Set env according to the build directory config. 3313578Sgblack@eecs.umich.edu 3323578Sgblack@eecs.umich.edu sticky_opts.files = [] 3333578Sgblack@eecs.umich.edu # Name of default options file is taken from 'default=' on command 3343578Sgblack@eecs.umich.edu # line if set, otherwise name of build dir. 3353578Sgblack@eecs.umich.edu default_options_file = os.path.join('build_options', 'default', 3363578Sgblack@eecs.umich.edu ARGUMENTS.get('default', build_dir)) 3373578Sgblack@eecs.umich.edu if os.path.isfile(default_options_file): 3384172Ssaidi@eecs.umich.edu sticky_opts.files.append(default_options_file) 3393578Sgblack@eecs.umich.edu current_options_file = os.path.join('build_options', 'current', build_dir) 3403578Sgblack@eecs.umich.edu if os.path.isfile(current_options_file): 3414172Ssaidi@eecs.umich.edu sticky_opts.files.append(current_options_file) 3423578Sgblack@eecs.umich.edu else: 3434172Ssaidi@eecs.umich.edu # if file doesn't exist, make sure at least the directory is there 3443578Sgblack@eecs.umich.edu # so we can create it later 3453578Sgblack@eecs.umich.edu opt_dir = os.path.dirname(current_options_file) 3464172Ssaidi@eecs.umich.edu if not os.path.isdir(opt_dir): 3473578Sgblack@eecs.umich.edu os.mkdir(opt_dir) 3483578Sgblack@eecs.umich.edu if not sticky_opts.files: 3494172Ssaidi@eecs.umich.edu print "%s: No options file found in build_options, using defaults." \ 3503578Sgblack@eecs.umich.edu % build_dir 3513578Sgblack@eecs.umich.edu 3524172Ssaidi@eecs.umich.edu # Apply current option settings to env 3533578Sgblack@eecs.umich.edu sticky_opts.Update(env) 3543926Ssaidi@eecs.umich.edu nonsticky_opts.Update(env) 3553926Ssaidi@eecs.umich.edu 3564172Ssaidi@eecs.umich.edu # Process option settings. 3573578Sgblack@eecs.umich.edu 3583578Sgblack@eecs.umich.edu if not have_fenv and env['USE_FENV']: 3593578Sgblack@eecs.umich.edu print "Warning: <fenv.h> not available; " \ 3603578Sgblack@eecs.umich.edu "forcing USE_FENV to False in", build_dir + "." 3613578Sgblack@eecs.umich.edu env['USE_FENV'] = False 3623578Sgblack@eecs.umich.edu 3633578Sgblack@eecs.umich.edu if not env['USE_FENV']: 3643578Sgblack@eecs.umich.edu print "Warning: No IEEE FP rounding mode control in", build_dir + "." 3653578Sgblack@eecs.umich.edu print " FP results may deviate slightly from other platforms." 3664172Ssaidi@eecs.umich.edu 3673578Sgblack@eecs.umich.edu if env['EFENCE']: 3683578Sgblack@eecs.umich.edu env.Append(LIBS=['efence']) 3693578Sgblack@eecs.umich.edu 3703578Sgblack@eecs.umich.edu if env['USE_MYSQL']: 3713578Sgblack@eecs.umich.edu if not have_mysql: 3723578Sgblack@eecs.umich.edu print "Warning: MySQL not available; " \ 3733578Sgblack@eecs.umich.edu "forcing USE_MYSQL to False in", build_dir + "." 3743578Sgblack@eecs.umich.edu env['USE_MYSQL'] = False 3753578Sgblack@eecs.umich.edu else: 3763578Sgblack@eecs.umich.edu print "Compiling in", build_dir, "with MySQL support." 3773578Sgblack@eecs.umich.edu env.ParseConfig(mysql_config_libs) 3783578Sgblack@eecs.umich.edu env.ParseConfig(mysql_config_include) 3793578Sgblack@eecs.umich.edu 3803578Sgblack@eecs.umich.edu # Save sticky option settings back to current options file 3814172Ssaidi@eecs.umich.edu sticky_opts.Save(current_options_file, env) 3823578Sgblack@eecs.umich.edu 3833578Sgblack@eecs.umich.edu # Do this after we save setting back, or else we'll tack on an 3843578Sgblack@eecs.umich.edu # extra 'qdo' every time we run scons. 3853578Sgblack@eecs.umich.edu if env['BATCH']: 3863578Sgblack@eecs.umich.edu env['CC'] = env['BATCH_CMD'] + ' ' + env['CC'] 3873578Sgblack@eecs.umich.edu env['CXX'] = env['BATCH_CMD'] + ' ' + env['CXX'] 3883578Sgblack@eecs.umich.edu 3893578Sgblack@eecs.umich.edu if env['USE_SSE2']: 3903578Sgblack@eecs.umich.edu env.Append(CCFLAGS='-msse2') 3913578Sgblack@eecs.umich.edu 3924172Ssaidi@eecs.umich.edu # The m5/SConscript file sets up the build rules in 'env' according 3934172Ssaidi@eecs.umich.edu # to the configured options. It returns a list of environments, 3944172Ssaidi@eecs.umich.edu # one for each variant build (debug, opt, etc.) 3954172Ssaidi@eecs.umich.edu envList = SConscript('m5/SConscript', build_dir = build_dir, 3964172Ssaidi@eecs.umich.edu exports = 'env', duplicate = False) 3973761Sgblack@eecs.umich.edu 3984172Ssaidi@eecs.umich.edu # Set up the regression tests for each build. 3994172Ssaidi@eecs.umich.edu for e in envList: 4004172Ssaidi@eecs.umich.edu SConscript('m5-test/SConscript', 4013761Sgblack@eecs.umich.edu build_dir = os.path.join(build_dir, 'test', e.Label), 4024172Ssaidi@eecs.umich.edu exports = { 'env' : e }, duplicate = False) 4033578Sgblack@eecs.umich.edu 4043578Sgblack@eecs.umich.edu################################################### 4053415Sgblack@eecs.umich.edu# 4063928Ssaidi@eecs.umich.edu# Let SCons do its thing. At this point SCons will use the defined 4073928Ssaidi@eecs.umich.edu# build environments to build the requested targets. 4083928Ssaidi@eecs.umich.edu# 4093928Ssaidi@eecs.umich.edu################################################### 4103928Ssaidi@eecs.umich.edu 4113415Sgblack@eecs.umich.edu