SConstruct revision 3940
1955SN/A# -*- mode:python -*-
2955SN/A
39812Sandreas.hansson@arm.com# Copyright (c) 2004-2005 The Regents of The University of Michigan
49812Sandreas.hansson@arm.com# All rights reserved.
59812Sandreas.hansson@arm.com#
69812Sandreas.hansson@arm.com# Redistribution and use in source and binary forms, with or without
79812Sandreas.hansson@arm.com# modification, are permitted provided that the following conditions are
89812Sandreas.hansson@arm.com# met: redistributions of source code must retain the above copyright
99812Sandreas.hansson@arm.com# notice, this list of conditions and the following disclaimer;
109812Sandreas.hansson@arm.com# redistributions in binary form must reproduce the above copyright
119812Sandreas.hansson@arm.com# notice, this list of conditions and the following disclaimer in the
129812Sandreas.hansson@arm.com# documentation and/or other materials provided with the distribution;
139812Sandreas.hansson@arm.com# neither the name of the copyright holders nor the names of its
149812Sandreas.hansson@arm.com# contributors may be used to endorse or promote products derived from
157816Ssteve.reinhardt@amd.com# this software without specific prior written permission.
165871Snate@binkert.org#
171762SN/A# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18955SN/A# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19955SN/A# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20955SN/A# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21955SN/A# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22955SN/A# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23955SN/A# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24955SN/A# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25955SN/A# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26955SN/A# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27955SN/A# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28955SN/A#
29955SN/A# Authors: Steve Reinhardt
30955SN/A
31955SN/A###################################################
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>'
37955SN/A# to build some other configuration (e.g., 'build/ALPHA_FS/m5.opt' for
38955SN/A# the optimized full-system version).
39955SN/A#
40955SN/A# 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
422665Ssaidi@eecs.umich.edu# expects that all configs under the same build directory are being
432665Ssaidi@eecs.umich.edu# built for the same host system.
445863Snate@binkert.org#
45955SN/A# Examples:
46955SN/A#
47955SN/A#   The following two commands are equivalent.  The '-u' option tells
48955SN/A#   scons to search up the directory tree for this SConstruct file.
49955SN/A#   % cd <path-to-src>/m5 ; scons build/ALPHA_FS/m5.debug
508878Ssteve.reinhardt@amd.com#   % cd <path-to-src>/m5/build/ALPHA_FS; scons -u m5.debug
512632Sstever@eecs.umich.edu#
528878Ssteve.reinhardt@amd.com#   The following two commands are equivalent and demonstrate building
532632Sstever@eecs.umich.edu#   in a directory outside of the source tree.  The '-C' option tells
54955SN/A#   scons to chdir to the specified directory to find this SConstruct
558878Ssteve.reinhardt@amd.com#   file.
562632Sstever@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
612761Sstever@eecs.umich.edu# file), you can use 'scons -h' to print all the M5-specific build
622761Sstever@eecs.umich.edu# options as well.
632761Sstever@eecs.umich.edu#
648878Ssteve.reinhardt@amd.com###################################################
658878Ssteve.reinhardt@amd.com
662761Sstever@eecs.umich.edu# Python library imports
672761Sstever@eecs.umich.eduimport sys
682761Sstever@eecs.umich.eduimport os
692761Sstever@eecs.umich.eduimport subprocess
702761Sstever@eecs.umich.edufrom os.path import join as joinpath
718878Ssteve.reinhardt@amd.com
728878Ssteve.reinhardt@amd.com# Check for recent-enough Python and SCons versions.  If your system's
732632Sstever@eecs.umich.edu# default installation of Python is not recent enough, you can use a
742632Sstever@eecs.umich.edu# non-default installation of the Python interpreter by either (1)
758878Ssteve.reinhardt@amd.com# rearranging your PATH so that scons finds the non-default 'python'
768878Ssteve.reinhardt@amd.com# first or (2) explicitly invoking an alternative interpreter on the
772632Sstever@eecs.umich.edu# scons script, e.g., "/usr/local/bin/python2.4 `which scons` [args]".
78955SN/AEnsurePythonVersion(2,4)
79955SN/A
80955SN/A# 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).
928878Ssteve.reinhardt@amd.comROOT = Dir('.').abspath
935863Snate@binkert.org
945863Snate@binkert.org# Path to the M5 source tree.
955863Snate@binkert.orgSRCDIR = joinpath(ROOT, 'src')
969812Sandreas.hansson@arm.com
979812Sandreas.hansson@arm.com# tell python where to find m5 python code
985863Snate@binkert.orgsys.path.append(joinpath(ROOT, 'src/python'))
999812Sandreas.hansson@arm.com
1005863Snate@binkert.org###################################################
1015863Snate@binkert.org#
1025863Snate@binkert.org# Figure out which configurations to set up based on the path(s) of
1039812Sandreas.hansson@arm.com# the target(s).
1049812Sandreas.hansson@arm.com#
1055863Snate@binkert.org###################################################
1065863Snate@binkert.org
1078878Ssteve.reinhardt@amd.com# Find default configuration & binary.
1085863Snate@binkert.orgDefault(os.environ.get('M5_DEFAULT_BINARY', 'build/ALPHA_SE/m5.debug'))
1095863Snate@binkert.org
1105863Snate@binkert.org# helper function: find last occurrence of element in list
1116654Snate@binkert.orgdef rfind(l, elt, offs = -1):
11210196SCurtis.Dunham@arm.com    for i in range(len(l)+offs, 0, -1):
113955SN/A        if l[i] == elt:
1145396Ssaidi@eecs.umich.edu            return i
1155863Snate@binkert.org    raise ValueError, "element not found"
1165863Snate@binkert.org
1174202Sbinkertn@umich.edu# helper function: compare dotted version numbers.
1185863Snate@binkert.org# E.g., compare_version('1.3.25', '1.4.1')
1195863Snate@binkert.org# returns -1, 0, 1 if v1 is <, ==, > v2
1205863Snate@binkert.orgdef compare_versions(v1, v2):
1215863Snate@binkert.org    # Convert dotted strings to lists
122955SN/A    v1 = map(int, v1.split('.'))
1236654Snate@binkert.org    v2 = map(int, v2.split('.'))
1245273Sstever@gmail.com    # Compare corresponding elements of lists
1255871Snate@binkert.org    for n1,n2 in zip(v1, v2):
1265273Sstever@gmail.com        if n1 < n2: return -1
1276655Snate@binkert.org        if n1 > n2: return  1
1288878Ssteve.reinhardt@amd.com    # all corresponding values are equal... see if one has extra values
1296655Snate@binkert.org    if len(v1) < len(v2): return -1
1306655Snate@binkert.org    if len(v1) > len(v2): return  1
1319219Spower.jg@gmail.com    return 0
1326655Snate@binkert.org
1335871Snate@binkert.org# Each target must have 'build' in the interior of the path; the
1346654Snate@binkert.org# directory below this will determine the build parameters.  For
1358947Sandreas.hansson@arm.com# example, for target 'foo/bar/build/ALPHA_SE/arch/alpha/blah.do' we
1365396Ssaidi@eecs.umich.edu# recognize that ALPHA_SE specifies the configuration because it
1378120Sgblack@eecs.umich.edu# follow 'build' in the bulid path.
1388120Sgblack@eecs.umich.edu
1398120Sgblack@eecs.umich.edu# Generate absolute paths to targets so we can see where the build dir is
1408120Sgblack@eecs.umich.eduif COMMAND_LINE_TARGETS:
1418120Sgblack@eecs.umich.edu    # Ask SCons which directory it was invoked from
1428120Sgblack@eecs.umich.edu    launch_dir = GetLaunchDir()
1438120Sgblack@eecs.umich.edu    # Make targets relative to invocation directory
1448120Sgblack@eecs.umich.edu    abs_targets = map(lambda x: os.path.normpath(joinpath(launch_dir, str(x))),
1458879Ssteve.reinhardt@amd.com                      COMMAND_LINE_TARGETS)
1468879Ssteve.reinhardt@amd.comelse:
1478879Ssteve.reinhardt@amd.com    # Default targets are relative to root of tree
1488879Ssteve.reinhardt@amd.com    abs_targets = map(lambda x: os.path.normpath(joinpath(ROOT, str(x))),
1498879Ssteve.reinhardt@amd.com                      DEFAULT_TARGETS)
1508879Ssteve.reinhardt@amd.com
1518879Ssteve.reinhardt@amd.com
1528879Ssteve.reinhardt@amd.com# Generate a list of the unique build roots and configs that the
1538879Ssteve.reinhardt@amd.com# collected targets reference.
1548879Ssteve.reinhardt@amd.combuild_paths = []
1558879Ssteve.reinhardt@amd.combuild_root = None
1568879Ssteve.reinhardt@amd.comfor t in abs_targets:
1578879Ssteve.reinhardt@amd.com    path_dirs = t.split('/')
1588120Sgblack@eecs.umich.edu    try:
1598120Sgblack@eecs.umich.edu        build_top = rfind(path_dirs, 'build', -2)
1608120Sgblack@eecs.umich.edu    except:
1618120Sgblack@eecs.umich.edu        print "Error: no non-leaf 'build' dir found on target path", t
1628120Sgblack@eecs.umich.edu        Exit(1)
1638120Sgblack@eecs.umich.edu    this_build_root = joinpath('/',*path_dirs[:build_top+1])
1648120Sgblack@eecs.umich.edu    if not build_root:
1658120Sgblack@eecs.umich.edu        build_root = this_build_root
1668120Sgblack@eecs.umich.edu    else:
1678120Sgblack@eecs.umich.edu        if this_build_root != build_root:
1688120Sgblack@eecs.umich.edu            print "Error: build targets not under same build root\n"\
1698120Sgblack@eecs.umich.edu                  "  %s\n  %s" % (build_root, this_build_root)
1708120Sgblack@eecs.umich.edu            Exit(1)
1718120Sgblack@eecs.umich.edu    build_path = joinpath('/',*path_dirs[:build_top+2])
1728879Ssteve.reinhardt@amd.com    if build_path not in build_paths:
1738879Ssteve.reinhardt@amd.com        build_paths.append(build_path)
1748879Ssteve.reinhardt@amd.com
1758879Ssteve.reinhardt@amd.com###################################################
1768879Ssteve.reinhardt@amd.com#
1778879Ssteve.reinhardt@amd.com# Set up the default build environment.  This environment is copied
1788879Ssteve.reinhardt@amd.com# and modified according to each selected configuration.
1798879Ssteve.reinhardt@amd.com#
1809227Sandreas.hansson@arm.com###################################################
1819227Sandreas.hansson@arm.com
1828879Ssteve.reinhardt@amd.comenv = Environment(ENV = os.environ,  # inherit user's environment vars
1838879Ssteve.reinhardt@amd.com                  ROOT = ROOT,
1848879Ssteve.reinhardt@amd.com                  SRCDIR = SRCDIR)
1858879Ssteve.reinhardt@amd.com
1868120Sgblack@eecs.umich.edu#Parse CC/CXX early so that we use the correct compiler for 
1878947Sandreas.hansson@arm.com# to test for dependencies/versions/libraries/includes
1887816Ssteve.reinhardt@amd.comif ARGUMENTS.get('CC', None):
1895871Snate@binkert.org    env['CC'] = ARGUMENTS.get('CC')
1905871Snate@binkert.org
1916121Snate@binkert.orgif ARGUMENTS.get('CXX', None):
1925871Snate@binkert.org    env['CXX'] = ARGUMENTS.get('CXX')
1935871Snate@binkert.org
1949926Sstan.czerniawski@arm.comenv.SConsignFile(joinpath(build_root,"sconsign"))
1959926Sstan.czerniawski@arm.com
1969119Sandreas.hansson@arm.com# Default duplicate option is to use hard links, but this messes up
19710068Sandreas.hansson@arm.com# when you use emacs to edit a file in the target dir, as emacs moves
19810068Sandreas.hansson@arm.com# file to file~ then copies to file, breaking the link.  Symbolic
199955SN/A# (soft) links work better.
2009416SAndreas.Sandberg@ARM.comenv.SetOption('duplicate', 'soft-copy')
2019416SAndreas.Sandberg@ARM.com
2029416SAndreas.Sandberg@ARM.com# I waffle on this setting... it does avoid a few painful but
2039416SAndreas.Sandberg@ARM.com# unnecessary builds, but it also seems to make trivial builds take
2049416SAndreas.Sandberg@ARM.com# noticeably longer.
2059416SAndreas.Sandberg@ARM.comif False:
2069416SAndreas.Sandberg@ARM.com    env.TargetSignatures('content')
2075871Snate@binkert.org
2085871Snate@binkert.org# M5_PLY is used by isa_parser.py to find the PLY package.
2099416SAndreas.Sandberg@ARM.comenv.Append(ENV = { 'M5_PLY' : Dir('ext/ply') })
2109416SAndreas.Sandberg@ARM.comenv['GCC'] = False
2115871Snate@binkert.orgenv['SUNCC'] = False
212955SN/Aenv['ICC'] = False
2136121Snate@binkert.orgenv['GCC'] = subprocess.Popen(env['CXX'] + ' --version', shell=True, 
2148881Smarc.orr@gmail.com        stdout=subprocess.PIPE, stderr=subprocess.STDOUT, 
2156121Snate@binkert.org        close_fds=True).communicate()[0].find('GCC') >= 0
2166121Snate@binkert.orgenv['SUNCC'] = subprocess.Popen(env['CXX'] + ' -V', shell=True, 
2171533SN/A        stdout=subprocess.PIPE, stderr=subprocess.STDOUT, 
2189239Sandreas.hansson@arm.com        close_fds=True).communicate()[0].find('Sun C++') >= 0
2199239Sandreas.hansson@arm.comenv['ICC'] = subprocess.Popen(env['CXX'] + ' -V', shell=True, 
2209239Sandreas.hansson@arm.com        stdout=subprocess.PIPE, stderr=subprocess.STDOUT, 
2219239Sandreas.hansson@arm.com        close_fds=True).communicate()[0].find('Intel') >= 0
2229239Sandreas.hansson@arm.comif env['GCC'] + env['SUNCC'] env['ICC'] > 1:
2239239Sandreas.hansson@arm.com    print 'Error: How can we have two at the same time?'
2249239Sandreas.hansson@arm.com    Exit(1)
2259239Sandreas.hansson@arm.com
2269239Sandreas.hansson@arm.com
2279239Sandreas.hansson@arm.com# Set up default C++ compiler flags
2289239Sandreas.hansson@arm.comif env['GCC']:
2299239Sandreas.hansson@arm.com    env.Append(CCFLAGS='-pipe')
2306655Snate@binkert.org    env.Append(CCFLAGS='-fno-strict-aliasing')
2316655Snate@binkert.org    env.Append(CCFLAGS=Split('-Wall -Wno-sign-compare -Werror -Wundef'))
2326655Snate@binkert.orgelif env['ICC']:
2336655Snate@binkert.org    pass #Fix me... add warning flags once we clean up icc warnings
2345871Snate@binkert.orgelif env['SUNCC']:
2355871Snate@binkert.org    env.Append(CCFLAGS='-Qoption ccfe')
2365863Snate@binkert.org    env.Append(CCFLAGS='-features=gcc')
2375871Snate@binkert.org    env.Append(CCFLAGS='-features=extensions')
2388878Ssteve.reinhardt@amd.com    env.Append(CCFLAGS='-library=stlport4')
2395871Snate@binkert.org    env.Append(CCFLAGS='-xar')
2405871Snate@binkert.org#    env.Append(CCFLAGS='-instances=semiexplicit')
2415871Snate@binkert.orgelse:
2425863Snate@binkert.org    print 'Error: Don\'t know what compiler options to use for your compiler.'
2436121Snate@binkert.org    print '       Please fix SConstruct and src/SConscript and try again.'
2445863Snate@binkert.org    Exit(1)
2455871Snate@binkert.org
2468336Ssteve.reinhardt@amd.comif sys.platform == 'cygwin':
2478336Ssteve.reinhardt@amd.com    # cygwin has some header file issues...
2488336Ssteve.reinhardt@amd.com    env.Append(CCFLAGS=Split("-Wno-uninitialized"))
2498336Ssteve.reinhardt@amd.comenv.Append(CPPPATH=[Dir('ext/dnet')])
2504678Snate@binkert.org
2518336Ssteve.reinhardt@amd.com# Check for SWIG
2528336Ssteve.reinhardt@amd.comif not env.has_key('SWIG'):
2538336Ssteve.reinhardt@amd.com    print 'Error: SWIG utility not found.'
2544678Snate@binkert.org    print '       Please install (see http://www.swig.org) and retry.'
2554678Snate@binkert.org    Exit(1)
2564678Snate@binkert.org
2574678Snate@binkert.org# Check for appropriate SWIG version
2587827Snate@binkert.orgswig_version = os.popen('swig -version').read().split()
2597827Snate@binkert.org# First 3 words should be "SWIG Version x.y.z"
2608336Ssteve.reinhardt@amd.comif swig_version[0] != 'SWIG' or swig_version[1] != 'Version':
2614678Snate@binkert.org    print 'Error determining SWIG version.'
2628336Ssteve.reinhardt@amd.com    Exit(1)
2638336Ssteve.reinhardt@amd.com
2648336Ssteve.reinhardt@amd.commin_swig_version = '1.3.28'
2658336Ssteve.reinhardt@amd.comif compare_versions(swig_version[2], min_swig_version) < 0:
2668336Ssteve.reinhardt@amd.com    print 'Error: SWIG version', min_swig_version, 'or newer required.'
2678336Ssteve.reinhardt@amd.com    print '       Installed version:', swig_version[2]
2685871Snate@binkert.org    Exit(1)
2695871Snate@binkert.org
2708336Ssteve.reinhardt@amd.com# Set up SWIG flags & scanner
2718336Ssteve.reinhardt@amd.comenv.Append(SWIGFLAGS=Split('-c++ -python -modern $_CPPINCFLAGS'))
2728336Ssteve.reinhardt@amd.com
2738336Ssteve.reinhardt@amd.comimport SCons.Scanner
2748336Ssteve.reinhardt@amd.com
2755871Snate@binkert.orgswig_inc_re = '^[ \t]*[%,#][ \t]*(?:include|import)[ \t]*(<|")([^>"]+)(>|")'
2768336Ssteve.reinhardt@amd.com
2778336Ssteve.reinhardt@amd.comswig_scanner = SCons.Scanner.ClassicCPP("SwigScan", ".i", "CPPPATH",
2788336Ssteve.reinhardt@amd.com                                        swig_inc_re)
2798336Ssteve.reinhardt@amd.com
2808336Ssteve.reinhardt@amd.comenv.Append(SCANNERS = swig_scanner)
2814678Snate@binkert.org
2825871Snate@binkert.org# Platform-specific configuration.  Note again that we assume that all
2834678Snate@binkert.org# builds under a given build root run on the same host platform.
2848336Ssteve.reinhardt@amd.comconf = Configure(env,
2858336Ssteve.reinhardt@amd.com                 conf_dir = joinpath(build_root, '.scons_config'),
2868336Ssteve.reinhardt@amd.com                 log_file = joinpath(build_root, 'scons_config.log'))
2878336Ssteve.reinhardt@amd.com
2888336Ssteve.reinhardt@amd.com# Find Python include and library directories for embedding the
2898336Ssteve.reinhardt@amd.com# interpreter.  For consistency, we will use the same Python
2908336Ssteve.reinhardt@amd.com# installation used to run scons (and thus this script).  If you want
2918336Ssteve.reinhardt@amd.com# to link in an alternate version, see above for instructions on how
2928336Ssteve.reinhardt@amd.com# to invoke scons with a different copy of the Python interpreter.
2938336Ssteve.reinhardt@amd.com
2948336Ssteve.reinhardt@amd.com# Get brief Python version name (e.g., "python2.4") for locating
2958336Ssteve.reinhardt@amd.com# include & library files
2968336Ssteve.reinhardt@amd.compy_version_name = 'python' + sys.version[:3]
2978336Ssteve.reinhardt@amd.com
2988336Ssteve.reinhardt@amd.com# include path, e.g. /usr/local/include/python2.4
2998336Ssteve.reinhardt@amd.compy_header_path = joinpath(sys.exec_prefix, 'include', py_version_name)
3008336Ssteve.reinhardt@amd.comenv.Append(CPPPATH = py_header_path)
3015871Snate@binkert.org# verify that it works
3026121Snate@binkert.orgif not conf.CheckHeader('Python.h', '<>'):
303955SN/A    print "Error: can't find Python.h header in", py_header_path
304955SN/A    Exit(1)
3052632Sstever@eecs.umich.edu
3062632Sstever@eecs.umich.edu# add library path too if it's not in the default place
307955SN/Apy_lib_path = None
308955SN/Aif sys.exec_prefix != '/usr':
309955SN/A    py_lib_path = joinpath(sys.exec_prefix, 'lib')
310955SN/Aelif sys.platform == 'cygwin':
3118878Ssteve.reinhardt@amd.com    # cygwin puts the .dll in /bin for some reason
312955SN/A    py_lib_path = '/bin'
3132632Sstever@eecs.umich.eduif py_lib_path:
3142632Sstever@eecs.umich.edu    env.Append(LIBPATH = py_lib_path)
3152632Sstever@eecs.umich.edu    print 'Adding', py_lib_path, 'to LIBPATH for', py_version_name
3162632Sstever@eecs.umich.eduif not conf.CheckLib(py_version_name):
3172632Sstever@eecs.umich.edu    print "Error: can't find Python library", py_version_name
3182632Sstever@eecs.umich.edu    Exit(1)
3192632Sstever@eecs.umich.edu
3208268Ssteve.reinhardt@amd.com# On Solaris you need to use libsocket for socket ops
3218268Ssteve.reinhardt@amd.comif not conf.CheckLibWithHeader(None, 'sys/socket.h', 'C++', 'accept(0,0,0);'):
3228268Ssteve.reinhardt@amd.com   if not conf.CheckLibWithHeader('socket', 'sys/socket.h', 'C++', 'accept(0,0,0);'):
3238268Ssteve.reinhardt@amd.com       print "Can't find library with socket calls (e.g. accept())"
3248268Ssteve.reinhardt@amd.com       Exit(1)
3258268Ssteve.reinhardt@amd.com
3268268Ssteve.reinhardt@amd.com# Check for zlib.  If the check passes, libz will be automatically
3272632Sstever@eecs.umich.edu# added to the LIBS environment variable.
3282632Sstever@eecs.umich.eduif not conf.CheckLibWithHeader('z', 'zlib.h', 'C++','zlibVersion();'):
3292632Sstever@eecs.umich.edu    print 'Error: did not find needed zlib compression library '\
3302632Sstever@eecs.umich.edu          'and/or zlib.h header file.'
3318268Ssteve.reinhardt@amd.com    print '       Please install zlib and try again.'
3322632Sstever@eecs.umich.edu    Exit(1)
3338268Ssteve.reinhardt@amd.com
3348268Ssteve.reinhardt@amd.com# Check for <fenv.h> (C99 FP environment control)
3358268Ssteve.reinhardt@amd.comhave_fenv = conf.CheckHeader('fenv.h', '<>')
3368268Ssteve.reinhardt@amd.comif not have_fenv:
3373718Sstever@eecs.umich.edu    print "Warning: Header file <fenv.h> not found."
3382634Sstever@eecs.umich.edu    print "         This host has no IEEE FP rounding mode control."
3392634Sstever@eecs.umich.edu
3405863Snate@binkert.org# Check for mysql.
3412638Sstever@eecs.umich.edumysql_config = WhereIs('mysql_config')
3428268Ssteve.reinhardt@amd.comhave_mysql = mysql_config != None
3432632Sstever@eecs.umich.edu
3442632Sstever@eecs.umich.edu# Check MySQL version.
3452632Sstever@eecs.umich.eduif have_mysql:
3462632Sstever@eecs.umich.edu    mysql_version = os.popen(mysql_config + ' --version').read()
3472632Sstever@eecs.umich.edu    min_mysql_version = '4.1'
3481858SN/A    if compare_versions(mysql_version, min_mysql_version) < 0:
3493716Sstever@eecs.umich.edu        print 'Warning: MySQL', min_mysql_version, 'or newer required.'
3502638Sstever@eecs.umich.edu        print '         Version', mysql_version, 'detected.'
3512638Sstever@eecs.umich.edu        have_mysql = False
3522638Sstever@eecs.umich.edu
3532638Sstever@eecs.umich.edu# Set up mysql_config commands.
3542638Sstever@eecs.umich.eduif have_mysql:
3552638Sstever@eecs.umich.edu    mysql_config_include = mysql_config + ' --include'
3562638Sstever@eecs.umich.edu    if os.system(mysql_config_include + ' > /dev/null') != 0:
3575863Snate@binkert.org        # older mysql_config versions don't support --include, use
3585863Snate@binkert.org        # --cflags instead
3595863Snate@binkert.org        mysql_config_include = mysql_config + ' --cflags | sed s/\\\'//g'
360955SN/A    # This seems to work in all versions
3615341Sstever@gmail.com    mysql_config_libs = mysql_config + ' --libs'
3625341Sstever@gmail.com
3635863Snate@binkert.orgenv = conf.Finish()
3647756SAli.Saidi@ARM.com
3655341Sstever@gmail.com# Define the universe of supported ISAs
3666121Snate@binkert.orgenv['ALL_ISA_LIST'] = ['alpha', 'sparc', 'mips']
3674494Ssaidi@eecs.umich.edu
3686121Snate@binkert.org# Define the universe of supported CPU models
3691105SN/Aenv['ALL_CPU_LIST'] = ['AtomicSimpleCPU', 'TimingSimpleCPU',
3702667Sstever@eecs.umich.edu                       'O3CPU', 'OzoneCPU']
3712667Sstever@eecs.umich.edu
3722667Sstever@eecs.umich.eduif os.path.isdir(joinpath(SRCDIR, 'encumbered/cpu/full')):
3732667Sstever@eecs.umich.edu    env['ALL_CPU_LIST'] += ['FullCPU']
3746121Snate@binkert.org
3752667Sstever@eecs.umich.edu# Sticky options get saved in the options file so they persist from
3765341Sstever@gmail.com# one invocation to the next (unless overridden, in which case the new
3775863Snate@binkert.org# value becomes sticky).
3785341Sstever@gmail.comsticky_opts = Options(args=ARGUMENTS)
3795341Sstever@gmail.comsticky_opts.AddOptions(
3805341Sstever@gmail.com    EnumOption('TARGET_ISA', 'Target ISA', 'alpha', env['ALL_ISA_LIST']),
3818120Sgblack@eecs.umich.edu    BoolOption('FULL_SYSTEM', 'Full-system support', False),
3825341Sstever@gmail.com    # There's a bug in scons 0.96.1 that causes ListOptions with list
3838120Sgblack@eecs.umich.edu    # values (more than one value) not to be able to be restored from
3845341Sstever@gmail.com    # a saved option file.  If this causes trouble then upgrade to
3858120Sgblack@eecs.umich.edu    # scons 0.96.90 or later.
3866121Snate@binkert.org    ListOption('CPU_MODELS', 'CPU models', 'AtomicSimpleCPU,TimingSimpleCPU,O3CPU',
3876121Snate@binkert.org               env['ALL_CPU_LIST']),
3888980Ssteve.reinhardt@amd.com    BoolOption('ALPHA_TLASER',
3899396Sandreas.hansson@arm.com               'Model Alpha TurboLaser platform (vs. Tsunami)', False),
3905397Ssaidi@eecs.umich.edu    BoolOption('NO_FAST_ALLOC', 'Disable fast object allocator', False),
3915397Ssaidi@eecs.umich.edu    BoolOption('EFENCE', 'Link with Electric Fence malloc debugger',
3927727SAli.Saidi@ARM.com               False),
3938268Ssteve.reinhardt@amd.com    BoolOption('SS_COMPATIBLE_FP',
3946168Snate@binkert.org               'Make floating-point results compatible with SimpleScalar',
3955341Sstever@gmail.com               False),
3968120Sgblack@eecs.umich.edu    BoolOption('USE_SSE2',
3978120Sgblack@eecs.umich.edu               'Compile for SSE2 (-msse2) to get IEEE FP on x86 hosts',
3988120Sgblack@eecs.umich.edu               False),
3996814Sgblack@eecs.umich.edu    BoolOption('USE_MYSQL', 'Use MySQL for stats output', have_mysql),
4005863Snate@binkert.org    BoolOption('USE_FENV', 'Use <fenv.h> IEEE mode control', have_fenv),
4018120Sgblack@eecs.umich.edu    BoolOption('USE_CHECKER', 'Use checker for detailed CPU models', False),
4025341Sstever@gmail.com    ('CC', 'C compiler', os.environ.get('CC', env['CC'])),
4035863Snate@binkert.org    ('CXX', 'C++ compiler', os.environ.get('CXX', env['CXX'])),
4048268Ssteve.reinhardt@amd.com    BoolOption('BATCH', 'Use batch pool for build and tests', False),
4056121Snate@binkert.org    ('BATCH_CMD', 'Batch pool submission command name', 'qdo'),
4066121Snate@binkert.org    ('PYTHONHOME',
4078268Ssteve.reinhardt@amd.com     'Override the default PYTHONHOME for this system (use with caution)',
4085742Snate@binkert.org     '%s:%s' % (sys.prefix, sys.exec_prefix))
4095742Snate@binkert.org    )
4105341Sstever@gmail.com
4115742Snate@binkert.org# Non-sticky options only apply to the current build.
4125742Snate@binkert.orgnonsticky_opts = Options(args=ARGUMENTS)
4135341Sstever@gmail.comnonsticky_opts.AddOptions(
4146017Snate@binkert.org    BoolOption('update_ref', 'Update test reference outputs', False)
4156121Snate@binkert.org    )
4166017Snate@binkert.org
4177816Ssteve.reinhardt@amd.com# These options get exported to #defines in config/*.hh (see src/SConscript).
4187756SAli.Saidi@ARM.comenv.ExportOptions = ['FULL_SYSTEM', 'ALPHA_TLASER', 'USE_FENV', \
4197756SAli.Saidi@ARM.com                     'USE_MYSQL', 'NO_FAST_ALLOC', 'SS_COMPATIBLE_FP', \
4207756SAli.Saidi@ARM.com                     'USE_CHECKER', 'PYTHONHOME', 'TARGET_ISA']
4217756SAli.Saidi@ARM.com
4227756SAli.Saidi@ARM.com# Define a handy 'no-op' action
4237756SAli.Saidi@ARM.comdef no_action(target, source, env):
4247756SAli.Saidi@ARM.com    return 0
4257756SAli.Saidi@ARM.com
4267816Ssteve.reinhardt@amd.comenv.NoAction = Action(no_action, None)
4277816Ssteve.reinhardt@amd.com
4287816Ssteve.reinhardt@amd.com###################################################
4297816Ssteve.reinhardt@amd.com#
4307816Ssteve.reinhardt@amd.com# Define a SCons builder for configuration flag headers.
4317816Ssteve.reinhardt@amd.com#
4327816Ssteve.reinhardt@amd.com###################################################
4337816Ssteve.reinhardt@amd.com
4347816Ssteve.reinhardt@amd.com# This function generates a config header file that #defines the
4357816Ssteve.reinhardt@amd.com# option symbol to the current option setting (0 or 1).  The source
4367756SAli.Saidi@ARM.com# operands are the name of the option and a Value node containing the
4377816Ssteve.reinhardt@amd.com# value of the option.
4387816Ssteve.reinhardt@amd.comdef build_config_file(target, source, env):
4397816Ssteve.reinhardt@amd.com    (option, value) = [s.get_contents() for s in source]
4407816Ssteve.reinhardt@amd.com    f = file(str(target[0]), 'w')
4417816Ssteve.reinhardt@amd.com    print >> f, '#define', option, value
4427816Ssteve.reinhardt@amd.com    f.close()
4437816Ssteve.reinhardt@amd.com    return None
4447816Ssteve.reinhardt@amd.com
4457816Ssteve.reinhardt@amd.com# Generate the message to be printed when building the config file.
4467816Ssteve.reinhardt@amd.comdef build_config_file_string(target, source, env):
4477816Ssteve.reinhardt@amd.com    (option, value) = [s.get_contents() for s in source]
4487816Ssteve.reinhardt@amd.com    return "Defining %s as %s in %s." % (option, value, target[0])
4497816Ssteve.reinhardt@amd.com
4507816Ssteve.reinhardt@amd.com# Combine the two functions into a scons Action object.
4517816Ssteve.reinhardt@amd.comconfig_action = Action(build_config_file, build_config_file_string)
4527816Ssteve.reinhardt@amd.com
4537816Ssteve.reinhardt@amd.com# The emitter munges the source & target node lists to reflect what
4547816Ssteve.reinhardt@amd.com# we're really doing.
4557816Ssteve.reinhardt@amd.comdef config_emitter(target, source, env):
4567816Ssteve.reinhardt@amd.com    # extract option name from Builder arg
4577816Ssteve.reinhardt@amd.com    option = str(target[0])
4587816Ssteve.reinhardt@amd.com    # True target is config header file
4597816Ssteve.reinhardt@amd.com    target = joinpath('config', option.lower() + '.hh')
4607816Ssteve.reinhardt@amd.com    val = env[option]
4617816Ssteve.reinhardt@amd.com    if isinstance(val, bool):
4627816Ssteve.reinhardt@amd.com        # Force value to 0/1
4637816Ssteve.reinhardt@amd.com        val = int(val)
4647816Ssteve.reinhardt@amd.com    elif isinstance(val, str):
4657816Ssteve.reinhardt@amd.com        val = '"' + val + '"'
4667816Ssteve.reinhardt@amd.com        
4677816Ssteve.reinhardt@amd.com    # Sources are option name & value (packaged in SCons Value nodes)
4687816Ssteve.reinhardt@amd.com    return ([target], [Value(option), Value(val)])
4697816Ssteve.reinhardt@amd.com
4707816Ssteve.reinhardt@amd.comconfig_builder = Builder(emitter = config_emitter, action = config_action)
4717816Ssteve.reinhardt@amd.com
4727816Ssteve.reinhardt@amd.comenv.Append(BUILDERS = { 'ConfigFile' : config_builder })
4737816Ssteve.reinhardt@amd.com
4747816Ssteve.reinhardt@amd.com###################################################
4757816Ssteve.reinhardt@amd.com#
4767816Ssteve.reinhardt@amd.com# Define a SCons builder for copying files.  This is used by the
4777816Ssteve.reinhardt@amd.com# Python zipfile code in src/python/SConscript, but is placed up here
4787816Ssteve.reinhardt@amd.com# since it's potentially more generally applicable.
4797816Ssteve.reinhardt@amd.com#
4807816Ssteve.reinhardt@amd.com###################################################
4817816Ssteve.reinhardt@amd.com
4827816Ssteve.reinhardt@amd.comcopy_builder = Builder(action = Copy("$TARGET", "$SOURCE"))
4837816Ssteve.reinhardt@amd.com
4847816Ssteve.reinhardt@amd.comenv.Append(BUILDERS = { 'CopyFile' : copy_builder })
4857816Ssteve.reinhardt@amd.com
4867816Ssteve.reinhardt@amd.com###################################################
4877816Ssteve.reinhardt@amd.com#
4887816Ssteve.reinhardt@amd.com# Define a simple SCons builder to concatenate files.
4897816Ssteve.reinhardt@amd.com#
4907816Ssteve.reinhardt@amd.com# Used to append the Python zip archive to the executable.
4917816Ssteve.reinhardt@amd.com#
4927816Ssteve.reinhardt@amd.com###################################################
4937816Ssteve.reinhardt@amd.com
4947816Ssteve.reinhardt@amd.comconcat_builder = Builder(action = Action(['cat $SOURCES > $TARGET',
4957816Ssteve.reinhardt@amd.com                                          'chmod +x $TARGET']))
4967816Ssteve.reinhardt@amd.com
4977816Ssteve.reinhardt@amd.comenv.Append(BUILDERS = { 'Concat' : concat_builder })
4988947Sandreas.hansson@arm.com
4998947Sandreas.hansson@arm.com
5007756SAli.Saidi@ARM.com# base help text
5018120Sgblack@eecs.umich.eduhelp_text = '''
5027756SAli.Saidi@ARM.comUsage: scons [scons options] [build options] [target(s)]
5037756SAli.Saidi@ARM.com
5047756SAli.Saidi@ARM.com'''
5057756SAli.Saidi@ARM.com
5067816Ssteve.reinhardt@amd.com# libelf build is shared across all configs in the build root.
5077816Ssteve.reinhardt@amd.comenv.SConscript('ext/libelf/SConscript',
5087816Ssteve.reinhardt@amd.com               build_dir = joinpath(build_root, 'libelf'),
5097816Ssteve.reinhardt@amd.com               exports = 'env')
5107816Ssteve.reinhardt@amd.com
5117816Ssteve.reinhardt@amd.com###################################################
5127816Ssteve.reinhardt@amd.com#
5137816Ssteve.reinhardt@amd.com# This function is used to set up a directory with switching headers
5147816Ssteve.reinhardt@amd.com#
5157816Ssteve.reinhardt@amd.com###################################################
5167756SAli.Saidi@ARM.com
5177756SAli.Saidi@ARM.comdef make_switching_dir(dirname, switch_headers, env):
5189227Sandreas.hansson@arm.com    # Generate the header.  target[0] is the full path of the output
5199227Sandreas.hansson@arm.com    # header to generate.  'source' is a dummy variable, since we get the
5209227Sandreas.hansson@arm.com    # list of ISAs from env['ALL_ISA_LIST'].
5219227Sandreas.hansson@arm.com    def gen_switch_hdr(target, source, env):
5229590Sandreas@sandberg.pp.se	fname = str(target[0])
5239590Sandreas@sandberg.pp.se	basename = os.path.basename(fname)
5249590Sandreas@sandberg.pp.se	f = open(fname, 'w')
5259590Sandreas@sandberg.pp.se	f.write('#include "arch/isa_specific.hh"\n')
5269590Sandreas@sandberg.pp.se	cond = '#if'
5279590Sandreas@sandberg.pp.se	for isa in env['ALL_ISA_LIST']:
5286654Snate@binkert.org	    f.write('%s THE_ISA == %s_ISA\n#include "%s/%s/%s"\n'
5296654Snate@binkert.org		    % (cond, isa.upper(), dirname, isa, basename))
5305871Snate@binkert.org	    cond = '#elif'
5316121Snate@binkert.org	f.write('#else\n#error "THE_ISA not set"\n#endif\n')
5328946Sandreas.hansson@arm.com	f.close()
5339419Sandreas.hansson@arm.com	return 0
5343940Ssaidi@eecs.umich.edu
5353918Ssaidi@eecs.umich.edu    # String to print when generating header
5363918Ssaidi@eecs.umich.edu    def gen_switch_hdr_string(target, source, env):
5371858SN/A	return "Generating switch header " + str(target[0])
5389556Sandreas.hansson@arm.com
5399556Sandreas.hansson@arm.com    # Build SCons Action object. 'varlist' specifies env vars that this
5409556Sandreas.hansson@arm.com    # action depends on; when env['ALL_ISA_LIST'] changes these actions
5419556Sandreas.hansson@arm.com    # should get re-executed.
5429556Sandreas.hansson@arm.com    switch_hdr_action = Action(gen_switch_hdr, gen_switch_hdr_string,
5439556Sandreas.hansson@arm.com                               varlist=['ALL_ISA_LIST'])
5449556Sandreas.hansson@arm.com
5459556Sandreas.hansson@arm.com    # Instantiate actions for each header
5469556Sandreas.hansson@arm.com    for hdr in switch_headers:
5479556Sandreas.hansson@arm.com        env.Command(hdr, [], switch_hdr_action)
5489556Sandreas.hansson@arm.com
5499556Sandreas.hansson@arm.comenv.make_switching_dir = make_switching_dir
5509556Sandreas.hansson@arm.com
5519556Sandreas.hansson@arm.com###################################################
5529556Sandreas.hansson@arm.com#
5539556Sandreas.hansson@arm.com# Define build environments for selected configurations.
5549556Sandreas.hansson@arm.com#
5559556Sandreas.hansson@arm.com###################################################
5569556Sandreas.hansson@arm.com
5579556Sandreas.hansson@arm.com# rename base env
5589556Sandreas.hansson@arm.combase_env = env
5599556Sandreas.hansson@arm.com
5609556Sandreas.hansson@arm.comfor build_path in build_paths:
5619556Sandreas.hansson@arm.com    print "Building in", build_path
5629556Sandreas.hansson@arm.com    # build_dir is the tail component of build path, and is used to
5639556Sandreas.hansson@arm.com    # determine the build parameters (e.g., 'ALPHA_SE')
5649556Sandreas.hansson@arm.com    (build_root, build_dir) = os.path.split(build_path)
5659556Sandreas.hansson@arm.com    # Make a copy of the build-root environment to use for this config.
5669556Sandreas.hansson@arm.com    env = base_env.Copy()
5679556Sandreas.hansson@arm.com
5689556Sandreas.hansson@arm.com    # Set env options according to the build directory config.
5699556Sandreas.hansson@arm.com    sticky_opts.files = []
5706121Snate@binkert.org    # Options for $BUILD_ROOT/$BUILD_DIR are stored in
57110238Sandreas.hansson@arm.com    # $BUILD_ROOT/options/$BUILD_DIR so you can nuke
57210238Sandreas.hansson@arm.com    # $BUILD_ROOT/$BUILD_DIR without losing your options settings.
57310238Sandreas.hansson@arm.com    current_opts_file = joinpath(build_root, 'options', build_dir)
57410238Sandreas.hansson@arm.com    if os.path.isfile(current_opts_file):
5759420Sandreas.hansson@arm.com        sticky_opts.files.append(current_opts_file)
57610238Sandreas.hansson@arm.com        print "Using saved options file %s" % current_opts_file
57710238Sandreas.hansson@arm.com    else:
5789420Sandreas.hansson@arm.com        # Build dir-specific options file doesn't exist.
5799420Sandreas.hansson@arm.com
5809420Sandreas.hansson@arm.com        # Make sure the directory is there so we can create it later
5819420Sandreas.hansson@arm.com        opt_dir = os.path.dirname(current_opts_file)
5829420Sandreas.hansson@arm.com        if not os.path.isdir(opt_dir):
58310264Sandreas.hansson@arm.com            os.mkdir(opt_dir)
58410264Sandreas.hansson@arm.com
58510264Sandreas.hansson@arm.com        # Get default build options from source tree.  Options are
58610264Sandreas.hansson@arm.com        # normally determined by name of $BUILD_DIR, but can be
58710264Sandreas.hansson@arm.com        # overriden by 'default=' arg on command line.
58810264Sandreas.hansson@arm.com        default_opts_file = joinpath('build_opts',
58910264Sandreas.hansson@arm.com                                     ARGUMENTS.get('default', build_dir))
59010264Sandreas.hansson@arm.com        if os.path.isfile(default_opts_file):
59110264Sandreas.hansson@arm.com            sticky_opts.files.append(default_opts_file)
59210264Sandreas.hansson@arm.com            print "Options file %s not found,\n  using defaults in %s" \
59310264Sandreas.hansson@arm.com                  % (current_opts_file, default_opts_file)
59410264Sandreas.hansson@arm.com        else:
59510264Sandreas.hansson@arm.com            print "Error: cannot find options file %s or %s" \
59610264Sandreas.hansson@arm.com                  % (current_opts_file, default_opts_file)
59710264Sandreas.hansson@arm.com            Exit(1)
59810264Sandreas.hansson@arm.com
59910238Sandreas.hansson@arm.com    # Apply current option settings to env
60010238Sandreas.hansson@arm.com    sticky_opts.Update(env)
60110238Sandreas.hansson@arm.com    nonsticky_opts.Update(env)
60210238Sandreas.hansson@arm.com
60310238Sandreas.hansson@arm.com    help_text += "Sticky options for %s:\n" % build_dir \
60410238Sandreas.hansson@arm.com                 + sticky_opts.GenerateHelpText(env) \
60510238Sandreas.hansson@arm.com                 + "\nNon-sticky options for %s:\n" % build_dir \
60610238Sandreas.hansson@arm.com                 + nonsticky_opts.GenerateHelpText(env)
6079227Sandreas.hansson@arm.com
60810238Sandreas.hansson@arm.com    # Process option settings.
60910238Sandreas.hansson@arm.com
61010238Sandreas.hansson@arm.com    if not have_fenv and env['USE_FENV']:
61110238Sandreas.hansson@arm.com        print "Warning: <fenv.h> not available; " \
61210238Sandreas.hansson@arm.com              "forcing USE_FENV to False in", build_dir + "."
6139227Sandreas.hansson@arm.com        env['USE_FENV'] = False
6149590Sandreas@sandberg.pp.se
6159590Sandreas@sandberg.pp.se    if not env['USE_FENV']:
6169590Sandreas@sandberg.pp.se        print "Warning: No IEEE FP rounding mode control in", build_dir + "."
6178737Skoansin.tan@gmail.com        print "         FP results may deviate slightly from other platforms."
61810238Sandreas.hansson@arm.com
61910238Sandreas.hansson@arm.com    if env['EFENCE']:
6209420Sandreas.hansson@arm.com        env.Append(LIBS=['efence'])
6218737Skoansin.tan@gmail.com
62210106SMitch.Hayenga@arm.com    if env['USE_MYSQL']:
6238737Skoansin.tan@gmail.com        if not have_mysql:
6248737Skoansin.tan@gmail.com            print "Warning: MySQL not available; " \
62510238Sandreas.hansson@arm.com                  "forcing USE_MYSQL to False in", build_dir + "."
62610238Sandreas.hansson@arm.com            env['USE_MYSQL'] = False
6278737Skoansin.tan@gmail.com        else:
6288737Skoansin.tan@gmail.com            print "Compiling in", build_dir, "with MySQL support."
6298737Skoansin.tan@gmail.com            env.ParseConfig(mysql_config_libs)
6308737Skoansin.tan@gmail.com            env.ParseConfig(mysql_config_include)
6318737Skoansin.tan@gmail.com
6328737Skoansin.tan@gmail.com    # Save sticky option settings back to current options file
6339556Sandreas.hansson@arm.com    sticky_opts.Save(current_opts_file, env)
6349556Sandreas.hansson@arm.com
6359556Sandreas.hansson@arm.com    # Do this after we save setting back, or else we'll tack on an
6369556Sandreas.hansson@arm.com    # extra 'qdo' every time we run scons.
6379556Sandreas.hansson@arm.com    if env['BATCH']:
6389556Sandreas.hansson@arm.com        env['CC']  = env['BATCH_CMD'] + ' ' + env['CC']
6399556Sandreas.hansson@arm.com        env['CXX'] = env['BATCH_CMD'] + ' ' + env['CXX']
6409556Sandreas.hansson@arm.com
6419556Sandreas.hansson@arm.com    if env['USE_SSE2']:
6429556Sandreas.hansson@arm.com        env.Append(CCFLAGS='-msse2')
6439590Sandreas@sandberg.pp.se
6449590Sandreas@sandberg.pp.se    # The src/SConscript file sets up the build rules in 'env' according
6459420Sandreas.hansson@arm.com    # to the configured options.  It returns a list of environments,
6469846Sandreas.hansson@arm.com    # one for each variant build (debug, opt, etc.)
6479846Sandreas.hansson@arm.com    envList = SConscript('src/SConscript', build_dir = build_path,
6489846Sandreas.hansson@arm.com                         exports = 'env')
6499846Sandreas.hansson@arm.com
6508946Sandreas.hansson@arm.com    # Set up the regression tests for each build.
6513918Ssaidi@eecs.umich.edu    for e in envList:
6529068SAli.Saidi@ARM.com        SConscript('tests/SConscript',
6539068SAli.Saidi@ARM.com                   build_dir = joinpath(build_path, 'tests', e.Label),
6549068SAli.Saidi@ARM.com                   exports = { 'env' : e }, duplicate = False)
6559068SAli.Saidi@ARM.com
6569068SAli.Saidi@ARM.comHelp(help_text)
6579068SAli.Saidi@ARM.com
6589068SAli.Saidi@ARM.com
6599068SAli.Saidi@ARM.com###################################################
6609068SAli.Saidi@ARM.com#
6619419Sandreas.hansson@arm.com# Let SCons do its thing.  At this point SCons will use the defined
6629068SAli.Saidi@ARM.com# build environments to build the requested targets.
6639068SAli.Saidi@ARM.com#
6649068SAli.Saidi@ARM.com###################################################
6659068SAli.Saidi@ARM.com
6669068SAli.Saidi@ARM.com