SConstruct revision 5204
1955SN/A# -*- mode:python -*-
2955SN/A
35871Snate@binkert.org# Copyright (c) 2004-2005 The Regents of The University of Michigan
41762SN/A# All rights reserved.
5955SN/A#
6955SN/A# Redistribution and use in source and binary forms, with or without
7955SN/A# modification, are permitted provided that the following conditions are
8955SN/A# met: redistributions of source code must retain the above copyright
9955SN/A# notice, this list of conditions and the following disclaimer;
10955SN/A# redistributions in binary form must reproduce the above copyright
11955SN/A# notice, this list of conditions and the following disclaimer in the
12955SN/A# documentation and/or other materials provided with the distribution;
13955SN/A# neither the name of the copyright holders nor the names of its
14955SN/A# contributors may be used to endorse or promote products derived from
15955SN/A# this software without specific prior written permission.
16955SN/A#
17955SN/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#
292665Ssaidi@eecs.umich.edu# Authors: Steve Reinhardt
302665Ssaidi@eecs.umich.edu
315863Snate@binkert.org###################################################
32955SN/A#
33955SN/A# SCons top-level build description (SConstruct) file.
34955SN/A#
35955SN/A# While in this directory ('m5'), just type 'scons' to build the default
36955SN/A# configuration (see below), or type 'scons build/<CONFIG>/<binary>'
372632Sstever@eecs.umich.edu# to build some other configuration (e.g., 'build/ALPHA_FS/m5.opt' for
382632Sstever@eecs.umich.edu# the optimized full-system version).
392632Sstever@eecs.umich.edu#
402632Sstever@eecs.umich.edu# You can build M5 in a different directory as long as there is a
41955SN/A# 'build/<CONFIG>' somewhere along the target path.  The build system
422632Sstever@eecs.umich.edu# expects that all configs under the same build directory are being
432632Sstever@eecs.umich.edu# built for the same host system.
442761Sstever@eecs.umich.edu#
452632Sstever@eecs.umich.edu# Examples:
462632Sstever@eecs.umich.edu#
472632Sstever@eecs.umich.edu#   The following two commands are equivalent.  The '-u' option tells
482761Sstever@eecs.umich.edu#   scons to search up the directory tree for this SConstruct file.
492761Sstever@eecs.umich.edu#   % cd <path-to-src>/m5 ; scons build/ALPHA_FS/m5.debug
502761Sstever@eecs.umich.edu#   % cd <path-to-src>/m5/build/ALPHA_FS; scons -u m5.debug
512632Sstever@eecs.umich.edu#
522632Sstever@eecs.umich.edu#   The following two commands are equivalent and demonstrate building
532761Sstever@eecs.umich.edu#   in a directory outside of the source tree.  The '-C' option tells
542761Sstever@eecs.umich.edu#   scons to chdir to the specified directory to find this SConstruct
552761Sstever@eecs.umich.edu#   file.
562761Sstever@eecs.umich.edu#   % cd <path-to-src>/m5 ; scons /local/foo/build/ALPHA_FS/m5.debug
572761Sstever@eecs.umich.edu#   % cd /local/foo/build/ALPHA_FS; scons -C <path-to-src>/m5 m5.debug
582632Sstever@eecs.umich.edu#
592632Sstever@eecs.umich.edu# You can use 'scons -H' to print scons options.  If you're in this
602632Sstever@eecs.umich.edu# 'm5' directory (or use -u or -C to tell scons where to find this
612632Sstever@eecs.umich.edu# file), you can use 'scons -h' to print all the M5-specific build
622632Sstever@eecs.umich.edu# options as well.
632632Sstever@eecs.umich.edu#
642632Sstever@eecs.umich.edu###################################################
65955SN/A
66955SN/Aimport sys
67955SN/Aimport os
685863Snate@binkert.orgimport subprocess
695863Snate@binkert.org
705863Snate@binkert.orgfrom os.path import isdir, join as joinpath
715863Snate@binkert.org
725863Snate@binkert.org# Check for recent-enough Python and SCons versions.  If your system's
735863Snate@binkert.org# default installation of Python is not recent enough, you can use a
745863Snate@binkert.org# non-default installation of the Python interpreter by either (1)
755863Snate@binkert.org# rearranging your PATH so that scons finds the non-default 'python'
765863Snate@binkert.org# first or (2) explicitly invoking an alternative interpreter on the
775863Snate@binkert.org# scons script, e.g., "/usr/local/bin/python2.4 `which scons` [args]".
785863Snate@binkert.orgEnsurePythonVersion(2,4)
795863Snate@binkert.org
805863Snate@binkert.org# Ironically, SCons 0.96 dies if you give EnsureSconsVersion a
815863Snate@binkert.org# 3-element version number.
825863Snate@binkert.orgmin_scons_version = (0,96,91)
835863Snate@binkert.orgtry:
845863Snate@binkert.org    EnsureSConsVersion(*min_scons_version)
855863Snate@binkert.orgexcept:
865863Snate@binkert.org    print "Error checking current SCons version."
875863Snate@binkert.org    print "SCons", ".".join(map(str,min_scons_version)), "or greater required."
885863Snate@binkert.org    Exit(2)
895863Snate@binkert.org
905863Snate@binkert.org
915863Snate@binkert.org# The absolute path to the current directory (where this file lives).
925863Snate@binkert.orgROOT = Dir('.').abspath
935863Snate@binkert.org
945863Snate@binkert.org# Path to the M5 source tree.
955863Snate@binkert.orgSRCDIR = joinpath(ROOT, 'src')
965863Snate@binkert.org
975863Snate@binkert.org# tell python where to find m5 python code
985863Snate@binkert.orgsys.path.append(joinpath(ROOT, 'src/python'))
99955SN/A
1005396Ssaidi@eecs.umich.edudef check_style_hook(ui):
1015863Snate@binkert.org    ui.readconfig(joinpath(ROOT, '.hg', 'hgrc'))
1025863Snate@binkert.org    style_hook = ui.config('hooks', 'pretxncommit.style', None)
1034202Sbinkertn@umich.edu
1045863Snate@binkert.org    if not style_hook:
1055863Snate@binkert.org        print """\
1065863Snate@binkert.orgYou're missing the M5 style hook.
1075863Snate@binkert.orgPlease install the hook so we can ensure that all code fits a common style.
108955SN/A
1095273Sstever@gmail.comAll you'd need to do is add the following lines to your repository .hg/hgrc
1105871Snate@binkert.orgor your personal .hgrc
1115273Sstever@gmail.com----------------
1125871Snate@binkert.org
1135863Snate@binkert.org[extensions]
1145863Snate@binkert.orgstyle = %s/util/style.py
1155863Snate@binkert.org
1165871Snate@binkert.org[hooks]
1175872Snate@binkert.orgpretxncommit.style = python:style.check_whitespace
1185872Snate@binkert.org""" % (ROOT)
1195872Snate@binkert.org        sys.exit(1)
1205871Snate@binkert.org
1215871Snate@binkert.orgif ARGUMENTS.get('IGNORE_STYLE') != 'True' and isdir(joinpath(ROOT, '.hg')):
1225871Snate@binkert.org    try:
1235871Snate@binkert.org        from mercurial import ui
1245871Snate@binkert.org        check_style_hook(ui.ui())
1255871Snate@binkert.org    except ImportError:
1265871Snate@binkert.org        pass
1275871Snate@binkert.org
1285871Snate@binkert.org###################################################
1295871Snate@binkert.org#
1305871Snate@binkert.org# Figure out which configurations to set up based on the path(s) of
1315871Snate@binkert.org# the target(s).
1325871Snate@binkert.org#
1335871Snate@binkert.org###################################################
1345863Snate@binkert.org
1355227Ssaidi@eecs.umich.edu# Find default configuration & binary.
1365396Ssaidi@eecs.umich.eduDefault(os.environ.get('M5_DEFAULT_BINARY', 'build/ALPHA_SE/m5.debug'))
1375396Ssaidi@eecs.umich.edu
1385396Ssaidi@eecs.umich.edu# helper function: find last occurrence of element in list
1395396Ssaidi@eecs.umich.edudef rfind(l, elt, offs = -1):
1405396Ssaidi@eecs.umich.edu    for i in range(len(l)+offs, 0, -1):
1415396Ssaidi@eecs.umich.edu        if l[i] == elt:
1425396Ssaidi@eecs.umich.edu            return i
1435396Ssaidi@eecs.umich.edu    raise ValueError, "element not found"
1445588Ssaidi@eecs.umich.edu
1455396Ssaidi@eecs.umich.edu# helper function: compare dotted version numbers.
1465396Ssaidi@eecs.umich.edu# E.g., compare_version('1.3.25', '1.4.1')
1475396Ssaidi@eecs.umich.edu# returns -1, 0, 1 if v1 is <, ==, > v2
1485396Ssaidi@eecs.umich.edudef compare_versions(v1, v2):
1495396Ssaidi@eecs.umich.edu    # Convert dotted strings to lists
1505396Ssaidi@eecs.umich.edu    v1 = map(int, v1.split('.'))
1515396Ssaidi@eecs.umich.edu    v2 = map(int, v2.split('.'))
1525396Ssaidi@eecs.umich.edu    # Compare corresponding elements of lists
1535396Ssaidi@eecs.umich.edu    for n1,n2 in zip(v1, v2):
1545396Ssaidi@eecs.umich.edu        if n1 < n2: return -1
1555396Ssaidi@eecs.umich.edu        if n1 > n2: return  1
1565396Ssaidi@eecs.umich.edu    # all corresponding values are equal... see if one has extra values
1575396Ssaidi@eecs.umich.edu    if len(v1) < len(v2): return -1
1585396Ssaidi@eecs.umich.edu    if len(v1) > len(v2): return  1
1595871Snate@binkert.org    return 0
1605871Snate@binkert.org
1616121Snate@binkert.org# Each target must have 'build' in the interior of the path; the
1625871Snate@binkert.org# directory below this will determine the build parameters.  For
1635871Snate@binkert.org# example, for target 'foo/bar/build/ALPHA_SE/arch/alpha/blah.do' we
1646003Snate@binkert.org# recognize that ALPHA_SE specifies the configuration because it
1656003Snate@binkert.org# follow 'build' in the bulid path.
166955SN/A
1675871Snate@binkert.org# Generate absolute paths to targets so we can see where the build dir is
1685871Snate@binkert.orgif COMMAND_LINE_TARGETS:
1695871Snate@binkert.org    # Ask SCons which directory it was invoked from
1705871Snate@binkert.org    launch_dir = GetLaunchDir()
171955SN/A    # Make targets relative to invocation directory
1726121Snate@binkert.org    abs_targets = map(lambda x: os.path.normpath(joinpath(launch_dir, str(x))),
1736121Snate@binkert.org                      COMMAND_LINE_TARGETS)
1746121Snate@binkert.orgelse:
1751533SN/A    # Default targets are relative to root of tree
1765871Snate@binkert.org    abs_targets = map(lambda x: os.path.normpath(joinpath(ROOT, str(x))),
1775871Snate@binkert.org                      DEFAULT_TARGETS)
1785863Snate@binkert.org
1795871Snate@binkert.org
1805871Snate@binkert.org# Generate a list of the unique build roots and configs that the
1815871Snate@binkert.org# collected targets reference.
1825871Snate@binkert.orgbuild_paths = []
1835871Snate@binkert.orgbuild_root = None
1845863Snate@binkert.orgfor t in abs_targets:
1856121Snate@binkert.org    path_dirs = t.split('/')
1865863Snate@binkert.org    try:
1875871Snate@binkert.org        build_top = rfind(path_dirs, 'build', -2)
1884678Snate@binkert.org    except:
1894678Snate@binkert.org        print "Error: no non-leaf 'build' dir found on target path", t
1904678Snate@binkert.org        Exit(1)
1914678Snate@binkert.org    this_build_root = joinpath('/',*path_dirs[:build_top+1])
1924678Snate@binkert.org    if not build_root:
1934678Snate@binkert.org        build_root = this_build_root
1944678Snate@binkert.org    else:
1954678Snate@binkert.org        if this_build_root != build_root:
1964678Snate@binkert.org            print "Error: build targets not under same build root\n"\
1974678Snate@binkert.org                  "  %s\n  %s" % (build_root, this_build_root)
1984678Snate@binkert.org            Exit(1)
1994678Snate@binkert.org    build_path = joinpath('/',*path_dirs[:build_top+2])
2006121Snate@binkert.org    if build_path not in build_paths:
2014678Snate@binkert.org        build_paths.append(build_path)
2025871Snate@binkert.org
2035871Snate@binkert.org###################################################
2045871Snate@binkert.org#
2055871Snate@binkert.org# Set up the default build environment.  This environment is copied
2065871Snate@binkert.org# and modified according to each selected configuration.
2075871Snate@binkert.org#
2085871Snate@binkert.org###################################################
2095871Snate@binkert.org
2105871Snate@binkert.orgenv = Environment(ENV = os.environ,  # inherit user's environment vars
2115871Snate@binkert.org                  ROOT = ROOT,
2125871Snate@binkert.org                  SRCDIR = SRCDIR)
2135871Snate@binkert.org
2145871Snate@binkert.org#Parse CC/CXX early so that we use the correct compiler for
2155990Ssaidi@eecs.umich.edu# to test for dependencies/versions/libraries/includes
2165871Snate@binkert.orgif ARGUMENTS.get('CC', None):
2175871Snate@binkert.org    env['CC'] = ARGUMENTS.get('CC')
2185871Snate@binkert.org
2194678Snate@binkert.orgif ARGUMENTS.get('CXX', None):
2206121Snate@binkert.org    env['CXX'] = ARGUMENTS.get('CXX')
2215871Snate@binkert.org
2225871Snate@binkert.orgExport('env')
2235871Snate@binkert.org
2245871Snate@binkert.orgenv.SConsignFile(joinpath(build_root,"sconsign"))
2255871Snate@binkert.org
2265871Snate@binkert.org# Default duplicate option is to use hard links, but this messes up
2275871Snate@binkert.org# when you use emacs to edit a file in the target dir, as emacs moves
2285871Snate@binkert.org# file to file~ then copies to file, breaking the link.  Symbolic
2295871Snate@binkert.org# (soft) links work better.
2304678Snate@binkert.orgenv.SetOption('duplicate', 'soft-copy')
2315871Snate@binkert.org
2324678Snate@binkert.org# I waffle on this setting... it does avoid a few painful but
2335871Snate@binkert.org# unnecessary builds, but it also seems to make trivial builds take
2345871Snate@binkert.org# noticeably longer.
2355871Snate@binkert.orgif False:
2365871Snate@binkert.org    env.TargetSignatures('content')
2375871Snate@binkert.org
2385871Snate@binkert.org# M5_PLY is used by isa_parser.py to find the PLY package.
2395871Snate@binkert.orgenv.Append(ENV = { 'M5_PLY' : str(Dir('ext/ply')) })
2405871Snate@binkert.orgenv['GCC'] = False
2415871Snate@binkert.orgenv['SUNCC'] = False
2426121Snate@binkert.orgenv['ICC'] = False
2436121Snate@binkert.orgenv['GCC'] = subprocess.Popen(env['CXX'] + ' --version', shell=True,
2445863Snate@binkert.org        stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
245955SN/A        close_fds=True).communicate()[0].find('GCC') >= 0
246955SN/Aenv['SUNCC'] = subprocess.Popen(env['CXX'] + ' -V', shell=True,
2472632Sstever@eecs.umich.edu        stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
2482632Sstever@eecs.umich.edu        close_fds=True).communicate()[0].find('Sun C++') >= 0
249955SN/Aenv['ICC'] = subprocess.Popen(env['CXX'] + ' -V', shell=True,
250955SN/A        stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
251955SN/A        close_fds=True).communicate()[0].find('Intel') >= 0
252955SN/Aif env['GCC'] + env['SUNCC'] + env['ICC'] > 1:
2535863Snate@binkert.org    print 'Error: How can we have two at the same time?'
254955SN/A    Exit(1)
2552632Sstever@eecs.umich.edu
2562632Sstever@eecs.umich.edu
2572632Sstever@eecs.umich.edu# Set up default C++ compiler flags
2582632Sstever@eecs.umich.eduif env['GCC']:
2592632Sstever@eecs.umich.edu    env.Append(CCFLAGS='-pipe')
2602632Sstever@eecs.umich.edu    env.Append(CCFLAGS='-fno-strict-aliasing')
2612632Sstever@eecs.umich.edu    env.Append(CCFLAGS=Split('-Wall -Wno-sign-compare -Werror -Wundef'))
2622632Sstever@eecs.umich.eduelif env['ICC']:
2632632Sstever@eecs.umich.edu    pass #Fix me... add warning flags once we clean up icc warnings
2642632Sstever@eecs.umich.eduelif env['SUNCC']:
2652632Sstever@eecs.umich.edu    env.Append(CCFLAGS='-Qoption ccfe')
2662632Sstever@eecs.umich.edu    env.Append(CCFLAGS='-features=gcc')
2672632Sstever@eecs.umich.edu    env.Append(CCFLAGS='-features=extensions')
2683718Sstever@eecs.umich.edu    env.Append(CCFLAGS='-library=stlport4')
2693718Sstever@eecs.umich.edu    env.Append(CCFLAGS='-xar')
2703718Sstever@eecs.umich.edu#    env.Append(CCFLAGS='-instances=semiexplicit')
2713718Sstever@eecs.umich.eduelse:
2723718Sstever@eecs.umich.edu    print 'Error: Don\'t know what compiler options to use for your compiler.'
2735863Snate@binkert.org    print '       Please fix SConstruct and src/SConscript and try again.'
2745863Snate@binkert.org    Exit(1)
2753718Sstever@eecs.umich.edu
2763718Sstever@eecs.umich.eduif sys.platform == 'cygwin':
2776121Snate@binkert.org    # cygwin has some header file issues...
2785863Snate@binkert.org    env.Append(CCFLAGS=Split("-Wno-uninitialized"))
2793718Sstever@eecs.umich.eduenv.Append(CPPPATH=[Dir('ext/dnet')])
2803718Sstever@eecs.umich.edu
2812634Sstever@eecs.umich.edu# Check for SWIG
2822634Sstever@eecs.umich.eduif not env.has_key('SWIG'):
2835863Snate@binkert.org    print 'Error: SWIG utility not found.'
2842638Sstever@eecs.umich.edu    print '       Please install (see http://www.swig.org) and retry.'
2852632Sstever@eecs.umich.edu    Exit(1)
2862632Sstever@eecs.umich.edu
2872632Sstever@eecs.umich.edu# Check for appropriate SWIG version
2882632Sstever@eecs.umich.eduswig_version = os.popen('swig -version').read().split()
2892632Sstever@eecs.umich.edu# First 3 words should be "SWIG Version x.y.z"
2902632Sstever@eecs.umich.eduif len(swig_version) < 3 or \
2911858SN/A        swig_version[0] != 'SWIG' or swig_version[1] != 'Version':
2923716Sstever@eecs.umich.edu    print 'Error determining SWIG version.'
2932638Sstever@eecs.umich.edu    Exit(1)
2942638Sstever@eecs.umich.edu
2952638Sstever@eecs.umich.edumin_swig_version = '1.3.28'
2962638Sstever@eecs.umich.eduif compare_versions(swig_version[2], min_swig_version) < 0:
2972638Sstever@eecs.umich.edu    print 'Error: SWIG version', min_swig_version, 'or newer required.'
2982638Sstever@eecs.umich.edu    print '       Installed version:', swig_version[2]
2992638Sstever@eecs.umich.edu    Exit(1)
3005863Snate@binkert.org
3015863Snate@binkert.org# Set up SWIG flags & scanner
3025863Snate@binkert.orgswig_flags=Split('-c++ -python -modern -templatereduce $_CPPINCFLAGS')
303955SN/Aenv.Append(SWIGFLAGS=swig_flags)
3045341Sstever@gmail.com
3055341Sstever@gmail.com# filter out all existing swig scanners, they mess up the dependency
3065863Snate@binkert.org# stuff for some reason
3075341Sstever@gmail.comscanners = []
3086121Snate@binkert.orgfor scanner in env['SCANNERS']:
3094494Ssaidi@eecs.umich.edu    skeys = scanner.skeys
3106121Snate@binkert.org    if skeys == '.i':
3111105SN/A        continue
3122667Sstever@eecs.umich.edu
3132667Sstever@eecs.umich.edu    if isinstance(skeys, (list, tuple)) and '.i' in skeys:
3142667Sstever@eecs.umich.edu        continue
3152667Sstever@eecs.umich.edu
3166121Snate@binkert.org    scanners.append(scanner)
3172667Sstever@eecs.umich.edu
3185341Sstever@gmail.com# add the new swig scanner that we like better
3195863Snate@binkert.orgfrom SCons.Scanner import ClassicCPP as CPPScanner
3205341Sstever@gmail.comswig_inc_re = '^[ \t]*[%,#][ \t]*(?:include|import)[ \t]*(<|")([^>"]+)(>|")'
3215341Sstever@gmail.comscanners.append(CPPScanner("SwigScan", [ ".i" ], "CPPPATH", swig_inc_re))
3225341Sstever@gmail.com
3235863Snate@binkert.org# replace the scanners list that has what we want
3245341Sstever@gmail.comenv['SCANNERS'] = scanners
3255341Sstever@gmail.com
3265341Sstever@gmail.com# Platform-specific configuration.  Note again that we assume that all
3275863Snate@binkert.org# builds under a given build root run on the same host platform.
3285341Sstever@gmail.comconf = Configure(env,
3295341Sstever@gmail.com                 conf_dir = joinpath(build_root, '.scons_config'),
3305341Sstever@gmail.com                 log_file = joinpath(build_root, 'scons_config.log'))
3315341Sstever@gmail.com
3325341Sstever@gmail.com# Recent versions of scons substitute a "Null" object for Configure()
3335341Sstever@gmail.com# when configuration isn't necessary, e.g., if the "--help" option is
3345341Sstever@gmail.com# present.  Unfortuantely this Null object always returns false,
3355341Sstever@gmail.com# breaking all our configuration checks.  We replace it with our own
3365341Sstever@gmail.com# more optimistic null object that returns True instead.
3375341Sstever@gmail.comif not conf:
3385863Snate@binkert.org    def NullCheck(*args, **kwargs):
3395341Sstever@gmail.com        return True
3405863Snate@binkert.org
3415341Sstever@gmail.com    class NullConf:
3425863Snate@binkert.org        def __init__(self, env):
3436121Snate@binkert.org            self.env = env
3446121Snate@binkert.org        def Finish(self):
3455397Ssaidi@eecs.umich.edu            return self.env
3465397Ssaidi@eecs.umich.edu        def __getattr__(self, mname):
3475341Sstever@gmail.com            return NullCheck
3486168Snate@binkert.org
3496168Snate@binkert.org    conf = NullConf(env)
3506168Snate@binkert.org
3515341Sstever@gmail.com# Find Python include and library directories for embedding the
3525341Sstever@gmail.com# interpreter.  For consistency, we will use the same Python
3535341Sstever@gmail.com# installation used to run scons (and thus this script).  If you want
3545341Sstever@gmail.com# to link in an alternate version, see above for instructions on how
3555341Sstever@gmail.com# to invoke scons with a different copy of the Python interpreter.
3565863Snate@binkert.org
3575341Sstever@gmail.com# Get brief Python version name (e.g., "python2.4") for locating
3585341Sstever@gmail.com# include & library files
3596121Snate@binkert.orgpy_version_name = 'python' + sys.version[:3]
3605341Sstever@gmail.com
3616121Snate@binkert.org# include path, e.g. /usr/local/include/python2.4
3626121Snate@binkert.orgpy_header_path = joinpath(sys.exec_prefix, 'include', py_version_name)
3635341Sstever@gmail.comenv.Append(CPPPATH = py_header_path)
3645863Snate@binkert.org# verify that it works
3656121Snate@binkert.orgif not conf.CheckHeader('Python.h', '<>'):
3665341Sstever@gmail.com    print "Error: can't find Python.h header in", py_header_path
3675863Snate@binkert.org    Exit(1)
3685341Sstever@gmail.com
3696121Snate@binkert.org# add library path too if it's not in the default place
3706121Snate@binkert.orgpy_lib_path = None
3716121Snate@binkert.orgif sys.exec_prefix != '/usr':
3725742Snate@binkert.org    py_lib_path = joinpath(sys.exec_prefix, 'lib')
3735742Snate@binkert.orgelif sys.platform == 'cygwin':
3745341Sstever@gmail.com    # cygwin puts the .dll in /bin for some reason
3755742Snate@binkert.org    py_lib_path = '/bin'
3765742Snate@binkert.orgif py_lib_path:
3775341Sstever@gmail.com    env.Append(LIBPATH = py_lib_path)
3786017Snate@binkert.org    print 'Adding', py_lib_path, 'to LIBPATH for', py_version_name
3796121Snate@binkert.orgif not conf.CheckLib(py_version_name):
3806017Snate@binkert.org    print "Error: can't find Python library", py_version_name
3812632Sstever@eecs.umich.edu    Exit(1)
3826121Snate@binkert.org
3835871Snate@binkert.org# On Solaris you need to use libsocket for socket ops
3846121Snate@binkert.orgif not conf.CheckLibWithHeader(None, 'sys/socket.h', 'C++', 'accept(0,0,0);'):
3856121Snate@binkert.org   if not conf.CheckLibWithHeader('socket', 'sys/socket.h', 'C++', 'accept(0,0,0);'):
3865871Snate@binkert.org       print "Can't find library with socket calls (e.g. accept())"
3876121Snate@binkert.org       Exit(1)
3886121Snate@binkert.org
3896121Snate@binkert.org# Check for zlib.  If the check passes, libz will be automatically
3906121Snate@binkert.org# added to the LIBS environment variable.
3913940Ssaidi@eecs.umich.eduif not conf.CheckLibWithHeader('z', 'zlib.h', 'C++','zlibVersion();'):
3923918Ssaidi@eecs.umich.edu    print 'Error: did not find needed zlib compression library '\
3933918Ssaidi@eecs.umich.edu          'and/or zlib.h header file.'
3941858SN/A    print '       Please install zlib and try again.'
3956121Snate@binkert.org    Exit(1)
3966121Snate@binkert.org
3976121Snate@binkert.org# Check for <fenv.h> (C99 FP environment control)
3986143Snate@binkert.orghave_fenv = conf.CheckHeader('fenv.h', '<>')
3996121Snate@binkert.orgif not have_fenv:
4006121Snate@binkert.org    print "Warning: Header file <fenv.h> not found."
4013940Ssaidi@eecs.umich.edu    print "         This host has no IEEE FP rounding mode control."
4026121Snate@binkert.org
4036121Snate@binkert.org# Check for mysql.
4046121Snate@binkert.orgmysql_config = WhereIs('mysql_config')
4056121Snate@binkert.orghave_mysql = mysql_config != None
4066121Snate@binkert.org
4076121Snate@binkert.org# Check MySQL version.
4086121Snate@binkert.orgif have_mysql:
4093918Ssaidi@eecs.umich.edu    mysql_version = os.popen(mysql_config + ' --version').read()
4103918Ssaidi@eecs.umich.edu    min_mysql_version = '4.1'
4113940Ssaidi@eecs.umich.edu    if compare_versions(mysql_version, min_mysql_version) < 0:
4123918Ssaidi@eecs.umich.edu        print 'Warning: MySQL', min_mysql_version, 'or newer required.'
4133918Ssaidi@eecs.umich.edu        print '         Version', mysql_version, 'detected.'
4146157Snate@binkert.org        have_mysql = False
4156157Snate@binkert.org
4166157Snate@binkert.org# Set up mysql_config commands.
4176157Snate@binkert.orgif have_mysql:
4185397Ssaidi@eecs.umich.edu    mysql_config_include = mysql_config + ' --include'
4195397Ssaidi@eecs.umich.edu    if os.system(mysql_config_include + ' > /dev/null') != 0:
4206121Snate@binkert.org        # older mysql_config versions don't support --include, use
4216121Snate@binkert.org        # --cflags instead
4226121Snate@binkert.org        mysql_config_include = mysql_config + ' --cflags | sed s/\\\'//g'
4236121Snate@binkert.org    # This seems to work in all versions
4246121Snate@binkert.org    mysql_config_libs = mysql_config + ' --libs'
4256121Snate@binkert.org
4265397Ssaidi@eecs.umich.eduenv = conf.Finish()
4271851SN/A
4281851SN/A# Define the universe of supported ISAs
4296121Snate@binkert.orgall_isa_list = [ ]
430955SN/AExport('all_isa_list')
4313053Sstever@eecs.umich.edu
4326121Snate@binkert.org# Define the universe of supported CPU models
4333053Sstever@eecs.umich.eduall_cpu_list = [ ]
4343053Sstever@eecs.umich.edudefault_cpus = [ ]
4353053Sstever@eecs.umich.eduExport('all_cpu_list', 'default_cpus')
4363053Sstever@eecs.umich.edu
4373053Sstever@eecs.umich.edu# Sticky options get saved in the options file so they persist from
4385871Snate@binkert.org# one invocation to the next (unless overridden, in which case the new
4393053Sstever@eecs.umich.edu# value becomes sticky).
4404742Sstever@eecs.umich.edusticky_opts = Options(args=ARGUMENTS)
4414742Sstever@eecs.umich.eduExport('sticky_opts')
4423053Sstever@eecs.umich.edu
4433053Sstever@eecs.umich.edu# Non-sticky options only apply to the current build.
4443053Sstever@eecs.umich.edunonsticky_opts = Options(args=ARGUMENTS)
4453053Sstever@eecs.umich.eduExport('nonsticky_opts')
4463053Sstever@eecs.umich.edu
4473053Sstever@eecs.umich.edu# Walk the tree and execute all SConsopts scripts that wil add to the
4483053Sstever@eecs.umich.edu# above options
4493053Sstever@eecs.umich.edufor root, dirs, files in os.walk('.'):
4503053Sstever@eecs.umich.edu    if 'SConsopts' in files:
4512667Sstever@eecs.umich.edu        SConscript(os.path.join(root, 'SConsopts'))
4524554Sbinkertn@umich.edu
4536121Snate@binkert.orgall_isa_list.sort()
4542667Sstever@eecs.umich.eduall_cpu_list.sort()
4554554Sbinkertn@umich.edudefault_cpus.sort()
4564554Sbinkertn@umich.edu
4574554Sbinkertn@umich.edudef ExtraPathValidator(key, val, env):
4586121Snate@binkert.org    if not val:
4594554Sbinkertn@umich.edu        return
4604554Sbinkertn@umich.edu    paths = val.split(':')
4614554Sbinkertn@umich.edu    for path in paths:
4624781Snate@binkert.org        path = os.path.expanduser(path)
4634554Sbinkertn@umich.edu        if not isdir(path):
4644554Sbinkertn@umich.edu            raise AttributeError, "Invalid path: '%s'" % path
4652667Sstever@eecs.umich.edu
4664554Sbinkertn@umich.edusticky_opts.AddOptions(
4674554Sbinkertn@umich.edu    EnumOption('TARGET_ISA', 'Target ISA', 'alpha', all_isa_list),
4684554Sbinkertn@umich.edu    BoolOption('FULL_SYSTEM', 'Full-system support', False),
4694554Sbinkertn@umich.edu    # There's a bug in scons 0.96.1 that causes ListOptions with list
4702667Sstever@eecs.umich.edu    # values (more than one value) not to be able to be restored from
4714554Sbinkertn@umich.edu    # a saved option file.  If this causes trouble then upgrade to
4722667Sstever@eecs.umich.edu    # scons 0.96.90 or later.
4734554Sbinkertn@umich.edu    ListOption('CPU_MODELS', 'CPU models', default_cpus, all_cpu_list),
4746121Snate@binkert.org    BoolOption('NO_FAST_ALLOC', 'Disable fast object allocator', False),
4752667Sstever@eecs.umich.edu    BoolOption('EFENCE', 'Link with Electric Fence malloc debugger',
4765522Snate@binkert.org               False),
4775522Snate@binkert.org    BoolOption('SS_COMPATIBLE_FP',
4785522Snate@binkert.org               'Make floating-point results compatible with SimpleScalar',
4795522Snate@binkert.org               False),
4805522Snate@binkert.org    BoolOption('USE_SSE2',
4815522Snate@binkert.org               'Compile for SSE2 (-msse2) to get IEEE FP on x86 hosts',
4825522Snate@binkert.org               False),
4835522Snate@binkert.org    BoolOption('USE_MYSQL', 'Use MySQL for stats output', have_mysql),
4845522Snate@binkert.org    BoolOption('USE_FENV', 'Use <fenv.h> IEEE mode control', have_fenv),
4855522Snate@binkert.org    BoolOption('USE_CHECKER', 'Use checker for detailed CPU models', False),
4865522Snate@binkert.org    ('CC', 'C compiler', os.environ.get('CC', env['CC'])),
4875522Snate@binkert.org    ('CXX', 'C++ compiler', os.environ.get('CXX', env['CXX'])),
4885522Snate@binkert.org    BoolOption('BATCH', 'Use batch pool for build and tests', False),
4895522Snate@binkert.org    ('BATCH_CMD', 'Batch pool submission command name', 'qdo'),
4905522Snate@binkert.org    ('PYTHONHOME',
4915522Snate@binkert.org     'Override the default PYTHONHOME for this system (use with caution)',
4925522Snate@binkert.org     '%s:%s' % (sys.prefix, sys.exec_prefix)),
4935522Snate@binkert.org    ('EXTRAS', 'Add Extra directories to the compilation', '',
4945522Snate@binkert.org     ExtraPathValidator)
4955522Snate@binkert.org    )
4965522Snate@binkert.org
4975522Snate@binkert.orgnonsticky_opts.AddOptions(
4985522Snate@binkert.org    BoolOption('update_ref', 'Update test reference outputs', False)
4995522Snate@binkert.org    )
5005522Snate@binkert.org
5015522Snate@binkert.org# These options get exported to #defines in config/*.hh (see src/SConscript).
5022638Sstever@eecs.umich.eduenv.ExportOptions = ['FULL_SYSTEM', 'ALPHA_TLASER', 'USE_FENV', \
5032638Sstever@eecs.umich.edu                     'USE_MYSQL', 'NO_FAST_ALLOC', 'SS_COMPATIBLE_FP', \
5046121Snate@binkert.org                     'USE_CHECKER', 'PYTHONHOME', 'TARGET_ISA']
5053716Sstever@eecs.umich.edu
5065522Snate@binkert.org# Define a handy 'no-op' action
5075522Snate@binkert.orgdef no_action(target, source, env):
5085522Snate@binkert.org    return 0
5095522Snate@binkert.org
5105522Snate@binkert.orgenv.NoAction = Action(no_action, None)
5115522Snate@binkert.org
5121858SN/A###################################################
5135227Ssaidi@eecs.umich.edu#
5145227Ssaidi@eecs.umich.edu# Define a SCons builder for configuration flag headers.
5155227Ssaidi@eecs.umich.edu#
5165227Ssaidi@eecs.umich.edu###################################################
5175227Ssaidi@eecs.umich.edu
5185863Snate@binkert.org# This function generates a config header file that #defines the
5196121Snate@binkert.org# option symbol to the current option setting (0 or 1).  The source
5206121Snate@binkert.org# operands are the name of the option and a Value node containing the
5216121Snate@binkert.org# value of the option.
5226121Snate@binkert.orgdef build_config_file(target, source, env):
5235227Ssaidi@eecs.umich.edu    (option, value) = [s.get_contents() for s in source]
5245227Ssaidi@eecs.umich.edu    f = file(str(target[0]), 'w')
5255227Ssaidi@eecs.umich.edu    print >> f, '#define', option, value
5265204Sstever@gmail.com    f.close()
5275204Sstever@gmail.com    return None
5285204Sstever@gmail.com
5295204Sstever@gmail.com# Generate the message to be printed when building the config file.
5305204Sstever@gmail.comdef build_config_file_string(target, source, env):
5315204Sstever@gmail.com    (option, value) = [s.get_contents() for s in source]
5325204Sstever@gmail.com    return "Defining %s as %s in %s." % (option, value, target[0])
5335204Sstever@gmail.com
5345204Sstever@gmail.com# Combine the two functions into a scons Action object.
5355204Sstever@gmail.comconfig_action = Action(build_config_file, build_config_file_string)
5365204Sstever@gmail.com
5375204Sstever@gmail.com# The emitter munges the source & target node lists to reflect what
5385204Sstever@gmail.com# we're really doing.
5395204Sstever@gmail.comdef config_emitter(target, source, env):
5405204Sstever@gmail.com    # extract option name from Builder arg
5415204Sstever@gmail.com    option = str(target[0])
5425204Sstever@gmail.com    # True target is config header file
5436121Snate@binkert.org    target = joinpath('config', option.lower() + '.hh')
5445204Sstever@gmail.com    val = env[option]
5453118Sstever@eecs.umich.edu    if isinstance(val, bool):
5463118Sstever@eecs.umich.edu        # Force value to 0/1
5473118Sstever@eecs.umich.edu        val = int(val)
5483118Sstever@eecs.umich.edu    elif isinstance(val, str):
5493118Sstever@eecs.umich.edu        val = '"' + val + '"'
5505863Snate@binkert.org
5513118Sstever@eecs.umich.edu    # Sources are option name & value (packaged in SCons Value nodes)
5525863Snate@binkert.org    return ([target], [Value(option), Value(val)])
5533118Sstever@eecs.umich.edu
5545863Snate@binkert.orgconfig_builder = Builder(emitter = config_emitter, action = config_action)
5555863Snate@binkert.org
5565863Snate@binkert.orgenv.Append(BUILDERS = { 'ConfigFile' : config_builder })
5575863Snate@binkert.org
5585863Snate@binkert.org###################################################
5595863Snate@binkert.org#
5605863Snate@binkert.org# Define a SCons builder for copying files.  This is used by the
5615863Snate@binkert.org# Python zipfile code in src/python/SConscript, but is placed up here
5626003Snate@binkert.org# since it's potentially more generally applicable.
5635863Snate@binkert.org#
5645863Snate@binkert.org###################################################
5655863Snate@binkert.org
5666120Snate@binkert.orgcopy_builder = Builder(action = Copy("$TARGET", "$SOURCE"))
5675863Snate@binkert.org
5685863Snate@binkert.orgenv.Append(BUILDERS = { 'CopyFile' : copy_builder })
5695863Snate@binkert.org
5706120Snate@binkert.org###################################################
5716120Snate@binkert.org#
5725863Snate@binkert.org# Define a simple SCons builder to concatenate files.
5735863Snate@binkert.org#
5746120Snate@binkert.org# Used to append the Python zip archive to the executable.
5755863Snate@binkert.org#
5766121Snate@binkert.org###################################################
5776121Snate@binkert.org
5785863Snate@binkert.orgconcat_builder = Builder(action = Action(['cat $SOURCES > $TARGET',
5795863Snate@binkert.org                                          'chmod +x $TARGET']))
5803118Sstever@eecs.umich.edu
5815863Snate@binkert.orgenv.Append(BUILDERS = { 'Concat' : concat_builder })
5823118Sstever@eecs.umich.edu
5833118Sstever@eecs.umich.edu
5845863Snate@binkert.org# base help text
5855863Snate@binkert.orghelp_text = '''
5865863Snate@binkert.orgUsage: scons [scons options] [build options] [target(s)]
5875863Snate@binkert.org
5883118Sstever@eecs.umich.edu'''
5893483Ssaidi@eecs.umich.edu
5903494Ssaidi@eecs.umich.edu# libelf build is shared across all configs in the build root.
5913494Ssaidi@eecs.umich.eduenv.SConscript('ext/libelf/SConscript',
5923483Ssaidi@eecs.umich.edu               build_dir = joinpath(build_root, 'libelf'),
5933483Ssaidi@eecs.umich.edu               exports = 'env')
5943483Ssaidi@eecs.umich.edu
5953053Sstever@eecs.umich.edu###################################################
5963053Sstever@eecs.umich.edu#
5973918Ssaidi@eecs.umich.edu# This function is used to set up a directory with switching headers
5983053Sstever@eecs.umich.edu#
5993053Sstever@eecs.umich.edu###################################################
6003053Sstever@eecs.umich.edu
6013053Sstever@eecs.umich.eduenv['ALL_ISA_LIST'] = all_isa_list
6023053Sstever@eecs.umich.edudef make_switching_dir(dirname, switch_headers, env):
6031858SN/A    # Generate the header.  target[0] is the full path of the output
6041858SN/A    # header to generate.  'source' is a dummy variable, since we get the
6051858SN/A    # list of ISAs from env['ALL_ISA_LIST'].
6061858SN/A    def gen_switch_hdr(target, source, env):
6071858SN/A        fname = str(target[0])
6081858SN/A        basename = os.path.basename(fname)
6095863Snate@binkert.org        f = open(fname, 'w')
6105863Snate@binkert.org        f.write('#include "arch/isa_specific.hh"\n')
6111859SN/A        cond = '#if'
6125863Snate@binkert.org        for isa in all_isa_list:
6131858SN/A            f.write('%s THE_ISA == %s_ISA\n#include "%s/%s/%s"\n'
6145863Snate@binkert.org                    % (cond, isa.upper(), dirname, isa, basename))
6151858SN/A            cond = '#elif'
6161859SN/A        f.write('#else\n#error "THE_ISA not set"\n#endif\n')
6171859SN/A        f.close()
6185863Snate@binkert.org        return 0
6193053Sstever@eecs.umich.edu
6203053Sstever@eecs.umich.edu    # String to print when generating header
6213053Sstever@eecs.umich.edu    def gen_switch_hdr_string(target, source, env):
6223053Sstever@eecs.umich.edu        return "Generating switch header " + str(target[0])
6231859SN/A
6241859SN/A    # Build SCons Action object. 'varlist' specifies env vars that this
6251859SN/A    # action depends on; when env['ALL_ISA_LIST'] changes these actions
6261859SN/A    # should get re-executed.
6271859SN/A    switch_hdr_action = Action(gen_switch_hdr, gen_switch_hdr_string,
6281859SN/A                               varlist=['ALL_ISA_LIST'])
6291859SN/A
6301859SN/A    # Instantiate actions for each header
6311862SN/A    for hdr in switch_headers:
6321859SN/A        env.Command(hdr, [], switch_hdr_action)
6331859SN/AExport('make_switching_dir')
6341859SN/A
6355863Snate@binkert.org###################################################
6365863Snate@binkert.org#
6375863Snate@binkert.org# Define build environments for selected configurations.
6385863Snate@binkert.org#
6396121Snate@binkert.org###################################################
6401858SN/A
6415863Snate@binkert.org# rename base env
6425863Snate@binkert.orgbase_env = env
6435863Snate@binkert.org
6445863Snate@binkert.orgfor build_path in build_paths:
6455863Snate@binkert.org    print "Building in", build_path
6462139SN/A    env['BUILDDIR'] = build_path
6474202Sbinkertn@umich.edu
6484202Sbinkertn@umich.edu    # build_dir is the tail component of build path, and is used to
6492139SN/A    # determine the build parameters (e.g., 'ALPHA_SE')
6502155SN/A    (build_root, build_dir) = os.path.split(build_path)
6514202Sbinkertn@umich.edu    # Make a copy of the build-root environment to use for this config.
6524202Sbinkertn@umich.edu    env = base_env.Copy()
6534202Sbinkertn@umich.edu
6542155SN/A    # Set env options according to the build directory config.
6555863Snate@binkert.org    sticky_opts.files = []
6561869SN/A    # Options for $BUILD_ROOT/$BUILD_DIR are stored in
6571869SN/A    # $BUILD_ROOT/options/$BUILD_DIR so you can nuke
6585863Snate@binkert.org    # $BUILD_ROOT/$BUILD_DIR without losing your options settings.
6595863Snate@binkert.org    current_opts_file = joinpath(build_root, 'options', build_dir)
6604202Sbinkertn@umich.edu    if os.path.isfile(current_opts_file):
6616108Snate@binkert.org        sticky_opts.files.append(current_opts_file)
6626108Snate@binkert.org        print "Using saved options file %s" % current_opts_file
6636108Snate@binkert.org    else:
6646108Snate@binkert.org        # Build dir-specific options file doesn't exist.
6655863Snate@binkert.org
6665863Snate@binkert.org        # Make sure the directory is there so we can create it later
6675863Snate@binkert.org        opt_dir = os.path.dirname(current_opts_file)
6684202Sbinkertn@umich.edu        if not os.path.isdir(opt_dir):
6694202Sbinkertn@umich.edu            os.mkdir(opt_dir)
6705863Snate@binkert.org
6715742Snate@binkert.org        # Get default build options from source tree.  Options are
6725742Snate@binkert.org        # normally determined by name of $BUILD_DIR, but can be
6735341Sstever@gmail.com        # overriden by 'default=' arg on command line.
6745342Sstever@gmail.com        default_opts_file = joinpath('build_opts',
6755342Sstever@gmail.com                                     ARGUMENTS.get('default', build_dir))
6764202Sbinkertn@umich.edu        if os.path.isfile(default_opts_file):
6774202Sbinkertn@umich.edu            sticky_opts.files.append(default_opts_file)
6784202Sbinkertn@umich.edu            print "Options file %s not found,\n  using defaults in %s" \
6794202Sbinkertn@umich.edu                  % (current_opts_file, default_opts_file)
6804202Sbinkertn@umich.edu        else:
6815863Snate@binkert.org            print "Error: cannot find options file %s or %s" \
6825863Snate@binkert.org                  % (current_opts_file, default_opts_file)
6835863Snate@binkert.org            Exit(1)
6845863Snate@binkert.org
6855863Snate@binkert.org    # Apply current option settings to env
6865863Snate@binkert.org    sticky_opts.Update(env)
6875863Snate@binkert.org    nonsticky_opts.Update(env)
6885863Snate@binkert.org
6895863Snate@binkert.org    help_text += "Sticky options for %s:\n" % build_dir \
6905863Snate@binkert.org                 + sticky_opts.GenerateHelpText(env) \
6915863Snate@binkert.org                 + "\nNon-sticky options for %s:\n" % build_dir \
6925863Snate@binkert.org                 + nonsticky_opts.GenerateHelpText(env)
6935863Snate@binkert.org
6945863Snate@binkert.org    # Process option settings.
6955863Snate@binkert.org
6965863Snate@binkert.org    if not have_fenv and env['USE_FENV']:
6975863Snate@binkert.org        print "Warning: <fenv.h> not available; " \
6985863Snate@binkert.org              "forcing USE_FENV to False in", build_dir + "."
6995863Snate@binkert.org        env['USE_FENV'] = False
7005863Snate@binkert.org
7015952Ssaidi@eecs.umich.edu    if not env['USE_FENV']:
7021869SN/A        print "Warning: No IEEE FP rounding mode control in", build_dir + "."
7031858SN/A        print "         FP results may deviate slightly from other platforms."
7045863Snate@binkert.org
7055863Snate@binkert.org    if env['EFENCE']:
7061869SN/A        env.Append(LIBS=['efence'])
7071858SN/A
7085863Snate@binkert.org    if env['USE_MYSQL']:
7096108Snate@binkert.org        if not have_mysql:
7106108Snate@binkert.org            print "Warning: MySQL not available; " \
7116108Snate@binkert.org                  "forcing USE_MYSQL to False in", build_dir + "."
7121858SN/A            env['USE_MYSQL'] = False
713955SN/A        else:
714955SN/A            print "Compiling in", build_dir, "with MySQL support."
7151869SN/A            env.ParseConfig(mysql_config_libs)
7161869SN/A            env.ParseConfig(mysql_config_include)
7171869SN/A
7181869SN/A    # Save sticky option settings back to current options file
7191869SN/A    sticky_opts.Save(current_opts_file, env)
7205863Snate@binkert.org
7215863Snate@binkert.org    # Do this after we save setting back, or else we'll tack on an
7225863Snate@binkert.org    # extra 'qdo' every time we run scons.
7231869SN/A    if env['BATCH']:
7245863Snate@binkert.org        env['CC']  = env['BATCH_CMD'] + ' ' + env['CC']
7251869SN/A        env['CXX'] = env['BATCH_CMD'] + ' ' + env['CXX']
7265863Snate@binkert.org
7271869SN/A    if env['USE_SSE2']:
7281869SN/A        env.Append(CCFLAGS='-msse2')
7291869SN/A
7301869SN/A    # The src/SConscript file sets up the build rules in 'env' according
7311869SN/A    # to the configured options.  It returns a list of environments,
7325863Snate@binkert.org    # one for each variant build (debug, opt, etc.)
7335863Snate@binkert.org    envList = SConscript('src/SConscript', build_dir = build_path,
7341869SN/A                         exports = 'env')
7351869SN/A
7361869SN/A    # Set up the regression tests for each build.
7371869SN/A    for e in envList:
7381869SN/A        SConscript('tests/SConscript',
7391869SN/A                   build_dir = joinpath(build_path, 'tests', e.Label),
7401869SN/A                   exports = { 'env' : e }, duplicate = False)
7415863Snate@binkert.org
7425863Snate@binkert.orgHelp(help_text)
7431869SN/A
7445863Snate@binkert.org
7455863Snate@binkert.org###################################################
7463356Sbinkertn@umich.edu#
7473356Sbinkertn@umich.edu# Let SCons do its thing.  At this point SCons will use the defined
7483356Sbinkertn@umich.edu# build environments to build the requested targets.
7493356Sbinkertn@umich.edu#
7503356Sbinkertn@umich.edu###################################################
7514781Snate@binkert.org
7525863Snate@binkert.org