SConstruct revision 8120
1955SN/A# -*- mode:python -*- 2955SN/A 314209Sandreas.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 8112563Sgabeblack@google.com""" 8212563Sgabeblack@google.com raise 836654Snate@binkert.org 8410196SCurtis.Dunham@arm.com# We ensure the python version early because we have stuff that 85955SN/A# requires python 2.4 865396Ssaidi@eecs.umich.edutry: 8711401Sandreas.sandberg@arm.com EnsurePythonVersion(2, 4) 885863Snate@binkert.orgexcept SystemExit, e: 895863Snate@binkert.org print """ 904202Sbinkertn@umich.eduYou 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 925863Snate@binkert.org'python' first or (2) explicitly invoking an alternative interpreter 935863Snate@binkert.orgon the scons script. 945863Snate@binkert.org 9513541Sandrea.mondelli@ucf.eduFor more details, see: 96955SN/A http://m5sim.org/wiki/index.php/Using_a_non-default_Python_installation 976654Snate@binkert.org""" 985273Sstever@gmail.com raise 995871Snate@binkert.org 10013758Sgabeblack@google.com# Global Python includes 1015273Sstever@gmail.comimport os 1026654Snate@binkert.orgimport re 1035396Ssaidi@eecs.umich.eduimport subprocess 1048120Sgblack@eecs.umich.eduimport sys 1058120Sgblack@eecs.umich.edu 1068120Sgblack@eecs.umich.edufrom os import mkdir, environ 1078120Sgblack@eecs.umich.edufrom os.path import abspath, basename, dirname, expanduser, normpath 1088120Sgblack@eecs.umich.edufrom os.path import exists, isdir, isfile 1098120Sgblack@eecs.umich.edufrom os.path import join as joinpath, split as splitpath 1108120Sgblack@eecs.umich.edu 1118120Sgblack@eecs.umich.edu# SCons includes 1128879Ssteve.reinhardt@amd.comimport SCons 1138879Ssteve.reinhardt@amd.comimport SCons.Node 1148879Ssteve.reinhardt@amd.com 1158879Ssteve.reinhardt@amd.comextra_python_paths = [ 1168879Ssteve.reinhardt@amd.com Dir('src/python').srcnode().abspath, # M5 includes 1178879Ssteve.reinhardt@amd.com Dir('ext/ply').srcnode().abspath, # ply is used by several files 1188879Ssteve.reinhardt@amd.com ] 1198879Ssteve.reinhardt@amd.com 1208879Ssteve.reinhardt@amd.comsys.path[1:1] = extra_python_paths 1218879Ssteve.reinhardt@amd.com 1228879Ssteve.reinhardt@amd.comfrom m5.util import compareVersions, readCommand 1238879Ssteve.reinhardt@amd.com 1248879Ssteve.reinhardt@amd.comhelp_texts = { 1258120Sgblack@eecs.umich.edu "options" : "", 1268120Sgblack@eecs.umich.edu "global_vars" : "", 1278120Sgblack@eecs.umich.edu "local_vars" : "" 1288120Sgblack@eecs.umich.edu} 1298120Sgblack@eecs.umich.edu 1308120Sgblack@eecs.umich.eduExport("help_texts") 1318120Sgblack@eecs.umich.edu 1328120Sgblack@eecs.umich.edudef AddM5Option(*args, **kwargs): 1338120Sgblack@eecs.umich.edu col_width = 30 1348120Sgblack@eecs.umich.edu 1358120Sgblack@eecs.umich.edu help = " " + ", ".join(args) 1368120Sgblack@eecs.umich.edu if "help" in kwargs: 1378120Sgblack@eecs.umich.edu length = len(help) 1388120Sgblack@eecs.umich.edu if length >= col_width: 1398879Ssteve.reinhardt@amd.com help += "\n" + " " * col_width 1408879Ssteve.reinhardt@amd.com else: 1418879Ssteve.reinhardt@amd.com help += " " * (col_width - length) 1428879Ssteve.reinhardt@amd.com help += kwargs["help"] 14310458Sandreas.hansson@arm.com help_texts["options"] += help + "\n" 14410458Sandreas.hansson@arm.com 14510458Sandreas.hansson@arm.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', 15013421Sciro.santilli@arm.com help="Don't add color to abbreviated scons output") 15113421Sciro.santilli@arm.comAddM5Option('--default', dest='default', type='string', action='store', 1529227Sandreas.hansson@arm.com help='Override which build_opts file to use for defaults') 1539227Sandreas.hansson@arm.comAddM5Option('--ignore-style', dest='ignore_style', action='store_true', 15412063Sgabeblack@google.com help='Disable style checking hooks') 15512063Sgabeblack@google.comAddM5Option('--update-ref', dest='update_ref', action='store_true', 15612063Sgabeblack@google.com help='Update test reference outputs') 1578879Ssteve.reinhardt@amd.comAddM5Option('--verbose', dest='verbose', action='store_true', 1588879Ssteve.reinhardt@amd.com help='Print full tool command lines') 1598879Ssteve.reinhardt@amd.com 1608879Ssteve.reinhardt@amd.comuse_colors = GetOption('use_colors') 16110453SAndrew.Bardsley@arm.comif use_colors: 16210453SAndrew.Bardsley@arm.com from m5.util.terminal import termcap 16310453SAndrew.Bardsley@arm.comelif use_colors is None: 16410456SCurtis.Dunham@arm.com # option unspecified; default behavior is to use colors iff isatty 16510456SCurtis.Dunham@arm.com from m5.util.terminal import tty_termcap as termcap 16610456SCurtis.Dunham@arm.comelse: 16710457Sandreas.hansson@arm.com from m5.util.terminal import no_termcap as termcap 16810457Sandreas.hansson@arm.com 16911342Sandreas.hansson@arm.com######################################################################## 17011342Sandreas.hansson@arm.com# 1718120Sgblack@eecs.umich.edu# Set up the main build environment. 17212063Sgabeblack@google.com# 17312563Sgabeblack@google.com######################################################################## 17412063Sgabeblack@google.comuse_vars = set([ 'AS', 'AR', 'CC', 'CXX', 'HOME', 'LD_LIBRARY_PATH', 'PATH', 17512063Sgabeblack@google.com 'PYTHONPATH', 'RANLIB' ]) 1765871Snate@binkert.org 1775871Snate@binkert.orguse_env = {} 1786121Snate@binkert.orgfor key,val in os.environ.iteritems(): 1795871Snate@binkert.org if key in use_vars or key.startswith("M5"): 1805871Snate@binkert.org use_env[key] = val 1819926Sstan.czerniawski@arm.com 18212243Sgabeblack@google.commain = Environment(ENV=use_env) 1831533SN/Amain.root = Dir(".") # The current directory (where this file lives). 18412246Sgabeblack@google.commain.srcdir = Dir("src") # The source directory 18512246Sgabeblack@google.com 18612246Sgabeblack@google.com# add useful python code PYTHONPATH so it can be used by subprocesses 18712246Sgabeblack@google.com# as well 1889239Sandreas.hansson@arm.commain.AppendENVPath('PYTHONPATH', extra_python_paths) 1899239Sandreas.hansson@arm.com 1909239Sandreas.hansson@arm.com######################################################################## 1919239Sandreas.hansson@arm.com# 19212563Sgabeblack@google.com# Mercurial Stuff. 1939239Sandreas.hansson@arm.com# 1949239Sandreas.hansson@arm.com# If the M5 directory is a mercurial repository, we should do some 195955SN/A# extra things. 196955SN/A# 1972632Sstever@eecs.umich.edu######################################################################## 1982632Sstever@eecs.umich.edu 199955SN/Ahgdir = main.root.Dir(".hg") 200955SN/A 201955SN/Amercurial_style_message = """ 202955SN/AYou're missing the M5 style hook. 2038878Ssteve.reinhardt@amd.comPlease install the hook so we can ensure that all code fits a common style. 204955SN/A 2052632Sstever@eecs.umich.eduAll you'd need to do is add the following lines to your repository .hg/hgrc 2062632Sstever@eecs.umich.eduor your personal .hgrc 2072632Sstever@eecs.umich.edu---------------- 2082632Sstever@eecs.umich.edu 2092632Sstever@eecs.umich.edu[extensions] 2102632Sstever@eecs.umich.edustyle = %s/util/style.py 2112632Sstever@eecs.umich.edu 2128268Ssteve.reinhardt@amd.com[hooks] 2138268Ssteve.reinhardt@amd.compretxncommit.style = python:style.check_style 2148268Ssteve.reinhardt@amd.compre-qrefresh.style = python:style.check_style 2158268Ssteve.reinhardt@amd.com""" % (main.root) 2168268Ssteve.reinhardt@amd.com 2178268Ssteve.reinhardt@amd.commercurial_bin_not_found = """ 2188268Ssteve.reinhardt@amd.comMercurial binary cannot be found, unfortunately this means that we 21913715Sandreas.sandberg@arm.comcannot easily determine the version of M5 that you are running and 22013715Sandreas.sandberg@arm.comthis makes error messages more difficult to collect. Please consider 22113715Sandreas.sandberg@arm.cominstalling mercurial if you choose to post an error message 22213715Sandreas.sandberg@arm.com""" 22313715Sandreas.sandberg@arm.com 22413715Sandreas.sandberg@arm.commercurial_lib_not_found = """ 22513715Sandreas.sandberg@arm.comMercurial libraries cannot be found, ignoring style hook 22613715Sandreas.sandberg@arm.comIf you are actually a M5 developer, please fix this and 22713715Sandreas.sandberg@arm.comrun the style hook. It is important. 22813715Sandreas.sandberg@arm.com""" 22913715Sandreas.sandberg@arm.com 23013715Sandreas.sandberg@arm.comhg_info = "Unknown" 23113715Sandreas.sandberg@arm.comif hgdir.exists(): 2322632Sstever@eecs.umich.edu # 1) Grab repository revision if we know it. 2332632Sstever@eecs.umich.edu cmd = "hg id -n -i -t -b" 2342632Sstever@eecs.umich.edu try: 2352632Sstever@eecs.umich.edu hg_info = readCommand(cmd, cwd=main.root.abspath).strip() 2368268Ssteve.reinhardt@amd.com except OSError: 2372632Sstever@eecs.umich.edu print mercurial_bin_not_found 2388268Ssteve.reinhardt@amd.com 2398268Ssteve.reinhardt@amd.com # 2) Ensure that the style hook is in place. 2408268Ssteve.reinhardt@amd.com try: 2418268Ssteve.reinhardt@amd.com ui = None 2423718Sstever@eecs.umich.edu if GetOption('ignore_style'): 2432634Sstever@eecs.umich.edu from mercurial import ui 2442634Sstever@eecs.umich.edu ui = ui.ui() 2455863Snate@binkert.org except ImportError: 2462638Sstever@eecs.umich.edu print mercurial_lib_not_found 2478268Ssteve.reinhardt@amd.com 2482632Sstever@eecs.umich.edu if ui is not None: 2492632Sstever@eecs.umich.edu ui.readconfig(hgdir.File('hgrc').abspath) 2502632Sstever@eecs.umich.edu style_hook = ui.config('hooks', 'pretxncommit.style', None) 2512632Sstever@eecs.umich.edu 25212563Sgabeblack@google.com if not style_hook: 2531858SN/A print mercurial_style_message 2543716Sstever@eecs.umich.edu sys.exit(1) 2552638Sstever@eecs.umich.eduelse: 2562638Sstever@eecs.umich.edu print ".hg directory not found" 2572638Sstever@eecs.umich.edu 2582638Sstever@eecs.umich.edumain['HG_INFO'] = hg_info 25912563Sgabeblack@google.com 26012563Sgabeblack@google.com################################################### 2612638Sstever@eecs.umich.edu# 2625863Snate@binkert.org# Figure out which configurations to set up based on the path(s) of 2635863Snate@binkert.org# the target(s). 2645863Snate@binkert.org# 265955SN/A################################################### 2665341Sstever@gmail.com 2675341Sstever@gmail.com# Find default configuration & binary. 2685863Snate@binkert.orgDefault(environ.get('M5_DEFAULT_BINARY', 'build/ALPHA_SE/m5.debug')) 2697756SAli.Saidi@ARM.com 2705341Sstever@gmail.com# helper function: find last occurrence of element in list 2716121Snate@binkert.orgdef rfind(l, elt, offs = -1): 2724494Ssaidi@eecs.umich.edu for i in range(len(l)+offs, 0, -1): 2736121Snate@binkert.org if l[i] == elt: 2741105SN/A return i 2752667Sstever@eecs.umich.edu raise ValueError, "element not found" 2762667Sstever@eecs.umich.edu 2772667Sstever@eecs.umich.edu# Each target must have 'build' in the interior of the path; the 2782667Sstever@eecs.umich.edu# directory below this will determine the build parameters. For 2796121Snate@binkert.org# example, for target 'foo/bar/build/ALPHA_SE/arch/alpha/blah.do' we 2802667Sstever@eecs.umich.edu# recognize that ALPHA_SE specifies the configuration because it 2815341Sstever@gmail.com# follow 'build' in the bulid path. 2825863Snate@binkert.org 2835341Sstever@gmail.com# Generate absolute paths to targets so we can see where the build dir is 2845341Sstever@gmail.comif COMMAND_LINE_TARGETS: 2855341Sstever@gmail.com # Ask SCons which directory it was invoked from 2868120Sgblack@eecs.umich.edu launch_dir = GetLaunchDir() 2875341Sstever@gmail.com # Make targets relative to invocation directory 2888120Sgblack@eecs.umich.edu abs_targets = [ normpath(joinpath(launch_dir, str(x))) for x in \ 2895341Sstever@gmail.com COMMAND_LINE_TARGETS] 2908120Sgblack@eecs.umich.eduelse: 2916121Snate@binkert.org # Default targets are relative to root of tree 2926121Snate@binkert.org abs_targets = [ normpath(joinpath(main.root.abspath, str(x))) for x in \ 29314044Sciro.santilli@arm.com DEFAULT_TARGETS] 29414044Sciro.santilli@arm.com 29513715Sandreas.sandberg@arm.com 29613715Sandreas.sandberg@arm.com# Generate a list of the unique build roots and configs that the 2979396Sandreas.hansson@arm.com# collected targets reference. 2985397Ssaidi@eecs.umich.eduvariant_paths = [] 2995397Ssaidi@eecs.umich.edubuild_root = None 3007727SAli.Saidi@ARM.comfor t in abs_targets: 3018268Ssteve.reinhardt@amd.com path_dirs = t.split('/') 3026168Snate@binkert.org try: 3035341Sstever@gmail.com build_top = rfind(path_dirs, 'build', -2) 3048120Sgblack@eecs.umich.edu except: 3058120Sgblack@eecs.umich.edu print "Error: no non-leaf 'build' dir found on target path", t 3068120Sgblack@eecs.umich.edu Exit(1) 3076814Sgblack@eecs.umich.edu this_build_root = joinpath('/',*path_dirs[:build_top+1]) 3085863Snate@binkert.org if not build_root: 3098120Sgblack@eecs.umich.edu build_root = this_build_root 3105341Sstever@gmail.com else: 3115863Snate@binkert.org if this_build_root != build_root: 3128268Ssteve.reinhardt@amd.com print "Error: build targets not under same build root\n"\ 3136121Snate@binkert.org " %s\n %s" % (build_root, this_build_root) 3146121Snate@binkert.org Exit(1) 3158268Ssteve.reinhardt@amd.com variant_path = joinpath('/',*path_dirs[:build_top+2]) 3165742Snate@binkert.org if variant_path not in variant_paths: 3175742Snate@binkert.org variant_paths.append(variant_path) 3185341Sstever@gmail.com 3195742Snate@binkert.org# Make sure build_root exists (might not if this is the first build there) 3205742Snate@binkert.orgif not isdir(build_root): 3215341Sstever@gmail.com mkdir(build_root) 3226017Snate@binkert.orgmain['BUILDROOT'] = build_root 3236121Snate@binkert.org 3246017Snate@binkert.orgExport('main') 32512158Sandreas.sandberg@arm.com 32612158Sandreas.sandberg@arm.commain.SConsignFile(joinpath(build_root, "sconsign")) 32712158Sandreas.sandberg@arm.com 3288120Sgblack@eecs.umich.edu# Default duplicate option is to use hard links, but this messes up 3297756SAli.Saidi@ARM.com# when you use emacs to edit a file in the target dir, as emacs moves 3307756SAli.Saidi@ARM.com# file to file~ then copies to file, breaking the link. Symbolic 3317756SAli.Saidi@ARM.com# (soft) links work better. 3327756SAli.Saidi@ARM.commain.SetOption('duplicate', 'soft-copy') 3337816Ssteve.reinhardt@amd.com 3347816Ssteve.reinhardt@amd.com# 3357816Ssteve.reinhardt@amd.com# Set up global sticky variables... these are common to an entire build 3367816Ssteve.reinhardt@amd.com# tree (not specific to a particular build like ALPHA_SE) 3377816Ssteve.reinhardt@amd.com# 33811979Sgabeblack@google.com 3397816Ssteve.reinhardt@amd.com# Variable validators & converters for global sticky variables 3407816Ssteve.reinhardt@amd.comdef PathListMakeAbsolute(val): 3417816Ssteve.reinhardt@amd.com if not val: 3427816Ssteve.reinhardt@amd.com return val 3437756SAli.Saidi@ARM.com f = lambda p: abspath(expanduser(p)) 3447756SAli.Saidi@ARM.com return ':'.join(map(f, val.split(':'))) 3459227Sandreas.hansson@arm.com 3469227Sandreas.hansson@arm.comdef PathListAllExist(key, val, env): 3479227Sandreas.hansson@arm.com if not val: 3489227Sandreas.hansson@arm.com return 3499590Sandreas@sandberg.pp.se paths = val.split(':') 3509590Sandreas@sandberg.pp.se for path in paths: 3519590Sandreas@sandberg.pp.se if not isdir(path): 3529590Sandreas@sandberg.pp.se raise SCons.Errors.UserError("Path does not exist: '%s'" % path) 3539590Sandreas@sandberg.pp.se 3549590Sandreas@sandberg.pp.seglobal_vars_file = joinpath(build_root, 'variables.global') 3556654Snate@binkert.org 3566654Snate@binkert.orgglobal_vars = Variables(global_vars_file, args=ARGUMENTS) 3575871Snate@binkert.org 3586121Snate@binkert.orgglobal_vars.AddVariables( 3598946Sandreas.hansson@arm.com ('CC', 'C compiler', environ.get('CC', main['CC'])), 3609419Sandreas.hansson@arm.com ('CXX', 'C++ compiler', environ.get('CXX', main['CXX'])), 36112563Sgabeblack@google.com ('BATCH', 'Use batch pool for build and tests', False), 3623918Ssaidi@eecs.umich.edu ('BATCH_CMD', 'Batch pool submission command name', 'qdo'), 3633918Ssaidi@eecs.umich.edu ('M5_BUILD_CACHE', 'Cache built objects in this directory', False), 3641858SN/A ('EXTRAS', 'Add Extra directories to the compilation', '', 3659556Sandreas.hansson@arm.com PathListAllExist, PathListMakeAbsolute), 3669556Sandreas.hansson@arm.com ) 3679556Sandreas.hansson@arm.com 3689556Sandreas.hansson@arm.com# Update main environment with values from ARGUMENTS & global_vars_file 36911294Sandreas.hansson@arm.comglobal_vars.Update(main) 37011294Sandreas.hansson@arm.comhelp_texts["global_vars"] += global_vars.GenerateHelpText(main) 37111294Sandreas.hansson@arm.com 37211294Sandreas.hansson@arm.com# Save sticky variable settings back to current variables file 37310878Sandreas.hansson@arm.comglobal_vars.Save(global_vars_file, main) 37410878Sandreas.hansson@arm.com 37511811Sbaz21@cam.ac.uk# Parse EXTRAS variable to build list of all directories where we're 37611811Sbaz21@cam.ac.uk# look for sources etc. This list is exported as base_dir_list. 37711811Sbaz21@cam.ac.ukbase_dir = main.srcdir.abspath 37811982Sgabeblack@google.comif main['EXTRAS']: 37911982Sgabeblack@google.com extras_dir_list = main['EXTRAS'].split(':') 38011982Sgabeblack@google.comelse: 38113421Sciro.santilli@arm.com extras_dir_list = [] 38213421Sciro.santilli@arm.com 38311982Sgabeblack@google.comExport('base_dir') 38411992Sgabeblack@google.comExport('extras_dir_list') 38511982Sgabeblack@google.com 38611982Sgabeblack@google.com# the ext directory should be on the #includes path 38712305Sgabeblack@google.commain.Append(CPPPATH=[Dir('ext')]) 38812305Sgabeblack@google.com 38912305Sgabeblack@google.comdef strip_build_path(path, env): 39012305Sgabeblack@google.com path = str(path) 39112305Sgabeblack@google.com variant_base = env['BUILDROOT'] + os.path.sep 39212305Sgabeblack@google.com if path.startswith(variant_base): 39312305Sgabeblack@google.com path = path[len(variant_base):] 3949556Sandreas.hansson@arm.com elif path.startswith('build/'): 39512563Sgabeblack@google.com path = path[6:] 39612563Sgabeblack@google.com return path 39712563Sgabeblack@google.com 39812563Sgabeblack@google.com# Generate a string of the form: 3999556Sandreas.hansson@arm.com# common/path/prefix/src1, src2 -> tgt1, tgt2 40012563Sgabeblack@google.com# to print while building. 40112563Sgabeblack@google.comclass Transform(object): 4029556Sandreas.hansson@arm.com # all specific color settings should be here and nowhere else 40312563Sgabeblack@google.com tool_color = termcap.Normal 40412563Sgabeblack@google.com pfx_color = termcap.Yellow 40512563Sgabeblack@google.com srcs_color = termcap.Yellow + termcap.Bold 40612563Sgabeblack@google.com arrow_color = termcap.Blue + termcap.Bold 40712563Sgabeblack@google.com tgts_color = termcap.Yellow + termcap.Bold 40812563Sgabeblack@google.com 40912563Sgabeblack@google.com def __init__(self, tool, max_sources=99): 41012563Sgabeblack@google.com self.format = self.tool_color + (" [%8s] " % tool) \ 4119556Sandreas.hansson@arm.com + self.pfx_color + "%s" \ 4129556Sandreas.hansson@arm.com + self.srcs_color + "%s" \ 4136121Snate@binkert.org + self.arrow_color + " -> " \ 41411500Sandreas.hansson@arm.com + self.tgts_color + "%s" \ 41510238Sandreas.hansson@arm.com + termcap.Normal 41610878Sandreas.hansson@arm.com self.max_sources = max_sources 4179420Sandreas.hansson@arm.com 41811500Sandreas.hansson@arm.com def __call__(self, target, source, env, for_signature=None): 41912563Sgabeblack@google.com # truncate source list according to max_sources param 42012563Sgabeblack@google.com source = source[0:self.max_sources] 4219420Sandreas.hansson@arm.com def strip(f): 4229420Sandreas.hansson@arm.com return strip_build_path(str(f), env) 4239420Sandreas.hansson@arm.com if len(source) > 0: 4249420Sandreas.hansson@arm.com srcs = map(strip, source) 42512063Sgabeblack@google.com else: 42612063Sgabeblack@google.com srcs = [''] 42712063Sgabeblack@google.com tgts = map(strip, target) 42812063Sgabeblack@google.com # surprisingly, os.path.commonprefix is a dumb char-by-char string 42912063Sgabeblack@google.com # operation that has nothing to do with paths. 43012063Sgabeblack@google.com com_pfx = os.path.commonprefix(srcs + tgts) 43112063Sgabeblack@google.com com_pfx_len = len(com_pfx) 43212063Sgabeblack@google.com if com_pfx: 43312063Sgabeblack@google.com # do some cleanup and sanity checking on common prefix 43412063Sgabeblack@google.com if com_pfx[-1] == ".": 43512063Sgabeblack@google.com # prefix matches all but file extension: ok 43612063Sgabeblack@google.com # back up one to change 'foo.cc -> o' to 'foo.cc -> .o' 43712063Sgabeblack@google.com com_pfx = com_pfx[0:-1] 43812063Sgabeblack@google.com elif com_pfx[-1] == "/": 43912063Sgabeblack@google.com # common prefix is directory path: OK 44012063Sgabeblack@google.com pass 44112063Sgabeblack@google.com else: 44212063Sgabeblack@google.com src0_len = len(srcs[0]) 44312063Sgabeblack@google.com tgt0_len = len(tgts[0]) 44412063Sgabeblack@google.com if src0_len == com_pfx_len: 44512063Sgabeblack@google.com # source is a substring of target, OK 44612063Sgabeblack@google.com pass 44710457Sandreas.hansson@arm.com elif tgt0_len == com_pfx_len: 44810457Sandreas.hansson@arm.com # target is a substring of source, need to back up to 44910457Sandreas.hansson@arm.com # avoid empty string on RHS of arrow 45010457Sandreas.hansson@arm.com sep_idx = com_pfx.rfind(".") 45110457Sandreas.hansson@arm.com if sep_idx != -1: 45212563Sgabeblack@google.com com_pfx = com_pfx[0:sep_idx] 45312563Sgabeblack@google.com else: 45412563Sgabeblack@google.com com_pfx = '' 45510457Sandreas.hansson@arm.com elif src0_len > com_pfx_len and srcs[0][com_pfx_len] == ".": 45612063Sgabeblack@google.com # still splitting at file extension: ok 45712063Sgabeblack@google.com pass 45812063Sgabeblack@google.com else: 45912563Sgabeblack@google.com # probably a fluke; ignore it 46012563Sgabeblack@google.com com_pfx = '' 46112563Sgabeblack@google.com # recalculate length in case com_pfx was modified 46212563Sgabeblack@google.com com_pfx_len = len(com_pfx) 46312563Sgabeblack@google.com def fmt(files): 46412563Sgabeblack@google.com f = map(lambda s: s[com_pfx_len:], files) 46512063Sgabeblack@google.com return ', '.join(f) 46612063Sgabeblack@google.com return self.format % (com_pfx, fmt(srcs), fmt(tgts)) 46710238Sandreas.hansson@arm.com 46810238Sandreas.hansson@arm.comExport('Transform') 46910238Sandreas.hansson@arm.com 47012063Sgabeblack@google.com 47110238Sandreas.hansson@arm.comif GetOption('verbose'): 47210238Sandreas.hansson@arm.com def MakeAction(action, string, *args, **kwargs): 47310416Sandreas.hansson@arm.com return Action(action, *args, **kwargs) 47410238Sandreas.hansson@arm.comelse: 4759227Sandreas.hansson@arm.com MakeAction = Action 47610238Sandreas.hansson@arm.com main['CCCOMSTR'] = Transform("CC") 47710416Sandreas.hansson@arm.com main['CXXCOMSTR'] = Transform("CXX") 47810416Sandreas.hansson@arm.com main['ASCOMSTR'] = Transform("AS") 4799227Sandreas.hansson@arm.com main['SWIGCOMSTR'] = Transform("SWIG") 4809590Sandreas@sandberg.pp.se main['ARCOMSTR'] = Transform("AR", 0) 4819590Sandreas@sandberg.pp.se main['LINKCOMSTR'] = Transform("LINK", 0) 4829590Sandreas@sandberg.pp.se main['RANLIBCOMSTR'] = Transform("RANLIB", 0) 48312304Sgabeblack@google.com main['M4COMSTR'] = Transform("M4") 48412304Sgabeblack@google.com main['SHCCCOMSTR'] = Transform("SHCC") 48512304Sgabeblack@google.com main['SHCXXCOMSTR'] = Transform("SHCXX") 48612688Sgiacomo.travaglini@arm.comExport('MakeAction') 48712688Sgiacomo.travaglini@arm.com 48812688Sgiacomo.travaglini@arm.comCXX_version = readCommand([main['CXX'],'--version'], exception=False) 48913020Sshunhsingou@google.comCXX_V = readCommand([main['CXX'],'-V'], exception=False) 49012304Sgabeblack@google.com 49112688Sgiacomo.travaglini@arm.commain['GCC'] = CXX_version and CXX_version.find('g++') >= 0 49212688Sgiacomo.travaglini@arm.commain['SUNCC'] = CXX_V and CXX_V.find('Sun C++') >= 0 49313020Sshunhsingou@google.commain['ICC'] = CXX_V and CXX_V.find('Intel') >= 0 49412304Sgabeblack@google.comif main['GCC'] + main['SUNCC'] + main['ICC'] > 1: 49512304Sgabeblack@google.com print 'Error: How can we have two at the same time?' 49612304Sgabeblack@google.com Exit(1) 49712304Sgabeblack@google.com 49812688Sgiacomo.travaglini@arm.com# Set up default C++ compiler flags 49912688Sgiacomo.travaglini@arm.comif main['GCC']: 50012688Sgiacomo.travaglini@arm.com main.Append(CCFLAGS=['-pipe']) 50112304Sgabeblack@google.com main.Append(CCFLAGS=['-fno-strict-aliasing']) 5028737Skoansin.tan@gmail.com main.Append(CCFLAGS=['-Wall', '-Wno-sign-compare', '-Wundef']) 50310878Sandreas.hansson@arm.com main.Append(CXXFLAGS=['-Wno-deprecated']) 50411500Sandreas.hansson@arm.com # Read the GCC version to check for versions with bugs 5059420Sandreas.hansson@arm.com # Note CCVERSION doesn't work here because it is run with the CC 5068737Skoansin.tan@gmail.com # before we override it from the command line 50710106SMitch.Hayenga@arm.com gcc_version = readCommand([main['CXX'], '-dumpversion'], exception=False) 5088737Skoansin.tan@gmail.com if not compareVersions(gcc_version, '4.4.1') or \ 5098737Skoansin.tan@gmail.com not compareVersions(gcc_version, '4.4.2'): 51010878Sandreas.hansson@arm.com print 'Info: Tree vectorizer in GCC 4.4.1 & 4.4.2 is buggy, disabling.' 51112563Sgabeblack@google.com main.Append(CCFLAGS=['-fno-tree-vectorize']) 51212563Sgabeblack@google.comelif main['ICC']: 5138737Skoansin.tan@gmail.com pass #Fix me... add warning flags once we clean up icc warnings 5148737Skoansin.tan@gmail.comelif main['SUNCC']: 51512563Sgabeblack@google.com main.Append(CCFLAGS=['-Qoption ccfe']) 5168737Skoansin.tan@gmail.com main.Append(CCFLAGS=['-features=gcc']) 5178737Skoansin.tan@gmail.com main.Append(CCFLAGS=['-features=extensions']) 51811294Sandreas.hansson@arm.com main.Append(CCFLAGS=['-library=stlport4']) 5199556Sandreas.hansson@arm.com main.Append(CCFLAGS=['-xar']) 5209556Sandreas.hansson@arm.com #main.Append(CCFLAGS=['-instances=semiexplicit']) 5219556Sandreas.hansson@arm.comelse: 52211294Sandreas.hansson@arm.com print 'Error: Don\'t know what compiler options to use for your compiler.' 52310278SAndreas.Sandberg@ARM.com print ' Please fix SConstruct and src/SConscript and try again.' 52410278SAndreas.Sandberg@ARM.com Exit(1) 52510278SAndreas.Sandberg@ARM.com 52610278SAndreas.Sandberg@ARM.com# Set up common yacc/bison flags (needed for Ruby) 52710278SAndreas.Sandberg@ARM.commain['YACCFLAGS'] = '-d' 52810278SAndreas.Sandberg@ARM.commain['YACCHXXFILESUFFIX'] = '.hh' 5299556Sandreas.hansson@arm.com 5309590Sandreas@sandberg.pp.se# Do this after we save setting back, or else we'll tack on an 5319590Sandreas@sandberg.pp.se# extra 'qdo' every time we run scons. 5329420Sandreas.hansson@arm.comif main['BATCH']: 5339846Sandreas.hansson@arm.com main['CC'] = main['BATCH_CMD'] + ' ' + main['CC'] 5349846Sandreas.hansson@arm.com main['CXX'] = main['BATCH_CMD'] + ' ' + main['CXX'] 5359846Sandreas.hansson@arm.com main['AS'] = main['BATCH_CMD'] + ' ' + main['AS'] 5369846Sandreas.hansson@arm.com main['AR'] = main['BATCH_CMD'] + ' ' + main['AR'] 5378946Sandreas.hansson@arm.com main['RANLIB'] = main['BATCH_CMD'] + ' ' + main['RANLIB'] 53811811Sbaz21@cam.ac.uk 53911811Sbaz21@cam.ac.ukif sys.platform == 'cygwin': 54011811Sbaz21@cam.ac.uk # cygwin has some header file issues... 54111811Sbaz21@cam.ac.uk main.Append(CCFLAGS=["-Wno-uninitialized"]) 54212304Sgabeblack@google.com 54312304Sgabeblack@google.com# Check for SWIG 54412304Sgabeblack@google.comif not main.has_key('SWIG'): 54512304Sgabeblack@google.com print 'Error: SWIG utility not found.' 54613020Sshunhsingou@google.com print ' Please install (see http://www.swig.org) and retry.' 54713020Sshunhsingou@google.com Exit(1) 54812304Sgabeblack@google.com 54912304Sgabeblack@google.com# Check for appropriate SWIG version 55013020Sshunhsingou@google.comswig_version = readCommand(('swig', '-version'), exception='').split() 55113020Sshunhsingou@google.com# First 3 words should be "SWIG Version x.y.z" 55212304Sgabeblack@google.comif len(swig_version) < 3 or \ 55312304Sgabeblack@google.com swig_version[0] != 'SWIG' or swig_version[1] != 'Version': 55413020Sshunhsingou@google.com print 'Error determining SWIG version.' 55513020Sshunhsingou@google.com Exit(1) 55612304Sgabeblack@google.com 55712304Sgabeblack@google.commin_swig_version = '1.3.28' 5583918Ssaidi@eecs.umich.eduif compareVersions(swig_version[2], min_swig_version) < 0: 55912563Sgabeblack@google.com print 'Error: SWIG version', min_swig_version, 'or newer required.' 56012563Sgabeblack@google.com print ' Installed version:', swig_version[2] 56112563Sgabeblack@google.com Exit(1) 56212563Sgabeblack@google.com 5639068SAli.Saidi@ARM.com# Set up SWIG flags & scanner 56412563Sgabeblack@google.comswig_flags=Split('-c++ -python -modern -templatereduce $_CPPINCFLAGS') 56512563Sgabeblack@google.commain.Append(SWIGFLAGS=swig_flags) 5669068SAli.Saidi@ARM.com 56712563Sgabeblack@google.com# filter out all existing swig scanners, they mess up the dependency 56812563Sgabeblack@google.com# stuff for some reason 56912563Sgabeblack@google.comscanners = [] 57012563Sgabeblack@google.comfor scanner in main['SCANNERS']: 57112563Sgabeblack@google.com skeys = scanner.skeys 57212563Sgabeblack@google.com if skeys == '.i': 57312563Sgabeblack@google.com continue 57412563Sgabeblack@google.com 5753918Ssaidi@eecs.umich.edu if isinstance(skeys, (list, tuple)) and '.i' in skeys: 5763918Ssaidi@eecs.umich.edu continue 5776157Snate@binkert.org 5786157Snate@binkert.org scanners.append(scanner) 5796157Snate@binkert.org 5806157Snate@binkert.org# add the new swig scanner that we like better 5815397Ssaidi@eecs.umich.edufrom SCons.Scanner import ClassicCPP as CPPScanner 5825397Ssaidi@eecs.umich.eduswig_inc_re = '^[ \t]*[%,#][ \t]*(?:include|import)[ \t]*(<|")([^>"]+)(>|")' 5836121Snate@binkert.orgscanners.append(CPPScanner("SwigScan", [ ".i" ], "CPPPATH", swig_inc_re)) 5846121Snate@binkert.org 5856121Snate@binkert.org# replace the scanners list that has what we want 5866121Snate@binkert.orgmain['SCANNERS'] = scanners 5876121Snate@binkert.org 5886121Snate@binkert.org# Add a custom Check function to the Configure context so that we can 5895397Ssaidi@eecs.umich.edu# figure out if the compiler adds leading underscores to global 5901851SN/A# variables. This is needed for the autogenerated asm files that we 5911851SN/A# use for embedding the python code. 5927739Sgblack@eecs.umich.edudef CheckLeading(context): 593955SN/A context.Message("Checking for leading underscore in global variables...") 59414209Sandreas.sandberg@arm.com # 1) Define a global variable called x from asm so the C compiler 59514209Sandreas.sandberg@arm.com # won't change the symbol at all. 59614209Sandreas.sandberg@arm.com # 2) Declare that variable. 5979396Sandreas.hansson@arm.com # 3) Use the variable 5989396Sandreas.hansson@arm.com # 5999396Sandreas.hansson@arm.com # If the compiler prepends an underscore, this will successfully 6009396Sandreas.hansson@arm.com # link because the external symbol 'x' will be called '_x' which 6019396Sandreas.hansson@arm.com # was defined by the asm statement. If the compiler does not 6029396Sandreas.hansson@arm.com # prepend an underscore, this will not successfully link because 60312563Sgabeblack@google.com # '_x' will have been defined by assembly, while the C portion of 60412563Sgabeblack@google.com # the code will be trying to use 'x' 60512563Sgabeblack@google.com ret = context.TryLink(''' 60612563Sgabeblack@google.com asm(".globl _x; _x: .byte 0"); 6079396Sandreas.hansson@arm.com extern int x; 6089396Sandreas.hansson@arm.com int main() { return x; } 6099396Sandreas.hansson@arm.com ''', extension=".c") 6109396Sandreas.hansson@arm.com context.env.Append(LEADING_UNDERSCORE=ret) 6119396Sandreas.hansson@arm.com context.Result(ret) 6129396Sandreas.hansson@arm.com return ret 61312563Sgabeblack@google.com 61412563Sgabeblack@google.com# Platform-specific configuration. Note again that we assume that all 61512563Sgabeblack@google.com# builds under a given build root run on the same host platform. 61612563Sgabeblack@google.comconf = Configure(main, 61712563Sgabeblack@google.com conf_dir = joinpath(build_root, '.scons_config'), 6189477Sandreas.hansson@arm.com log_file = joinpath(build_root, 'scons_config.log'), 6199477Sandreas.hansson@arm.com custom_tests = { 'CheckLeading' : CheckLeading }) 6209477Sandreas.hansson@arm.com 6219477Sandreas.hansson@arm.com# Check for leading underscores. Don't really need to worry either 6229477Sandreas.hansson@arm.com# way so don't need to check the return code. 6239477Sandreas.hansson@arm.comconf.CheckLeading() 6249477Sandreas.hansson@arm.com 6259477Sandreas.hansson@arm.com# Check if we should compile a 64 bit binary on Mac OS X/Darwin 62614209Sandreas.sandberg@arm.comtry: 6279477Sandreas.hansson@arm.com import platform 6289477Sandreas.hansson@arm.com uname = platform.uname() 6299477Sandreas.hansson@arm.com if uname[0] == 'Darwin' and compareVersions(uname[2], '9.0.0') >= 0: 6309477Sandreas.hansson@arm.com if int(readCommand('sysctl -n hw.cpu64bit_capable')[0]): 6319477Sandreas.hansson@arm.com main.Append(CCFLAGS=['-arch', 'x86_64']) 63212563Sgabeblack@google.com main.Append(CFLAGS=['-arch', 'x86_64']) 63312563Sgabeblack@google.com main.Append(LINKFLAGS=['-arch', 'x86_64']) 63412563Sgabeblack@google.com main.Append(ASFLAGS=['-arch', 'x86_64']) 6359396Sandreas.hansson@arm.comexcept: 6362667Sstever@eecs.umich.edu pass 63710710Sandreas.hansson@arm.com 63810710Sandreas.hansson@arm.com# Recent versions of scons substitute a "Null" object for Configure() 63910710Sandreas.hansson@arm.com# when configuration isn't necessary, e.g., if the "--help" option is 64011811Sbaz21@cam.ac.uk# present. Unfortuantely this Null object always returns false, 64111811Sbaz21@cam.ac.uk# breaking all our configuration checks. We replace it with our own 64211811Sbaz21@cam.ac.uk# more optimistic null object that returns True instead. 64311811Sbaz21@cam.ac.ukif not conf: 64411811Sbaz21@cam.ac.uk def NullCheck(*args, **kwargs): 64511811Sbaz21@cam.ac.uk return True 64610710Sandreas.hansson@arm.com 64710710Sandreas.hansson@arm.com class NullConf: 64810710Sandreas.hansson@arm.com def __init__(self, env): 64910710Sandreas.hansson@arm.com self.env = env 65010384SCurtis.Dunham@arm.com def Finish(self): 6519986Sandreas@sandberg.pp.se return self.env 6529986Sandreas@sandberg.pp.se def __getattr__(self, mname): 6539986Sandreas@sandberg.pp.se return NullCheck 6549986Sandreas@sandberg.pp.se 6559986Sandreas@sandberg.pp.se conf = NullConf(main) 6569986Sandreas@sandberg.pp.se 6579986Sandreas@sandberg.pp.se# Find Python include and library directories for embedding the 6589986Sandreas@sandberg.pp.se# interpreter. For consistency, we will use the same Python 6599986Sandreas@sandberg.pp.se# installation used to run scons (and thus this script). If you want 6609986Sandreas@sandberg.pp.se# to link in an alternate version, see above for instructions on how 6619986Sandreas@sandberg.pp.se# to invoke scons with a different copy of the Python interpreter. 6629986Sandreas@sandberg.pp.sefrom distutils import sysconfig 6639986Sandreas@sandberg.pp.se 6649986Sandreas@sandberg.pp.sepy_getvar = sysconfig.get_config_var 6659986Sandreas@sandberg.pp.se 6669986Sandreas@sandberg.pp.sepy_debug = getattr(sys, 'pydebug', False) 6679986Sandreas@sandberg.pp.sepy_version = 'python' + py_getvar('VERSION') + (py_debug and "_d" or "") 6689986Sandreas@sandberg.pp.se 6699986Sandreas@sandberg.pp.sepy_general_include = sysconfig.get_python_inc() 6709986Sandreas@sandberg.pp.sepy_platform_include = sysconfig.get_python_inc(plat_specific=True) 6712638Sstever@eecs.umich.edupy_includes = [ py_general_include ] 6722638Sstever@eecs.umich.eduif py_platform_include != py_general_include: 6736121Snate@binkert.org py_includes.append(py_platform_include) 6743716Sstever@eecs.umich.edu 6755522Snate@binkert.orgpy_lib_path = [ py_getvar('LIBDIR') ] 6769986Sandreas@sandberg.pp.se# add the prefix/lib/pythonX.Y/config dir, but only if there is no 6779986Sandreas@sandberg.pp.se# shared library in prefix/lib/. 6789986Sandreas@sandberg.pp.seif not py_getvar('Py_ENABLE_SHARED'): 6795522Snate@binkert.org py_lib_path.append(py_getvar('LIBPL')) 6805227Ssaidi@eecs.umich.edu 6815227Ssaidi@eecs.umich.edupy_libs = [] 6825227Ssaidi@eecs.umich.edufor lib in py_getvar('LIBS').split() + py_getvar('SYSLIBS').split(): 6835227Ssaidi@eecs.umich.edu assert lib.startswith('-l') 6846654Snate@binkert.org lib = lib[2:] 6856654Snate@binkert.org if lib not in py_libs: 6867769SAli.Saidi@ARM.com py_libs.append(lib) 6877769SAli.Saidi@ARM.compy_libs.append(py_version) 6887769SAli.Saidi@ARM.com 6897769SAli.Saidi@ARM.commain.Append(CPPPATH=py_includes) 6905227Ssaidi@eecs.umich.edumain.Append(LIBPATH=py_lib_path) 6915227Ssaidi@eecs.umich.edu 6925227Ssaidi@eecs.umich.edu# Cache build files in the supplied directory. 6935204Sstever@gmail.comif main['M5_BUILD_CACHE']: 6945204Sstever@gmail.com print 'Using build cache located at', main['M5_BUILD_CACHE'] 6955204Sstever@gmail.com CacheDir(main['M5_BUILD_CACHE']) 6965204Sstever@gmail.com 6975204Sstever@gmail.com 6985204Sstever@gmail.com# verify that this stuff works 6995204Sstever@gmail.comif not conf.CheckHeader('Python.h', '<>'): 7005204Sstever@gmail.com print "Error: can't find Python.h header in", py_includes 7015204Sstever@gmail.com Exit(1) 7025204Sstever@gmail.com 7035204Sstever@gmail.comfor lib in py_libs: 7045204Sstever@gmail.com if not conf.CheckLib(lib): 7055204Sstever@gmail.com print "Error: can't find library %s required by python" % lib 7065204Sstever@gmail.com Exit(1) 7075204Sstever@gmail.com 7085204Sstever@gmail.com# On Solaris you need to use libsocket for socket ops 7095204Sstever@gmail.comif not conf.CheckLibWithHeader(None, 'sys/socket.h', 'C++', 'accept(0,0,0);'): 7106121Snate@binkert.org if not conf.CheckLibWithHeader('socket', 'sys/socket.h', 'C++', 'accept(0,0,0);'): 7115204Sstever@gmail.com print "Can't find library with socket calls (e.g. accept())" 7127727SAli.Saidi@ARM.com Exit(1) 7137727SAli.Saidi@ARM.com 71412563Sgabeblack@google.com# Check for zlib. If the check passes, libz will be automatically 7157727SAli.Saidi@ARM.com# added to the LIBS environment variable. 7167727SAli.Saidi@ARM.comif not conf.CheckLibWithHeader('z', 'zlib.h', 'C++','zlibVersion();'): 71711988Sandreas.sandberg@arm.com print 'Error: did not find needed zlib compression library '\ 71811988Sandreas.sandberg@arm.com 'and/or zlib.h header file.' 71910453SAndrew.Bardsley@arm.com print ' Please install zlib and try again.' 72010453SAndrew.Bardsley@arm.com Exit(1) 72110453SAndrew.Bardsley@arm.com 72210453SAndrew.Bardsley@arm.com# Check for librt. 72310453SAndrew.Bardsley@arm.comhave_posix_clock = \ 72410453SAndrew.Bardsley@arm.com conf.CheckLibWithHeader(None, 'time.h', 'C', 72510453SAndrew.Bardsley@arm.com 'clock_nanosleep(0,0,NULL,NULL);') or \ 72613715Sandreas.sandberg@arm.com conf.CheckLibWithHeader('rt', 'time.h', 'C', 72713715Sandreas.sandberg@arm.com 'clock_nanosleep(0,0,NULL,NULL);') 72813715Sandreas.sandberg@arm.com 72913715Sandreas.sandberg@arm.comif not have_posix_clock: 73013715Sandreas.sandberg@arm.com print "Can't find library for POSIX clocks." 73113715Sandreas.sandberg@arm.com 73213715Sandreas.sandberg@arm.com# Check for <fenv.h> (C99 FP environment control) 73313715Sandreas.sandberg@arm.comhave_fenv = conf.CheckHeader('fenv.h', '<>') 73410453SAndrew.Bardsley@arm.comif not have_fenv: 73510453SAndrew.Bardsley@arm.com print "Warning: Header file <fenv.h> not found." 73613541Sandrea.mondelli@ucf.edu print " This host has no IEEE FP rounding mode control." 73710453SAndrew.Bardsley@arm.com 73810453SAndrew.Bardsley@arm.com###################################################################### 73913541Sandrea.mondelli@ucf.edu# 74013541Sandrea.mondelli@ucf.edu# Check for mysql. 7419812Sandreas.hansson@arm.com# 74210453SAndrew.Bardsley@arm.commysql_config = WhereIs('mysql_config') 74310453SAndrew.Bardsley@arm.comhave_mysql = bool(mysql_config) 74410453SAndrew.Bardsley@arm.com 74510453SAndrew.Bardsley@arm.com# Check MySQL version. 74610453SAndrew.Bardsley@arm.comif have_mysql: 74710453SAndrew.Bardsley@arm.com mysql_version = readCommand(mysql_config + ' --version') 74810453SAndrew.Bardsley@arm.com min_mysql_version = '4.1' 74910453SAndrew.Bardsley@arm.com if compareVersions(mysql_version, min_mysql_version) < 0: 75010453SAndrew.Bardsley@arm.com print 'Warning: MySQL', min_mysql_version, 'or newer required.' 75110453SAndrew.Bardsley@arm.com print ' Version', mysql_version, 'detected.' 75210453SAndrew.Bardsley@arm.com have_mysql = False 75310453SAndrew.Bardsley@arm.com 7547727SAli.Saidi@ARM.com# Set up mysql_config commands. 75510453SAndrew.Bardsley@arm.comif have_mysql: 75610453SAndrew.Bardsley@arm.com mysql_config_include = mysql_config + ' --include' 75712790Smatteo.fusi@bsc.es if os.system(mysql_config_include + ' > /dev/null') != 0: 75812790Smatteo.fusi@bsc.es # older mysql_config versions don't support --include, use 75912790Smatteo.fusi@bsc.es # --cflags instead 76012790Smatteo.fusi@bsc.es mysql_config_include = mysql_config + ' --cflags | sed s/\\\'//g' 76112790Smatteo.fusi@bsc.es # This seems to work in all versions 76212790Smatteo.fusi@bsc.es mysql_config_libs = mysql_config + ' --libs' 76312790Smatteo.fusi@bsc.es 76410453SAndrew.Bardsley@arm.com###################################################################### 7653118Sstever@eecs.umich.edu# 76610453SAndrew.Bardsley@arm.com# Finish the configuration 76710453SAndrew.Bardsley@arm.com# 76812563Sgabeblack@google.commain = conf.Finish() 76910453SAndrew.Bardsley@arm.com 7703118Sstever@eecs.umich.edu###################################################################### 7713483Ssaidi@eecs.umich.edu# 7723494Ssaidi@eecs.umich.edu# Collect all non-global variables 7733494Ssaidi@eecs.umich.edu# 77412563Sgabeblack@google.com 7753483Ssaidi@eecs.umich.edu# Define the universe of supported ISAs 7763483Ssaidi@eecs.umich.eduall_isa_list = [ ] 7773053Sstever@eecs.umich.eduExport('all_isa_list') 7783053Sstever@eecs.umich.edu 7793918Ssaidi@eecs.umich.educlass CpuModel(object): 78012563Sgabeblack@google.com '''The CpuModel class encapsulates everything the ISA parser needs to 78112563Sgabeblack@google.com know about a particular CPU model.''' 78212563Sgabeblack@google.com 7833053Sstever@eecs.umich.edu # Dict of available CPU model objects. Accessible as CpuModel.dict. 7843053Sstever@eecs.umich.edu dict = {} 7859396Sandreas.hansson@arm.com list = [] 7869396Sandreas.hansson@arm.com defaults = [] 7879396Sandreas.hansson@arm.com 7889396Sandreas.hansson@arm.com # Constructor. Automatically adds models to CpuModel.dict. 7899396Sandreas.hansson@arm.com def __init__(self, name, filename, includes, strings, default=False): 7909396Sandreas.hansson@arm.com self.name = name # name of model 7919396Sandreas.hansson@arm.com self.filename = filename # filename for output exec code 7929396Sandreas.hansson@arm.com self.includes = includes # include files needed in exec file 7939396Sandreas.hansson@arm.com # The 'strings' dict holds all the per-CPU symbols we can 79412920Sgabeblack@google.com # substitute into templates etc. 79512920Sgabeblack@google.com self.strings = strings 79612920Sgabeblack@google.com 79712920Sgabeblack@google.com # This cpu is enabled by default 7989477Sandreas.hansson@arm.com self.default = default 7999396Sandreas.hansson@arm.com 80012563Sgabeblack@google.com # Add self to dict 80112563Sgabeblack@google.com if name in CpuModel.dict: 80212563Sgabeblack@google.com raise AttributeError, "CpuModel '%s' already registered" % name 80312563Sgabeblack@google.com CpuModel.dict[name] = self 8049396Sandreas.hansson@arm.com CpuModel.list.append(name) 8057840Snate@binkert.org 8067865Sgblack@eecs.umich.eduExport('CpuModel') 8077865Sgblack@eecs.umich.edu 8087865Sgblack@eecs.umich.edu# Sticky variables get saved in the variables file so they persist from 8097865Sgblack@eecs.umich.edu# one invocation to the next (unless overridden, in which case the new 8107865Sgblack@eecs.umich.edu# value becomes sticky). 8117840Snate@binkert.orgsticky_vars = Variables(args=ARGUMENTS) 8129900Sandreas@sandberg.pp.seExport('sticky_vars') 8139900Sandreas@sandberg.pp.se 8149900Sandreas@sandberg.pp.se# Sticky variables that should be exported 8159900Sandreas@sandberg.pp.seexport_vars = [] 81610456SCurtis.Dunham@arm.comExport('export_vars') 81710456SCurtis.Dunham@arm.com 81810456SCurtis.Dunham@arm.com# Walk the tree and execute all SConsopts scripts that wil add to the 81910456SCurtis.Dunham@arm.com# above variables 82010456SCurtis.Dunham@arm.comfor bdir in [ base_dir ] + extras_dir_list: 82110456SCurtis.Dunham@arm.com for root, dirs, files in os.walk(bdir): 82212563Sgabeblack@google.com if 'SConsopts' in files: 82312563Sgabeblack@google.com print "Reading", joinpath(root, 'SConsopts') 82412563Sgabeblack@google.com SConscript(joinpath(root, 'SConsopts')) 82512563Sgabeblack@google.com 8269045SAli.Saidi@ARM.comall_isa_list.sort() 82711235Sandreas.sandberg@arm.com 82811235Sandreas.sandberg@arm.comsticky_vars.AddVariables( 82911235Sandreas.sandberg@arm.com EnumVariable('TARGET_ISA', 'Target ISA', 'alpha', all_isa_list), 83011235Sandreas.sandberg@arm.com BoolVariable('FULL_SYSTEM', 'Full-system support', False), 83111235Sandreas.sandberg@arm.com ListVariable('CPU_MODELS', 'CPU models', 83212485Sjang.hanhwi@gmail.com sorted(n for n,m in CpuModel.dict.iteritems() if m.default), 83312485Sjang.hanhwi@gmail.com sorted(CpuModel.list)), 83412485Sjang.hanhwi@gmail.com BoolVariable('NO_FAST_ALLOC', 'Disable fast object allocator', False), 83511235Sandreas.sandberg@arm.com BoolVariable('FAST_ALLOC_DEBUG', 'Enable fast object allocator debugging', 83611811Sbaz21@cam.ac.uk False), 83712485Sjang.hanhwi@gmail.com BoolVariable('FAST_ALLOC_STATS', 'Enable fast object allocator statistics', 83811811Sbaz21@cam.ac.uk False), 83911811Sbaz21@cam.ac.uk BoolVariable('EFENCE', 'Link with Electric Fence malloc debugger', 84011811Sbaz21@cam.ac.uk False), 84111235Sandreas.sandberg@arm.com BoolVariable('SS_COMPATIBLE_FP', 84211235Sandreas.sandberg@arm.com 'Make floating-point results compatible with SimpleScalar', 84311235Sandreas.sandberg@arm.com False), 84412563Sgabeblack@google.com BoolVariable('USE_SSE2', 84512563Sgabeblack@google.com 'Compile for SSE2 (-msse2) to get IEEE FP on x86 hosts', 84612563Sgabeblack@google.com False), 84711235Sandreas.sandberg@arm.com BoolVariable('USE_MYSQL', 'Use MySQL for stats output', have_mysql), 8487840Snate@binkert.org BoolVariable('USE_POSIX_CLOCK', 'Use POSIX Clocks', have_posix_clock), 84912563Sgabeblack@google.com BoolVariable('USE_FENV', 'Use <fenv.h> IEEE mode control', have_fenv), 8507840Snate@binkert.org BoolVariable('USE_CHECKER', 'Use checker for detailed CPU models', False), 8511858SN/A BoolVariable('CP_ANNOTATE', 'Enable critical path annotation capability', False), 8521858SN/A BoolVariable('RUBY', 'Build with Ruby', False), 8531858SN/A ) 85412563Sgabeblack@google.com 85512563Sgabeblack@google.com# These variables get exported to #defines in config/*.hh (see src/SConscript). 8561858SN/Aexport_vars += ['FULL_SYSTEM', 'USE_FENV', 'USE_MYSQL', 85712230Sgiacomo.travaglini@arm.com 'NO_FAST_ALLOC', 'FAST_ALLOC_DEBUG', 'FAST_ALLOC_STATS', 85812230Sgiacomo.travaglini@arm.com 'SS_COMPATIBLE_FP', 'USE_CHECKER', 'TARGET_ISA', 'CP_ANNOTATE', 85912230Sgiacomo.travaglini@arm.com 'USE_POSIX_CLOCK' ] 86012230Sgiacomo.travaglini@arm.com 86112563Sgabeblack@google.com################################################### 86212563Sgabeblack@google.com# 86312563Sgabeblack@google.com# Define a SCons builder for configuration flag headers. 86412230Sgiacomo.travaglini@arm.com# 8659903Sandreas.hansson@arm.com################################################### 8669903Sandreas.hansson@arm.com 8679903Sandreas.hansson@arm.com# This function generates a config header file that #defines the 8689903Sandreas.hansson@arm.com# variable symbol to the current variable setting (0 or 1). The source 86910841Sandreas.sandberg@arm.com# operands are the name of the variable and a Value node containing the 8709651SAndreas.Sandberg@ARM.com# value of the variable. 87112563Sgabeblack@google.comdef build_config_file(target, source, env): 87212563Sgabeblack@google.com (variable, value) = [s.get_contents() for s in source] 8739651SAndreas.Sandberg@ARM.com f = file(str(target[0]), 'w') 87412056Sgabeblack@google.com print >> f, '#define', variable, value 87512056Sgabeblack@google.com f.close() 87612056Sgabeblack@google.com return None 87712563Sgabeblack@google.com 87812056Sgabeblack@google.com# Generate the message to be printed when building the config file. 87910841Sandreas.sandberg@arm.comdef build_config_file_string(target, source, env): 88010841Sandreas.sandberg@arm.com (variable, value) = [s.get_contents() for s in source] 88110841Sandreas.sandberg@arm.com return "Defining %s as %s in %s." % (variable, value, target[0]) 88210841Sandreas.sandberg@arm.com 88310841Sandreas.sandberg@arm.com# Combine the two functions into a scons Action object. 88410841Sandreas.sandberg@arm.comconfig_action = Action(build_config_file, build_config_file_string) 8859651SAndreas.Sandberg@ARM.com 8869651SAndreas.Sandberg@ARM.com# The emitter munges the source & target node lists to reflect what 8879651SAndreas.Sandberg@ARM.com# we're really doing. 8889651SAndreas.Sandberg@ARM.comdef config_emitter(target, source, env): 8899651SAndreas.Sandberg@ARM.com # extract variable name from Builder arg 8909651SAndreas.Sandberg@ARM.com variable = str(target[0]) 89112563Sgabeblack@google.com # True target is config header file 8929651SAndreas.Sandberg@ARM.com target = joinpath('config', variable.lower() + '.hh') 8939651SAndreas.Sandberg@ARM.com val = env[variable] 89410841Sandreas.sandberg@arm.com if isinstance(val, bool): 89512563Sgabeblack@google.com # Force value to 0/1 89612563Sgabeblack@google.com val = int(val) 89710841Sandreas.sandberg@arm.com elif isinstance(val, str): 89810841Sandreas.sandberg@arm.com val = '"' + val + '"' 89910841Sandreas.sandberg@arm.com 90010860Sandreas.sandberg@arm.com # Sources are variable name & value (packaged in SCons Value nodes) 90110841Sandreas.sandberg@arm.com return ([target], [Value(variable), Value(val)]) 90210841Sandreas.sandberg@arm.com 90310841Sandreas.sandberg@arm.comconfig_builder = Builder(emitter = config_emitter, action = config_action) 90410841Sandreas.sandberg@arm.com 90510841Sandreas.sandberg@arm.commain.Append(BUILDERS = { 'ConfigFile' : config_builder }) 90612563Sgabeblack@google.com 90710841Sandreas.sandberg@arm.com# libelf build is shared across all configs in the build root. 90810841Sandreas.sandberg@arm.commain.SConscript('ext/libelf/SConscript', 90910841Sandreas.sandberg@arm.com variant_dir = joinpath(build_root, 'libelf')) 91010841Sandreas.sandberg@arm.com 91110841Sandreas.sandberg@arm.com# gzstream build is shared across all configs in the build root. 9129651SAndreas.Sandberg@ARM.commain.SConscript('ext/gzstream/SConscript', 9139651SAndreas.Sandberg@ARM.com variant_dir = joinpath(build_root, 'gzstream')) 9149986Sandreas@sandberg.pp.se 9159986Sandreas@sandberg.pp.se################################################### 9169986Sandreas@sandberg.pp.se# 9179986Sandreas@sandberg.pp.se# This function is used to set up a directory with switching headers 9189986Sandreas@sandberg.pp.se# 91914209Sandreas.sandberg@arm.com################################################### 92014209Sandreas.sandberg@arm.com 92114209Sandreas.sandberg@arm.commain['ALL_ISA_LIST'] = all_isa_list 92214209Sandreas.sandberg@arm.comdef make_switching_dir(dname, switch_headers, env): 92314209Sandreas.sandberg@arm.com # Generate the header. target[0] is the full path of the output 92414209Sandreas.sandberg@arm.com # header to generate. 'source' is a dummy variable, since we get the 92514209Sandreas.sandberg@arm.com # list of ISAs from env['ALL_ISA_LIST']. 92614209Sandreas.sandberg@arm.com def gen_switch_hdr(target, source, env): 92714209Sandreas.sandberg@arm.com fname = str(target[0]) 92814209Sandreas.sandberg@arm.com f = open(fname, 'w') 92914209Sandreas.sandberg@arm.com isa = env['TARGET_ISA'].lower() 93014209Sandreas.sandberg@arm.com print >>f, '#include "%s/%s/%s"' % (dname, isa, basename(fname)) 93114209Sandreas.sandberg@arm.com f.close() 93214209Sandreas.sandberg@arm.com 93314209Sandreas.sandberg@arm.com # Build SCons Action object. 'varlist' specifies env vars that this 93414209Sandreas.sandberg@arm.com # action depends on; when env['ALL_ISA_LIST'] changes these actions 93514209Sandreas.sandberg@arm.com # should get re-executed. 93614209Sandreas.sandberg@arm.com switch_hdr_action = MakeAction(gen_switch_hdr, 93714209Sandreas.sandberg@arm.com Transform("GENERATE"), varlist=['ALL_ISA_LIST']) 93814209Sandreas.sandberg@arm.com 93914209Sandreas.sandberg@arm.com # Instantiate actions for each header 94014209Sandreas.sandberg@arm.com for hdr in switch_headers: 94114209Sandreas.sandberg@arm.com env.Command(hdr, [], switch_hdr_action) 94214209Sandreas.sandberg@arm.comExport('make_switching_dir') 94314209Sandreas.sandberg@arm.com 94414209Sandreas.sandberg@arm.com################################################### 94514209Sandreas.sandberg@arm.com# 94614209Sandreas.sandberg@arm.com# Define build environments for selected configurations. 94714209Sandreas.sandberg@arm.com# 94814209Sandreas.sandberg@arm.com################################################### 94914209Sandreas.sandberg@arm.com 95014209Sandreas.sandberg@arm.comfor variant_path in variant_paths: 95114209Sandreas.sandberg@arm.com print "Building in", variant_path 95214209Sandreas.sandberg@arm.com 95314209Sandreas.sandberg@arm.com # Make a copy of the build-root environment to use for this config. 95414209Sandreas.sandberg@arm.com env = main.Clone() 9559986Sandreas@sandberg.pp.se env['BUILDDIR'] = variant_path 9565863Snate@binkert.org 9575863Snate@binkert.org # variant_dir is the tail component of build path, and is used to 9585863Snate@binkert.org # determine the build parameters (e.g., 'ALPHA_SE') 9595863Snate@binkert.org (build_root, variant_dir) = splitpath(variant_path) 9606121Snate@binkert.org 9611858SN/A # Set env variables according to the build directory config. 9625863Snate@binkert.org sticky_vars.files = [] 9635863Snate@binkert.org # Variables for $BUILD_ROOT/$VARIANT_DIR are stored in 9645863Snate@binkert.org # $BUILD_ROOT/variables/$VARIANT_DIR so you can nuke 9655863Snate@binkert.org # $BUILD_ROOT/$VARIANT_DIR without losing your variables settings. 9665863Snate@binkert.org current_vars_file = joinpath(build_root, 'variables', variant_dir) 9672139SN/A if isfile(current_vars_file): 9684202Sbinkertn@umich.edu sticky_vars.files.append(current_vars_file) 96911308Santhony.gutierrez@amd.com print "Using saved variables file %s" % current_vars_file 9704202Sbinkertn@umich.edu else: 97111308Santhony.gutierrez@amd.com # Build dir-specific variables file doesn't exist. 9722139SN/A 9736994Snate@binkert.org # Make sure the directory is there so we can create it later 9746994Snate@binkert.org opt_dir = dirname(current_vars_file) 9756994Snate@binkert.org if not isdir(opt_dir): 9766994Snate@binkert.org mkdir(opt_dir) 9776994Snate@binkert.org 9786994Snate@binkert.org # Get default build variables from source tree. Variables are 9796994Snate@binkert.org # normally determined by name of $VARIANT_DIR, but can be 9806994Snate@binkert.org # overriden by 'default=' arg on command line. 98110319SAndreas.Sandberg@ARM.com default = GetOption('default') 9826994Snate@binkert.org if not default: 9836994Snate@binkert.org default = variant_dir 9846994Snate@binkert.org default_vars_file = joinpath('build_opts', default) 9856994Snate@binkert.org if isfile(default_vars_file): 9866994Snate@binkert.org sticky_vars.files.append(default_vars_file) 9876994Snate@binkert.org print "Variables file %s not found,\n using defaults in %s" \ 9886994Snate@binkert.org % (current_vars_file, default_vars_file) 9896994Snate@binkert.org else: 9906994Snate@binkert.org print "Error: cannot find variables file %s or %s" \ 9916994Snate@binkert.org % (current_vars_file, default_vars_file) 9926994Snate@binkert.org Exit(1) 9932155SN/A 9945863Snate@binkert.org # Apply current variable settings to env 9951869SN/A sticky_vars.Update(env) 9961869SN/A 9975863Snate@binkert.org help_texts["local_vars"] += \ 9985863Snate@binkert.org "Build variables for %s:\n" % variant_dir \ 9994202Sbinkertn@umich.edu + sticky_vars.GenerateHelpText(env) 10006108Snate@binkert.org 10016108Snate@binkert.org # Process variable settings. 10026108Snate@binkert.org 10036108Snate@binkert.org if not have_fenv and env['USE_FENV']: 10049219Spower.jg@gmail.com print "Warning: <fenv.h> not available; " \ 10059219Spower.jg@gmail.com "forcing USE_FENV to False in", variant_dir + "." 10069219Spower.jg@gmail.com env['USE_FENV'] = False 10079219Spower.jg@gmail.com 10089219Spower.jg@gmail.com if not env['USE_FENV']: 10099219Spower.jg@gmail.com print "Warning: No IEEE FP rounding mode control in", variant_dir + "." 10109219Spower.jg@gmail.com print " FP results may deviate slightly from other platforms." 10119219Spower.jg@gmail.com 10124202Sbinkertn@umich.edu if env['EFENCE']: 10135863Snate@binkert.org env.Append(LIBS=['efence']) 101410135SCurtis.Dunham@arm.com 101512563Sgabeblack@google.com if env['USE_MYSQL']: 10165742Snate@binkert.org if not have_mysql: 10178268Ssteve.reinhardt@amd.com print "Warning: MySQL not available; " \ 101812563Sgabeblack@google.com "forcing USE_MYSQL to False in", variant_dir + "." 10198268Ssteve.reinhardt@amd.com env['USE_MYSQL'] = False 10205742Snate@binkert.org else: 10215341Sstever@gmail.com print "Compiling in", variant_dir, "with MySQL support." 10228474Sgblack@eecs.umich.edu env.ParseConfig(mysql_config_libs) 102312563Sgabeblack@google.com env.ParseConfig(mysql_config_include) 10245342Sstever@gmail.com 10254202Sbinkertn@umich.edu # Save sticky variable settings back to current variables file 10264202Sbinkertn@umich.edu sticky_vars.Save(current_vars_file, env) 102711308Santhony.gutierrez@amd.com 10284202Sbinkertn@umich.edu if env['USE_SSE2']: 10295863Snate@binkert.org env.Append(CCFLAGS=['-msse2']) 10305863Snate@binkert.org 103111308Santhony.gutierrez@amd.com # The src/SConscript file sets up the build rules in 'env' according 10326994Snate@binkert.org # to the configured variables. It returns a list of environments, 10336994Snate@binkert.org # one for each variant build (debug, opt, etc.) 103410319SAndreas.Sandberg@ARM.com envList = SConscript('src/SConscript', variant_dir = variant_path, 10355863Snate@binkert.org exports = 'env') 10365863Snate@binkert.org 10375863Snate@binkert.org # Set up the regression tests for each build. 10385863Snate@binkert.org for e in envList: 10395863Snate@binkert.org SConscript('tests/SConscript', 10405863Snate@binkert.org variant_dir = joinpath(variant_path, 'tests', e.Label), 10415863Snate@binkert.org exports = { 'env' : e }, duplicate = False) 10425863Snate@binkert.org 10437840Snate@binkert.org# base help text 10445863Snate@binkert.orgHelp(''' 104512230Sgiacomo.travaglini@arm.comUsage: scons [scons options] [build variables] [target(s)] 104612230Sgiacomo.travaglini@arm.com 104712230Sgiacomo.travaglini@arm.comExtra scons options: 104812230Sgiacomo.travaglini@arm.com%(options)s 104912230Sgiacomo.travaglini@arm.com 105012056Sgabeblack@google.comGlobal build variables: 105112056Sgabeblack@google.com%(global_vars)s 105212056Sgabeblack@google.com 105311308Santhony.gutierrez@amd.com%(local_vars)s 10549219Spower.jg@gmail.com''' % help_texts) 10559219Spower.jg@gmail.com