SConstruct revision 8122
1955SN/A# -*- mode:python -*- 2955SN/A 311408Sandreas.sandberg@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: 9612178Sprosenfeld@micron.com http://m5sim.org/wiki/index.php/Using_a_non-default_Python_installation 975863Snate@binkert.org""" 9812178Sprosenfeld@micron.com raise 995863Snate@binkert.org 1005863Snate@binkert.org# Global Python includes 1015863Snate@binkert.orgimport os 1029812Sandreas.hansson@arm.comimport re 1039812Sandreas.hansson@arm.comimport subprocess 1045863Snate@binkert.orgimport sys 1055863Snate@binkert.org 1068878Ssteve.reinhardt@amd.comfrom os import mkdir, environ 1075863Snate@binkert.orgfrom 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 1106654Snate@binkert.org 11110196SCurtis.Dunham@arm.com# SCons includes 112955SN/Aimport SCons 1135396Ssaidi@eecs.umich.eduimport SCons.Node 11411401Sandreas.sandberg@arm.com 1155863Snate@binkert.orgextra_python_paths = [ 1165863Snate@binkert.org Dir('src/python').srcnode().abspath, # M5 includes 1174202Sbinkertn@umich.edu 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 1215863Snate@binkert.org 122955SN/Afrom m5.util import compareVersions, readCommand 1236654Snate@binkert.org 1245273Sstever@gmail.comhelp_texts = { 1255871Snate@binkert.org "options" : "", 1265273Sstever@gmail.com "global_vars" : "", 1276655Snate@binkert.org "local_vars" : "" 1288878Ssteve.reinhardt@amd.com} 1296655Snate@binkert.org 1306655Snate@binkert.orgExport("help_texts") 1319219Spower.jg@gmail.com 1326655Snate@binkert.orgdef AddM5Option(*args, **kwargs): 1335871Snate@binkert.org col_width = 30 1346654Snate@binkert.org 1358947Sandreas.hansson@arm.com help = " " + ", ".join(args) 1365396Ssaidi@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" 1448120Sgblack@eecs.umich.edu 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') 1578879Ssteve.reinhardt@amd.comAddM5Option('--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# 1718120Sgblack@eecs.umich.edu# 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' ]) 17610458Sandreas.hansson@arm.com 17710458Sandreas.hansson@arm.comuse_env = {} 17810458Sandreas.hansson@arm.comfor key,val in os.environ.iteritems(): 1798879Ssteve.reinhardt@amd.com if key in use_vars or key.startswith("M5"): 1808879Ssteve.reinhardt@amd.com use_env[key] = val 1818879Ssteve.reinhardt@amd.com 1828879Ssteve.reinhardt@amd.commain = Environment(ENV=use_env) 1839227Sandreas.hansson@arm.commain.root = Dir(".") # The current directory (where this file lives). 1849227Sandreas.hansson@arm.commain.srcdir = Dir("src") # The source directory 18512063Sgabeblack@google.com 18612063Sgabeblack@google.com# add useful python code PYTHONPATH so it can be used by subprocesses 18712063Sgabeblack@google.com# as well 1888879Ssteve.reinhardt@amd.commain.AppendENVPath('PYTHONPATH', extra_python_paths) 1898879Ssteve.reinhardt@amd.com 1908879Ssteve.reinhardt@amd.com######################################################################## 1918879Ssteve.reinhardt@amd.com# 19210453SAndrew.Bardsley@arm.com# Mercurial Stuff. 19310453SAndrew.Bardsley@arm.com# 19410453SAndrew.Bardsley@arm.com# If the M5 directory is a mercurial repository, we should do some 19510456SCurtis.Dunham@arm.com# extra things. 19610456SCurtis.Dunham@arm.com# 19710456SCurtis.Dunham@arm.com######################################################################## 19810457Sandreas.hansson@arm.com 19910457Sandreas.hansson@arm.comhgdir = main.root.Dir(".hg") 20011342Sandreas.hansson@arm.com 20111342Sandreas.hansson@arm.commercurial_style_message = """ 2028120Sgblack@eecs.umich.eduYou're missing the M5 style hook. 20312063Sgabeblack@google.comPlease install the hook so we can ensure that all code fits a common style. 20412063Sgabeblack@google.com 20512063Sgabeblack@google.comAll you'd need to do is add the following lines to your repository .hg/hgrc 20612063Sgabeblack@google.comor your personal .hgrc 2078947Sandreas.hansson@arm.com---------------- 2087816Ssteve.reinhardt@amd.com 2095871Snate@binkert.org[extensions] 2105871Snate@binkert.orgstyle = %s/util/style.py 2116121Snate@binkert.org 2125871Snate@binkert.org[hooks] 2135871Snate@binkert.orgpretxncommit.style = python:style.check_style 2149926Sstan.czerniawski@arm.compre-qrefresh.style = python:style.check_style 2159926Sstan.czerniawski@arm.com""" % (main.root) 2169119Sandreas.hansson@arm.com 21710068Sandreas.hansson@arm.commercurial_bin_not_found = """ 21811989Sandreas.sandberg@arm.comMercurial binary cannot be found, unfortunately this means that we 219955SN/Acannot easily determine the version of M5 that you are running and 2209416SAndreas.Sandberg@ARM.comthis makes error messages more difficult to collect. Please consider 22111342Sandreas.hansson@arm.cominstalling mercurial if you choose to post an error message 22211212Sjoseph.gross@amd.com""" 22311212Sjoseph.gross@amd.com 22411212Sjoseph.gross@amd.commercurial_lib_not_found = """ 22511212Sjoseph.gross@amd.comMercurial libraries cannot be found, ignoring style hook 22611212Sjoseph.gross@amd.comIf you are actually a M5 developer, please fix this and 2279416SAndreas.Sandberg@ARM.comrun the style hook. It is important. 2289416SAndreas.Sandberg@ARM.com""" 2295871Snate@binkert.org 23010584Sandreas.hansson@arm.comhg_info = "Unknown" 2319416SAndreas.Sandberg@ARM.comif hgdir.exists(): 2329416SAndreas.Sandberg@ARM.com # 1) Grab repository revision if we know it. 2335871Snate@binkert.org cmd = "hg id -n -i -t -b" 234955SN/A try: 23510671Sandreas.hansson@arm.com hg_info = readCommand(cmd, cwd=main.root.abspath).strip() 23610671Sandreas.hansson@arm.com except OSError: 23710671Sandreas.hansson@arm.com print mercurial_bin_not_found 23810671Sandreas.hansson@arm.com 2398881Smarc.orr@gmail.com # 2) Ensure that the style hook is in place. 2406121Snate@binkert.org try: 2416121Snate@binkert.org ui = None 2421533SN/A if not GetOption('ignore_style'): 2439239Sandreas.hansson@arm.com from mercurial import ui 2449239Sandreas.hansson@arm.com ui = ui.ui() 2459239Sandreas.hansson@arm.com except ImportError: 2469239Sandreas.hansson@arm.com print mercurial_lib_not_found 2479239Sandreas.hansson@arm.com 2489239Sandreas.hansson@arm.com if ui is not None: 2499239Sandreas.hansson@arm.com ui.readconfig(hgdir.File('hgrc').abspath) 2506655Snate@binkert.org style_hook = ui.config('hooks', 'pretxncommit.style', None) 2516655Snate@binkert.org 2526655Snate@binkert.org if not style_hook: 2536655Snate@binkert.org print mercurial_style_message 2545871Snate@binkert.org sys.exit(1) 2555871Snate@binkert.orgelse: 2565863Snate@binkert.org print ".hg directory not found" 2575871Snate@binkert.org 2588878Ssteve.reinhardt@amd.commain['HG_INFO'] = hg_info 2595871Snate@binkert.org 2605871Snate@binkert.org################################################### 2615871Snate@binkert.org# 2625863Snate@binkert.org# Figure out which configurations to set up based on the path(s) of 2636121Snate@binkert.org# the target(s). 2645863Snate@binkert.org# 26511408Sandreas.sandberg@arm.com################################################### 26611408Sandreas.sandberg@arm.com 2678336Ssteve.reinhardt@amd.com# Find default configuration & binary. 26811469SCurtis.Dunham@arm.comDefault(environ.get('M5_DEFAULT_BINARY', 'build/ALPHA_SE/m5.debug')) 26911469SCurtis.Dunham@arm.com 2708336Ssteve.reinhardt@amd.com# helper function: find last occurrence of element in list 2714678Snate@binkert.orgdef rfind(l, elt, offs = -1): 27211887Sandreas.sandberg@arm.com for i in range(len(l)+offs, 0, -1): 27311887Sandreas.sandberg@arm.com if l[i] == elt: 27411887Sandreas.sandberg@arm.com return i 27511887Sandreas.sandberg@arm.com raise ValueError, "element not found" 27611887Sandreas.sandberg@arm.com 27711887Sandreas.sandberg@arm.com# Each target must have 'build' in the interior of the path; the 27811887Sandreas.sandberg@arm.com# directory below this will determine the build parameters. For 27911887Sandreas.sandberg@arm.com# example, for target 'foo/bar/build/ALPHA_SE/arch/alpha/blah.do' we 28011887Sandreas.sandberg@arm.com# recognize that ALPHA_SE specifies the configuration because it 28111887Sandreas.sandberg@arm.com# follow 'build' in the bulid path. 28211887Sandreas.sandberg@arm.com 28311408Sandreas.sandberg@arm.com# Generate absolute paths to targets so we can see where the build dir is 28411401Sandreas.sandberg@arm.comif COMMAND_LINE_TARGETS: 28511401Sandreas.sandberg@arm.com # Ask SCons which directory it was invoked from 28611401Sandreas.sandberg@arm.com launch_dir = GetLaunchDir() 28711401Sandreas.sandberg@arm.com # Make targets relative to invocation directory 28811401Sandreas.sandberg@arm.com abs_targets = [ normpath(joinpath(launch_dir, str(x))) for x in \ 28911401Sandreas.sandberg@arm.com COMMAND_LINE_TARGETS] 2908336Ssteve.reinhardt@amd.comelse: 2918336Ssteve.reinhardt@amd.com # Default targets are relative to root of tree 2928336Ssteve.reinhardt@amd.com abs_targets = [ normpath(joinpath(main.root.abspath, str(x))) for x in \ 2934678Snate@binkert.org DEFAULT_TARGETS] 29411401Sandreas.sandberg@arm.com 2954678Snate@binkert.org 2964678Snate@binkert.org# Generate a list of the unique build roots and configs that the 29711401Sandreas.sandberg@arm.com# collected targets reference. 29811401Sandreas.sandberg@arm.comvariant_paths = [] 2998336Ssteve.reinhardt@amd.combuild_root = None 3004678Snate@binkert.orgfor t in abs_targets: 3018336Ssteve.reinhardt@amd.com path_dirs = t.split('/') 3028336Ssteve.reinhardt@amd.com try: 3038336Ssteve.reinhardt@amd.com build_top = rfind(path_dirs, 'build', -2) 3048336Ssteve.reinhardt@amd.com except: 3058336Ssteve.reinhardt@amd.com print "Error: no non-leaf 'build' dir found on target path", t 3068336Ssteve.reinhardt@amd.com Exit(1) 3075871Snate@binkert.org this_build_root = joinpath('/',*path_dirs[:build_top+1]) 3085871Snate@binkert.org if not build_root: 3098336Ssteve.reinhardt@amd.com build_root = this_build_root 31011408Sandreas.sandberg@arm.com else: 31111408Sandreas.sandberg@arm.com if this_build_root != build_root: 31211408Sandreas.sandberg@arm.com print "Error: build targets not under same build root\n"\ 31311408Sandreas.sandberg@arm.com " %s\n %s" % (build_root, this_build_root) 31411408Sandreas.sandberg@arm.com Exit(1) 31511408Sandreas.sandberg@arm.com variant_path = joinpath('/',*path_dirs[:build_top+2]) 31611408Sandreas.sandberg@arm.com if variant_path not in variant_paths: 3178336Ssteve.reinhardt@amd.com variant_paths.append(variant_path) 31811401Sandreas.sandberg@arm.com 31911401Sandreas.sandberg@arm.com# Make sure build_root exists (might not if this is the first build there) 32011401Sandreas.sandberg@arm.comif not isdir(build_root): 3215871Snate@binkert.org mkdir(build_root) 3228336Ssteve.reinhardt@amd.commain['BUILDROOT'] = build_root 3238336Ssteve.reinhardt@amd.com 32411401Sandreas.sandberg@arm.comExport('main') 32511401Sandreas.sandberg@arm.com 32611401Sandreas.sandberg@arm.commain.SConsignFile(joinpath(build_root, "sconsign")) 32711401Sandreas.sandberg@arm.com 32811401Sandreas.sandberg@arm.com# Default duplicate option is to use hard links, but this messes up 3294678Snate@binkert.org# when you use emacs to edit a file in the target dir, as emacs moves 3305871Snate@binkert.org# file to file~ then copies to file, breaking the link. Symbolic 3314678Snate@binkert.org# (soft) links work better. 33211401Sandreas.sandberg@arm.commain.SetOption('duplicate', 'soft-copy') 33311401Sandreas.sandberg@arm.com 33411401Sandreas.sandberg@arm.com# 33511401Sandreas.sandberg@arm.com# Set up global sticky variables... these are common to an entire build 33611401Sandreas.sandberg@arm.com# tree (not specific to a particular build like ALPHA_SE) 33711401Sandreas.sandberg@arm.com# 33811401Sandreas.sandberg@arm.com 33911401Sandreas.sandberg@arm.com# Variable validators & converters for global sticky variables 34011401Sandreas.sandberg@arm.comdef PathListMakeAbsolute(val): 34111401Sandreas.sandberg@arm.com if not val: 34211401Sandreas.sandberg@arm.com return val 34311401Sandreas.sandberg@arm.com f = lambda p: abspath(expanduser(p)) 34411450Sandreas.sandberg@arm.com return ':'.join(map(f, val.split(':'))) 34511450Sandreas.sandberg@arm.com 34611450Sandreas.sandberg@arm.comdef PathListAllExist(key, val, env): 34711450Sandreas.sandberg@arm.com if not val: 34811450Sandreas.sandberg@arm.com return 34911450Sandreas.sandberg@arm.com paths = val.split(':') 35011450Sandreas.sandberg@arm.com for path in paths: 35111450Sandreas.sandberg@arm.com if not isdir(path): 35211450Sandreas.sandberg@arm.com raise SCons.Errors.UserError("Path does not exist: '%s'" % path) 35311450Sandreas.sandberg@arm.com 35411450Sandreas.sandberg@arm.comglobal_vars_file = joinpath(build_root, 'variables.global') 35511401Sandreas.sandberg@arm.com 35611450Sandreas.sandberg@arm.comglobal_vars = Variables(global_vars_file, args=ARGUMENTS) 35711450Sandreas.sandberg@arm.com 35811450Sandreas.sandberg@arm.comglobal_vars.AddVariables( 35911401Sandreas.sandberg@arm.com ('CC', 'C compiler', environ.get('CC', main['CC'])), 36011450Sandreas.sandberg@arm.com ('CXX', 'C++ compiler', environ.get('CXX', main['CXX'])), 36111401Sandreas.sandberg@arm.com ('BATCH', 'Use batch pool for build and tests', False), 3628336Ssteve.reinhardt@amd.com ('BATCH_CMD', 'Batch pool submission command name', 'qdo'), 3638336Ssteve.reinhardt@amd.com ('M5_BUILD_CACHE', 'Cache built objects in this directory', False), 3648336Ssteve.reinhardt@amd.com ('EXTRAS', 'Add extra directories to the compilation', '', 3658336Ssteve.reinhardt@amd.com PathListAllExist, PathListMakeAbsolute), 3668336Ssteve.reinhardt@amd.com ) 3678336Ssteve.reinhardt@amd.com 3688336Ssteve.reinhardt@amd.com# Update main environment with values from ARGUMENTS & global_vars_file 3698336Ssteve.reinhardt@amd.comglobal_vars.Update(main) 3708336Ssteve.reinhardt@amd.comhelp_texts["global_vars"] += global_vars.GenerateHelpText(main) 3718336Ssteve.reinhardt@amd.com 37211401Sandreas.sandberg@arm.com# Save sticky variable settings back to current variables file 37311401Sandreas.sandberg@arm.comglobal_vars.Save(global_vars_file, main) 3748336Ssteve.reinhardt@amd.com 3758336Ssteve.reinhardt@amd.com# Parse EXTRAS variable to build list of all directories where we're 3768336Ssteve.reinhardt@amd.com# look for sources etc. This list is exported as base_dir_list. 3775871Snate@binkert.orgbase_dir = main.srcdir.abspath 37811476Sandreas.sandberg@arm.comif main['EXTRAS']: 37911476Sandreas.sandberg@arm.com extras_dir_list = main['EXTRAS'].split(':') 38011476Sandreas.sandberg@arm.comelse: 38111476Sandreas.sandberg@arm.com extras_dir_list = [] 38211476Sandreas.sandberg@arm.com 38311476Sandreas.sandberg@arm.comExport('base_dir') 38411476Sandreas.sandberg@arm.comExport('extras_dir_list') 38511476Sandreas.sandberg@arm.com 38611476Sandreas.sandberg@arm.com# the ext directory should be on the #includes path 38711887Sandreas.sandberg@arm.commain.Append(CPPPATH=[Dir('ext')]) 38811887Sandreas.sandberg@arm.com 38911887Sandreas.sandberg@arm.comdef strip_build_path(path, env): 39011408Sandreas.sandberg@arm.com path = str(path) 39111887Sandreas.sandberg@arm.com variant_base = env['BUILDROOT'] + os.path.sep 39211887Sandreas.sandberg@arm.com if path.startswith(variant_base): 39311887Sandreas.sandberg@arm.com path = path[len(variant_base):] 39411887Sandreas.sandberg@arm.com elif path.startswith('build/'): 39511887Sandreas.sandberg@arm.com path = path[6:] 39611887Sandreas.sandberg@arm.com return path 39711926Sgabeblack@google.com 39811926Sgabeblack@google.com# Generate a string of the form: 39911926Sgabeblack@google.com# common/path/prefix/src1, src2 -> tgt1, tgt2 40011926Sgabeblack@google.com# to print while building. 40111887Sandreas.sandberg@arm.comclass Transform(object): 40211887Sandreas.sandberg@arm.com # all specific color settings should be here and nowhere else 40311944Sandreas.sandberg@arm.com tool_color = termcap.Normal 40411887Sandreas.sandberg@arm.com pfx_color = termcap.Yellow 40511927Sgabeblack@google.com srcs_color = termcap.Yellow + termcap.Bold 40611927Sgabeblack@google.com arrow_color = termcap.Blue + termcap.Bold 40711927Sgabeblack@google.com tgts_color = termcap.Yellow + termcap.Bold 40811927Sgabeblack@google.com 40911927Sgabeblack@google.com def __init__(self, tool, max_sources=99): 41011927Sgabeblack@google.com self.format = self.tool_color + (" [%8s] " % tool) \ 41111887Sandreas.sandberg@arm.com + self.pfx_color + "%s" \ 41211928Sgabeblack@google.com + self.srcs_color + "%s" \ 41311928Sgabeblack@google.com + self.arrow_color + " -> " \ 41411887Sandreas.sandberg@arm.com + self.tgts_color + "%s" \ 41511887Sandreas.sandberg@arm.com + termcap.Normal 41611887Sandreas.sandberg@arm.com self.max_sources = max_sources 41711887Sandreas.sandberg@arm.com 41811887Sandreas.sandberg@arm.com def __call__(self, target, source, env, for_signature=None): 41911887Sandreas.sandberg@arm.com # truncate source list according to max_sources param 42011887Sandreas.sandberg@arm.com source = source[0:self.max_sources] 42111887Sandreas.sandberg@arm.com def strip(f): 42211887Sandreas.sandberg@arm.com return strip_build_path(str(f), env) 42311887Sandreas.sandberg@arm.com if len(source) > 0: 42411476Sandreas.sandberg@arm.com srcs = map(strip, source) 42511476Sandreas.sandberg@arm.com else: 42611408Sandreas.sandberg@arm.com srcs = [''] 42711408Sandreas.sandberg@arm.com tgts = map(strip, target) 42811408Sandreas.sandberg@arm.com # surprisingly, os.path.commonprefix is a dumb char-by-char string 42911408Sandreas.sandberg@arm.com # operation that has nothing to do with paths. 43011408Sandreas.sandberg@arm.com com_pfx = os.path.commonprefix(srcs + tgts) 43111408Sandreas.sandberg@arm.com com_pfx_len = len(com_pfx) 43211408Sandreas.sandberg@arm.com if com_pfx: 43311887Sandreas.sandberg@arm.com # do some cleanup and sanity checking on common prefix 43411887Sandreas.sandberg@arm.com if com_pfx[-1] == ".": 43511476Sandreas.sandberg@arm.com # prefix matches all but file extension: ok 43611887Sandreas.sandberg@arm.com # back up one to change 'foo.cc -> o' to 'foo.cc -> .o' 43711887Sandreas.sandberg@arm.com com_pfx = com_pfx[0:-1] 43811476Sandreas.sandberg@arm.com elif com_pfx[-1] == "/": 43911476Sandreas.sandberg@arm.com # common prefix is directory path: OK 44011476Sandreas.sandberg@arm.com pass 44111476Sandreas.sandberg@arm.com else: 4426121Snate@binkert.org src0_len = len(srcs[0]) 443955SN/A tgt0_len = len(tgts[0]) 444955SN/A if src0_len == com_pfx_len: 4452632Sstever@eecs.umich.edu # source is a substring of target, OK 4462632Sstever@eecs.umich.edu pass 447955SN/A elif tgt0_len == com_pfx_len: 448955SN/A # target is a substring of source, need to back up to 449955SN/A # avoid empty string on RHS of arrow 450955SN/A sep_idx = com_pfx.rfind(".") 4518878Ssteve.reinhardt@amd.com if sep_idx != -1: 452955SN/A com_pfx = com_pfx[0:sep_idx] 4532632Sstever@eecs.umich.edu else: 4542632Sstever@eecs.umich.edu com_pfx = '' 4552632Sstever@eecs.umich.edu elif src0_len > com_pfx_len and srcs[0][com_pfx_len] == ".": 4562632Sstever@eecs.umich.edu # still splitting at file extension: ok 4572632Sstever@eecs.umich.edu pass 4582632Sstever@eecs.umich.edu else: 4592632Sstever@eecs.umich.edu # probably a fluke; ignore it 4608268Ssteve.reinhardt@amd.com com_pfx = '' 4618268Ssteve.reinhardt@amd.com # recalculate length in case com_pfx was modified 4628268Ssteve.reinhardt@amd.com com_pfx_len = len(com_pfx) 4638268Ssteve.reinhardt@amd.com def fmt(files): 4648268Ssteve.reinhardt@amd.com f = map(lambda s: s[com_pfx_len:], files) 4658268Ssteve.reinhardt@amd.com return ', '.join(f) 4668268Ssteve.reinhardt@amd.com return self.format % (com_pfx, fmt(srcs), fmt(tgts)) 4672632Sstever@eecs.umich.edu 4682632Sstever@eecs.umich.eduExport('Transform') 4692632Sstever@eecs.umich.edu 4702632Sstever@eecs.umich.edu 4718268Ssteve.reinhardt@amd.comif GetOption('verbose'): 4722632Sstever@eecs.umich.edu def MakeAction(action, string, *args, **kwargs): 4738268Ssteve.reinhardt@amd.com return Action(action, *args, **kwargs) 4748268Ssteve.reinhardt@amd.comelse: 4758268Ssteve.reinhardt@amd.com MakeAction = Action 4768268Ssteve.reinhardt@amd.com main['CCCOMSTR'] = Transform("CC") 4773718Sstever@eecs.umich.edu main['CXXCOMSTR'] = Transform("CXX") 4782634Sstever@eecs.umich.edu main['ASCOMSTR'] = Transform("AS") 4792634Sstever@eecs.umich.edu main['SWIGCOMSTR'] = Transform("SWIG") 4805863Snate@binkert.org main['ARCOMSTR'] = Transform("AR", 0) 4812638Sstever@eecs.umich.edu main['LINKCOMSTR'] = Transform("LINK", 0) 4828268Ssteve.reinhardt@amd.com main['RANLIBCOMSTR'] = Transform("RANLIB", 0) 4832632Sstever@eecs.umich.edu main['M4COMSTR'] = Transform("M4") 4842632Sstever@eecs.umich.edu main['SHCCCOMSTR'] = Transform("SHCC") 4852632Sstever@eecs.umich.edu main['SHCXXCOMSTR'] = Transform("SHCXX") 4862632Sstever@eecs.umich.eduExport('MakeAction') 4872632Sstever@eecs.umich.edu 4881858SN/ACXX_version = readCommand([main['CXX'],'--version'], exception=False) 4893716Sstever@eecs.umich.eduCXX_V = readCommand([main['CXX'],'-V'], exception=False) 4902638Sstever@eecs.umich.edu 4912638Sstever@eecs.umich.edumain['GCC'] = CXX_version and CXX_version.find('g++') >= 0 4922638Sstever@eecs.umich.edumain['SUNCC'] = CXX_V and CXX_V.find('Sun C++') >= 0 4932638Sstever@eecs.umich.edumain['ICC'] = CXX_V and CXX_V.find('Intel') >= 0 4942638Sstever@eecs.umich.eduif main['GCC'] + main['SUNCC'] + main['ICC'] > 1: 4952638Sstever@eecs.umich.edu print 'Error: How can we have two at the same time?' 4962638Sstever@eecs.umich.edu Exit(1) 4975863Snate@binkert.org 4985863Snate@binkert.org# Set up default C++ compiler flags 4995863Snate@binkert.orgif main['GCC']: 500955SN/A main.Append(CCFLAGS=['-pipe']) 5015341Sstever@gmail.com main.Append(CCFLAGS=['-fno-strict-aliasing']) 5025341Sstever@gmail.com main.Append(CCFLAGS=['-Wall', '-Wno-sign-compare', '-Wundef']) 5035863Snate@binkert.org main.Append(CXXFLAGS=['-Wno-deprecated']) 5047756SAli.Saidi@ARM.com # Read the GCC version to check for versions with bugs 5055341Sstever@gmail.com # Note CCVERSION doesn't work here because it is run with the CC 5066121Snate@binkert.org # before we override it from the command line 5074494Ssaidi@eecs.umich.edu gcc_version = readCommand([main['CXX'], '-dumpversion'], exception=False) 5086121Snate@binkert.org if not compareVersions(gcc_version, '4.4.1') or \ 5091105SN/A not compareVersions(gcc_version, '4.4.2'): 5102667Sstever@eecs.umich.edu print 'Info: Tree vectorizer in GCC 4.4.1 & 4.4.2 is buggy, disabling.' 5112667Sstever@eecs.umich.edu main.Append(CCFLAGS=['-fno-tree-vectorize']) 5122667Sstever@eecs.umich.eduelif main['ICC']: 5132667Sstever@eecs.umich.edu pass #Fix me... add warning flags once we clean up icc warnings 5146121Snate@binkert.orgelif main['SUNCC']: 5152667Sstever@eecs.umich.edu main.Append(CCFLAGS=['-Qoption ccfe']) 5165341Sstever@gmail.com main.Append(CCFLAGS=['-features=gcc']) 5175863Snate@binkert.org main.Append(CCFLAGS=['-features=extensions']) 5185341Sstever@gmail.com main.Append(CCFLAGS=['-library=stlport4']) 5195341Sstever@gmail.com main.Append(CCFLAGS=['-xar']) 5205341Sstever@gmail.com #main.Append(CCFLAGS=['-instances=semiexplicit']) 5218120Sgblack@eecs.umich.eduelse: 5225341Sstever@gmail.com print 'Error: Don\'t know what compiler options to use for your compiler.' 5238120Sgblack@eecs.umich.edu print ' Please fix SConstruct and src/SConscript and try again.' 5245341Sstever@gmail.com Exit(1) 5258120Sgblack@eecs.umich.edu 5266121Snate@binkert.org# Set up common yacc/bison flags (needed for Ruby) 5276121Snate@binkert.orgmain['YACCFLAGS'] = '-d' 5289396Sandreas.hansson@arm.commain['YACCHXXFILESUFFIX'] = '.hh' 5295397Ssaidi@eecs.umich.edu 5305397Ssaidi@eecs.umich.edu# Do this after we save setting back, or else we'll tack on an 5317727SAli.Saidi@ARM.com# extra 'qdo' every time we run scons. 5328268Ssteve.reinhardt@amd.comif main['BATCH']: 5336168Snate@binkert.org main['CC'] = main['BATCH_CMD'] + ' ' + main['CC'] 5345341Sstever@gmail.com main['CXX'] = main['BATCH_CMD'] + ' ' + main['CXX'] 5358120Sgblack@eecs.umich.edu main['AS'] = main['BATCH_CMD'] + ' ' + main['AS'] 5368120Sgblack@eecs.umich.edu main['AR'] = main['BATCH_CMD'] + ' ' + main['AR'] 5378120Sgblack@eecs.umich.edu main['RANLIB'] = main['BATCH_CMD'] + ' ' + main['RANLIB'] 5386814Sgblack@eecs.umich.edu 5395863Snate@binkert.orgif sys.platform == 'cygwin': 5408120Sgblack@eecs.umich.edu # cygwin has some header file issues... 5415341Sstever@gmail.com main.Append(CCFLAGS=["-Wno-uninitialized"]) 5425863Snate@binkert.org 5438268Ssteve.reinhardt@amd.com# Check for SWIG 5446121Snate@binkert.orgif not main.has_key('SWIG'): 5456121Snate@binkert.org print 'Error: SWIG utility not found.' 5468268Ssteve.reinhardt@amd.com print ' Please install (see http://www.swig.org) and retry.' 5475742Snate@binkert.org Exit(1) 5485742Snate@binkert.org 5495341Sstever@gmail.com# Check for appropriate SWIG version 5505742Snate@binkert.orgswig_version = readCommand(('swig', '-version'), exception='').split() 5515742Snate@binkert.org# First 3 words should be "SWIG Version x.y.z" 5525341Sstever@gmail.comif len(swig_version) < 3 or \ 5536017Snate@binkert.org swig_version[0] != 'SWIG' or swig_version[1] != 'Version': 5546121Snate@binkert.org print 'Error determining SWIG version.' 5556017Snate@binkert.org Exit(1) 55612158Sandreas.sandberg@arm.com 55712158Sandreas.sandberg@arm.commin_swig_version = '1.3.28' 55812158Sandreas.sandberg@arm.comif compareVersions(swig_version[2], min_swig_version) < 0: 5597816Ssteve.reinhardt@amd.com print 'Error: SWIG version', min_swig_version, 'or newer required.' 5607756SAli.Saidi@ARM.com print ' Installed version:', swig_version[2] 5617756SAli.Saidi@ARM.com Exit(1) 5627756SAli.Saidi@ARM.com 5637756SAli.Saidi@ARM.com# Set up SWIG flags & scanner 5647756SAli.Saidi@ARM.comswig_flags=Split('-c++ -python -modern -templatereduce $_CPPINCFLAGS') 5657756SAli.Saidi@ARM.commain.Append(SWIGFLAGS=swig_flags) 5667756SAli.Saidi@ARM.com 5677756SAli.Saidi@ARM.com# filter out all existing swig scanners, they mess up the dependency 5687816Ssteve.reinhardt@amd.com# stuff for some reason 5697816Ssteve.reinhardt@amd.comscanners = [] 5707816Ssteve.reinhardt@amd.comfor scanner in main['SCANNERS']: 5717816Ssteve.reinhardt@amd.com skeys = scanner.skeys 5727816Ssteve.reinhardt@amd.com if skeys == '.i': 5737816Ssteve.reinhardt@amd.com continue 5747816Ssteve.reinhardt@amd.com 5757816Ssteve.reinhardt@amd.com if isinstance(skeys, (list, tuple)) and '.i' in skeys: 5767816Ssteve.reinhardt@amd.com continue 5777816Ssteve.reinhardt@amd.com 5787756SAli.Saidi@ARM.com scanners.append(scanner) 5797816Ssteve.reinhardt@amd.com 5807816Ssteve.reinhardt@amd.com# add the new swig scanner that we like better 5817816Ssteve.reinhardt@amd.comfrom SCons.Scanner import ClassicCPP as CPPScanner 5827816Ssteve.reinhardt@amd.comswig_inc_re = '^[ \t]*[%,#][ \t]*(?:include|import)[ \t]*(<|")([^>"]+)(>|")' 5837816Ssteve.reinhardt@amd.comscanners.append(CPPScanner("SwigScan", [ ".i" ], "CPPPATH", swig_inc_re)) 5847816Ssteve.reinhardt@amd.com 5857816Ssteve.reinhardt@amd.com# replace the scanners list that has what we want 5867816Ssteve.reinhardt@amd.commain['SCANNERS'] = scanners 5877816Ssteve.reinhardt@amd.com 5887816Ssteve.reinhardt@amd.com# Add a custom Check function to the Configure context so that we can 5897816Ssteve.reinhardt@amd.com# figure out if the compiler adds leading underscores to global 5907816Ssteve.reinhardt@amd.com# variables. This is needed for the autogenerated asm files that we 5917816Ssteve.reinhardt@amd.com# use for embedding the python code. 5927816Ssteve.reinhardt@amd.comdef CheckLeading(context): 5937816Ssteve.reinhardt@amd.com context.Message("Checking for leading underscore in global variables...") 5947816Ssteve.reinhardt@amd.com # 1) Define a global variable called x from asm so the C compiler 5957816Ssteve.reinhardt@amd.com # won't change the symbol at all. 5967816Ssteve.reinhardt@amd.com # 2) Declare that variable. 5977816Ssteve.reinhardt@amd.com # 3) Use the variable 5987816Ssteve.reinhardt@amd.com # 5997816Ssteve.reinhardt@amd.com # If the compiler prepends an underscore, this will successfully 6007816Ssteve.reinhardt@amd.com # link because the external symbol 'x' will be called '_x' which 6017816Ssteve.reinhardt@amd.com # was defined by the asm statement. If the compiler does not 6027816Ssteve.reinhardt@amd.com # prepend an underscore, this will not successfully link because 6037816Ssteve.reinhardt@amd.com # '_x' will have been defined by assembly, while the C portion of 6047816Ssteve.reinhardt@amd.com # the code will be trying to use 'x' 6057816Ssteve.reinhardt@amd.com ret = context.TryLink(''' 6067816Ssteve.reinhardt@amd.com asm(".globl _x; _x: .byte 0"); 6077816Ssteve.reinhardt@amd.com extern int x; 6087816Ssteve.reinhardt@amd.com int main() { return x; } 6097816Ssteve.reinhardt@amd.com ''', extension=".c") 6107816Ssteve.reinhardt@amd.com context.env.Append(LEADING_UNDERSCORE=ret) 6117816Ssteve.reinhardt@amd.com context.Result(ret) 6127816Ssteve.reinhardt@amd.com return ret 6137816Ssteve.reinhardt@amd.com 6147816Ssteve.reinhardt@amd.com# Platform-specific configuration. Note again that we assume that all 6157816Ssteve.reinhardt@amd.com# builds under a given build root run on the same host platform. 6167816Ssteve.reinhardt@amd.comconf = Configure(main, 6177816Ssteve.reinhardt@amd.com conf_dir = joinpath(build_root, '.scons_config'), 6187816Ssteve.reinhardt@amd.com log_file = joinpath(build_root, 'scons_config.log'), 6197816Ssteve.reinhardt@amd.com custom_tests = { 'CheckLeading' : CheckLeading }) 6207816Ssteve.reinhardt@amd.com 6217816Ssteve.reinhardt@amd.com# Check for leading underscores. Don't really need to worry either 6227816Ssteve.reinhardt@amd.com# way so don't need to check the return code. 6237816Ssteve.reinhardt@amd.comconf.CheckLeading() 6247816Ssteve.reinhardt@amd.com 6257816Ssteve.reinhardt@amd.com# Check if we should compile a 64 bit binary on Mac OS X/Darwin 6267816Ssteve.reinhardt@amd.comtry: 6277816Ssteve.reinhardt@amd.com import platform 6287816Ssteve.reinhardt@amd.com uname = platform.uname() 6297816Ssteve.reinhardt@amd.com if uname[0] == 'Darwin' and compareVersions(uname[2], '9.0.0') >= 0: 6307816Ssteve.reinhardt@amd.com if int(readCommand('sysctl -n hw.cpu64bit_capable')[0]): 6317816Ssteve.reinhardt@amd.com main.Append(CCFLAGS=['-arch', 'x86_64']) 6327816Ssteve.reinhardt@amd.com main.Append(CFLAGS=['-arch', 'x86_64']) 6337816Ssteve.reinhardt@amd.com main.Append(LINKFLAGS=['-arch', 'x86_64']) 6347816Ssteve.reinhardt@amd.com main.Append(ASFLAGS=['-arch', 'x86_64']) 6357816Ssteve.reinhardt@amd.comexcept: 6367816Ssteve.reinhardt@amd.com pass 6377816Ssteve.reinhardt@amd.com 6387816Ssteve.reinhardt@amd.com# Recent versions of scons substitute a "Null" object for Configure() 6397816Ssteve.reinhardt@amd.com# when configuration isn't necessary, e.g., if the "--help" option is 6408947Sandreas.hansson@arm.com# present. Unfortuantely this Null object always returns false, 6418947Sandreas.hansson@arm.com# breaking all our configuration checks. We replace it with our own 6427756SAli.Saidi@ARM.com# more optimistic null object that returns True instead. 6438120Sgblack@eecs.umich.eduif not conf: 6447756SAli.Saidi@ARM.com def NullCheck(*args, **kwargs): 6457756SAli.Saidi@ARM.com return True 6467756SAli.Saidi@ARM.com 6477756SAli.Saidi@ARM.com class NullConf: 6487816Ssteve.reinhardt@amd.com def __init__(self, env): 6497816Ssteve.reinhardt@amd.com self.env = env 6507816Ssteve.reinhardt@amd.com def Finish(self): 6517816Ssteve.reinhardt@amd.com return self.env 6527816Ssteve.reinhardt@amd.com def __getattr__(self, mname): 65311979Sgabeblack@google.com return NullCheck 6547816Ssteve.reinhardt@amd.com 6557816Ssteve.reinhardt@amd.com conf = NullConf(main) 6567816Ssteve.reinhardt@amd.com 6577816Ssteve.reinhardt@amd.com# Find Python include and library directories for embedding the 6587756SAli.Saidi@ARM.com# interpreter. For consistency, we will use the same Python 6597756SAli.Saidi@ARM.com# installation used to run scons (and thus this script). If you want 6609227Sandreas.hansson@arm.com# to link in an alternate version, see above for instructions on how 6619227Sandreas.hansson@arm.com# to invoke scons with a different copy of the Python interpreter. 6629227Sandreas.hansson@arm.comfrom distutils import sysconfig 6639227Sandreas.hansson@arm.com 6649590Sandreas@sandberg.pp.sepy_getvar = sysconfig.get_config_var 6659590Sandreas@sandberg.pp.se 6669590Sandreas@sandberg.pp.sepy_debug = getattr(sys, 'pydebug', False) 6679590Sandreas@sandberg.pp.sepy_version = 'python' + py_getvar('VERSION') + (py_debug and "_d" or "") 6689590Sandreas@sandberg.pp.se 6699590Sandreas@sandberg.pp.sepy_general_include = sysconfig.get_python_inc() 6706654Snate@binkert.orgpy_platform_include = sysconfig.get_python_inc(plat_specific=True) 6716654Snate@binkert.orgpy_includes = [ py_general_include ] 6725871Snate@binkert.orgif py_platform_include != py_general_include: 6736121Snate@binkert.org py_includes.append(py_platform_include) 6748946Sandreas.hansson@arm.com 6759419Sandreas.hansson@arm.compy_lib_path = [ py_getvar('LIBDIR') ] 6763940Ssaidi@eecs.umich.edu# add the prefix/lib/pythonX.Y/config dir, but only if there is no 6773918Ssaidi@eecs.umich.edu# shared library in prefix/lib/. 6783918Ssaidi@eecs.umich.eduif not py_getvar('Py_ENABLE_SHARED'): 6791858SN/A py_lib_path.append(py_getvar('LIBPL')) 6809556Sandreas.hansson@arm.com 6819556Sandreas.hansson@arm.compy_libs = [] 6829556Sandreas.hansson@arm.comfor lib in py_getvar('LIBS').split() + py_getvar('SYSLIBS').split(): 6839556Sandreas.hansson@arm.com assert lib.startswith('-l') 68411294Sandreas.hansson@arm.com lib = lib[2:] 68511294Sandreas.hansson@arm.com if lib not in py_libs: 68611294Sandreas.hansson@arm.com py_libs.append(lib) 68711294Sandreas.hansson@arm.compy_libs.append(py_version) 68810878Sandreas.hansson@arm.com 68910878Sandreas.hansson@arm.commain.Append(CPPPATH=py_includes) 69011811Sbaz21@cam.ac.ukmain.Append(LIBPATH=py_lib_path) 69111811Sbaz21@cam.ac.uk 69211811Sbaz21@cam.ac.uk# Cache build files in the supplied directory. 69311982Sgabeblack@google.comif main['M5_BUILD_CACHE']: 69411982Sgabeblack@google.com print 'Using build cache located at', main['M5_BUILD_CACHE'] 69511982Sgabeblack@google.com CacheDir(main['M5_BUILD_CACHE']) 69611982Sgabeblack@google.com 69711992Sgabeblack@google.com 69811982Sgabeblack@google.com# verify that this stuff works 69911982Sgabeblack@google.comif not conf.CheckHeader('Python.h', '<>'): 7009556Sandreas.hansson@arm.com print "Error: can't find Python.h header in", py_includes 7019556Sandreas.hansson@arm.com Exit(1) 7029556Sandreas.hansson@arm.com 7039556Sandreas.hansson@arm.comfor lib in py_libs: 7049556Sandreas.hansson@arm.com if not conf.CheckLib(lib): 7059556Sandreas.hansson@arm.com print "Error: can't find library %s required by python" % lib 7069556Sandreas.hansson@arm.com Exit(1) 7079556Sandreas.hansson@arm.com 7089556Sandreas.hansson@arm.com# On Solaris you need to use libsocket for socket ops 7099556Sandreas.hansson@arm.comif not conf.CheckLibWithHeader(None, 'sys/socket.h', 'C++', 'accept(0,0,0);'): 7109556Sandreas.hansson@arm.com if not conf.CheckLibWithHeader('socket', 'sys/socket.h', 'C++', 'accept(0,0,0);'): 7119556Sandreas.hansson@arm.com print "Can't find library with socket calls (e.g. accept())" 7129556Sandreas.hansson@arm.com Exit(1) 7139556Sandreas.hansson@arm.com 7149556Sandreas.hansson@arm.com# Check for zlib. If the check passes, libz will be automatically 7159556Sandreas.hansson@arm.com# added to the LIBS environment variable. 7169556Sandreas.hansson@arm.comif not conf.CheckLibWithHeader('z', 'zlib.h', 'C++','zlibVersion();'): 7179556Sandreas.hansson@arm.com print 'Error: did not find needed zlib compression library '\ 7189556Sandreas.hansson@arm.com 'and/or zlib.h header file.' 7196121Snate@binkert.org print ' Please install zlib and try again.' 72011500Sandreas.hansson@arm.com Exit(1) 72110238Sandreas.hansson@arm.com 72210878Sandreas.hansson@arm.com# Check for librt. 7239420Sandreas.hansson@arm.comhave_posix_clock = \ 72411500Sandreas.hansson@arm.com conf.CheckLibWithHeader(None, 'time.h', 'C', 72511500Sandreas.hansson@arm.com 'clock_nanosleep(0,0,NULL,NULL);') or \ 7269420Sandreas.hansson@arm.com conf.CheckLibWithHeader('rt', 'time.h', 'C', 7279420Sandreas.hansson@arm.com 'clock_nanosleep(0,0,NULL,NULL);') 7289420Sandreas.hansson@arm.com 7299420Sandreas.hansson@arm.comif not have_posix_clock: 7309420Sandreas.hansson@arm.com print "Can't find library for POSIX clocks." 73112063Sgabeblack@google.com 73212063Sgabeblack@google.com# Check for <fenv.h> (C99 FP environment control) 73312063Sgabeblack@google.comhave_fenv = conf.CheckHeader('fenv.h', '<>') 73412063Sgabeblack@google.comif not have_fenv: 73512063Sgabeblack@google.com print "Warning: Header file <fenv.h> not found." 73612063Sgabeblack@google.com print " This host has no IEEE FP rounding mode control." 73712063Sgabeblack@google.com 73812063Sgabeblack@google.com###################################################################### 73912063Sgabeblack@google.com# 74012063Sgabeblack@google.com# Check for mysql. 74112063Sgabeblack@google.com# 74212063Sgabeblack@google.commysql_config = WhereIs('mysql_config') 74312063Sgabeblack@google.comhave_mysql = bool(mysql_config) 74412063Sgabeblack@google.com 74512063Sgabeblack@google.com# Check MySQL version. 74612063Sgabeblack@google.comif have_mysql: 74712063Sgabeblack@google.com mysql_version = readCommand(mysql_config + ' --version') 74812063Sgabeblack@google.com min_mysql_version = '4.1' 74912063Sgabeblack@google.com if compareVersions(mysql_version, min_mysql_version) < 0: 75012063Sgabeblack@google.com print 'Warning: MySQL', min_mysql_version, 'or newer required.' 75112063Sgabeblack@google.com print ' Version', mysql_version, 'detected.' 75212063Sgabeblack@google.com have_mysql = False 75310264Sandreas.hansson@arm.com 75410264Sandreas.hansson@arm.com# Set up mysql_config commands. 75510264Sandreas.hansson@arm.comif have_mysql: 75610264Sandreas.hansson@arm.com mysql_config_include = mysql_config + ' --include' 75711925Sgabeblack@google.com if os.system(mysql_config_include + ' > /dev/null') != 0: 75811925Sgabeblack@google.com # older mysql_config versions don't support --include, use 75911500Sandreas.hansson@arm.com # --cflags instead 76010264Sandreas.hansson@arm.com mysql_config_include = mysql_config + ' --cflags | sed s/\\\'//g' 76111500Sandreas.hansson@arm.com # This seems to work in all versions 76211500Sandreas.hansson@arm.com mysql_config_libs = mysql_config + ' --libs' 76311500Sandreas.hansson@arm.com 76411500Sandreas.hansson@arm.com###################################################################### 76510866Sandreas.hansson@arm.com# 76611500Sandreas.hansson@arm.com# Finish the configuration 76711500Sandreas.hansson@arm.com# 76811500Sandreas.hansson@arm.commain = conf.Finish() 76911500Sandreas.hansson@arm.com 77011500Sandreas.hansson@arm.com###################################################################### 77111500Sandreas.hansson@arm.com# 77211500Sandreas.hansson@arm.com# Collect all non-global variables 77310264Sandreas.hansson@arm.com# 77410457Sandreas.hansson@arm.com 77510457Sandreas.hansson@arm.com# Define the universe of supported ISAs 77610457Sandreas.hansson@arm.comall_isa_list = [ ] 77710457Sandreas.hansson@arm.comExport('all_isa_list') 77810457Sandreas.hansson@arm.com 77910457Sandreas.hansson@arm.comclass CpuModel(object): 78010457Sandreas.hansson@arm.com '''The CpuModel class encapsulates everything the ISA parser needs to 78110457Sandreas.hansson@arm.com know about a particular CPU model.''' 78210457Sandreas.hansson@arm.com 78312063Sgabeblack@google.com # Dict of available CPU model objects. Accessible as CpuModel.dict. 78412063Sgabeblack@google.com dict = {} 78512063Sgabeblack@google.com list = [] 78612063Sgabeblack@google.com defaults = [] 78712063Sgabeblack@google.com 78812063Sgabeblack@google.com # Constructor. Automatically adds models to CpuModel.dict. 78912063Sgabeblack@google.com def __init__(self, name, filename, includes, strings, default=False): 79012063Sgabeblack@google.com self.name = name # name of model 79112063Sgabeblack@google.com self.filename = filename # filename for output exec code 79212063Sgabeblack@google.com self.includes = includes # include files needed in exec file 79312063Sgabeblack@google.com # The 'strings' dict holds all the per-CPU symbols we can 79410238Sandreas.hansson@arm.com # substitute into templates etc. 79510238Sandreas.hansson@arm.com self.strings = strings 79610238Sandreas.hansson@arm.com 79712063Sgabeblack@google.com # This cpu is enabled by default 79810238Sandreas.hansson@arm.com self.default = default 79910238Sandreas.hansson@arm.com 80010416Sandreas.hansson@arm.com # Add self to dict 80110238Sandreas.hansson@arm.com if name in CpuModel.dict: 8029227Sandreas.hansson@arm.com raise AttributeError, "CpuModel '%s' already registered" % name 80310238Sandreas.hansson@arm.com CpuModel.dict[name] = self 80410416Sandreas.hansson@arm.com CpuModel.list.append(name) 80510416Sandreas.hansson@arm.com 8069227Sandreas.hansson@arm.comExport('CpuModel') 8079590Sandreas@sandberg.pp.se 8089590Sandreas@sandberg.pp.se# Sticky variables get saved in the variables file so they persist from 8099590Sandreas@sandberg.pp.se# one invocation to the next (unless overridden, in which case the new 81011497SMatteo.Andreozzi@arm.com# value becomes sticky). 81111497SMatteo.Andreozzi@arm.comsticky_vars = Variables(args=ARGUMENTS) 81211497SMatteo.Andreozzi@arm.comExport('sticky_vars') 81311497SMatteo.Andreozzi@arm.com 8148737Skoansin.tan@gmail.com# Sticky variables that should be exported 81510878Sandreas.hansson@arm.comexport_vars = [] 81611500Sandreas.hansson@arm.comExport('export_vars') 8179420Sandreas.hansson@arm.com 8188737Skoansin.tan@gmail.com# Walk the tree and execute all SConsopts scripts that wil add to the 81910106SMitch.Hayenga@arm.com# above variables 8208737Skoansin.tan@gmail.comfor bdir in [ base_dir ] + extras_dir_list: 8218737Skoansin.tan@gmail.com for root, dirs, files in os.walk(bdir): 82210878Sandreas.hansson@arm.com if 'SConsopts' in files: 82310878Sandreas.hansson@arm.com print "Reading", joinpath(root, 'SConsopts') 8248737Skoansin.tan@gmail.com SConscript(joinpath(root, 'SConsopts')) 8258737Skoansin.tan@gmail.com 8268737Skoansin.tan@gmail.comall_isa_list.sort() 8278737Skoansin.tan@gmail.com 8288737Skoansin.tan@gmail.comsticky_vars.AddVariables( 8298737Skoansin.tan@gmail.com EnumVariable('TARGET_ISA', 'Target ISA', 'alpha', all_isa_list), 83011294Sandreas.hansson@arm.com BoolVariable('FULL_SYSTEM', 'Full-system support', False), 8319556Sandreas.hansson@arm.com ListVariable('CPU_MODELS', 'CPU models', 8329556Sandreas.hansson@arm.com sorted(n for n,m in CpuModel.dict.iteritems() if m.default), 8339556Sandreas.hansson@arm.com sorted(CpuModel.list)), 83411294Sandreas.hansson@arm.com BoolVariable('NO_FAST_ALLOC', 'Disable fast object allocator', False), 83510278SAndreas.Sandberg@ARM.com BoolVariable('FAST_ALLOC_DEBUG', 'Enable fast object allocator debugging', 83610278SAndreas.Sandberg@ARM.com False), 83710278SAndreas.Sandberg@ARM.com BoolVariable('FAST_ALLOC_STATS', 'Enable fast object allocator statistics', 83810278SAndreas.Sandberg@ARM.com False), 83910278SAndreas.Sandberg@ARM.com BoolVariable('EFENCE', 'Link with Electric Fence malloc debugger', 84010278SAndreas.Sandberg@ARM.com False), 8419556Sandreas.hansson@arm.com BoolVariable('SS_COMPATIBLE_FP', 8429590Sandreas@sandberg.pp.se 'Make floating-point results compatible with SimpleScalar', 8439590Sandreas@sandberg.pp.se False), 8449420Sandreas.hansson@arm.com BoolVariable('USE_SSE2', 8459846Sandreas.hansson@arm.com 'Compile for SSE2 (-msse2) to get IEEE FP on x86 hosts', 8469846Sandreas.hansson@arm.com False), 8479846Sandreas.hansson@arm.com BoolVariable('USE_MYSQL', 'Use MySQL for stats output', have_mysql), 8489846Sandreas.hansson@arm.com BoolVariable('USE_POSIX_CLOCK', 'Use POSIX Clocks', have_posix_clock), 8498946Sandreas.hansson@arm.com BoolVariable('USE_FENV', 'Use <fenv.h> IEEE mode control', have_fenv), 85011811Sbaz21@cam.ac.uk BoolVariable('USE_CHECKER', 'Use checker for detailed CPU models', False), 85111811Sbaz21@cam.ac.uk BoolVariable('CP_ANNOTATE', 'Enable critical path annotation capability', False), 85211811Sbaz21@cam.ac.uk BoolVariable('RUBY', 'Build with Ruby', False), 85311811Sbaz21@cam.ac.uk ) 8543918Ssaidi@eecs.umich.edu 8559068SAli.Saidi@ARM.com# These variables get exported to #defines in config/*.hh (see src/SConscript). 8569068SAli.Saidi@ARM.comexport_vars += ['FULL_SYSTEM', 'USE_FENV', 'USE_MYSQL', 8579068SAli.Saidi@ARM.com 'NO_FAST_ALLOC', 'FAST_ALLOC_DEBUG', 'FAST_ALLOC_STATS', 8589068SAli.Saidi@ARM.com 'SS_COMPATIBLE_FP', 'USE_CHECKER', 'TARGET_ISA', 'CP_ANNOTATE', 8599068SAli.Saidi@ARM.com 'USE_POSIX_CLOCK' ] 8609068SAli.Saidi@ARM.com 8619068SAli.Saidi@ARM.com################################################### 8629068SAli.Saidi@ARM.com# 8639068SAli.Saidi@ARM.com# Define a SCons builder for configuration flag headers. 8649419Sandreas.hansson@arm.com# 8659068SAli.Saidi@ARM.com################################################### 8669068SAli.Saidi@ARM.com 8679068SAli.Saidi@ARM.com# This function generates a config header file that #defines the 8689068SAli.Saidi@ARM.com# variable symbol to the current variable setting (0 or 1). The source 8699068SAli.Saidi@ARM.com# operands are the name of the variable and a Value node containing the 8709068SAli.Saidi@ARM.com# value of the variable. 8713918Ssaidi@eecs.umich.edudef build_config_file(target, source, env): 8723918Ssaidi@eecs.umich.edu (variable, value) = [s.get_contents() for s in source] 8736157Snate@binkert.org f = file(str(target[0]), 'w') 8746157Snate@binkert.org print >> f, '#define', variable, value 8756157Snate@binkert.org f.close() 8766157Snate@binkert.org return None 8775397Ssaidi@eecs.umich.edu 8785397Ssaidi@eecs.umich.edu# Generate the message to be printed when building the config file. 8796121Snate@binkert.orgdef build_config_file_string(target, source, env): 8806121Snate@binkert.org (variable, value) = [s.get_contents() for s in source] 8816121Snate@binkert.org return "Defining %s as %s in %s." % (variable, value, target[0]) 8826121Snate@binkert.org 8836121Snate@binkert.org# Combine the two functions into a scons Action object. 8846121Snate@binkert.orgconfig_action = Action(build_config_file, build_config_file_string) 8855397Ssaidi@eecs.umich.edu 8861851SN/A# The emitter munges the source & target node lists to reflect what 8871851SN/A# we're really doing. 8887739Sgblack@eecs.umich.edudef config_emitter(target, source, env): 889955SN/A # extract variable name from Builder arg 8909396Sandreas.hansson@arm.com variable = str(target[0]) 8919396Sandreas.hansson@arm.com # True target is config header file 8929396Sandreas.hansson@arm.com target = joinpath('config', variable.lower() + '.hh') 8939396Sandreas.hansson@arm.com val = env[variable] 8949396Sandreas.hansson@arm.com if isinstance(val, bool): 8959396Sandreas.hansson@arm.com # Force value to 0/1 8969396Sandreas.hansson@arm.com val = int(val) 8979396Sandreas.hansson@arm.com elif isinstance(val, str): 8989396Sandreas.hansson@arm.com val = '"' + val + '"' 8999396Sandreas.hansson@arm.com 9009396Sandreas.hansson@arm.com # Sources are variable name & value (packaged in SCons Value nodes) 9019396Sandreas.hansson@arm.com return ([target], [Value(variable), Value(val)]) 9029396Sandreas.hansson@arm.com 9039396Sandreas.hansson@arm.comconfig_builder = Builder(emitter = config_emitter, action = config_action) 9049396Sandreas.hansson@arm.com 9059396Sandreas.hansson@arm.commain.Append(BUILDERS = { 'ConfigFile' : config_builder }) 9069477Sandreas.hansson@arm.com 9079477Sandreas.hansson@arm.com# libelf build is shared across all configs in the build root. 9089477Sandreas.hansson@arm.commain.SConscript('ext/libelf/SConscript', 9099477Sandreas.hansson@arm.com variant_dir = joinpath(build_root, 'libelf')) 9109477Sandreas.hansson@arm.com 9119477Sandreas.hansson@arm.com# gzstream build is shared across all configs in the build root. 9129477Sandreas.hansson@arm.commain.SConscript('ext/gzstream/SConscript', 9139477Sandreas.hansson@arm.com variant_dir = joinpath(build_root, 'gzstream')) 9149477Sandreas.hansson@arm.com 9159477Sandreas.hansson@arm.com################################################### 9169477Sandreas.hansson@arm.com# 9179477Sandreas.hansson@arm.com# This function is used to set up a directory with switching headers 9189477Sandreas.hansson@arm.com# 9199477Sandreas.hansson@arm.com################################################### 9209477Sandreas.hansson@arm.com 9219477Sandreas.hansson@arm.commain['ALL_ISA_LIST'] = all_isa_list 9229477Sandreas.hansson@arm.comdef make_switching_dir(dname, switch_headers, env): 9239477Sandreas.hansson@arm.com # Generate the header. target[0] is the full path of the output 9249477Sandreas.hansson@arm.com # header to generate. 'source' is a dummy variable, since we get the 9259477Sandreas.hansson@arm.com # list of ISAs from env['ALL_ISA_LIST']. 9269477Sandreas.hansson@arm.com def gen_switch_hdr(target, source, env): 9279477Sandreas.hansson@arm.com fname = str(target[0]) 9289396Sandreas.hansson@arm.com f = open(fname, 'w') 9292667Sstever@eecs.umich.edu isa = env['TARGET_ISA'].lower() 93010710Sandreas.hansson@arm.com print >>f, '#include "%s/%s/%s"' % (dname, isa, basename(fname)) 93110710Sandreas.hansson@arm.com f.close() 93210710Sandreas.hansson@arm.com 93311811Sbaz21@cam.ac.uk # Build SCons Action object. 'varlist' specifies env vars that this 93411811Sbaz21@cam.ac.uk # action depends on; when env['ALL_ISA_LIST'] changes these actions 93511811Sbaz21@cam.ac.uk # should get re-executed. 93611811Sbaz21@cam.ac.uk switch_hdr_action = MakeAction(gen_switch_hdr, 93711811Sbaz21@cam.ac.uk Transform("GENERATE"), varlist=['ALL_ISA_LIST']) 93811811Sbaz21@cam.ac.uk 93910710Sandreas.hansson@arm.com # Instantiate actions for each header 94010710Sandreas.hansson@arm.com for hdr in switch_headers: 94110710Sandreas.hansson@arm.com env.Command(hdr, [], switch_hdr_action) 94210710Sandreas.hansson@arm.comExport('make_switching_dir') 94310384SCurtis.Dunham@arm.com 9449986Sandreas@sandberg.pp.se################################################### 9459986Sandreas@sandberg.pp.se# 9469986Sandreas@sandberg.pp.se# Define build environments for selected configurations. 9479986Sandreas@sandberg.pp.se# 9489986Sandreas@sandberg.pp.se################################################### 9499986Sandreas@sandberg.pp.se 9509986Sandreas@sandberg.pp.sefor variant_path in variant_paths: 9519986Sandreas@sandberg.pp.se print "Building in", variant_path 9529986Sandreas@sandberg.pp.se 9539986Sandreas@sandberg.pp.se # Make a copy of the build-root environment to use for this config. 9549986Sandreas@sandberg.pp.se env = main.Clone() 9559986Sandreas@sandberg.pp.se env['BUILDDIR'] = variant_path 9569986Sandreas@sandberg.pp.se 9579986Sandreas@sandberg.pp.se # variant_dir is the tail component of build path, and is used to 9589986Sandreas@sandberg.pp.se # determine the build parameters (e.g., 'ALPHA_SE') 9599986Sandreas@sandberg.pp.se (build_root, variant_dir) = splitpath(variant_path) 9609986Sandreas@sandberg.pp.se 9619986Sandreas@sandberg.pp.se # Set env variables according to the build directory config. 9629986Sandreas@sandberg.pp.se sticky_vars.files = [] 9639986Sandreas@sandberg.pp.se # Variables for $BUILD_ROOT/$VARIANT_DIR are stored in 9642638Sstever@eecs.umich.edu # $BUILD_ROOT/variables/$VARIANT_DIR so you can nuke 9652638Sstever@eecs.umich.edu # $BUILD_ROOT/$VARIANT_DIR without losing your variables settings. 9666121Snate@binkert.org current_vars_file = joinpath(build_root, 'variables', variant_dir) 9673716Sstever@eecs.umich.edu if isfile(current_vars_file): 9685522Snate@binkert.org sticky_vars.files.append(current_vars_file) 9699986Sandreas@sandberg.pp.se print "Using saved variables file %s" % current_vars_file 9709986Sandreas@sandberg.pp.se else: 9719986Sandreas@sandberg.pp.se # Build dir-specific variables file doesn't exist. 9725522Snate@binkert.org 9735227Ssaidi@eecs.umich.edu # Make sure the directory is there so we can create it later 9745227Ssaidi@eecs.umich.edu opt_dir = dirname(current_vars_file) 9755227Ssaidi@eecs.umich.edu if not isdir(opt_dir): 9765227Ssaidi@eecs.umich.edu mkdir(opt_dir) 9776654Snate@binkert.org 9786654Snate@binkert.org # Get default build variables from source tree. Variables are 9797769SAli.Saidi@ARM.com # normally determined by name of $VARIANT_DIR, but can be 9807769SAli.Saidi@ARM.com # overriden by 'default=' arg on command line. 9817769SAli.Saidi@ARM.com default = GetOption('default') 9827769SAli.Saidi@ARM.com if not default: 9835227Ssaidi@eecs.umich.edu default = variant_dir 9845227Ssaidi@eecs.umich.edu default_vars_file = joinpath('build_opts', default) 9855227Ssaidi@eecs.umich.edu if isfile(default_vars_file): 9865204Sstever@gmail.com sticky_vars.files.append(default_vars_file) 9875204Sstever@gmail.com print "Variables file %s not found,\n using defaults in %s" \ 9885204Sstever@gmail.com % (current_vars_file, default_vars_file) 9895204Sstever@gmail.com else: 9905204Sstever@gmail.com print "Error: cannot find variables file %s or %s" \ 9915204Sstever@gmail.com % (current_vars_file, default_vars_file) 9925204Sstever@gmail.com Exit(1) 9935204Sstever@gmail.com 9945204Sstever@gmail.com # Apply current variable settings to env 9955204Sstever@gmail.com sticky_vars.Update(env) 9965204Sstever@gmail.com 9975204Sstever@gmail.com help_texts["local_vars"] += \ 9985204Sstever@gmail.com "Build variables for %s:\n" % variant_dir \ 9995204Sstever@gmail.com + sticky_vars.GenerateHelpText(env) 10005204Sstever@gmail.com 10015204Sstever@gmail.com # Process variable settings. 10025204Sstever@gmail.com 10036121Snate@binkert.org if not have_fenv and env['USE_FENV']: 10045204Sstever@gmail.com print "Warning: <fenv.h> not available; " \ 10057727SAli.Saidi@ARM.com "forcing USE_FENV to False in", variant_dir + "." 10067727SAli.Saidi@ARM.com env['USE_FENV'] = False 10077727SAli.Saidi@ARM.com 10087727SAli.Saidi@ARM.com if not env['USE_FENV']: 10097727SAli.Saidi@ARM.com print "Warning: No IEEE FP rounding mode control in", variant_dir + "." 101011988Sandreas.sandberg@arm.com print " FP results may deviate slightly from other platforms." 101111988Sandreas.sandberg@arm.com 101210453SAndrew.Bardsley@arm.com if env['EFENCE']: 101310453SAndrew.Bardsley@arm.com env.Append(LIBS=['efence']) 101410453SAndrew.Bardsley@arm.com 101510453SAndrew.Bardsley@arm.com if env['USE_MYSQL']: 101610453SAndrew.Bardsley@arm.com if not have_mysql: 101710453SAndrew.Bardsley@arm.com print "Warning: MySQL not available; " \ 101810453SAndrew.Bardsley@arm.com "forcing USE_MYSQL to False in", variant_dir + "." 101910453SAndrew.Bardsley@arm.com env['USE_MYSQL'] = False 102010453SAndrew.Bardsley@arm.com else: 102110453SAndrew.Bardsley@arm.com print "Compiling in", variant_dir, "with MySQL support." 102210160Sandreas.hansson@arm.com env.ParseConfig(mysql_config_libs) 102310453SAndrew.Bardsley@arm.com env.ParseConfig(mysql_config_include) 102410453SAndrew.Bardsley@arm.com 102510453SAndrew.Bardsley@arm.com # Save sticky variable settings back to current variables file 102610453SAndrew.Bardsley@arm.com sticky_vars.Save(current_vars_file, env) 102710453SAndrew.Bardsley@arm.com 102810453SAndrew.Bardsley@arm.com if env['USE_SSE2']: 102910453SAndrew.Bardsley@arm.com env.Append(CCFLAGS=['-msse2']) 103010453SAndrew.Bardsley@arm.com 10319812Sandreas.hansson@arm.com # The src/SConscript file sets up the build rules in 'env' according 103210453SAndrew.Bardsley@arm.com # to the configured variables. It returns a list of environments, 103310453SAndrew.Bardsley@arm.com # one for each variant build (debug, opt, etc.) 103410453SAndrew.Bardsley@arm.com envList = SConscript('src/SConscript', variant_dir = variant_path, 103510453SAndrew.Bardsley@arm.com exports = 'env') 103610453SAndrew.Bardsley@arm.com 103710453SAndrew.Bardsley@arm.com # Set up the regression tests for each build. 103810453SAndrew.Bardsley@arm.com for e in envList: 103910453SAndrew.Bardsley@arm.com SConscript('tests/SConscript', 104010453SAndrew.Bardsley@arm.com variant_dir = joinpath(variant_path, 'tests', e.Label), 104110453SAndrew.Bardsley@arm.com exports = { 'env' : e }, duplicate = False) 104210453SAndrew.Bardsley@arm.com 104310453SAndrew.Bardsley@arm.com# base help text 10447727SAli.Saidi@ARM.comHelp(''' 104510453SAndrew.Bardsley@arm.comUsage: scons [scons options] [build variables] [target(s)] 104610453SAndrew.Bardsley@arm.com 104710453SAndrew.Bardsley@arm.comExtra scons options: 104810453SAndrew.Bardsley@arm.com%(options)s 104910453SAndrew.Bardsley@arm.com 10503118Sstever@eecs.umich.eduGlobal build variables: 105110453SAndrew.Bardsley@arm.com%(global_vars)s 105210453SAndrew.Bardsley@arm.com 105310453SAndrew.Bardsley@arm.com%(local_vars)s 105410453SAndrew.Bardsley@arm.com''' % help_texts) 10553118Sstever@eecs.umich.edu