SConstruct revision 8483
1955SN/A# -*- mode:python -*-
2955SN/A
39812Sandreas.hansson@arm.com# Copyright (c) 2011 Advanced Micro Devices, Inc.
49812Sandreas.hansson@arm.com# Copyright (c) 2009 The Hewlett-Packard Development Company
59812Sandreas.hansson@arm.com# Copyright (c) 2004-2005 The Regents of The University of Michigan
69812Sandreas.hansson@arm.com# All rights reserved.
79812Sandreas.hansson@arm.com#
89812Sandreas.hansson@arm.com# Redistribution and use in source and binary forms, with or without
99812Sandreas.hansson@arm.com# modification, are permitted provided that the following conditions are
109812Sandreas.hansson@arm.com# met: redistributions of source code must retain the above copyright
119812Sandreas.hansson@arm.com# notice, this list of conditions and the following disclaimer;
129812Sandreas.hansson@arm.com# redistributions in binary form must reproduce the above copyright
139812Sandreas.hansson@arm.com# notice, this list of conditions and the following disclaimer in the
149812Sandreas.hansson@arm.com# documentation and/or other materials provided with the distribution;
157816Ssteve.reinhardt@amd.com# neither the name of the copyright holders nor the names of its
165871Snate@binkert.org# contributors may be used to endorse or promote products derived from
171762SN/A# this software without specific prior written permission.
18955SN/A#
19955SN/A# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20955SN/A# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21955SN/A# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22955SN/A# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23955SN/A# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24955SN/A# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25955SN/A# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26955SN/A# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27955SN/A# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28955SN/A# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29955SN/A# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30955SN/A#
31955SN/A# Authors: Steve Reinhardt
32955SN/A#          Nathan Binkert
33955SN/A
34955SN/A###################################################
35955SN/A#
36955SN/A# SCons top-level build description (SConstruct) file.
37955SN/A#
38955SN/A# While in this directory ('m5'), just type 'scons' to build the default
39955SN/A# configuration (see below), or type 'scons build/<CONFIG>/<binary>'
40955SN/A# to build some other configuration (e.g., 'build/ALPHA_FS/m5.opt' for
41955SN/A# the optimized full-system version).
422665Ssaidi@eecs.umich.edu#
432665Ssaidi@eecs.umich.edu# You can build M5 in a different directory as long as there is a
445863Snate@binkert.org# 'build/<CONFIG>' somewhere along the target path.  The build system
45955SN/A# expects that all configs under the same build directory are being
46955SN/A# built for the same host system.
47955SN/A#
48955SN/A# Examples:
49955SN/A#
508878Ssteve.reinhardt@amd.com#   The following two commands are equivalent.  The '-u' option tells
512632Sstever@eecs.umich.edu#   scons to search up the directory tree for this SConstruct file.
528878Ssteve.reinhardt@amd.com#   % cd <path-to-src>/m5 ; scons build/ALPHA_FS/m5.debug
532632Sstever@eecs.umich.edu#   % cd <path-to-src>/m5/build/ALPHA_FS; scons -u m5.debug
54955SN/A#
558878Ssteve.reinhardt@amd.com#   The following two commands are equivalent and demonstrate building
562632Sstever@eecs.umich.edu#   in a directory outside of the source tree.  The '-C' option tells
572761Sstever@eecs.umich.edu#   scons to chdir to the specified directory to find this SConstruct
582632Sstever@eecs.umich.edu#   file.
592632Sstever@eecs.umich.edu#   % cd <path-to-src>/m5 ; scons /local/foo/build/ALPHA_FS/m5.debug
602632Sstever@eecs.umich.edu#   % cd /local/foo/build/ALPHA_FS; scons -C <path-to-src>/m5 m5.debug
612761Sstever@eecs.umich.edu#
622761Sstever@eecs.umich.edu# You can use 'scons -H' to print scons options.  If you're in this
632761Sstever@eecs.umich.edu# 'm5' directory (or use -u or -C to tell scons where to find this
648878Ssteve.reinhardt@amd.com# file), you can use 'scons -h' to print all the M5-specific build
658878Ssteve.reinhardt@amd.com# options as well.
662761Sstever@eecs.umich.edu#
672761Sstever@eecs.umich.edu###################################################
682761Sstever@eecs.umich.edu
692761Sstever@eecs.umich.edu# Check for recent-enough Python and SCons versions.
702761Sstever@eecs.umich.edutry:
718878Ssteve.reinhardt@amd.com    # Really old versions of scons only take two options for the
728878Ssteve.reinhardt@amd.com    # function, so check once without the revision and once with the
732632Sstever@eecs.umich.edu    # revision, the first instance will fail for stuff other than
742632Sstever@eecs.umich.edu    # 0.98, and the second will fail for 0.98.0
758878Ssteve.reinhardt@amd.com    EnsureSConsVersion(0, 98)
768878Ssteve.reinhardt@amd.com    EnsureSConsVersion(0, 98, 1)
772632Sstever@eecs.umich.eduexcept SystemExit, e:
78955SN/A    print """
79955SN/AFor more details, see:
80955SN/A    http://m5sim.org/wiki/index.php/Compiling_M5
815863Snate@binkert.org"""
825863Snate@binkert.org    raise
835863Snate@binkert.org
845863Snate@binkert.org# We ensure the python version early because we have stuff that
855863Snate@binkert.org# requires python 2.4
865863Snate@binkert.orgtry:
875863Snate@binkert.org    EnsurePythonVersion(2, 4)
885863Snate@binkert.orgexcept SystemExit, e:
895863Snate@binkert.org    print """
905863Snate@binkert.orgYou can use a non-default installation of the Python interpreter by
915863Snate@binkert.orgeither (1) rearranging your PATH so that scons finds the non-default
928878Ssteve.reinhardt@amd.com'python' first or (2) explicitly invoking an alternative interpreter
935863Snate@binkert.orgon the scons script.
945863Snate@binkert.org
955863Snate@binkert.orgFor more details, see:
969812Sandreas.hansson@arm.com    http://m5sim.org/wiki/index.php/Using_a_non-default_Python_installation
979812Sandreas.hansson@arm.com"""
985863Snate@binkert.org    raise
999812Sandreas.hansson@arm.com
1005863Snate@binkert.org# Global Python includes
1015863Snate@binkert.orgimport os
1025863Snate@binkert.orgimport re
1039812Sandreas.hansson@arm.comimport subprocess
1049812Sandreas.hansson@arm.comimport sys
1055863Snate@binkert.org
1065863Snate@binkert.orgfrom os import mkdir, environ
1078878Ssteve.reinhardt@amd.comfrom os.path import abspath, basename, dirname, expanduser, normpath
1085863Snate@binkert.orgfrom os.path import exists,  isdir, isfile
1095863Snate@binkert.orgfrom os.path import join as joinpath, split as splitpath
1105863Snate@binkert.org
1116654Snate@binkert.org# SCons includes
112955SN/Aimport SCons
1135396Ssaidi@eecs.umich.eduimport SCons.Node
1145863Snate@binkert.org
1155863Snate@binkert.orgextra_python_paths = [
1164202Sbinkertn@umich.edu    Dir('src/python').srcnode().abspath, # M5 includes
1175863Snate@binkert.org    Dir('ext/ply').srcnode().abspath, # ply is used by several files
1185863Snate@binkert.org    ]
1195863Snate@binkert.org    
1205863Snate@binkert.orgsys.path[1:1] = extra_python_paths
121955SN/A
1226654Snate@binkert.orgfrom m5.util import compareVersions, readCommand
1235273Sstever@gmail.com
1245871Snate@binkert.orghelp_texts = {
1255273Sstever@gmail.com    "options" : "",
1266655Snate@binkert.org    "global_vars" : "",
1278878Ssteve.reinhardt@amd.com    "local_vars" : ""
1286655Snate@binkert.org}
1296655Snate@binkert.org
1309219Spower.jg@gmail.comExport("help_texts")
1316655Snate@binkert.org
1325871Snate@binkert.orgdef AddM5Option(*args, **kwargs):
1336654Snate@binkert.org    col_width = 30
1348947Sandreas.hansson@arm.com
1355396Ssaidi@eecs.umich.edu    help = "  " + ", ".join(args)
1368120Sgblack@eecs.umich.edu    if "help" in kwargs:
1378120Sgblack@eecs.umich.edu        length = len(help)
1388120Sgblack@eecs.umich.edu        if length >= col_width:
1398120Sgblack@eecs.umich.edu            help += "\n" + " " * col_width
1408120Sgblack@eecs.umich.edu        else:
1418120Sgblack@eecs.umich.edu            help += " " * (col_width - length)
1428120Sgblack@eecs.umich.edu        help += kwargs["help"]
1438120Sgblack@eecs.umich.edu    help_texts["options"] += help + "\n"
1448879Ssteve.reinhardt@amd.com
1458879Ssteve.reinhardt@amd.com    AddOption(*args, **kwargs)
1468879Ssteve.reinhardt@amd.com
1478879Ssteve.reinhardt@amd.comAddM5Option('--colors', dest='use_colors', action='store_true',
1488879Ssteve.reinhardt@amd.com            help="Add color to abbreviated scons output")
1498879Ssteve.reinhardt@amd.comAddM5Option('--no-colors', dest='use_colors', action='store_false',
1508879Ssteve.reinhardt@amd.com            help="Don't add color to abbreviated scons output")
1518879Ssteve.reinhardt@amd.comAddM5Option('--default', dest='default', type='string', action='store',
1528879Ssteve.reinhardt@amd.com            help='Override which build_opts file to use for defaults')
1538879Ssteve.reinhardt@amd.comAddM5Option('--ignore-style', dest='ignore_style', action='store_true',
1548879Ssteve.reinhardt@amd.com            help='Disable style checking hooks')
1558879Ssteve.reinhardt@amd.comAddM5Option('--update-ref', dest='update_ref', action='store_true',
1568879Ssteve.reinhardt@amd.com            help='Update test reference outputs')
1578120Sgblack@eecs.umich.eduAddM5Option('--verbose', dest='verbose', action='store_true',
1588120Sgblack@eecs.umich.edu            help='Print full tool command lines')
1598120Sgblack@eecs.umich.edu
1608120Sgblack@eecs.umich.eduuse_colors = GetOption('use_colors')
1618120Sgblack@eecs.umich.eduif use_colors:
1628120Sgblack@eecs.umich.edu    from m5.util.terminal import termcap
1638120Sgblack@eecs.umich.eduelif use_colors is None:
1648120Sgblack@eecs.umich.edu    # option unspecified; default behavior is to use colors iff isatty
1658120Sgblack@eecs.umich.edu    from m5.util.terminal import tty_termcap as termcap
1668120Sgblack@eecs.umich.eduelse:
1678120Sgblack@eecs.umich.edu    from m5.util.terminal import no_termcap as termcap
1688120Sgblack@eecs.umich.edu
1698120Sgblack@eecs.umich.edu########################################################################
1708120Sgblack@eecs.umich.edu#
1718879Ssteve.reinhardt@amd.com# Set up the main build environment.
1728879Ssteve.reinhardt@amd.com#
1738879Ssteve.reinhardt@amd.com########################################################################
1748879Ssteve.reinhardt@amd.comuse_vars = set([ 'AS', 'AR', 'CC', 'CXX', 'HOME', 'LD_LIBRARY_PATH', 'PATH',
1758879Ssteve.reinhardt@amd.com                 'PYTHONPATH', 'RANLIB' ])
1768879Ssteve.reinhardt@amd.com
1778879Ssteve.reinhardt@amd.comuse_env = {}
1788879Ssteve.reinhardt@amd.comfor key,val in os.environ.iteritems():
1799227Sandreas.hansson@arm.com    if key in use_vars or key.startswith("M5"):
1809227Sandreas.hansson@arm.com        use_env[key] = val
1818879Ssteve.reinhardt@amd.com
1828879Ssteve.reinhardt@amd.commain = Environment(ENV=use_env)
1838879Ssteve.reinhardt@amd.commain.root = Dir(".")         # The current directory (where this file lives).
1848879Ssteve.reinhardt@amd.commain.srcdir = Dir("src")     # The source directory
1858120Sgblack@eecs.umich.edu
1868947Sandreas.hansson@arm.com# add useful python code PYTHONPATH so it can be used by subprocesses
1877816Ssteve.reinhardt@amd.com# as well
1885871Snate@binkert.orgmain.AppendENVPath('PYTHONPATH', extra_python_paths)
1895871Snate@binkert.org
1906121Snate@binkert.org########################################################################
1915871Snate@binkert.org#
1925871Snate@binkert.org# Mercurial Stuff.
1939926Sstan.czerniawski@arm.com#
1949926Sstan.czerniawski@arm.com# If the M5 directory is a mercurial repository, we should do some
1959119Sandreas.hansson@arm.com# extra things.
1969396Sandreas.hansson@arm.com#
1979926Sstan.czerniawski@arm.com########################################################################
198955SN/A
1999416SAndreas.Sandberg@ARM.comhgdir = main.root.Dir(".hg")
2009416SAndreas.Sandberg@ARM.com
2019416SAndreas.Sandberg@ARM.commercurial_style_message = """
2029416SAndreas.Sandberg@ARM.comYou're missing the gem5 style hook, which automatically checks your code
2039416SAndreas.Sandberg@ARM.comagainst the gem5 style rules on hg commit and qrefresh commands.  This
2049416SAndreas.Sandberg@ARM.comscript will now install the hook in your .hg/hgrc file.
2059416SAndreas.Sandberg@ARM.comPress enter to continue, or ctrl-c to abort: """
2065871Snate@binkert.org
2075871Snate@binkert.orgmercurial_style_hook = """
2089416SAndreas.Sandberg@ARM.com# The following lines were automatically added by gem5/SConstruct
2099416SAndreas.Sandberg@ARM.com# to provide the gem5 style-checking hooks
2105871Snate@binkert.org[extensions]
211955SN/Astyle = %s/util/style.py
2126121Snate@binkert.org
2138881Smarc.orr@gmail.com[hooks]
2146121Snate@binkert.orgpretxncommit.style = python:style.check_style
2156121Snate@binkert.orgpre-qrefresh.style = python:style.check_style
2161533SN/A# End of SConstruct additions
2179239Sandreas.hansson@arm.com
2189239Sandreas.hansson@arm.com""" % (main.root.abspath)
2199239Sandreas.hansson@arm.com
2209239Sandreas.hansson@arm.commercurial_lib_not_found = """
2219239Sandreas.hansson@arm.comMercurial libraries cannot be found, ignoring style hook.  If
2229239Sandreas.hansson@arm.comyou are a gem5 developer, please fix this and run the style
2239239Sandreas.hansson@arm.comhook. It is important.
2249239Sandreas.hansson@arm.com"""
2259239Sandreas.hansson@arm.com
2269239Sandreas.hansson@arm.com# Check for style hook and prompt for installation if it's not there.
2279239Sandreas.hansson@arm.com# Skip this if --ignore-style was specified, there's no .hg dir to
2289239Sandreas.hansson@arm.com# install a hook in, or there's no interactive terminal to prompt.
2296655Snate@binkert.orgif not GetOption('ignore_style') and hgdir.exists() and sys.stdin.isatty():
2306655Snate@binkert.org    style_hook = True
2316655Snate@binkert.org    try:
2326655Snate@binkert.org        from mercurial import ui
2335871Snate@binkert.org        ui = ui.ui()
2345871Snate@binkert.org        ui.readconfig(hgdir.File('hgrc').abspath)
2355863Snate@binkert.org        style_hook = ui.config('hooks', 'pretxncommit.style', None) and \
2365871Snate@binkert.org                     ui.config('hooks', 'pre-qrefresh.style', None)
2378878Ssteve.reinhardt@amd.com    except ImportError:
2385871Snate@binkert.org        print mercurial_lib_not_found
2395871Snate@binkert.org
2405871Snate@binkert.org    if not style_hook:
2415863Snate@binkert.org        print mercurial_style_message,
2426121Snate@binkert.org        # continue unless user does ctrl-c/ctrl-d etc.
2435863Snate@binkert.org        try:
2445871Snate@binkert.org            raw_input()
2458336Ssteve.reinhardt@amd.com        except:
2468336Ssteve.reinhardt@amd.com            print "Input exception, exiting scons.\n"
2478336Ssteve.reinhardt@amd.com            sys.exit(1)
2488336Ssteve.reinhardt@amd.com        hgrc_path = '%s/.hg/hgrc' % main.root.abspath
2494678Snate@binkert.org        print "Adding style hook to", hgrc_path, "\n"
2508336Ssteve.reinhardt@amd.com        try:
2518336Ssteve.reinhardt@amd.com            hgrc = open(hgrc_path, 'a')
2528336Ssteve.reinhardt@amd.com            hgrc.write(mercurial_style_hook)
2534678Snate@binkert.org            hgrc.close()
2544678Snate@binkert.org        except:
2554678Snate@binkert.org            print "Error updating", hgrc_path
2564678Snate@binkert.org            sys.exit(1)
2577827Snate@binkert.org
2587827Snate@binkert.org
2598336Ssteve.reinhardt@amd.com###################################################
2604678Snate@binkert.org#
2618336Ssteve.reinhardt@amd.com# Figure out which configurations to set up based on the path(s) of
2628336Ssteve.reinhardt@amd.com# the target(s).
2638336Ssteve.reinhardt@amd.com#
2648336Ssteve.reinhardt@amd.com###################################################
2658336Ssteve.reinhardt@amd.com
2668336Ssteve.reinhardt@amd.com# Find default configuration & binary.
2675871Snate@binkert.orgDefault(environ.get('M5_DEFAULT_BINARY', 'build/ALPHA_SE/m5.debug'))
2685871Snate@binkert.org
2698336Ssteve.reinhardt@amd.com# helper function: find last occurrence of element in list
2708336Ssteve.reinhardt@amd.comdef rfind(l, elt, offs = -1):
2718336Ssteve.reinhardt@amd.com    for i in range(len(l)+offs, 0, -1):
2728336Ssteve.reinhardt@amd.com        if l[i] == elt:
2738336Ssteve.reinhardt@amd.com            return i
2745871Snate@binkert.org    raise ValueError, "element not found"
2758336Ssteve.reinhardt@amd.com
2768336Ssteve.reinhardt@amd.com# Take a list of paths (or SCons Nodes) and return a list with all
2778336Ssteve.reinhardt@amd.com# paths made absolute and ~-expanded.  Paths will be interpreted
2788336Ssteve.reinhardt@amd.com# relative to the launch directory unless a different root is provided
2798336Ssteve.reinhardt@amd.comdef makePathListAbsolute(path_list, root=GetLaunchDir()):
2804678Snate@binkert.org    return [abspath(joinpath(root, expanduser(str(p))))
2815871Snate@binkert.org            for p in path_list]
2824678Snate@binkert.org
2838336Ssteve.reinhardt@amd.com# Each target must have 'build' in the interior of the path; the
2848336Ssteve.reinhardt@amd.com# directory below this will determine the build parameters.  For
2858336Ssteve.reinhardt@amd.com# example, for target 'foo/bar/build/ALPHA_SE/arch/alpha/blah.do' we
2868336Ssteve.reinhardt@amd.com# recognize that ALPHA_SE specifies the configuration because it
2878336Ssteve.reinhardt@amd.com# follow 'build' in the build path.
2888336Ssteve.reinhardt@amd.com
2898336Ssteve.reinhardt@amd.com# The funky assignment to "[:]" is needed to replace the list contents
2908336Ssteve.reinhardt@amd.com# in place rather than reassign the symbol to a new list, which
2918336Ssteve.reinhardt@amd.com# doesn't work (obviously!).
2928336Ssteve.reinhardt@amd.comBUILD_TARGETS[:] = makePathListAbsolute(BUILD_TARGETS)
2938336Ssteve.reinhardt@amd.com
2948336Ssteve.reinhardt@amd.com# Generate a list of the unique build roots and configs that the
2958336Ssteve.reinhardt@amd.com# collected targets reference.
2968336Ssteve.reinhardt@amd.comvariant_paths = []
2978336Ssteve.reinhardt@amd.combuild_root = None
2988336Ssteve.reinhardt@amd.comfor t in BUILD_TARGETS:
2998336Ssteve.reinhardt@amd.com    path_dirs = t.split('/')
3005871Snate@binkert.org    try:
3016121Snate@binkert.org        build_top = rfind(path_dirs, 'build', -2)
302955SN/A    except:
303955SN/A        print "Error: no non-leaf 'build' dir found on target path", t
3042632Sstever@eecs.umich.edu        Exit(1)
3052632Sstever@eecs.umich.edu    this_build_root = joinpath('/',*path_dirs[:build_top+1])
306955SN/A    if not build_root:
307955SN/A        build_root = this_build_root
308955SN/A    else:
309955SN/A        if this_build_root != build_root:
3108878Ssteve.reinhardt@amd.com            print "Error: build targets not under same build root\n"\
311955SN/A                  "  %s\n  %s" % (build_root, this_build_root)
3122632Sstever@eecs.umich.edu            Exit(1)
3132632Sstever@eecs.umich.edu    variant_path = joinpath('/',*path_dirs[:build_top+2])
3142632Sstever@eecs.umich.edu    if variant_path not in variant_paths:
3152632Sstever@eecs.umich.edu        variant_paths.append(variant_path)
3162632Sstever@eecs.umich.edu
3172632Sstever@eecs.umich.edu# Make sure build_root exists (might not if this is the first build there)
3182632Sstever@eecs.umich.eduif not isdir(build_root):
3198268Ssteve.reinhardt@amd.com    mkdir(build_root)
3208268Ssteve.reinhardt@amd.commain['BUILDROOT'] = build_root
3218268Ssteve.reinhardt@amd.com
3228268Ssteve.reinhardt@amd.comExport('main')
3238268Ssteve.reinhardt@amd.com
3248268Ssteve.reinhardt@amd.commain.SConsignFile(joinpath(build_root, "sconsign"))
3258268Ssteve.reinhardt@amd.com
3262632Sstever@eecs.umich.edu# Default duplicate option is to use hard links, but this messes up
3272632Sstever@eecs.umich.edu# when you use emacs to edit a file in the target dir, as emacs moves
3282632Sstever@eecs.umich.edu# file to file~ then copies to file, breaking the link.  Symbolic
3292632Sstever@eecs.umich.edu# (soft) links work better.
3308268Ssteve.reinhardt@amd.commain.SetOption('duplicate', 'soft-copy')
3312632Sstever@eecs.umich.edu
3328268Ssteve.reinhardt@amd.com#
3338268Ssteve.reinhardt@amd.com# Set up global sticky variables... these are common to an entire build
3348268Ssteve.reinhardt@amd.com# tree (not specific to a particular build like ALPHA_SE)
3358268Ssteve.reinhardt@amd.com#
3363718Sstever@eecs.umich.edu
3372634Sstever@eecs.umich.eduglobal_vars_file = joinpath(build_root, 'variables.global')
3382634Sstever@eecs.umich.edu
3395863Snate@binkert.orgglobal_vars = Variables(global_vars_file, args=ARGUMENTS)
3402638Sstever@eecs.umich.edu
3418268Ssteve.reinhardt@amd.comglobal_vars.AddVariables(
3422632Sstever@eecs.umich.edu    ('CC', 'C compiler', environ.get('CC', main['CC'])),
3432632Sstever@eecs.umich.edu    ('CXX', 'C++ compiler', environ.get('CXX', main['CXX'])),
3442632Sstever@eecs.umich.edu    ('BATCH', 'Use batch pool for build and tests', False),
3452632Sstever@eecs.umich.edu    ('BATCH_CMD', 'Batch pool submission command name', 'qdo'),
3462632Sstever@eecs.umich.edu    ('M5_BUILD_CACHE', 'Cache built objects in this directory', False),
3471858SN/A    ('EXTRAS', 'Add extra directories to the compilation', '')
3483716Sstever@eecs.umich.edu    )
3492638Sstever@eecs.umich.edu
3502638Sstever@eecs.umich.edu# Update main environment with values from ARGUMENTS & global_vars_file
3512638Sstever@eecs.umich.eduglobal_vars.Update(main)
3522638Sstever@eecs.umich.eduhelp_texts["global_vars"] += global_vars.GenerateHelpText(main)
3532638Sstever@eecs.umich.edu
3542638Sstever@eecs.umich.edu# Save sticky variable settings back to current variables file
3552638Sstever@eecs.umich.eduglobal_vars.Save(global_vars_file, main)
3565863Snate@binkert.org
3575863Snate@binkert.org# Parse EXTRAS variable to build list of all directories where we're
3585863Snate@binkert.org# look for sources etc.  This list is exported as extras_dir_list.
359955SN/Abase_dir = main.srcdir.abspath
3605341Sstever@gmail.comif main['EXTRAS']:
3615341Sstever@gmail.com    extras_dir_list = makePathListAbsolute(main['EXTRAS'].split(':'))
3625863Snate@binkert.orgelse:
3637756SAli.Saidi@ARM.com    extras_dir_list = []
3645341Sstever@gmail.com
3656121Snate@binkert.orgExport('base_dir')
3664494Ssaidi@eecs.umich.eduExport('extras_dir_list')
3676121Snate@binkert.org
3681105SN/A# the ext directory should be on the #includes path
3692667Sstever@eecs.umich.edumain.Append(CPPPATH=[Dir('ext')])
3702667Sstever@eecs.umich.edu
3712667Sstever@eecs.umich.edudef strip_build_path(path, env):
3722667Sstever@eecs.umich.edu    path = str(path)
3736121Snate@binkert.org    variant_base = env['BUILDROOT'] + os.path.sep
3742667Sstever@eecs.umich.edu    if path.startswith(variant_base):
3755341Sstever@gmail.com        path = path[len(variant_base):]
3765863Snate@binkert.org    elif path.startswith('build/'):
3775341Sstever@gmail.com        path = path[6:]
3785341Sstever@gmail.com    return path
3795341Sstever@gmail.com
3808120Sgblack@eecs.umich.edu# Generate a string of the form:
3815341Sstever@gmail.com#   common/path/prefix/src1, src2 -> tgt1, tgt2
3828120Sgblack@eecs.umich.edu# to print while building.
3835341Sstever@gmail.comclass Transform(object):
3848120Sgblack@eecs.umich.edu    # all specific color settings should be here and nowhere else
3856121Snate@binkert.org    tool_color = termcap.Normal
3866121Snate@binkert.org    pfx_color = termcap.Yellow
3878980Ssteve.reinhardt@amd.com    srcs_color = termcap.Yellow + termcap.Bold
3889396Sandreas.hansson@arm.com    arrow_color = termcap.Blue + termcap.Bold
3895397Ssaidi@eecs.umich.edu    tgts_color = termcap.Yellow + termcap.Bold
3905397Ssaidi@eecs.umich.edu
3917727SAli.Saidi@ARM.com    def __init__(self, tool, max_sources=99):
3928268Ssteve.reinhardt@amd.com        self.format = self.tool_color + (" [%8s] " % tool) \
3936168Snate@binkert.org                      + self.pfx_color + "%s" \
3945341Sstever@gmail.com                      + self.srcs_color + "%s" \
3958120Sgblack@eecs.umich.edu                      + self.arrow_color + " -> " \
3968120Sgblack@eecs.umich.edu                      + self.tgts_color + "%s" \
3978120Sgblack@eecs.umich.edu                      + termcap.Normal
3986814Sgblack@eecs.umich.edu        self.max_sources = max_sources
3995863Snate@binkert.org
4008120Sgblack@eecs.umich.edu    def __call__(self, target, source, env, for_signature=None):
4015341Sstever@gmail.com        # truncate source list according to max_sources param
4025863Snate@binkert.org        source = source[0:self.max_sources]
4038268Ssteve.reinhardt@amd.com        def strip(f):
4046121Snate@binkert.org            return strip_build_path(str(f), env)
4056121Snate@binkert.org        if len(source) > 0:
4068268Ssteve.reinhardt@amd.com            srcs = map(strip, source)
4075742Snate@binkert.org        else:
4085742Snate@binkert.org            srcs = ['']
4095341Sstever@gmail.com        tgts = map(strip, target)
4105742Snate@binkert.org        # surprisingly, os.path.commonprefix is a dumb char-by-char string
4115742Snate@binkert.org        # operation that has nothing to do with paths.
4125341Sstever@gmail.com        com_pfx = os.path.commonprefix(srcs + tgts)
4136017Snate@binkert.org        com_pfx_len = len(com_pfx)
4146121Snate@binkert.org        if com_pfx:
4156017Snate@binkert.org            # do some cleanup and sanity checking on common prefix
4167816Ssteve.reinhardt@amd.com            if com_pfx[-1] == ".":
4177756SAli.Saidi@ARM.com                # prefix matches all but file extension: ok
4187756SAli.Saidi@ARM.com                # back up one to change 'foo.cc -> o' to 'foo.cc -> .o'
4197756SAli.Saidi@ARM.com                com_pfx = com_pfx[0:-1]
4207756SAli.Saidi@ARM.com            elif com_pfx[-1] == "/":
4217756SAli.Saidi@ARM.com                # common prefix is directory path: OK
4227756SAli.Saidi@ARM.com                pass
4237756SAli.Saidi@ARM.com            else:
4247756SAli.Saidi@ARM.com                src0_len = len(srcs[0])
4257816Ssteve.reinhardt@amd.com                tgt0_len = len(tgts[0])
4267816Ssteve.reinhardt@amd.com                if src0_len == com_pfx_len:
4277816Ssteve.reinhardt@amd.com                    # source is a substring of target, OK
4287816Ssteve.reinhardt@amd.com                    pass
4297816Ssteve.reinhardt@amd.com                elif tgt0_len == com_pfx_len:
4307816Ssteve.reinhardt@amd.com                    # target is a substring of source, need to back up to
4317816Ssteve.reinhardt@amd.com                    # avoid empty string on RHS of arrow
4327816Ssteve.reinhardt@amd.com                    sep_idx = com_pfx.rfind(".")
4337816Ssteve.reinhardt@amd.com                    if sep_idx != -1:
4347816Ssteve.reinhardt@amd.com                        com_pfx = com_pfx[0:sep_idx]
4357756SAli.Saidi@ARM.com                    else:
4367816Ssteve.reinhardt@amd.com                        com_pfx = ''
4377816Ssteve.reinhardt@amd.com                elif src0_len > com_pfx_len and srcs[0][com_pfx_len] == ".":
4387816Ssteve.reinhardt@amd.com                    # still splitting at file extension: ok
4397816Ssteve.reinhardt@amd.com                    pass
4407816Ssteve.reinhardt@amd.com                else:
4417816Ssteve.reinhardt@amd.com                    # probably a fluke; ignore it
4427816Ssteve.reinhardt@amd.com                    com_pfx = ''
4437816Ssteve.reinhardt@amd.com        # recalculate length in case com_pfx was modified
4447816Ssteve.reinhardt@amd.com        com_pfx_len = len(com_pfx)
4457816Ssteve.reinhardt@amd.com        def fmt(files):
4467816Ssteve.reinhardt@amd.com            f = map(lambda s: s[com_pfx_len:], files)
4477816Ssteve.reinhardt@amd.com            return ', '.join(f)
4487816Ssteve.reinhardt@amd.com        return self.format % (com_pfx, fmt(srcs), fmt(tgts))
4497816Ssteve.reinhardt@amd.com
4507816Ssteve.reinhardt@amd.comExport('Transform')
4517816Ssteve.reinhardt@amd.com
4527816Ssteve.reinhardt@amd.com
4537816Ssteve.reinhardt@amd.comif GetOption('verbose'):
4547816Ssteve.reinhardt@amd.com    def MakeAction(action, string, *args, **kwargs):
4557816Ssteve.reinhardt@amd.com        return Action(action, *args, **kwargs)
4567816Ssteve.reinhardt@amd.comelse:
4577816Ssteve.reinhardt@amd.com    MakeAction = Action
4587816Ssteve.reinhardt@amd.com    main['CCCOMSTR']        = Transform("CC")
4597816Ssteve.reinhardt@amd.com    main['CXXCOMSTR']       = Transform("CXX")
4607816Ssteve.reinhardt@amd.com    main['ASCOMSTR']        = Transform("AS")
4617816Ssteve.reinhardt@amd.com    main['SWIGCOMSTR']      = Transform("SWIG")
4627816Ssteve.reinhardt@amd.com    main['ARCOMSTR']        = Transform("AR", 0)
4637816Ssteve.reinhardt@amd.com    main['LINKCOMSTR']      = Transform("LINK", 0)
4647816Ssteve.reinhardt@amd.com    main['RANLIBCOMSTR']    = Transform("RANLIB", 0)
4657816Ssteve.reinhardt@amd.com    main['M4COMSTR']        = Transform("M4")
4667816Ssteve.reinhardt@amd.com    main['SHCCCOMSTR']      = Transform("SHCC")
4677816Ssteve.reinhardt@amd.com    main['SHCXXCOMSTR']     = Transform("SHCXX")
4687816Ssteve.reinhardt@amd.comExport('MakeAction')
4697816Ssteve.reinhardt@amd.com
4707816Ssteve.reinhardt@amd.comCXX_version = readCommand([main['CXX'],'--version'], exception=False)
4717816Ssteve.reinhardt@amd.comCXX_V = readCommand([main['CXX'],'-V'], exception=False)
4727816Ssteve.reinhardt@amd.com
4737816Ssteve.reinhardt@amd.commain['GCC'] = CXX_version and CXX_version.find('g++') >= 0
4747816Ssteve.reinhardt@amd.commain['SUNCC'] = CXX_V and CXX_V.find('Sun C++') >= 0
4757816Ssteve.reinhardt@amd.commain['ICC'] = CXX_V and CXX_V.find('Intel') >= 0
4767816Ssteve.reinhardt@amd.comif main['GCC'] + main['SUNCC'] + main['ICC'] > 1:
4777816Ssteve.reinhardt@amd.com    print 'Error: How can we have two at the same time?'
4787816Ssteve.reinhardt@amd.com    Exit(1)
4797816Ssteve.reinhardt@amd.com
4807816Ssteve.reinhardt@amd.com# Set up default C++ compiler flags
4817816Ssteve.reinhardt@amd.comif main['GCC']:
4827816Ssteve.reinhardt@amd.com    main.Append(CCFLAGS=['-pipe'])
4837816Ssteve.reinhardt@amd.com    main.Append(CCFLAGS=['-fno-strict-aliasing'])
4847816Ssteve.reinhardt@amd.com    main.Append(CCFLAGS=['-Wall', '-Wno-sign-compare', '-Wundef'])
4857816Ssteve.reinhardt@amd.com    main.Append(CXXFLAGS=['-Wno-deprecated'])
4867816Ssteve.reinhardt@amd.com    # Read the GCC version to check for versions with bugs
4877816Ssteve.reinhardt@amd.com    # Note CCVERSION doesn't work here because it is run with the CC
4887816Ssteve.reinhardt@amd.com    # before we override it from the command line
4897816Ssteve.reinhardt@amd.com    gcc_version = readCommand([main['CXX'], '-dumpversion'], exception=False)
4907816Ssteve.reinhardt@amd.com    if not compareVersions(gcc_version, '4.4.1') or \
4917816Ssteve.reinhardt@amd.com       not compareVersions(gcc_version, '4.4.2'):
4927816Ssteve.reinhardt@amd.com        print 'Info: Tree vectorizer in GCC 4.4.1 & 4.4.2 is buggy, disabling.'
4937816Ssteve.reinhardt@amd.com        main.Append(CCFLAGS=['-fno-tree-vectorize'])
4947816Ssteve.reinhardt@amd.comelif main['ICC']:
4957816Ssteve.reinhardt@amd.com    pass #Fix me... add warning flags once we clean up icc warnings
4967816Ssteve.reinhardt@amd.comelif main['SUNCC']:
4978947Sandreas.hansson@arm.com    main.Append(CCFLAGS=['-Qoption ccfe'])
4988947Sandreas.hansson@arm.com    main.Append(CCFLAGS=['-features=gcc'])
4997756SAli.Saidi@ARM.com    main.Append(CCFLAGS=['-features=extensions'])
5008120Sgblack@eecs.umich.edu    main.Append(CCFLAGS=['-library=stlport4'])
5017756SAli.Saidi@ARM.com    main.Append(CCFLAGS=['-xar'])
5027756SAli.Saidi@ARM.com    #main.Append(CCFLAGS=['-instances=semiexplicit'])
5037756SAli.Saidi@ARM.comelse:
5047756SAli.Saidi@ARM.com    print 'Error: Don\'t know what compiler options to use for your compiler.'
5057816Ssteve.reinhardt@amd.com    print '       Please fix SConstruct and src/SConscript and try again.'
5067816Ssteve.reinhardt@amd.com    Exit(1)
5077816Ssteve.reinhardt@amd.com
5087816Ssteve.reinhardt@amd.com# Set up common yacc/bison flags (needed for Ruby)
5097816Ssteve.reinhardt@amd.commain['YACCFLAGS'] = '-d'
5107816Ssteve.reinhardt@amd.commain['YACCHXXFILESUFFIX'] = '.hh'
5117816Ssteve.reinhardt@amd.com
5127816Ssteve.reinhardt@amd.com# Do this after we save setting back, or else we'll tack on an
5137816Ssteve.reinhardt@amd.com# extra 'qdo' every time we run scons.
5147816Ssteve.reinhardt@amd.comif main['BATCH']:
5157756SAli.Saidi@ARM.com    main['CC']     = main['BATCH_CMD'] + ' ' + main['CC']
5167756SAli.Saidi@ARM.com    main['CXX']    = main['BATCH_CMD'] + ' ' + main['CXX']
5179227Sandreas.hansson@arm.com    main['AS']     = main['BATCH_CMD'] + ' ' + main['AS']
5189227Sandreas.hansson@arm.com    main['AR']     = main['BATCH_CMD'] + ' ' + main['AR']
5199227Sandreas.hansson@arm.com    main['RANLIB'] = main['BATCH_CMD'] + ' ' + main['RANLIB']
5209227Sandreas.hansson@arm.com
5219590Sandreas@sandberg.pp.seif sys.platform == 'cygwin':
5229590Sandreas@sandberg.pp.se    # cygwin has some header file issues...
5239590Sandreas@sandberg.pp.se    main.Append(CCFLAGS=["-Wno-uninitialized"])
5249590Sandreas@sandberg.pp.se
5259590Sandreas@sandberg.pp.se# Check for SWIG
5269590Sandreas@sandberg.pp.seif not main.has_key('SWIG'):
5276654Snate@binkert.org    print 'Error: SWIG utility not found.'
5286654Snate@binkert.org    print '       Please install (see http://www.swig.org) and retry.'
5295871Snate@binkert.org    Exit(1)
5306121Snate@binkert.org
5318946Sandreas.hansson@arm.com# Check for appropriate SWIG version
5329419Sandreas.hansson@arm.comswig_version = readCommand(('swig', '-version'), exception='').split()
5333940Ssaidi@eecs.umich.edu# First 3 words should be "SWIG Version x.y.z"
5343918Ssaidi@eecs.umich.eduif len(swig_version) < 3 or \
5353918Ssaidi@eecs.umich.edu        swig_version[0] != 'SWIG' or swig_version[1] != 'Version':
5361858SN/A    print 'Error determining SWIG version.'
5379556Sandreas.hansson@arm.com    Exit(1)
5389556Sandreas.hansson@arm.com
5399556Sandreas.hansson@arm.commin_swig_version = '1.3.28'
5409556Sandreas.hansson@arm.comif compareVersions(swig_version[2], min_swig_version) < 0:
5419556Sandreas.hansson@arm.com    print 'Error: SWIG version', min_swig_version, 'or newer required.'
5429556Sandreas.hansson@arm.com    print '       Installed version:', swig_version[2]
5439556Sandreas.hansson@arm.com    Exit(1)
5449556Sandreas.hansson@arm.com
5459556Sandreas.hansson@arm.com# Set up SWIG flags & scanner
5469556Sandreas.hansson@arm.comswig_flags=Split('-c++ -python -modern -templatereduce $_CPPINCFLAGS')
5479556Sandreas.hansson@arm.commain.Append(SWIGFLAGS=swig_flags)
5489556Sandreas.hansson@arm.com
5499556Sandreas.hansson@arm.com# filter out all existing swig scanners, they mess up the dependency
5509556Sandreas.hansson@arm.com# stuff for some reason
5519556Sandreas.hansson@arm.comscanners = []
5529556Sandreas.hansson@arm.comfor scanner in main['SCANNERS']:
5539556Sandreas.hansson@arm.com    skeys = scanner.skeys
5549556Sandreas.hansson@arm.com    if skeys == '.i':
5559556Sandreas.hansson@arm.com        continue
5569556Sandreas.hansson@arm.com
5579556Sandreas.hansson@arm.com    if isinstance(skeys, (list, tuple)) and '.i' in skeys:
5589556Sandreas.hansson@arm.com        continue
5599556Sandreas.hansson@arm.com
5609556Sandreas.hansson@arm.com    scanners.append(scanner)
5619556Sandreas.hansson@arm.com
5629556Sandreas.hansson@arm.com# add the new swig scanner that we like better
5639556Sandreas.hansson@arm.comfrom SCons.Scanner import ClassicCPP as CPPScanner
5649556Sandreas.hansson@arm.comswig_inc_re = '^[ \t]*[%,#][ \t]*(?:include|import)[ \t]*(<|")([^>"]+)(>|")'
5659556Sandreas.hansson@arm.comscanners.append(CPPScanner("SwigScan", [ ".i" ], "CPPPATH", swig_inc_re))
5669556Sandreas.hansson@arm.com
5679556Sandreas.hansson@arm.com# replace the scanners list that has what we want
5689556Sandreas.hansson@arm.commain['SCANNERS'] = scanners
5696121Snate@binkert.org
5709420Sandreas.hansson@arm.com# Add a custom Check function to the Configure context so that we can
5719420Sandreas.hansson@arm.com# figure out if the compiler adds leading underscores to global
5729420Sandreas.hansson@arm.com# variables.  This is needed for the autogenerated asm files that we
5739420Sandreas.hansson@arm.com# use for embedding the python code.
5749420Sandreas.hansson@arm.comdef CheckLeading(context):
5759420Sandreas.hansson@arm.com    context.Message("Checking for leading underscore in global variables...")
5769420Sandreas.hansson@arm.com    # 1) Define a global variable called x from asm so the C compiler
5779420Sandreas.hansson@arm.com    #    won't change the symbol at all.
5789420Sandreas.hansson@arm.com    # 2) Declare that variable.
5799420Sandreas.hansson@arm.com    # 3) Use the variable
5809420Sandreas.hansson@arm.com    #
5817618SAli.Saidi@arm.com    # If the compiler prepends an underscore, this will successfully
5827618SAli.Saidi@arm.com    # link because the external symbol 'x' will be called '_x' which
5837618SAli.Saidi@arm.com    # was defined by the asm statement.  If the compiler does not
5847739Sgblack@eecs.umich.edu    # prepend an underscore, this will not successfully link because
5859227Sandreas.hansson@arm.com    # '_x' will have been defined by assembly, while the C portion of
5869227Sandreas.hansson@arm.com    # the code will be trying to use 'x'
5879227Sandreas.hansson@arm.com    ret = context.TryLink('''
5889227Sandreas.hansson@arm.com        asm(".globl _x; _x: .byte 0");
5899227Sandreas.hansson@arm.com        extern int x;
5909227Sandreas.hansson@arm.com        int main() { return x; }
5919227Sandreas.hansson@arm.com        ''', extension=".c")
5929227Sandreas.hansson@arm.com    context.env.Append(LEADING_UNDERSCORE=ret)
5939227Sandreas.hansson@arm.com    context.Result(ret)
5949227Sandreas.hansson@arm.com    return ret
5959227Sandreas.hansson@arm.com
5969227Sandreas.hansson@arm.com# Platform-specific configuration.  Note again that we assume that all
5979227Sandreas.hansson@arm.com# builds under a given build root run on the same host platform.
5989227Sandreas.hansson@arm.comconf = Configure(main,
5999227Sandreas.hansson@arm.com                 conf_dir = joinpath(build_root, '.scons_config'),
6009227Sandreas.hansson@arm.com                 log_file = joinpath(build_root, 'scons_config.log'),
6019227Sandreas.hansson@arm.com                 custom_tests = { 'CheckLeading' : CheckLeading })
6029227Sandreas.hansson@arm.com
6039590Sandreas@sandberg.pp.se# Check for leading underscores.  Don't really need to worry either
6049590Sandreas@sandberg.pp.se# way so don't need to check the return code.
6059590Sandreas@sandberg.pp.seconf.CheckLeading()
6068737Skoansin.tan@gmail.com
6079420Sandreas.hansson@arm.com# Check if we should compile a 64 bit binary on Mac OS X/Darwin
6089420Sandreas.hansson@arm.comtry:
6099420Sandreas.hansson@arm.com    import platform
6108737Skoansin.tan@gmail.com    uname = platform.uname()
6118737Skoansin.tan@gmail.com    if uname[0] == 'Darwin' and compareVersions(uname[2], '9.0.0') >= 0:
6128737Skoansin.tan@gmail.com        if int(readCommand('sysctl -n hw.cpu64bit_capable')[0]):
6138737Skoansin.tan@gmail.com            main.Append(CCFLAGS=['-arch', 'x86_64'])
6148737Skoansin.tan@gmail.com            main.Append(CFLAGS=['-arch', 'x86_64'])
6158737Skoansin.tan@gmail.com            main.Append(LINKFLAGS=['-arch', 'x86_64'])
6168737Skoansin.tan@gmail.com            main.Append(ASFLAGS=['-arch', 'x86_64'])
6178737Skoansin.tan@gmail.comexcept:
6188737Skoansin.tan@gmail.com    pass
6198737Skoansin.tan@gmail.com
6208737Skoansin.tan@gmail.com# Recent versions of scons substitute a "Null" object for Configure()
6218737Skoansin.tan@gmail.com# when configuration isn't necessary, e.g., if the "--help" option is
6229556Sandreas.hansson@arm.com# present.  Unfortuantely this Null object always returns false,
6239556Sandreas.hansson@arm.com# breaking all our configuration checks.  We replace it with our own
6249556Sandreas.hansson@arm.com# more optimistic null object that returns True instead.
6259556Sandreas.hansson@arm.comif not conf:
6269556Sandreas.hansson@arm.com    def NullCheck(*args, **kwargs):
6279556Sandreas.hansson@arm.com        return True
6289556Sandreas.hansson@arm.com
6299556Sandreas.hansson@arm.com    class NullConf:
6309556Sandreas.hansson@arm.com        def __init__(self, env):
6319556Sandreas.hansson@arm.com            self.env = env
6329590Sandreas@sandberg.pp.se        def Finish(self):
6339590Sandreas@sandberg.pp.se            return self.env
6349420Sandreas.hansson@arm.com        def __getattr__(self, mname):
6359846Sandreas.hansson@arm.com            return NullCheck
6369846Sandreas.hansson@arm.com
6379846Sandreas.hansson@arm.com    conf = NullConf(main)
6389846Sandreas.hansson@arm.com
6398946Sandreas.hansson@arm.com# Find Python include and library directories for embedding the
6403918Ssaidi@eecs.umich.edu# interpreter.  For consistency, we will use the same Python
6419068SAli.Saidi@ARM.com# installation used to run scons (and thus this script).  If you want
6429068SAli.Saidi@ARM.com# to link in an alternate version, see above for instructions on how
6439068SAli.Saidi@ARM.com# to invoke scons with a different copy of the Python interpreter.
6449068SAli.Saidi@ARM.comfrom distutils import sysconfig
6459068SAli.Saidi@ARM.com
6469068SAli.Saidi@ARM.compy_getvar = sysconfig.get_config_var
6479068SAli.Saidi@ARM.com
6489068SAli.Saidi@ARM.compy_debug = getattr(sys, 'pydebug', False)
6499068SAli.Saidi@ARM.compy_version = 'python' + py_getvar('VERSION') + (py_debug and "_d" or "")
6509419Sandreas.hansson@arm.com
6519068SAli.Saidi@ARM.compy_general_include = sysconfig.get_python_inc()
6529068SAli.Saidi@ARM.compy_platform_include = sysconfig.get_python_inc(plat_specific=True)
6539068SAli.Saidi@ARM.compy_includes = [ py_general_include ]
6549068SAli.Saidi@ARM.comif py_platform_include != py_general_include:
6559068SAli.Saidi@ARM.com    py_includes.append(py_platform_include)
6569068SAli.Saidi@ARM.com
6573918Ssaidi@eecs.umich.edupy_lib_path = [ py_getvar('LIBDIR') ]
6583918Ssaidi@eecs.umich.edu# add the prefix/lib/pythonX.Y/config dir, but only if there is no
6596157Snate@binkert.org# shared library in prefix/lib/.
6606157Snate@binkert.orgif not py_getvar('Py_ENABLE_SHARED'):
6616157Snate@binkert.org    py_lib_path.append(py_getvar('LIBPL'))
6626157Snate@binkert.org
6635397Ssaidi@eecs.umich.edupy_libs = []
6645397Ssaidi@eecs.umich.edufor lib in py_getvar('LIBS').split() + py_getvar('SYSLIBS').split():
6656121Snate@binkert.org    assert lib.startswith('-l')
6666121Snate@binkert.org    lib = lib[2:]   
6676121Snate@binkert.org    if lib not in py_libs:
6686121Snate@binkert.org        py_libs.append(lib)
6696121Snate@binkert.orgpy_libs.append(py_version)
6706121Snate@binkert.org
6715397Ssaidi@eecs.umich.edumain.Append(CPPPATH=py_includes)
6721851SN/Amain.Append(LIBPATH=py_lib_path)
6731851SN/A
6747739Sgblack@eecs.umich.edu# Cache build files in the supplied directory.
675955SN/Aif main['M5_BUILD_CACHE']:
6769396Sandreas.hansson@arm.com    print 'Using build cache located at', main['M5_BUILD_CACHE']
6779396Sandreas.hansson@arm.com    CacheDir(main['M5_BUILD_CACHE'])
6789396Sandreas.hansson@arm.com
6799396Sandreas.hansson@arm.com
6809396Sandreas.hansson@arm.com# verify that this stuff works
6819396Sandreas.hansson@arm.comif not conf.CheckHeader('Python.h', '<>'):
6829396Sandreas.hansson@arm.com    print "Error: can't find Python.h header in", py_includes
6839396Sandreas.hansson@arm.com    Exit(1)
6849396Sandreas.hansson@arm.com
6859396Sandreas.hansson@arm.comfor lib in py_libs:
6869396Sandreas.hansson@arm.com    if not conf.CheckLib(lib):
6879396Sandreas.hansson@arm.com        print "Error: can't find library %s required by python" % lib
6889396Sandreas.hansson@arm.com        Exit(1)
6899396Sandreas.hansson@arm.com
6909396Sandreas.hansson@arm.com# On Solaris you need to use libsocket for socket ops
6919396Sandreas.hansson@arm.comif not conf.CheckLibWithHeader(None, 'sys/socket.h', 'C++', 'accept(0,0,0);'):
6929477Sandreas.hansson@arm.com   if not conf.CheckLibWithHeader('socket', 'sys/socket.h', 'C++', 'accept(0,0,0);'):
6939477Sandreas.hansson@arm.com       print "Can't find library with socket calls (e.g. accept())"
6949477Sandreas.hansson@arm.com       Exit(1)
6959477Sandreas.hansson@arm.com
6969477Sandreas.hansson@arm.com# Check for zlib.  If the check passes, libz will be automatically
6979477Sandreas.hansson@arm.com# added to the LIBS environment variable.
6989477Sandreas.hansson@arm.comif not conf.CheckLibWithHeader('z', 'zlib.h', 'C++','zlibVersion();'):
6999477Sandreas.hansson@arm.com    print 'Error: did not find needed zlib compression library '\
7009477Sandreas.hansson@arm.com          'and/or zlib.h header file.'
7019477Sandreas.hansson@arm.com    print '       Please install zlib and try again.'
7029477Sandreas.hansson@arm.com    Exit(1)
7039477Sandreas.hansson@arm.com
7049477Sandreas.hansson@arm.com# Check for librt.
7059477Sandreas.hansson@arm.comhave_posix_clock = \
7069477Sandreas.hansson@arm.com    conf.CheckLibWithHeader(None, 'time.h', 'C',
7079477Sandreas.hansson@arm.com                            'clock_nanosleep(0,0,NULL,NULL);') or \
7089477Sandreas.hansson@arm.com    conf.CheckLibWithHeader('rt', 'time.h', 'C',
7099477Sandreas.hansson@arm.com                            'clock_nanosleep(0,0,NULL,NULL);')
7109477Sandreas.hansson@arm.com
7119477Sandreas.hansson@arm.comif not have_posix_clock:
7129477Sandreas.hansson@arm.com    print "Can't find library for POSIX clocks."
7139477Sandreas.hansson@arm.com
7149396Sandreas.hansson@arm.com# Check for <fenv.h> (C99 FP environment control)
7153053Sstever@eecs.umich.eduhave_fenv = conf.CheckHeader('fenv.h', '<>')
7166121Snate@binkert.orgif not have_fenv:
7173053Sstever@eecs.umich.edu    print "Warning: Header file <fenv.h> not found."
7183053Sstever@eecs.umich.edu    print "         This host has no IEEE FP rounding mode control."
7193053Sstever@eecs.umich.edu
7203053Sstever@eecs.umich.edu######################################################################
7213053Sstever@eecs.umich.edu#
7229072Sandreas.hansson@arm.com# Finish the configuration
7233053Sstever@eecs.umich.edu#
7244742Sstever@eecs.umich.edumain = conf.Finish()
7254742Sstever@eecs.umich.edu
7263053Sstever@eecs.umich.edu######################################################################
7273053Sstever@eecs.umich.edu#
7283053Sstever@eecs.umich.edu# Collect all non-global variables
7298960Ssteve.reinhardt@amd.com#
7306654Snate@binkert.org
7313053Sstever@eecs.umich.edu# Define the universe of supported ISAs
7323053Sstever@eecs.umich.eduall_isa_list = [ ]
7333053Sstever@eecs.umich.eduExport('all_isa_list')
7343053Sstever@eecs.umich.edu
7359877Sandreas.hansson@arm.comclass CpuModel(object):
7369877Sandreas.hansson@arm.com    '''The CpuModel class encapsulates everything the ISA parser needs to
7379877Sandreas.hansson@arm.com    know about a particular CPU model.'''
7389877Sandreas.hansson@arm.com
7399877Sandreas.hansson@arm.com    # Dict of available CPU model objects.  Accessible as CpuModel.dict.
7409585Sandreas@sandberg.pp.se    dict = {}
7419877Sandreas.hansson@arm.com    list = []
7429585Sandreas@sandberg.pp.se    defaults = []
7439877Sandreas.hansson@arm.com
7449877Sandreas.hansson@arm.com    # Constructor.  Automatically adds models to CpuModel.dict.
7459585Sandreas@sandberg.pp.se    def __init__(self, name, filename, includes, strings, default=False):
7462667Sstever@eecs.umich.edu        self.name = name           # name of model
7474554Sbinkertn@umich.edu        self.filename = filename   # filename for output exec code
7486121Snate@binkert.org        self.includes = includes   # include files needed in exec file
7492667Sstever@eecs.umich.edu        # The 'strings' dict holds all the per-CPU symbols we can
7504554Sbinkertn@umich.edu        # substitute into templates etc.
7514554Sbinkertn@umich.edu        self.strings = strings
7524554Sbinkertn@umich.edu
7536121Snate@binkert.org        # This cpu is enabled by default
7544554Sbinkertn@umich.edu        self.default = default
7554554Sbinkertn@umich.edu
7564554Sbinkertn@umich.edu        # Add self to dict
7574781Snate@binkert.org        if name in CpuModel.dict:
7584554Sbinkertn@umich.edu            raise AttributeError, "CpuModel '%s' already registered" % name
7594554Sbinkertn@umich.edu        CpuModel.dict[name] = self
7602667Sstever@eecs.umich.edu        CpuModel.list.append(name)
7614554Sbinkertn@umich.edu
7624554Sbinkertn@umich.eduExport('CpuModel')
7634554Sbinkertn@umich.edu
7644554Sbinkertn@umich.edu# Sticky variables get saved in the variables file so they persist from
7652667Sstever@eecs.umich.edu# one invocation to the next (unless overridden, in which case the new
7664554Sbinkertn@umich.edu# value becomes sticky).
7672667Sstever@eecs.umich.edusticky_vars = Variables(args=ARGUMENTS)
7684554Sbinkertn@umich.eduExport('sticky_vars')
7696121Snate@binkert.org
7702667Sstever@eecs.umich.edu# Sticky variables that should be exported
7715522Snate@binkert.orgexport_vars = []
7725522Snate@binkert.orgExport('export_vars')
7735522Snate@binkert.org
7745522Snate@binkert.org# Walk the tree and execute all SConsopts scripts that wil add to the
7755522Snate@binkert.org# above variables
7765522Snate@binkert.orgif not GetOption('verbose'):
7775522Snate@binkert.org    print "Reading SConsopts"
7785522Snate@binkert.orgfor bdir in [ base_dir ] + extras_dir_list:
7795522Snate@binkert.org    if not isdir(bdir):
7805522Snate@binkert.org        print "Error: directory '%s' does not exist" % bdir
7815522Snate@binkert.org        Exit(1)
7825522Snate@binkert.org    for root, dirs, files in os.walk(bdir):
7835522Snate@binkert.org        if 'SConsopts' in files:
7845522Snate@binkert.org            if GetOption('verbose'):
7855522Snate@binkert.org                print "Reading", joinpath(root, 'SConsopts')
7865522Snate@binkert.org            SConscript(joinpath(root, 'SConsopts'))
7875522Snate@binkert.org
7885522Snate@binkert.orgall_isa_list.sort()
7895522Snate@binkert.org
7905522Snate@binkert.orgsticky_vars.AddVariables(
7915522Snate@binkert.org    EnumVariable('TARGET_ISA', 'Target ISA', 'alpha', all_isa_list),
7925522Snate@binkert.org    BoolVariable('FULL_SYSTEM', 'Full-system support', False),
7935522Snate@binkert.org    ListVariable('CPU_MODELS', 'CPU models',
7945522Snate@binkert.org                 sorted(n for n,m in CpuModel.dict.iteritems() if m.default),
7955522Snate@binkert.org                 sorted(CpuModel.list)),
7965522Snate@binkert.org    BoolVariable('NO_FAST_ALLOC', 'Disable fast object allocator', False),
7972638Sstever@eecs.umich.edu    BoolVariable('FORCE_FAST_ALLOC',
7982638Sstever@eecs.umich.edu                 'Enable fast object allocator, even for m5.debug', False),
7996121Snate@binkert.org    BoolVariable('FAST_ALLOC_STATS', 'Enable fast object allocator statistics',
8003716Sstever@eecs.umich.edu                 False),
8015522Snate@binkert.org    BoolVariable('EFENCE', 'Link with Electric Fence malloc debugger',
8029420Sandreas.hansson@arm.com                 False),
8035522Snate@binkert.org    BoolVariable('SS_COMPATIBLE_FP',
8045522Snate@binkert.org                 'Make floating-point results compatible with SimpleScalar',
8055522Snate@binkert.org                 False),
8065522Snate@binkert.org    BoolVariable('USE_SSE2',
8071858SN/A                 'Compile for SSE2 (-msse2) to get IEEE FP on x86 hosts',
8085227Ssaidi@eecs.umich.edu                 False),
8095227Ssaidi@eecs.umich.edu    BoolVariable('USE_POSIX_CLOCK', 'Use POSIX Clocks', have_posix_clock),
8105227Ssaidi@eecs.umich.edu    BoolVariable('USE_FENV', 'Use <fenv.h> IEEE mode control', have_fenv),
8115227Ssaidi@eecs.umich.edu    BoolVariable('USE_CHECKER', 'Use checker for detailed CPU models', False),
8126654Snate@binkert.org    BoolVariable('CP_ANNOTATE', 'Enable critical path annotation capability', False),
8136654Snate@binkert.org    )
8147769SAli.Saidi@ARM.com
8157769SAli.Saidi@ARM.com# These variables get exported to #defines in config/*.hh (see src/SConscript).
8167769SAli.Saidi@ARM.comexport_vars += ['FULL_SYSTEM', 'USE_FENV',
8177769SAli.Saidi@ARM.com                'NO_FAST_ALLOC', 'FORCE_FAST_ALLOC', 'FAST_ALLOC_STATS',
8185227Ssaidi@eecs.umich.edu                'SS_COMPATIBLE_FP', 'USE_CHECKER', 'TARGET_ISA', 'CP_ANNOTATE',
8195227Ssaidi@eecs.umich.edu                'USE_POSIX_CLOCK' ]
8205227Ssaidi@eecs.umich.edu
8215204Sstever@gmail.com###################################################
8225204Sstever@gmail.com#
8235204Sstever@gmail.com# Define a SCons builder for configuration flag headers.
8245204Sstever@gmail.com#
8255204Sstever@gmail.com###################################################
8265204Sstever@gmail.com
8275204Sstever@gmail.com# This function generates a config header file that #defines the
8285204Sstever@gmail.com# variable symbol to the current variable setting (0 or 1).  The source
8295204Sstever@gmail.com# operands are the name of the variable and a Value node containing the
8305204Sstever@gmail.com# value of the variable.
8315204Sstever@gmail.comdef build_config_file(target, source, env):
8325204Sstever@gmail.com    (variable, value) = [s.get_contents() for s in source]
8335204Sstever@gmail.com    f = file(str(target[0]), 'w')
8345204Sstever@gmail.com    print >> f, '#define', variable, value
8355204Sstever@gmail.com    f.close()
8365204Sstever@gmail.com    return None
8375204Sstever@gmail.com
8386121Snate@binkert.org# Combine the two functions into a scons Action object.
8395204Sstever@gmail.comconfig_action = MakeAction(build_config_file, Transform("CONFIG H", 2))
8407727SAli.Saidi@ARM.com
8417727SAli.Saidi@ARM.com# The emitter munges the source & target node lists to reflect what
8427727SAli.Saidi@ARM.com# we're really doing.
8437727SAli.Saidi@ARM.comdef config_emitter(target, source, env):
8447727SAli.Saidi@ARM.com    # extract variable name from Builder arg
8459812Sandreas.hansson@arm.com    variable = str(target[0])
8469812Sandreas.hansson@arm.com    # True target is config header file
8479812Sandreas.hansson@arm.com    target = joinpath('config', variable.lower() + '.hh')
8489812Sandreas.hansson@arm.com    val = env[variable]
8499812Sandreas.hansson@arm.com    if isinstance(val, bool):
8509812Sandreas.hansson@arm.com        # Force value to 0/1
8519812Sandreas.hansson@arm.com        val = int(val)
8529812Sandreas.hansson@arm.com    elif isinstance(val, str):
8539812Sandreas.hansson@arm.com        val = '"' + val + '"'
8549812Sandreas.hansson@arm.com
8559812Sandreas.hansson@arm.com    # Sources are variable name & value (packaged in SCons Value nodes)
8569812Sandreas.hansson@arm.com    return ([target], [Value(variable), Value(val)])
8579812Sandreas.hansson@arm.com
8589812Sandreas.hansson@arm.comconfig_builder = Builder(emitter = config_emitter, action = config_action)
8599812Sandreas.hansson@arm.com
8609812Sandreas.hansson@arm.commain.Append(BUILDERS = { 'ConfigFile' : config_builder })
8619812Sandreas.hansson@arm.com
8629812Sandreas.hansson@arm.com# libelf build is shared across all configs in the build root.
8639812Sandreas.hansson@arm.commain.SConscript('ext/libelf/SConscript',
8649812Sandreas.hansson@arm.com                variant_dir = joinpath(build_root, 'libelf'))
8659812Sandreas.hansson@arm.com
8669812Sandreas.hansson@arm.com# gzstream build is shared across all configs in the build root.
8679812Sandreas.hansson@arm.commain.SConscript('ext/gzstream/SConscript',
8689812Sandreas.hansson@arm.com                variant_dir = joinpath(build_root, 'gzstream'))
8697727SAli.Saidi@ARM.com
8705863Snate@binkert.org###################################################
8713118Sstever@eecs.umich.edu#
8725863Snate@binkert.org# This function is used to set up a directory with switching headers
8739239Sandreas.hansson@arm.com#
8743118Sstever@eecs.umich.edu###################################################
8753118Sstever@eecs.umich.edu
8765863Snate@binkert.orgmain['ALL_ISA_LIST'] = all_isa_list
8775863Snate@binkert.orgdef make_switching_dir(dname, switch_headers, env):
8785863Snate@binkert.org    # Generate the header.  target[0] is the full path of the output
8795863Snate@binkert.org    # header to generate.  'source' is a dummy variable, since we get the
8803118Sstever@eecs.umich.edu    # list of ISAs from env['ALL_ISA_LIST'].
8813483Ssaidi@eecs.umich.edu    def gen_switch_hdr(target, source, env):
8823494Ssaidi@eecs.umich.edu        fname = str(target[0])
8833494Ssaidi@eecs.umich.edu        f = open(fname, 'w')
8843483Ssaidi@eecs.umich.edu        isa = env['TARGET_ISA'].lower()
8853483Ssaidi@eecs.umich.edu        print >>f, '#include "%s/%s/%s"' % (dname, isa, basename(fname))
8863483Ssaidi@eecs.umich.edu        f.close()
8873053Sstever@eecs.umich.edu
8883053Sstever@eecs.umich.edu    # Build SCons Action object. 'varlist' specifies env vars that this
8893918Ssaidi@eecs.umich.edu    # action depends on; when env['ALL_ISA_LIST'] changes these actions
8903053Sstever@eecs.umich.edu    # should get re-executed.
8913053Sstever@eecs.umich.edu    switch_hdr_action = MakeAction(gen_switch_hdr,
8923053Sstever@eecs.umich.edu                          Transform("GENERATE"), varlist=['ALL_ISA_LIST'])
8933053Sstever@eecs.umich.edu
8943053Sstever@eecs.umich.edu    # Instantiate actions for each header
8959396Sandreas.hansson@arm.com    for hdr in switch_headers:
8969396Sandreas.hansson@arm.com        env.Command(hdr, [], switch_hdr_action)
8979396Sandreas.hansson@arm.comExport('make_switching_dir')
8989396Sandreas.hansson@arm.com
8999396Sandreas.hansson@arm.com###################################################
9009396Sandreas.hansson@arm.com#
9019396Sandreas.hansson@arm.com# Define build environments for selected configurations.
9029396Sandreas.hansson@arm.com#
9039396Sandreas.hansson@arm.com###################################################
9049477Sandreas.hansson@arm.com
9059396Sandreas.hansson@arm.comfor variant_path in variant_paths:
9069477Sandreas.hansson@arm.com    print "Building in", variant_path
9079477Sandreas.hansson@arm.com
9089477Sandreas.hansson@arm.com    # Make a copy of the build-root environment to use for this config.
9099477Sandreas.hansson@arm.com    env = main.Clone()
9109396Sandreas.hansson@arm.com    env['BUILDDIR'] = variant_path
9117840Snate@binkert.org
9127865Sgblack@eecs.umich.edu    # variant_dir is the tail component of build path, and is used to
9137865Sgblack@eecs.umich.edu    # determine the build parameters (e.g., 'ALPHA_SE')
9147865Sgblack@eecs.umich.edu    (build_root, variant_dir) = splitpath(variant_path)
9157865Sgblack@eecs.umich.edu
9167865Sgblack@eecs.umich.edu    # Set env variables according to the build directory config.
9177840Snate@binkert.org    sticky_vars.files = []
9189900Sandreas@sandberg.pp.se    # Variables for $BUILD_ROOT/$VARIANT_DIR are stored in
9199900Sandreas@sandberg.pp.se    # $BUILD_ROOT/variables/$VARIANT_DIR so you can nuke
9209900Sandreas@sandberg.pp.se    # $BUILD_ROOT/$VARIANT_DIR without losing your variables settings.
9219900Sandreas@sandberg.pp.se    current_vars_file = joinpath(build_root, 'variables', variant_dir)
9229591Sandreas@sandberg.pp.se    if isfile(current_vars_file):
9239591Sandreas@sandberg.pp.se        sticky_vars.files.append(current_vars_file)
9249591Sandreas@sandberg.pp.se        print "Using saved variables file %s" % current_vars_file
9259590Sandreas@sandberg.pp.se    else:
9269590Sandreas@sandberg.pp.se        # Build dir-specific variables file doesn't exist.
9279045SAli.Saidi@ARM.com
9289045SAli.Saidi@ARM.com        # Make sure the directory is there so we can create it later
9299071Sandreas.hansson@arm.com        opt_dir = dirname(current_vars_file)
9309071Sandreas.hansson@arm.com        if not isdir(opt_dir):
9319045SAli.Saidi@ARM.com            mkdir(opt_dir)
9327840Snate@binkert.org
9337840Snate@binkert.org        # Get default build variables from source tree.  Variables are
9347840Snate@binkert.org        # normally determined by name of $VARIANT_DIR, but can be
9351858SN/A        # overridden by '--default=' arg on command line.
9361858SN/A        default = GetOption('default')
9371858SN/A        opts_dir = joinpath(main.root.abspath, 'build_opts')
9381858SN/A        if default:
9391858SN/A            default_vars_files = [joinpath(build_root, 'variables', default),
9401858SN/A                                  joinpath(opts_dir, default)]
9419903Sandreas.hansson@arm.com        else:
9429903Sandreas.hansson@arm.com            default_vars_files = [joinpath(opts_dir, variant_dir)]
9439903Sandreas.hansson@arm.com        existing_files = filter(isfile, default_vars_files)
9449903Sandreas.hansson@arm.com        if existing_files:
9459903Sandreas.hansson@arm.com            default_vars_file = existing_files[0]
9469903Sandreas.hansson@arm.com            sticky_vars.files.append(default_vars_file)
9479651SAndreas.Sandberg@ARM.com            print "Variables file %s not found,\n  using defaults in %s" \
9489903Sandreas.hansson@arm.com                  % (current_vars_file, default_vars_file)
9499651SAndreas.Sandberg@ARM.com        else:
9509651SAndreas.Sandberg@ARM.com            print "Error: cannot find variables file %s or " \
9519651SAndreas.Sandberg@ARM.com                  "default file(s) %s" \
9529651SAndreas.Sandberg@ARM.com                  % (current_vars_file, ' or '.join(default_vars_files))
9539651SAndreas.Sandberg@ARM.com            Exit(1)
9549657Sandreas.sandberg@arm.com
9559883Sandreas@sandberg.pp.se    # Apply current variable settings to env
9569651SAndreas.Sandberg@ARM.com    sticky_vars.Update(env)
9579651SAndreas.Sandberg@ARM.com
9589651SAndreas.Sandberg@ARM.com    help_texts["local_vars"] += \
9599651SAndreas.Sandberg@ARM.com        "Build variables for %s:\n" % variant_dir \
9609651SAndreas.Sandberg@ARM.com                 + sticky_vars.GenerateHelpText(env)
9619651SAndreas.Sandberg@ARM.com
9629651SAndreas.Sandberg@ARM.com    # Process variable settings.
9639651SAndreas.Sandberg@ARM.com
9649651SAndreas.Sandberg@ARM.com    if not have_fenv and env['USE_FENV']:
9659651SAndreas.Sandberg@ARM.com        print "Warning: <fenv.h> not available; " \
9669651SAndreas.Sandberg@ARM.com              "forcing USE_FENV to False in", variant_dir + "."
9675863Snate@binkert.org        env['USE_FENV'] = False
9685863Snate@binkert.org
9695863Snate@binkert.org    if not env['USE_FENV']:
9705863Snate@binkert.org        print "Warning: No IEEE FP rounding mode control in", variant_dir + "."
9716121Snate@binkert.org        print "         FP results may deviate slightly from other platforms."
9721858SN/A
9735863Snate@binkert.org    if env['EFENCE']:
9745863Snate@binkert.org        env.Append(LIBS=['efence'])
9755863Snate@binkert.org
9765863Snate@binkert.org    # Save sticky variable settings back to current variables file
9775863Snate@binkert.org    sticky_vars.Save(current_vars_file, env)
9782139SN/A
9794202Sbinkertn@umich.edu    if env['USE_SSE2']:
9804202Sbinkertn@umich.edu        env.Append(CCFLAGS=['-msse2'])
9812139SN/A
9826994Snate@binkert.org    if env['PROTOCOL'] != 'None':
9836994Snate@binkert.org        env['RUBY'] = True
9846994Snate@binkert.org    else:
9856994Snate@binkert.org        env['RUBY'] = False
9866994Snate@binkert.org
9876994Snate@binkert.org    # The src/SConscript file sets up the build rules in 'env' according
9886994Snate@binkert.org    # to the configured variables.  It returns a list of environments,
9896994Snate@binkert.org    # one for each variant build (debug, opt, etc.)
9906994Snate@binkert.org    envList = SConscript('src/SConscript', variant_dir = variant_path,
9916994Snate@binkert.org                         exports = 'env')
9926994Snate@binkert.org
9936994Snate@binkert.org    # Set up the regression tests for each build.
9946994Snate@binkert.org    for e in envList:
9956994Snate@binkert.org        SConscript('tests/SConscript',
9966994Snate@binkert.org                   variant_dir = joinpath(variant_path, 'tests', e.Label),
9976994Snate@binkert.org                   exports = { 'env' : e }, duplicate = False)
9986994Snate@binkert.org
9996994Snate@binkert.org# base help text
10006994Snate@binkert.orgHelp('''
10016994Snate@binkert.orgUsage: scons [scons options] [build variables] [target(s)]
10026994Snate@binkert.org
10036994Snate@binkert.orgExtra scons options:
10046994Snate@binkert.org%(options)s
10056994Snate@binkert.org
10066994Snate@binkert.orgGlobal build variables:
10076994Snate@binkert.org%(global_vars)s
10086994Snate@binkert.org
10096994Snate@binkert.org%(local_vars)s
10102155SN/A''' % help_texts)
10115863Snate@binkert.org