SConstruct revision 9119:a8749b39f1f8
1360SN/A# -*- mode:python -*- 210850SGiacomo.Gabrielli@arm.com 310796Sbrandon.potter@amd.com# Copyright (c) 2011 Advanced Micro Devices, Inc. 410027SChris.Adeniyi-Jones@arm.com# Copyright (c) 2009 The Hewlett-Packard Development Company 510027SChris.Adeniyi-Jones@arm.com# Copyright (c) 2004-2005 The Regents of The University of Michigan 610027SChris.Adeniyi-Jones@arm.com# All rights reserved. 710027SChris.Adeniyi-Jones@arm.com# 810027SChris.Adeniyi-Jones@arm.com# Redistribution and use in source and binary forms, with or without 910027SChris.Adeniyi-Jones@arm.com# modification, are permitted provided that the following conditions are 1010027SChris.Adeniyi-Jones@arm.com# met: redistributions of source code must retain the above copyright 1110027SChris.Adeniyi-Jones@arm.com# notice, this list of conditions and the following disclaimer; 1210027SChris.Adeniyi-Jones@arm.com# redistributions in binary form must reproduce the above copyright 1310027SChris.Adeniyi-Jones@arm.com# notice, this list of conditions and the following disclaimer in the 1410027SChris.Adeniyi-Jones@arm.com# documentation and/or other materials provided with the distribution; 151458SN/A# neither the name of the copyright holders nor the names of its 16360SN/A# contributors may be used to endorse or promote products derived from 17360SN/A# this software without specific prior written permission. 18360SN/A# 19360SN/A# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20360SN/A# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21360SN/A# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22360SN/A# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23360SN/A# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24360SN/A# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25360SN/A# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26360SN/A# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27360SN/A# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28360SN/A# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29360SN/A# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30360SN/A# 31360SN/A# Authors: Steve Reinhardt 32360SN/A# Nathan Binkert 33360SN/A 34360SN/A################################################### 35360SN/A# 36360SN/A# SCons top-level build description (SConstruct) file. 37360SN/A# 38360SN/A# While in this directory ('gem5'), just type 'scons' to build the default 39360SN/A# configuration (see below), or type 'scons build/<CONFIG>/<binary>' 402665Ssaidi@eecs.umich.edu# to build some other configuration (e.g., 'build/ALPHA/gem5.opt' for 412665Ssaidi@eecs.umich.edu# the optimized full-system version). 422665Ssaidi@eecs.umich.edu# 43360SN/A# You can build gem5 in a different directory as long as there is a 44360SN/A# 'build/<CONFIG>' somewhere along the target path. The build system 451354SN/A# expects that all configs under the same build directory are being 461354SN/A# built for the same host system. 47360SN/A# 4812018Sandreas.sandberg@arm.com# Examples: 4912018Sandreas.sandberg@arm.com# 5012018Sandreas.sandberg@arm.com# The following two commands are equivalent. The '-u' option tells 5112018Sandreas.sandberg@arm.com# scons to search up the directory tree for this SConstruct file. 5212018Sandreas.sandberg@arm.com# % cd <path-to-src>/gem5 ; scons build/ALPHA/gem5.debug 5312018Sandreas.sandberg@arm.com# % cd <path-to-src>/gem5/build/ALPHA; scons -u gem5.debug 5412018Sandreas.sandberg@arm.com# 552064SN/A# The following two commands are equivalent and demonstrate building 5612018Sandreas.sandberg@arm.com# in a directory outside of the source tree. The '-C' option tells 5712018Sandreas.sandberg@arm.com# scons to chdir to the specified directory to find this SConstruct 5812018Sandreas.sandberg@arm.com# file. 5912018Sandreas.sandberg@arm.com# % cd <path-to-src>/gem5 ; scons /local/foo/build/ALPHA/gem5.debug 6012018Sandreas.sandberg@arm.com# % cd /local/foo/build/ALPHA; scons -C <path-to-src>/gem5 gem5.debug 6112018Sandreas.sandberg@arm.com# 6211799Sbrandon.potter@amd.com# You can use 'scons -H' to print scons options. If you're in this 6312018Sandreas.sandberg@arm.com# 'gem5' directory (or use -u or -C to tell scons where to find this 6412018Sandreas.sandberg@arm.com# file), you can use 'scons -h' to print all the gem5-specific build 6512018Sandreas.sandberg@arm.com# options as well. 6612018Sandreas.sandberg@arm.com# 6712018Sandreas.sandberg@arm.com################################################### 6812018Sandreas.sandberg@arm.com 6911799Sbrandon.potter@amd.com# Check for recent-enough Python and SCons versions. 70360SN/Atry: 71360SN/A # Really old versions of scons only take two options for the 72360SN/A # function, so check once without the revision and once with the 73360SN/A # revision, the first instance will fail for stuff other than 74360SN/A # 0.98, and the second will fail for 0.98.0 75360SN/A EnsureSConsVersion(0, 98) 761809SN/A EnsureSConsVersion(0, 98, 1) 7711800Sbrandon.potter@amd.comexcept SystemExit, e: 7811392Sbrandon.potter@amd.com print """ 791809SN/AFor more details, see: 8011392Sbrandon.potter@amd.com http://gem5.org/Dependencies 8111383Sbrandon.potter@amd.com""" 823113Sgblack@eecs.umich.edu raise 8311799Sbrandon.potter@amd.com 8411759Sbrandon.potter@amd.com# We ensure the python version early because we have stuff that 8511812Sbaz21@cam.ac.uk# requires python 2.4 8611812Sbaz21@cam.ac.uktry: 8711799Sbrandon.potter@amd.com EnsurePythonVersion(2, 4) 888229Snate@binkert.orgexcept SystemExit, e: 898229Snate@binkert.org print """ 9011594Santhony.gutierrez@amd.comYou can use a non-default installation of the Python interpreter by 917075Snate@binkert.orgeither (1) rearranging your PATH so that scons finds the non-default 928229Snate@binkert.org'python' first or (2) explicitly invoking an alternative interpreter 9311856Sbrandon.potter@amd.comon the scons script. 947075Snate@binkert.org 95360SN/AFor more details, see: 9612461Sgabeblack@google.com http://gem5.org/wiki/index.php/Using_a_non-default_Python_installation 9711886Sbrandon.potter@amd.com""" 9811800Sbrandon.potter@amd.com raise 9911392Sbrandon.potter@amd.com 10012334Sgabeblack@google.com# Global Python includes 1011354SN/Aimport os 1026216Snate@binkert.orgimport re 1036658Snate@binkert.orgimport subprocess 1042474SN/Aimport sys 1052680Sktlim@umich.edu 1068229Snate@binkert.orgfrom os import mkdir, environ 10711886Sbrandon.potter@amd.comfrom os.path import abspath, basename, dirname, expanduser, normpath 10810496Ssteve.reinhardt@amd.comfrom os.path import exists, isdir, isfile 10911911SBrandon.Potter@amd.comfrom os.path import join as joinpath, split as splitpath 1108229Snate@binkert.org 11111794Sbrandon.potter@amd.com# SCons includes 11211886Sbrandon.potter@amd.comimport SCons 11310497Ssteve.reinhardt@amd.comimport SCons.Node 11411794Sbrandon.potter@amd.com 115360SN/Aextra_python_paths = [ 116360SN/A Dir('src/python').srcnode().abspath, # gem5 includes 117360SN/A Dir('ext/ply').srcnode().abspath, # ply is used by several files 118360SN/A ] 119360SN/A 120360SN/Asys.path[1:1] = extra_python_paths 121360SN/A 122360SN/Afrom m5.util import compareVersions, readCommand 123360SN/Afrom m5.util.terminal import get_termcap 124360SN/A 125378SN/Ahelp_texts = { 1261706SN/A "options" : "", 12711851Sbrandon.potter@amd.com "global_vars" : "", 128378SN/A "local_vars" : "" 129378SN/A} 130378SN/A 131378SN/AExport("help_texts") 132378SN/A 1331706SN/A 13411851Sbrandon.potter@amd.com# There's a bug in scons in that (1) by default, the help texts from 135360SN/A# AddOption() are supposed to be displayed when you type 'scons -h' 13611760Sbrandon.potter@amd.com# and (2) you can override the help displayed by 'scons -h' using the 13711760Sbrandon.potter@amd.com# Help() function, but these two features are incompatible: once 13811851Sbrandon.potter@amd.com# you've overridden the help text using Help(), there's no way to get 13911760Sbrandon.potter@amd.com# at the help texts from AddOptions. See: 1406109Ssanchezd@stanford.edu# http://scons.tigris.org/issues/show_bug.cgi?id=2356 1411706SN/A# http://scons.tigris.org/issues/show_bug.cgi?id=2611 14211851Sbrandon.potter@amd.com# This hack lets us extract the help text from AddOptions and 143378SN/A# re-inject it via Help(). Ideally someday this bug will be fixed and 1446109Ssanchezd@stanford.edu# we can just use AddOption directly. 1456109Ssanchezd@stanford.edudef AddLocalOption(*args, **kwargs): 14611851Sbrandon.potter@amd.com col_width = 30 1476109Ssanchezd@stanford.edu 14811886Sbrandon.potter@amd.com help = " " + ", ".join(args) 14911886Sbrandon.potter@amd.com if "help" in kwargs: 15011886Sbrandon.potter@amd.com length = len(help) 15111886Sbrandon.potter@amd.com if length >= col_width: 152378SN/A help += "\n" + " " * col_width 1531706SN/A else: 15411851Sbrandon.potter@amd.com help += " " * (col_width - length) 155378SN/A help += kwargs["help"] 1565748SSteve.Reinhardt@amd.com help_texts["options"] += help + "\n" 1575748SSteve.Reinhardt@amd.com 15811851Sbrandon.potter@amd.com AddOption(*args, **kwargs) 159378SN/A 160378SN/AAddLocalOption('--colors', dest='use_colors', action='store_true', 1611706SN/A help="Add color to abbreviated scons output") 16211851Sbrandon.potter@amd.comAddLocalOption('--no-colors', dest='use_colors', action='store_false', 163378SN/A help="Don't add color to abbreviated scons output") 16411886Sbrandon.potter@amd.comAddLocalOption('--default', dest='default', type='string', action='store', 1651706SN/A help='Override which build_opts file to use for defaults') 16611851Sbrandon.potter@amd.comAddLocalOption('--ignore-style', dest='ignore_style', action='store_true', 167378SN/A help='Disable style checking hooks') 168378SN/AAddLocalOption('--update-ref', dest='update_ref', action='store_true', 1691706SN/A help='Update test reference outputs') 17011851Sbrandon.potter@amd.comAddLocalOption('--verbose', dest='verbose', action='store_true', 171378SN/A help='Print full tool command lines') 172378SN/A 1731706SN/Atermcap = get_termcap(GetOption('use_colors')) 17411851Sbrandon.potter@amd.com 175378SN/A######################################################################## 1764118Sgblack@eecs.umich.edu# 1774118Sgblack@eecs.umich.edu# Set up the main build environment. 17811851Sbrandon.potter@amd.com# 1794118Sgblack@eecs.umich.edu######################################################################## 180378SN/Ause_vars = set([ 'AS', 'AR', 'CC', 'CXX', 'HOME', 'LD_LIBRARY_PATH', 1811706SN/A 'LIBRARY_PATH', 'PATH', 'PYTHONPATH', 'RANLIB', 'SWIG' ]) 18211851Sbrandon.potter@amd.com 183378SN/Ause_env = {} 184378SN/Afor key,val in os.environ.iteritems(): 1851706SN/A if key in use_vars or key.startswith("M5"): 18611851Sbrandon.potter@amd.com use_env[key] = val 187360SN/A 1885513SMichael.Adler@intel.commain = Environment(ENV=use_env) 1895513SMichael.Adler@intel.commain.Decider('MD5-timestamp') 19011851Sbrandon.potter@amd.commain.root = Dir(".") # The current directory (where this file lives). 1915513SMichael.Adler@intel.commain.srcdir = Dir("src") # The source directory 19210203SAli.Saidi@ARM.com 19310203SAli.Saidi@ARM.com# add useful python code PYTHONPATH so it can be used by subprocesses 19411851Sbrandon.potter@amd.com# as well 19510203SAli.Saidi@ARM.commain.AppendENVPath('PYTHONPATH', extra_python_paths) 1965513SMichael.Adler@intel.com 19711851Sbrandon.potter@amd.com######################################################################## 1985513SMichael.Adler@intel.com# 199511SN/A# Mercurial Stuff. 20010633Smichaelupton@gmail.com# 20111851Sbrandon.potter@amd.com# If the gem5 directory is a mercurial repository, we should do some 20210633Smichaelupton@gmail.com# extra things. 2031706SN/A# 20411851Sbrandon.potter@amd.com######################################################################## 205511SN/A 20612795Smattdsinclair@gmail.comhgdir = main.root.Dir(".hg") 20712795Smattdsinclair@gmail.com 20812795Smattdsinclair@gmail.commercurial_style_message = """ 20912795Smattdsinclair@gmail.comYou're missing the gem5 style hook, which automatically checks your code 21012796Smattdsinclair@gmail.comagainst the gem5 style rules on hg commit and qrefresh commands. This 21112796Smattdsinclair@gmail.comscript will now install the hook in your .hg/hgrc file. 21212796Smattdsinclair@gmail.comPress enter to continue, or ctrl-c to abort: """ 21312796Smattdsinclair@gmail.com 2145513SMichael.Adler@intel.commercurial_style_hook = """ 2155513SMichael.Adler@intel.com# The following lines were automatically added by gem5/SConstruct 21611851Sbrandon.potter@amd.com# to provide the gem5 style-checking hooks 2175513SMichael.Adler@intel.com[extensions] 21813031Sbrandon.potter@amd.comstyle = %s/util/style.py 21913031Sbrandon.potter@amd.com 22013031Sbrandon.potter@amd.com[hooks] 22113031Sbrandon.potter@amd.compretxncommit.style = python:style.check_style 22213031Sbrandon.potter@amd.compre-qrefresh.style = python:style.check_style 22313031Sbrandon.potter@amd.com# End of SConstruct additions 22413031Sbrandon.potter@amd.com 22513031Sbrandon.potter@amd.com""" % (main.root.abspath) 22613031Sbrandon.potter@amd.com 22713031Sbrandon.potter@amd.commercurial_lib_not_found = """ 22813031Sbrandon.potter@amd.comMercurial libraries cannot be found, ignoring style hook. If 22913031Sbrandon.potter@amd.comyou are a gem5 developer, please fix this and run the style 230511SN/Ahook. It is important. 2311706SN/A""" 23211851Sbrandon.potter@amd.com 2331706SN/A# Check for style hook and prompt for installation if it's not there. 2341706SN/A# Skip this if --ignore-style was specified, there's no .hg dir to 2351706SN/A# install a hook in, or there's no interactive terminal to prompt. 2361706SN/Aif not GetOption('ignore_style') and hgdir.exists() and sys.stdin.isatty(): 23711851Sbrandon.potter@amd.com style_hook = True 2381706SN/A try: 2391706SN/A from mercurial import ui 2401706SN/A ui = ui.ui() 2411706SN/A ui.readconfig(hgdir.File('hgrc').abspath) 24211851Sbrandon.potter@amd.com style_hook = ui.config('hooks', 'pretxncommit.style', None) and \ 2431706SN/A ui.config('hooks', 'pre-qrefresh.style', None) 244511SN/A except ImportError: 2456703Svince@csl.cornell.edu print mercurial_lib_not_found 2466703Svince@csl.cornell.edu 24711851Sbrandon.potter@amd.com if not style_hook: 2486703Svince@csl.cornell.edu print mercurial_style_message, 2496685Stjones1@inf.ed.ac.uk # continue unless user does ctrl-c/ctrl-d etc. 2506685Stjones1@inf.ed.ac.uk try: 25111851Sbrandon.potter@amd.com raw_input() 2526685Stjones1@inf.ed.ac.uk except: 2536685Stjones1@inf.ed.ac.uk print "Input exception, exiting scons.\n" 2545513SMichael.Adler@intel.com sys.exit(1) 2555513SMichael.Adler@intel.com hgrc_path = '%s/.hg/hgrc' % main.root.abspath 25611851Sbrandon.potter@amd.com print "Adding style hook to", hgrc_path, "\n" 2575513SMichael.Adler@intel.com try: 25811885Sbrandon.potter@amd.com hgrc = open(hgrc_path, 'a') 25911885Sbrandon.potter@amd.com hgrc.write(mercurial_style_hook) 26011885Sbrandon.potter@amd.com hgrc.close() 2615513SMichael.Adler@intel.com except: 2621999SN/A print "Error updating", hgrc_path 2631999SN/A sys.exit(1) 26411851Sbrandon.potter@amd.com 2651999SN/A 26611885Sbrandon.potter@amd.com################################################### 26711885Sbrandon.potter@amd.com# 26811885Sbrandon.potter@amd.com# Figure out which configurations to set up based on the path(s) of 2691999SN/A# the target(s). 2701999SN/A# 2711999SN/A################################################### 27211851Sbrandon.potter@amd.com 2731999SN/A# Find default configuration & binary. 2743079Sstever@eecs.umich.eduDefault(environ.get('M5_DEFAULT_BINARY', 'build/ALPHA/gem5.debug')) 2753079Sstever@eecs.umich.edu 27611851Sbrandon.potter@amd.com# helper function: find last occurrence of element in list 2773079Sstever@eecs.umich.edudef rfind(l, elt, offs = -1): 27811908SBrandon.Potter@amd.com for i in range(len(l)+offs, 0, -1): 27911908SBrandon.Potter@amd.com if l[i] == elt: 28011908SBrandon.Potter@amd.com return i 28111908SBrandon.Potter@amd.com raise ValueError, "element not found" 28211875Sbrandon.potter@amd.com 2832093SN/A# Take a list of paths (or SCons Nodes) and return a list with all 28411851Sbrandon.potter@amd.com# paths made absolute and ~-expanded. Paths will be interpreted 2852093SN/A# relative to the launch directory unless a different root is provided 2862687Sksewell@umich.edudef makePathListAbsolute(path_list, root=GetLaunchDir()): 2872687Sksewell@umich.edu return [abspath(joinpath(root, expanduser(str(p)))) 28811851Sbrandon.potter@amd.com for p in path_list] 2892687Sksewell@umich.edu 2902238SN/A# Each target must have 'build' in the interior of the path; the 2912238SN/A# directory below this will determine the build parameters. For 29211851Sbrandon.potter@amd.com# example, for target 'foo/bar/build/ALPHA_SE/arch/alpha/blah.do' we 2932238SN/A# recognize that ALPHA_SE specifies the configuration because it 29411908SBrandon.Potter@amd.com# follow 'build' in the build path. 29511908SBrandon.Potter@amd.com 29611908SBrandon.Potter@amd.com# The funky assignment to "[:]" is needed to replace the list contents 29711908SBrandon.Potter@amd.com# in place rather than reassign the symbol to a new list, which 29811908SBrandon.Potter@amd.com# doesn't work (obviously!). 29911908SBrandon.Potter@amd.comBUILD_TARGETS[:] = makePathListAbsolute(BUILD_TARGETS) 30011908SBrandon.Potter@amd.com 30111908SBrandon.Potter@amd.com# Generate a list of the unique build roots and configs that the 3022238SN/A# collected targets reference. 3032238SN/Avariant_paths = [] 30411851Sbrandon.potter@amd.combuild_root = None 3052238SN/Afor t in BUILD_TARGETS: 30613448Sciro.santilli@arm.com path_dirs = t.split('/') 30713031Sbrandon.potter@amd.com try: 30813031Sbrandon.potter@amd.com build_top = rfind(path_dirs, 'build', -2) 30913031Sbrandon.potter@amd.com except: 31013448Sciro.santilli@arm.com print "Error: no non-leaf 'build' dir found on target path", t 31113031Sbrandon.potter@amd.com Exit(1) 31213031Sbrandon.potter@amd.com this_build_root = joinpath('/',*path_dirs[:build_top+1]) 3132238SN/A if not build_root: 31411851Sbrandon.potter@amd.com build_root = this_build_root 3152238SN/A else: 3162238SN/A if this_build_root != build_root: 3172238SN/A print "Error: build targets not under same build root\n"\ 31811851Sbrandon.potter@amd.com " %s\n %s" % (build_root, this_build_root) 3192238SN/A Exit(1) 3202238SN/A variant_path = joinpath('/',*path_dirs[:build_top+2]) 3212238SN/A if variant_path not in variant_paths: 32211851Sbrandon.potter@amd.com variant_paths.append(variant_path) 3232238SN/A 3242238SN/A# Make sure build_root exists (might not if this is the first build there) 3252238SN/Aif not isdir(build_root): 32611851Sbrandon.potter@amd.com mkdir(build_root) 3272238SN/Amain['BUILDROOT'] = build_root 3282238SN/A 3292238SN/AExport('main') 33011851Sbrandon.potter@amd.com 3312238SN/Amain.SConsignFile(joinpath(build_root, "sconsign")) 3329455Smitch.hayenga+gem5@gmail.com 3339455Smitch.hayenga+gem5@gmail.com# Default duplicate option is to use hard links, but this messes up 33411851Sbrandon.potter@amd.com# when you use emacs to edit a file in the target dir, as emacs moves 33510203SAli.Saidi@ARM.com# file to file~ then copies to file, breaking the link. Symbolic 33611851Sbrandon.potter@amd.com# (soft) links work better. 33711851Sbrandon.potter@amd.commain.SetOption('duplicate', 'soft-copy') 3389455Smitch.hayenga+gem5@gmail.com 3399112Smarc.orr@gmail.com# 34011906SBrandon.Potter@amd.com# Set up global sticky variables... these are common to an entire build 34111906SBrandon.Potter@amd.com# tree (not specific to a particular build like ALPHA_SE) 3429112Smarc.orr@gmail.com# 3439112Smarc.orr@gmail.com 34411851Sbrandon.potter@amd.comglobal_vars_file = joinpath(build_root, 'variables.global') 3459112Smarc.orr@gmail.com 3469112Smarc.orr@gmail.comglobal_vars = Variables(global_vars_file, args=ARGUMENTS) 34711911SBrandon.Potter@amd.com 3489112Smarc.orr@gmail.comglobal_vars.AddVariables( 34911911SBrandon.Potter@amd.com ('CC', 'C compiler', environ.get('CC', main['CC'])), 35011911SBrandon.Potter@amd.com ('CXX', 'C++ compiler', environ.get('CXX', main['CXX'])), 35111911SBrandon.Potter@amd.com ('SWIG', 'SWIG tool', environ.get('SWIG', main['SWIG'])), 35211911SBrandon.Potter@amd.com ('BATCH', 'Use batch pool for build and tests', False), 3539112Smarc.orr@gmail.com ('BATCH_CMD', 'Batch pool submission command name', 'qdo'), 35411911SBrandon.Potter@amd.com ('M5_BUILD_CACHE', 'Cache built objects in this directory', False), 35511911SBrandon.Potter@amd.com ('EXTRAS', 'Add extra directories to the compilation', '') 35611911SBrandon.Potter@amd.com ) 35711911SBrandon.Potter@amd.com 3589238Slluc.alvarez@bsc.es# Update main environment with values from ARGUMENTS & global_vars_file 3599112Smarc.orr@gmail.comglobal_vars.Update(main) 36011911SBrandon.Potter@amd.comhelp_texts["global_vars"] += global_vars.GenerateHelpText(main) 3619112Smarc.orr@gmail.com 36211911SBrandon.Potter@amd.com# Save sticky variable settings back to current variables file 36311911SBrandon.Potter@amd.comglobal_vars.Save(global_vars_file, main) 36411911SBrandon.Potter@amd.com 36511911SBrandon.Potter@amd.com# Parse EXTRAS variable to build list of all directories where we're 36611911SBrandon.Potter@amd.com# look for sources etc. This list is exported as extras_dir_list. 3679112Smarc.orr@gmail.combase_dir = main.srcdir.abspath 36811911SBrandon.Potter@amd.comif main['EXTRAS']: 36911911SBrandon.Potter@amd.com extras_dir_list = makePathListAbsolute(main['EXTRAS'].split(':')) 37011911SBrandon.Potter@amd.comelse: 37111911SBrandon.Potter@amd.com extras_dir_list = [] 37211911SBrandon.Potter@amd.com 37311911SBrandon.Potter@amd.comExport('base_dir') 3749112Smarc.orr@gmail.comExport('extras_dir_list') 3759112Smarc.orr@gmail.com 37611911SBrandon.Potter@amd.com# the ext directory should be on the #includes path 37711911SBrandon.Potter@amd.commain.Append(CPPPATH=[Dir('ext')]) 3789112Smarc.orr@gmail.com 37911911SBrandon.Potter@amd.comdef strip_build_path(path, env): 38011911SBrandon.Potter@amd.com path = str(path) 3819112Smarc.orr@gmail.com variant_base = env['BUILDROOT'] + os.path.sep 3829112Smarc.orr@gmail.com if path.startswith(variant_base): 38311911SBrandon.Potter@amd.com path = path[len(variant_base):] 38411911SBrandon.Potter@amd.com elif path.startswith('build/'): 3859112Smarc.orr@gmail.com path = path[6:] 3869112Smarc.orr@gmail.com return path 3872238SN/A 3882238SN/A# Generate a string of the form: 3892238SN/A# common/path/prefix/src1, src2 -> tgt1, tgt2 3902238SN/A# to print while building. 39111851Sbrandon.potter@amd.comclass Transform(object): 3922238SN/A # all specific color settings should be here and nowhere else 3932238SN/A tool_color = termcap.Normal 3942238SN/A pfx_color = termcap.Yellow 39511851Sbrandon.potter@amd.com srcs_color = termcap.Yellow + termcap.Bold 3962238SN/A arrow_color = termcap.Blue + termcap.Bold 3972238SN/A tgts_color = termcap.Yellow + termcap.Bold 3982238SN/A 39911851Sbrandon.potter@amd.com def __init__(self, tool, max_sources=99): 4002238SN/A self.format = self.tool_color + (" [%8s] " % tool) \ 4012238SN/A + self.pfx_color + "%s" \ 4022238SN/A + self.srcs_color + "%s" \ 40311851Sbrandon.potter@amd.com + self.arrow_color + " -> " \ 4042238SN/A + self.tgts_color + "%s" \ 4052238SN/A + termcap.Normal 4061354SN/A self.max_sources = max_sources 4071354SN/A 40810796Sbrandon.potter@amd.com def __call__(self, target, source, env, for_signature=None): 40910796Sbrandon.potter@amd.com # truncate source list according to max_sources param 4101354SN/A source = source[0:self.max_sources] 4111354SN/A def strip(f): 4121354SN/A return strip_build_path(str(f), env) 4131354SN/A if len(source) > 0: 4141354SN/A srcs = map(strip, source) 4151354SN/A else: 4161354SN/A srcs = [''] 4171354SN/A tgts = map(strip, target) 4181354SN/A # surprisingly, os.path.commonprefix is a dumb char-by-char string 4191354SN/A # operation that has nothing to do with paths. 42010796Sbrandon.potter@amd.com com_pfx = os.path.commonprefix(srcs + tgts) 4211354SN/A com_pfx_len = len(com_pfx) 42210796Sbrandon.potter@amd.com if com_pfx: 4231354SN/A # do some cleanup and sanity checking on common prefix 4241354SN/A if com_pfx[-1] == ".": 4251354SN/A # prefix matches all but file extension: ok 4261354SN/A # back up one to change 'foo.cc -> o' to 'foo.cc -> .o' 42710796Sbrandon.potter@amd.com com_pfx = com_pfx[0:-1] 42810796Sbrandon.potter@amd.com elif com_pfx[-1] == "/": 42910796Sbrandon.potter@amd.com # common prefix is directory path: OK 43010796Sbrandon.potter@amd.com pass 43110796Sbrandon.potter@amd.com else: 43210796Sbrandon.potter@amd.com src0_len = len(srcs[0]) 43310796Sbrandon.potter@amd.com tgt0_len = len(tgts[0]) 43410796Sbrandon.potter@amd.com if src0_len == com_pfx_len: 43510796Sbrandon.potter@amd.com # source is a substring of target, OK 43610796Sbrandon.potter@amd.com pass 43710796Sbrandon.potter@amd.com elif tgt0_len == com_pfx_len: 438360SN/A # target is a substring of source, need to back up to 439360SN/A # avoid empty string on RHS of arrow 440360SN/A sep_idx = com_pfx.rfind(".") 441360SN/A if sep_idx != -1: 442360SN/A com_pfx = com_pfx[0:sep_idx] 443360SN/A else: 444360SN/A com_pfx = '' 44511759Sbrandon.potter@amd.com elif src0_len > com_pfx_len and srcs[0][com_pfx_len] == ".": 4463113Sgblack@eecs.umich.edu # still splitting at file extension: ok 4473113Sgblack@eecs.umich.edu pass 4483113Sgblack@eecs.umich.edu else: 4493113Sgblack@eecs.umich.edu # probably a fluke; ignore it 4503113Sgblack@eecs.umich.edu com_pfx = '' 4513113Sgblack@eecs.umich.edu # recalculate length in case com_pfx was modified 4523113Sgblack@eecs.umich.edu com_pfx_len = len(com_pfx) 4533113Sgblack@eecs.umich.edu def fmt(files): 4543113Sgblack@eecs.umich.edu f = map(lambda s: s[com_pfx_len:], files) 4553113Sgblack@eecs.umich.edu return ', '.join(f) 4563113Sgblack@eecs.umich.edu return self.format % (com_pfx, fmt(srcs), fmt(tgts)) 4573113Sgblack@eecs.umich.edu 4583113Sgblack@eecs.umich.eduExport('Transform') 45912032Sandreas.sandberg@arm.com 4603113Sgblack@eecs.umich.edu# enable the regression script to use the termcap 4613113Sgblack@eecs.umich.edumain['TERMCAP'] = termcap 4624189Sgblack@eecs.umich.edu 4634189Sgblack@eecs.umich.eduif GetOption('verbose'): 4643113Sgblack@eecs.umich.edu def MakeAction(action, string, *args, **kwargs): 4653113Sgblack@eecs.umich.edu return Action(action, *args, **kwargs) 4663113Sgblack@eecs.umich.eduelse: 4673113Sgblack@eecs.umich.edu MakeAction = Action 4688737Skoansin.tan@gmail.com main['CCCOMSTR'] = Transform("CC") 4693113Sgblack@eecs.umich.edu main['CXXCOMSTR'] = Transform("CXX") 4708737Skoansin.tan@gmail.com main['ASCOMSTR'] = Transform("AS") 4713277Sgblack@eecs.umich.edu main['SWIGCOMSTR'] = Transform("SWIG") 4725515SMichael.Adler@intel.com main['ARCOMSTR'] = Transform("AR", 0) 4735515SMichael.Adler@intel.com main['LINKCOMSTR'] = Transform("LINK", 0) 4745515SMichael.Adler@intel.com main['RANLIBCOMSTR'] = Transform("RANLIB", 0) 4755515SMichael.Adler@intel.com main['M4COMSTR'] = Transform("M4") 4765515SMichael.Adler@intel.com main['SHCCCOMSTR'] = Transform("SHCC") 4778737Skoansin.tan@gmail.com main['SHCXXCOMSTR'] = Transform("SHCXX") 4783277Sgblack@eecs.umich.eduExport('MakeAction') 4798737Skoansin.tan@gmail.com 4803277Sgblack@eecs.umich.eduCXX_version = readCommand([main['CXX'],'--version'], exception=False) 4818737Skoansin.tan@gmail.comCXX_V = readCommand([main['CXX'],'-V'], exception=False) 4823277Sgblack@eecs.umich.edu 4838737Skoansin.tan@gmail.commain['GCC'] = CXX_version and CXX_version.find('g++') >= 0 4843113Sgblack@eecs.umich.edumain['SUNCC'] = CXX_V and CXX_V.find('Sun C++') >= 0 4853113Sgblack@eecs.umich.edumain['ICC'] = CXX_V and CXX_V.find('Intel') >= 0 4863113Sgblack@eecs.umich.edumain['CLANG'] = CXX_version and CXX_version.find('clang') >= 0 4873113Sgblack@eecs.umich.eduif main['GCC'] + main['SUNCC'] + main['ICC'] + main['CLANG'] > 1: 4888737Skoansin.tan@gmail.com print 'Error: How can we have two at the same time?' 4893113Sgblack@eecs.umich.edu Exit(1) 4908737Skoansin.tan@gmail.com 4913114Sgblack@eecs.umich.edu# Set up default C++ compiler flags 4928737Skoansin.tan@gmail.comif main['GCC']: 4933114Sgblack@eecs.umich.edu main.Append(CCFLAGS=['-pipe']) 4948737Skoansin.tan@gmail.com main.Append(CCFLAGS=['-fno-strict-aliasing']) 4953114Sgblack@eecs.umich.edu main.Append(CCFLAGS=['-Wall', '-Wno-sign-compare', '-Wundef']) 4968737Skoansin.tan@gmail.com # Read the GCC version to check for versions with bugs 49711906SBrandon.Potter@amd.com # Note CCVERSION doesn't work here because it is run with the CC 4984061Sgblack@eecs.umich.edu # before we override it from the command line 4994061Sgblack@eecs.umich.edu gcc_version = readCommand([main['CXX'], '-dumpversion'], exception=False) 5008737Skoansin.tan@gmail.com main['GCC_VERSION'] = gcc_version 5013113Sgblack@eecs.umich.edu if not compareVersions(gcc_version, '4.4.1') or \ 5028737Skoansin.tan@gmail.com not compareVersions(gcc_version, '4.4.2'): 5033113Sgblack@eecs.umich.edu print 'Info: Tree vectorizer in GCC 4.4.1 & 4.4.2 is buggy, disabling.' 5043113Sgblack@eecs.umich.edu main.Append(CCFLAGS=['-fno-tree-vectorize']) 5053113Sgblack@eecs.umich.edu if compareVersions(gcc_version, '4.6') >= 0: 5063113Sgblack@eecs.umich.edu main.Append(CXXFLAGS=['-std=c++0x']) 5073113Sgblack@eecs.umich.eduelif main['ICC']: 50812032Sandreas.sandberg@arm.com pass #Fix me... add warning flags once we clean up icc warnings 5093113Sgblack@eecs.umich.eduelif main['SUNCC']: 5103113Sgblack@eecs.umich.edu main.Append(CCFLAGS=['-Qoption ccfe']) 5114189Sgblack@eecs.umich.edu main.Append(CCFLAGS=['-features=gcc']) 5124189Sgblack@eecs.umich.edu main.Append(CCFLAGS=['-features=extensions']) 5133113Sgblack@eecs.umich.edu main.Append(CCFLAGS=['-library=stlport4']) 5143113Sgblack@eecs.umich.edu main.Append(CCFLAGS=['-xar']) 5153113Sgblack@eecs.umich.edu #main.Append(CCFLAGS=['-instances=semiexplicit']) 5168737Skoansin.tan@gmail.comelif main['CLANG']: 5173113Sgblack@eecs.umich.edu clang_version_re = re.compile(".* version (\d+\.\d+)") 5188737Skoansin.tan@gmail.com clang_version_match = clang_version_re.match(CXX_version) 5193113Sgblack@eecs.umich.edu if (clang_version_match): 5208737Skoansin.tan@gmail.com clang_version = clang_version_match.groups()[0] 5213113Sgblack@eecs.umich.edu if compareVersions(clang_version, "2.9") < 0: 5223113Sgblack@eecs.umich.edu print 'Error: clang version 2.9 or newer required.' 5233113Sgblack@eecs.umich.edu print ' Installed version:', clang_version 5243113Sgblack@eecs.umich.edu Exit(1) 5253113Sgblack@eecs.umich.edu else: 5263113Sgblack@eecs.umich.edu print 'Error: Unable to determine clang version.' 5273113Sgblack@eecs.umich.edu Exit(1) 52811906SBrandon.Potter@amd.com 5293113Sgblack@eecs.umich.edu main.Append(CCFLAGS=['-pipe']) 53012032Sandreas.sandberg@arm.com main.Append(CCFLAGS=['-fno-strict-aliasing']) 5318852Sandreas.hansson@arm.com main.Append(CCFLAGS=['-Wall', '-Wno-sign-compare', '-Wundef']) 53211906SBrandon.Potter@amd.com main.Append(CCFLAGS=['-Wno-tautological-compare']) 5333113Sgblack@eecs.umich.edu main.Append(CCFLAGS=['-Wno-self-assign']) 5343113Sgblack@eecs.umich.edu # Ruby makes frequent use of extraneous parantheses in the printing 5353113Sgblack@eecs.umich.edu # of if-statements 5363113Sgblack@eecs.umich.edu main.Append(CCFLAGS=['-Wno-parentheses']) 5373113Sgblack@eecs.umich.edu 5383113Sgblack@eecs.umich.edu if compareVersions(clang_version, "3") >= 0: 5393113Sgblack@eecs.umich.edu main.Append(CXXFLAGS=['-std=c++0x']) 5403113Sgblack@eecs.umich.eduelse: 54112032Sandreas.sandberg@arm.com print termcap.Yellow + termcap.Bold + 'Error' + termcap.Normal, 5428852Sandreas.hansson@arm.com print "Don't know what compiler options to use for your compiler." 54311906SBrandon.Potter@amd.com print termcap.Yellow + ' compiler:' + termcap.Normal, main['CXX'] 5443113Sgblack@eecs.umich.edu print termcap.Yellow + ' version:' + termcap.Normal, 5453113Sgblack@eecs.umich.edu if not CXX_version: 5463113Sgblack@eecs.umich.edu print termcap.Yellow + termcap.Bold + "COMMAND NOT FOUND!" +\ 5476686Stjones1@inf.ed.ac.uk termcap.Normal 5483113Sgblack@eecs.umich.edu else: 5493113Sgblack@eecs.umich.edu print CXX_version.replace('\n', '<nl>') 5503113Sgblack@eecs.umich.edu print " If you're trying to use a compiler other than GCC, ICC, SunCC," 55111759Sbrandon.potter@amd.com print " or clang, there appears to be something wrong with your" 55212032Sandreas.sandberg@arm.com print " environment." 55311759Sbrandon.potter@amd.com print " " 55411759Sbrandon.potter@amd.com print " If you are trying to use a compiler other than those listed" 55511759Sbrandon.potter@amd.com print " above you will need to ease fix SConstruct and " 55611759Sbrandon.potter@amd.com print " src/SConscript to support that compiler." 55711759Sbrandon.potter@amd.com Exit(1) 55811812Sbaz21@cam.ac.uk 55911812Sbaz21@cam.ac.uk# Set up common yacc/bison flags (needed for Ruby) 56011812Sbaz21@cam.ac.ukmain['YACCFLAGS'] = '-d' 56111759Sbrandon.potter@amd.commain['YACCHXXFILESUFFIX'] = '.hh' 56211812Sbaz21@cam.ac.uk 56311759Sbrandon.potter@amd.com# Do this after we save setting back, or else we'll tack on an 56411759Sbrandon.potter@amd.com# extra 'qdo' every time we run scons. 56511759Sbrandon.potter@amd.comif main['BATCH']: 56611759Sbrandon.potter@amd.com main['CC'] = main['BATCH_CMD'] + ' ' + main['CC'] 56711759Sbrandon.potter@amd.com main['CXX'] = main['BATCH_CMD'] + ' ' + main['CXX'] 56811759Sbrandon.potter@amd.com main['AS'] = main['BATCH_CMD'] + ' ' + main['AS'] 56911759Sbrandon.potter@amd.com main['AR'] = main['BATCH_CMD'] + ' ' + main['AR'] 57011812Sbaz21@cam.ac.uk main['RANLIB'] = main['BATCH_CMD'] + ' ' + main['RANLIB'] 57111812Sbaz21@cam.ac.uk 57211812Sbaz21@cam.ac.ukif sys.platform == 'cygwin': 57311812Sbaz21@cam.ac.uk # cygwin has some header file issues... 57411812Sbaz21@cam.ac.uk main.Append(CCFLAGS=["-Wno-uninitialized"]) 57511812Sbaz21@cam.ac.uk 57611812Sbaz21@cam.ac.uk# Check for SWIG 57711759Sbrandon.potter@amd.comif not main.has_key('SWIG'): 57811759Sbrandon.potter@amd.com print 'Error: SWIG utility not found.' 57911812Sbaz21@cam.ac.uk print ' Please install (see http://www.swig.org) and retry.' 58011812Sbaz21@cam.ac.uk Exit(1) 58111759Sbrandon.potter@amd.com 58211812Sbaz21@cam.ac.uk# Check for appropriate SWIG version 58311812Sbaz21@cam.ac.ukswig_version = readCommand([main['SWIG'], '-version'], exception='').split() 58411812Sbaz21@cam.ac.uk# First 3 words should be "SWIG Version x.y.z" 58511812Sbaz21@cam.ac.ukif len(swig_version) < 3 or \ 58611812Sbaz21@cam.ac.uk swig_version[0] != 'SWIG' or swig_version[1] != 'Version': 58711812Sbaz21@cam.ac.uk print 'Error determining SWIG version.' 58811812Sbaz21@cam.ac.uk Exit(1) 58911759Sbrandon.potter@amd.com 59011759Sbrandon.potter@amd.commin_swig_version = '1.3.34' 59111759Sbrandon.potter@amd.comif compareVersions(swig_version[2], min_swig_version) < 0: 59211759Sbrandon.potter@amd.com print 'Error: SWIG version', min_swig_version, 'or newer required.' 593378SN/A print ' Installed version:', swig_version[2] 594378SN/A Exit(1) 5959141Smarc.orr@gmail.com 5969141Smarc.orr@gmail.com# Set up SWIG flags & scanner 597360SN/Aswig_flags=Split('-c++ -python -modern -templatereduce $_CPPINCFLAGS') 5981450SN/Amain.Append(SWIGFLAGS=swig_flags) 59911856Sbrandon.potter@amd.com 600360SN/A# filter out all existing swig scanners, they mess up the dependency 6016701Sgblack@eecs.umich.edu# stuff for some reason 60211856Sbrandon.potter@amd.comscanners = [] 60311856Sbrandon.potter@amd.comfor scanner in main['SCANNERS']: 604360SN/A skeys = scanner.skeys 60510930Sbrandon.potter@amd.com if skeys == '.i': 606360SN/A continue 60711856Sbrandon.potter@amd.com 60811856Sbrandon.potter@amd.com if isinstance(skeys, (list, tuple)) and '.i' in skeys: 60910496Ssteve.reinhardt@amd.com continue 61011856Sbrandon.potter@amd.com 61111856Sbrandon.potter@amd.com scanners.append(scanner) 6121458SN/A 613360SN/A# add the new swig scanner that we like better 61411856Sbrandon.potter@amd.comfrom SCons.Scanner import ClassicCPP as CPPScanner 61511856Sbrandon.potter@amd.comswig_inc_re = '^[ \t]*[%,#][ \t]*(?:include|import)[ \t]*(<|")([^>"]+)(>|")' 61611856Sbrandon.potter@amd.comscanners.append(CPPScanner("SwigScan", [ ".i" ], "CPPPATH", swig_inc_re)) 61711856Sbrandon.potter@amd.com 61811856Sbrandon.potter@amd.com# replace the scanners list that has what we want 61911856Sbrandon.potter@amd.commain['SCANNERS'] = scanners 62011856Sbrandon.potter@amd.com 62111856Sbrandon.potter@amd.com# Add a custom Check function to the Configure context so that we can 62210496Ssteve.reinhardt@amd.com# figure out if the compiler adds leading underscores to global 62311856Sbrandon.potter@amd.com# variables. This is needed for the autogenerated asm files that we 62411856Sbrandon.potter@amd.com# use for embedding the python code. 62511856Sbrandon.potter@amd.comdef CheckLeading(context): 62611856Sbrandon.potter@amd.com context.Message("Checking for leading underscore in global variables...") 62711856Sbrandon.potter@amd.com # 1) Define a global variable called x from asm so the C compiler 62810930Sbrandon.potter@amd.com # won't change the symbol at all. 6299141Smarc.orr@gmail.com # 2) Declare that variable. 630360SN/A # 3) Use the variable 631360SN/A # 632360SN/A # If the compiler prepends an underscore, this will successfully 63311907SBrandon.Potter@amd.com # link because the external symbol 'x' will be called '_x' which 63411907SBrandon.Potter@amd.com # was defined by the asm statement. If the compiler does not 63511907SBrandon.Potter@amd.com # prepend an underscore, this will not successfully link because 636360SN/A # '_x' will have been defined by assembly, while the C portion of 63711907SBrandon.Potter@amd.com # the code will be trying to use 'x' 63811907SBrandon.Potter@amd.com ret = context.TryLink(''' 63911907SBrandon.Potter@amd.com asm(".globl _x; _x: .byte 0"); 64011907SBrandon.Potter@amd.com extern int x; 64111907SBrandon.Potter@amd.com int main() { return x; } 64211907SBrandon.Potter@amd.com ''', extension=".c") 64311907SBrandon.Potter@amd.com context.env.Append(LEADING_UNDERSCORE=ret) 64411907SBrandon.Potter@amd.com context.Result(ret) 64511907SBrandon.Potter@amd.com return ret 64611907SBrandon.Potter@amd.com 64711907SBrandon.Potter@amd.com# Platform-specific configuration. Note again that we assume that all 64811907SBrandon.Potter@amd.com# builds under a given build root run on the same host platform. 64911907SBrandon.Potter@amd.comconf = Configure(main, 65011907SBrandon.Potter@amd.com conf_dir = joinpath(build_root, '.scons_config'), 651360SN/A log_file = joinpath(build_root, 'scons_config.log'), 65211907SBrandon.Potter@amd.com custom_tests = { 'CheckLeading' : CheckLeading }) 6531458SN/A 654360SN/A# Check for leading underscores. Don't really need to worry either 65511907SBrandon.Potter@amd.com# way so don't need to check the return code. 65611907SBrandon.Potter@amd.comconf.CheckLeading() 65711907SBrandon.Potter@amd.com 65811907SBrandon.Potter@amd.com# Check if we should compile a 64 bit binary on Mac OS X/Darwin 65911907SBrandon.Potter@amd.comtry: 66011907SBrandon.Potter@amd.com import platform 66111907SBrandon.Potter@amd.com uname = platform.uname() 66211907SBrandon.Potter@amd.com if uname[0] == 'Darwin' and compareVersions(uname[2], '9.0.0') >= 0: 66311907SBrandon.Potter@amd.com if int(readCommand('sysctl -n hw.cpu64bit_capable')[0]): 66411907SBrandon.Potter@amd.com main.Append(CCFLAGS=['-arch', 'x86_64']) 665360SN/A main.Append(CFLAGS=['-arch', 'x86_64']) 66611907SBrandon.Potter@amd.com main.Append(LINKFLAGS=['-arch', 'x86_64']) 66711907SBrandon.Potter@amd.com main.Append(ASFLAGS=['-arch', 'x86_64']) 66811907SBrandon.Potter@amd.comexcept: 669360SN/A pass 670360SN/A 67111907SBrandon.Potter@amd.com# Recent versions of scons substitute a "Null" object for Configure() 67211907SBrandon.Potter@amd.com# when configuration isn't necessary, e.g., if the "--help" option is 67311907SBrandon.Potter@amd.com# present. Unfortuantely this Null object always returns false, 67411907SBrandon.Potter@amd.com# breaking all our configuration checks. We replace it with our own 675360SN/A# more optimistic null object that returns True instead. 67611907SBrandon.Potter@amd.comif not conf: 677360SN/A def NullCheck(*args, **kwargs): 678360SN/A return True 67911907SBrandon.Potter@amd.com 6803669Sbinkertn@umich.edu class NullConf: 68111907SBrandon.Potter@amd.com def __init__(self, env): 68211907SBrandon.Potter@amd.com self.env = env 68311907SBrandon.Potter@amd.com def Finish(self): 68411907SBrandon.Potter@amd.com return self.env 68511907SBrandon.Potter@amd.com def __getattr__(self, mname): 68611907SBrandon.Potter@amd.com return NullCheck 68711907SBrandon.Potter@amd.com 68811907SBrandon.Potter@amd.com conf = NullConf(main) 68911907SBrandon.Potter@amd.com 69011907SBrandon.Potter@amd.com# Find Python include and library directories for embedding the 69111907SBrandon.Potter@amd.com# interpreter. For consistency, we will use the same Python 69211907SBrandon.Potter@amd.com# installation used to run scons (and thus this script). If you want 69311907SBrandon.Potter@amd.com# to link in an alternate version, see above for instructions on how 69411907SBrandon.Potter@amd.com# to invoke scons with a different copy of the Python interpreter. 69511907SBrandon.Potter@amd.comfrom distutils import sysconfig 69611907SBrandon.Potter@amd.com 69711907SBrandon.Potter@amd.compy_getvar = sysconfig.get_config_var 69811907SBrandon.Potter@amd.com 69911907SBrandon.Potter@amd.compy_debug = getattr(sys, 'pydebug', False) 70013371Sciro.santilli@arm.compy_version = 'python' + py_getvar('VERSION') + (py_debug and "_d" or "") 70111907SBrandon.Potter@amd.com 7021706SN/Apy_general_include = sysconfig.get_python_inc() 70311907SBrandon.Potter@amd.compy_platform_include = sysconfig.get_python_inc(plat_specific=True) 70411907SBrandon.Potter@amd.compy_includes = [ py_general_include ] 70511907SBrandon.Potter@amd.comif py_platform_include != py_general_include: 70611907SBrandon.Potter@amd.com py_includes.append(py_platform_include) 70711907SBrandon.Potter@amd.com 70811907SBrandon.Potter@amd.compy_lib_path = [ py_getvar('LIBDIR') ] 70910496Ssteve.reinhardt@amd.com# add the prefix/lib/pythonX.Y/config dir, but only if there is no 71010496Ssteve.reinhardt@amd.com# shared library in prefix/lib/. 71111907SBrandon.Potter@amd.comif not py_getvar('Py_ENABLE_SHARED'): 71211907SBrandon.Potter@amd.com py_lib_path.append(py_getvar('LIBPL')) 71311907SBrandon.Potter@amd.com 71411907SBrandon.Potter@amd.compy_libs = [] 71511907SBrandon.Potter@amd.comfor lib in py_getvar('LIBS').split() + py_getvar('SYSLIBS').split(): 71611907SBrandon.Potter@amd.com if not lib.startswith('-l'): 71710496Ssteve.reinhardt@amd.com # Python requires some special flags to link (e.g. -framework 71811907SBrandon.Potter@amd.com # common on OS X systems), assume appending preserves order 71911907SBrandon.Potter@amd.com main.Append(LINKFLAGS=[lib]) 72011907SBrandon.Potter@amd.com else: 72111907SBrandon.Potter@amd.com lib = lib[2:] 72210496Ssteve.reinhardt@amd.com if lib not in py_libs: 72310496Ssteve.reinhardt@amd.com py_libs.append(lib) 72411907SBrandon.Potter@amd.compy_libs.append(py_version) 72511907SBrandon.Potter@amd.com 72611907SBrandon.Potter@amd.commain.Append(CPPPATH=py_includes) 72711907SBrandon.Potter@amd.commain.Append(LIBPATH=py_lib_path) 72811907SBrandon.Potter@amd.com 72911907SBrandon.Potter@amd.com# Cache build files in the supplied directory. 73011907SBrandon.Potter@amd.comif main['M5_BUILD_CACHE']: 73111907SBrandon.Potter@amd.com print 'Using build cache located at', main['M5_BUILD_CACHE'] 73211907SBrandon.Potter@amd.com CacheDir(main['M5_BUILD_CACHE']) 73311907SBrandon.Potter@amd.com 73411907SBrandon.Potter@amd.com 73511907SBrandon.Potter@amd.com# verify that this stuff works 73611907SBrandon.Potter@amd.comif not conf.CheckHeader('Python.h', '<>'): 73711907SBrandon.Potter@amd.com print "Error: can't find Python.h header in", py_includes 73811907SBrandon.Potter@amd.com Exit(1) 73911907SBrandon.Potter@amd.com 74011907SBrandon.Potter@amd.comfor lib in py_libs: 74111907SBrandon.Potter@amd.com if not conf.CheckLib(lib): 74211907SBrandon.Potter@amd.com print "Error: can't find library %s required by python" % lib 74311907SBrandon.Potter@amd.com Exit(1) 74411907SBrandon.Potter@amd.com 74511907SBrandon.Potter@amd.com# On Solaris you need to use libsocket for socket ops 74611907SBrandon.Potter@amd.comif not conf.CheckLibWithHeader(None, 'sys/socket.h', 'C++', 'accept(0,0,0);'): 74711907SBrandon.Potter@amd.com if not conf.CheckLibWithHeader('socket', 'sys/socket.h', 'C++', 'accept(0,0,0);'): 74811907SBrandon.Potter@amd.com print "Can't find library with socket calls (e.g. accept())" 749360SN/A Exit(1) 75011907SBrandon.Potter@amd.com 75111907SBrandon.Potter@amd.com# Check for zlib. If the check passes, libz will be automatically 75211907SBrandon.Potter@amd.com# added to the LIBS environment variable. 75311907SBrandon.Potter@amd.comif not conf.CheckLibWithHeader('z', 'zlib.h', 'C++','zlibVersion();'): 75411907SBrandon.Potter@amd.com print 'Error: did not find needed zlib compression library '\ 75511907SBrandon.Potter@amd.com 'and/or zlib.h header file.' 75611907SBrandon.Potter@amd.com print ' Please install zlib and try again.' 75711907SBrandon.Potter@amd.com Exit(1) 75811907SBrandon.Potter@amd.com 75911907SBrandon.Potter@amd.com# Check for librt. 76011907SBrandon.Potter@amd.comhave_posix_clock = \ 76111907SBrandon.Potter@amd.com conf.CheckLibWithHeader(None, 'time.h', 'C', 76211907SBrandon.Potter@amd.com 'clock_nanosleep(0,0,NULL,NULL);') or \ 763360SN/A conf.CheckLibWithHeader('rt', 'time.h', 'C', 764360SN/A 'clock_nanosleep(0,0,NULL,NULL);') 76510027SChris.Adeniyi-Jones@arm.com 76610027SChris.Adeniyi-Jones@arm.comif conf.CheckLib('tcmalloc_minimal'): 76710027SChris.Adeniyi-Jones@arm.com have_tcmalloc = True 76811851Sbrandon.potter@amd.comelse: 76910027SChris.Adeniyi-Jones@arm.com have_tcmalloc = False 77010027SChris.Adeniyi-Jones@arm.com print termcap.Yellow + termcap.Bold + \ 77111907SBrandon.Potter@amd.com "You can get a 12% performance improvement by installing tcmalloc "\ 77210027SChris.Adeniyi-Jones@arm.com "(libgoogle-perftools-dev package on Ubuntu or RedHat)." + \ 77310027SChris.Adeniyi-Jones@arm.com termcap.Normal 77410027SChris.Adeniyi-Jones@arm.com 77510027SChris.Adeniyi-Jones@arm.comif not have_posix_clock: 77610027SChris.Adeniyi-Jones@arm.com print "Can't find library for POSIX clocks." 77711851Sbrandon.potter@amd.com 77811851Sbrandon.potter@amd.com# Check for <fenv.h> (C99 FP environment control) 77910027SChris.Adeniyi-Jones@arm.comhave_fenv = conf.CheckHeader('fenv.h', '<>') 78011907SBrandon.Potter@amd.comif not have_fenv: 78110027SChris.Adeniyi-Jones@arm.com print "Warning: Header file <fenv.h> not found." 78210027SChris.Adeniyi-Jones@arm.com print " This host has no IEEE FP rounding mode control." 78310633Smichaelupton@gmail.com 78410633Smichaelupton@gmail.com###################################################################### 78510633Smichaelupton@gmail.com# 78611851Sbrandon.potter@amd.com# Finish the configuration 78710633Smichaelupton@gmail.com# 78810633Smichaelupton@gmail.commain = conf.Finish() 78910633Smichaelupton@gmail.com 79010633Smichaelupton@gmail.com###################################################################### 79110633Smichaelupton@gmail.com# 79210633Smichaelupton@gmail.com# Collect all non-global variables 79310633Smichaelupton@gmail.com# 79410633Smichaelupton@gmail.com 79510633Smichaelupton@gmail.com# Define the universe of supported ISAs 79610633Smichaelupton@gmail.comall_isa_list = [ ] 79710203SAli.Saidi@ARM.comExport('all_isa_list') 79810203SAli.Saidi@ARM.com 79910203SAli.Saidi@ARM.comclass CpuModel(object): 80011851Sbrandon.potter@amd.com '''The CpuModel class encapsulates everything the ISA parser needs to 80111851Sbrandon.potter@amd.com know about a particular CPU model.''' 80210203SAli.Saidi@ARM.com 80310203SAli.Saidi@ARM.com # Dict of available CPU model objects. Accessible as CpuModel.dict. 80410203SAli.Saidi@ARM.com dict = {} 80510203SAli.Saidi@ARM.com list = [] 80610203SAli.Saidi@ARM.com defaults = [] 80710203SAli.Saidi@ARM.com 80810203SAli.Saidi@ARM.com # Constructor. Automatically adds models to CpuModel.dict. 80910203SAli.Saidi@ARM.com def __init__(self, name, filename, includes, strings, default=False): 81010203SAli.Saidi@ARM.com self.name = name # name of model 81110203SAli.Saidi@ARM.com self.filename = filename # filename for output exec code 81210203SAli.Saidi@ARM.com self.includes = includes # include files needed in exec file 81311851Sbrandon.potter@amd.com # The 'strings' dict holds all the per-CPU symbols we can 81411851Sbrandon.potter@amd.com # substitute into templates etc. 81510203SAli.Saidi@ARM.com self.strings = strings 81610203SAli.Saidi@ARM.com 81710203SAli.Saidi@ARM.com # This cpu is enabled by default 81810203SAli.Saidi@ARM.com self.default = default 81910203SAli.Saidi@ARM.com 82010203SAli.Saidi@ARM.com # Add self to dict 82110203SAli.Saidi@ARM.com if name in CpuModel.dict: 82210203SAli.Saidi@ARM.com raise AttributeError, "CpuModel '%s' already registered" % name 82310850SGiacomo.Gabrielli@arm.com CpuModel.dict[name] = self 82410850SGiacomo.Gabrielli@arm.com CpuModel.list.append(name) 82510850SGiacomo.Gabrielli@arm.com 82611851Sbrandon.potter@amd.comExport('CpuModel') 82710850SGiacomo.Gabrielli@arm.com 82810850SGiacomo.Gabrielli@arm.com# Sticky variables get saved in the variables file so they persist from 82910850SGiacomo.Gabrielli@arm.com# one invocation to the next (unless overridden, in which case the new 83010850SGiacomo.Gabrielli@arm.com# value becomes sticky). 83110850SGiacomo.Gabrielli@arm.comsticky_vars = Variables(args=ARGUMENTS) 83210850SGiacomo.Gabrielli@arm.comExport('sticky_vars') 83310850SGiacomo.Gabrielli@arm.com 83410850SGiacomo.Gabrielli@arm.com# Sticky variables that should be exported 83510850SGiacomo.Gabrielli@arm.comexport_vars = [] 83610850SGiacomo.Gabrielli@arm.comExport('export_vars') 83710850SGiacomo.Gabrielli@arm.com 83810850SGiacomo.Gabrielli@arm.com# Walk the tree and execute all SConsopts scripts that wil add to the 83910850SGiacomo.Gabrielli@arm.com# above variables 84010850SGiacomo.Gabrielli@arm.comif not GetOption('verbose'): 84110850SGiacomo.Gabrielli@arm.com print "Reading SConsopts" 84210850SGiacomo.Gabrielli@arm.comfor bdir in [ base_dir ] + extras_dir_list: 84310850SGiacomo.Gabrielli@arm.com if not isdir(bdir): 84410850SGiacomo.Gabrielli@arm.com print "Error: directory '%s' does not exist" % bdir 84510850SGiacomo.Gabrielli@arm.com Exit(1) 84610850SGiacomo.Gabrielli@arm.com for root, dirs, files in os.walk(bdir): 84710850SGiacomo.Gabrielli@arm.com if 'SConsopts' in files: 84810850SGiacomo.Gabrielli@arm.com if GetOption('verbose'): 84910850SGiacomo.Gabrielli@arm.com print "Reading", joinpath(root, 'SConsopts') 85010850SGiacomo.Gabrielli@arm.com SConscript(joinpath(root, 'SConsopts')) 85110850SGiacomo.Gabrielli@arm.com 85210850SGiacomo.Gabrielli@arm.comall_isa_list.sort() 85310850SGiacomo.Gabrielli@arm.com 85410850SGiacomo.Gabrielli@arm.comsticky_vars.AddVariables( 85510850SGiacomo.Gabrielli@arm.com EnumVariable('TARGET_ISA', 'Target ISA', 'alpha', all_isa_list), 85610850SGiacomo.Gabrielli@arm.com ListVariable('CPU_MODELS', 'CPU models', 85710850SGiacomo.Gabrielli@arm.com sorted(n for n,m in CpuModel.dict.iteritems() if m.default), 85810850SGiacomo.Gabrielli@arm.com sorted(CpuModel.list)), 8596640Svince@csl.cornell.edu BoolVariable('EFENCE', 'Link with Electric Fence malloc debugger', 8606640Svince@csl.cornell.edu False), 8616640Svince@csl.cornell.edu BoolVariable('SS_COMPATIBLE_FP', 86211851Sbrandon.potter@amd.com 'Make floating-point results compatible with SimpleScalar', 86311851Sbrandon.potter@amd.com False), 8646640Svince@csl.cornell.edu BoolVariable('USE_SSE2', 8656640Svince@csl.cornell.edu 'Compile for SSE2 (-msse2) to get IEEE FP on x86 hosts', 8666701Sgblack@eecs.umich.edu False), 8676701Sgblack@eecs.umich.edu BoolVariable('USE_POSIX_CLOCK', 'Use POSIX Clocks', have_posix_clock), 86810793Sbrandon.potter@amd.com BoolVariable('USE_FENV', 'Use <fenv.h> IEEE mode control', have_fenv), 8696640Svince@csl.cornell.edu BoolVariable('CP_ANNOTATE', 'Enable critical path annotation capability', False), 87011758Sbrandon.potter@amd.com ) 87111758Sbrandon.potter@amd.com 87211758Sbrandon.potter@amd.com# These variables get exported to #defines in config/*.hh (see src/SConscript). 8736640Svince@csl.cornell.eduexport_vars += ['USE_FENV', 'SS_COMPATIBLE_FP', 8748706Sandreas.hansson@arm.com 'TARGET_ISA', 'CP_ANNOTATE', 'USE_POSIX_CLOCK' ] 8756640Svince@csl.cornell.edu 8766701Sgblack@eecs.umich.edu################################################### 8776640Svince@csl.cornell.edu# 878360SN/A# Define a SCons builder for configuration flag headers. 8791999SN/A# 8801999SN/A################################################### 8811999SN/A 88211851Sbrandon.potter@amd.com# This function generates a config header file that #defines the 8832680Sktlim@umich.edu# variable symbol to the current variable setting (0 or 1). The source 8841999SN/A# operands are the name of the variable and a Value node containing the 8851999SN/A# value of the variable. 8861999SN/Adef build_config_file(target, source, env): 8876701Sgblack@eecs.umich.edu (variable, value) = [s.get_contents() for s in source] 8888852Sandreas.hansson@arm.com f = file(str(target[0]), 'w') 8896701Sgblack@eecs.umich.edu print >> f, '#define', variable, value 8901999SN/A f.close() 8916701Sgblack@eecs.umich.edu return None 8921999SN/A 8936701Sgblack@eecs.umich.edu# Combine the two functions into a scons Action object. 8941999SN/Aconfig_action = MakeAction(build_config_file, Transform("CONFIG H", 2)) 8951999SN/A 8961999SN/A# The emitter munges the source & target node lists to reflect what 8971999SN/A# we're really doing. 8981999SN/Adef config_emitter(target, source, env): 8993669Sbinkertn@umich.edu # extract variable name from Builder arg 9003669Sbinkertn@umich.edu variable = str(target[0]) 9013669Sbinkertn@umich.edu # True target is config header file 9021999SN/A target = joinpath('config', variable.lower() + '.hh') 9031999SN/A val = env[variable] 9041999SN/A if isinstance(val, bool): 9052218SN/A # Force value to 0/1 9061999SN/A val = int(val) 9071999SN/A elif isinstance(val, str): 9081999SN/A val = '"' + val + '"' 9091999SN/A 9101999SN/A # Sources are variable name & value (packaged in SCons Value nodes) 9111999SN/A return ([target], [Value(variable), Value(val)]) 9121999SN/A 9131999SN/Aconfig_builder = Builder(emitter = config_emitter, action = config_action) 91411856Sbrandon.potter@amd.com 9151999SN/Amain.Append(BUILDERS = { 'ConfigFile' : config_builder }) 9166701Sgblack@eecs.umich.edu 91711856Sbrandon.potter@amd.com# libelf build is shared across all configs in the build root. 91811856Sbrandon.potter@amd.commain.SConscript('ext/libelf/SConscript', 91910931Sbrandon.potter@amd.com variant_dir = joinpath(build_root, 'libelf')) 92011856Sbrandon.potter@amd.com 92111856Sbrandon.potter@amd.com# gzstream build is shared across all configs in the build root. 9221999SN/Amain.SConscript('ext/gzstream/SConscript', 92311856Sbrandon.potter@amd.com variant_dir = joinpath(build_root, 'gzstream')) 9241999SN/A 92511856Sbrandon.potter@amd.com################################################### 9261999SN/A# 92711856Sbrandon.potter@amd.com# This function is used to set up a directory with switching headers 9281999SN/A# 92911856Sbrandon.potter@amd.com################################################### 9301999SN/A 9311999SN/Amain['ALL_ISA_LIST'] = all_isa_list 9325877Shsul@eecs.umich.edudef make_switching_dir(dname, switch_headers, env): 9335877Shsul@eecs.umich.edu # Generate the header. target[0] is the full path of the output 9345877Shsul@eecs.umich.edu # header to generate. 'source' is a dummy variable, since we get the 93511851Sbrandon.potter@amd.com # list of ISAs from env['ALL_ISA_LIST']. 9365877Shsul@eecs.umich.edu def gen_switch_hdr(target, source, env): 9376701Sgblack@eecs.umich.edu fname = str(target[0]) 9386701Sgblack@eecs.umich.edu f = open(fname, 'w') 9396701Sgblack@eecs.umich.edu isa = env['TARGET_ISA'].lower() 9406701Sgblack@eecs.umich.edu print >>f, '#include "%s/%s/%s"' % (dname, isa, basename(fname)) 9416701Sgblack@eecs.umich.edu f.close() 94210027SChris.Adeniyi-Jones@arm.com 94310027SChris.Adeniyi-Jones@arm.com # Build SCons Action object. 'varlist' specifies env vars that this 94410027SChris.Adeniyi-Jones@arm.com # action depends on; when env['ALL_ISA_LIST'] changes these actions 94510027SChris.Adeniyi-Jones@arm.com # should get re-executed. 94610027SChris.Adeniyi-Jones@arm.com switch_hdr_action = MakeAction(gen_switch_hdr, 9475877Shsul@eecs.umich.edu Transform("GENERATE"), varlist=['ALL_ISA_LIST']) 94810318Sandreas.hansson@arm.com 94910318Sandreas.hansson@arm.com # Instantiate actions for each header 9505877Shsul@eecs.umich.edu for hdr in switch_headers: 9515877Shsul@eecs.umich.edu env.Command(hdr, [], switch_hdr_action) 9525877Shsul@eecs.umich.eduExport('make_switching_dir') 9535877Shsul@eecs.umich.edu 95410486Stjablin@gmail.com################################################### 95510486Stjablin@gmail.com# 9565877Shsul@eecs.umich.edu# Define build environments for selected configurations. 95711905SBrandon.Potter@amd.com# 95811905SBrandon.Potter@amd.com################################################### 95911905SBrandon.Potter@amd.com 96011905SBrandon.Potter@amd.comfor variant_path in variant_paths: 96110027SChris.Adeniyi-Jones@arm.com print "Building in", variant_path 96212206Srico.amslinger@informatik.uni-augsburg.de 96312206Srico.amslinger@informatik.uni-augsburg.de # Make a copy of the build-root environment to use for this config. 9645877Shsul@eecs.umich.edu env = main.Clone() 96511905SBrandon.Potter@amd.com env['BUILDDIR'] = variant_path 96611905SBrandon.Potter@amd.com 9675877Shsul@eecs.umich.edu # variant_dir is the tail component of build path, and is used to 9685877Shsul@eecs.umich.edu # determine the build parameters (e.g., 'ALPHA_SE') 96910027SChris.Adeniyi-Jones@arm.com (build_root, variant_dir) = splitpath(variant_path) 9705877Shsul@eecs.umich.edu 9715877Shsul@eecs.umich.edu # Set env variables according to the build directory config. 9725877Shsul@eecs.umich.edu sticky_vars.files = [] 97312206Srico.amslinger@informatik.uni-augsburg.de # Variables for $BUILD_ROOT/$VARIANT_DIR are stored in 97412206Srico.amslinger@informatik.uni-augsburg.de # $BUILD_ROOT/variables/$VARIANT_DIR so you can nuke 97512206Srico.amslinger@informatik.uni-augsburg.de # $BUILD_ROOT/$VARIANT_DIR without losing your variables settings. 97612206Srico.amslinger@informatik.uni-augsburg.de current_vars_file = joinpath(build_root, 'variables', variant_dir) 97712206Srico.amslinger@informatik.uni-augsburg.de if isfile(current_vars_file): 97812206Srico.amslinger@informatik.uni-augsburg.de sticky_vars.files.append(current_vars_file) 97912206Srico.amslinger@informatik.uni-augsburg.de print "Using saved variables file %s" % current_vars_file 98012206Srico.amslinger@informatik.uni-augsburg.de else: 98112206Srico.amslinger@informatik.uni-augsburg.de # Build dir-specific variables file doesn't exist. 98210027SChris.Adeniyi-Jones@arm.com 98310027SChris.Adeniyi-Jones@arm.com # Make sure the directory is there so we can create it later 98410027SChris.Adeniyi-Jones@arm.com opt_dir = dirname(current_vars_file) 98510027SChris.Adeniyi-Jones@arm.com if not isdir(opt_dir): 9865877Shsul@eecs.umich.edu mkdir(opt_dir) 98710027SChris.Adeniyi-Jones@arm.com 98810027SChris.Adeniyi-Jones@arm.com # Get default build variables from source tree. Variables are 98910027SChris.Adeniyi-Jones@arm.com # normally determined by name of $VARIANT_DIR, but can be 99010027SChris.Adeniyi-Jones@arm.com # overridden by '--default=' arg on command line. 99112206Srico.amslinger@informatik.uni-augsburg.de default = GetOption('default') 99212206Srico.amslinger@informatik.uni-augsburg.de opts_dir = joinpath(main.root.abspath, 'build_opts') 99312206Srico.amslinger@informatik.uni-augsburg.de if default: 99412206Srico.amslinger@informatik.uni-augsburg.de default_vars_files = [joinpath(build_root, 'variables', default), 99510027SChris.Adeniyi-Jones@arm.com joinpath(opts_dir, default)] 99610027SChris.Adeniyi-Jones@arm.com else: 99710027SChris.Adeniyi-Jones@arm.com default_vars_files = [joinpath(opts_dir, variant_dir)] 99810027SChris.Adeniyi-Jones@arm.com existing_files = filter(isfile, default_vars_files) 99910027SChris.Adeniyi-Jones@arm.com if existing_files: 100010027SChris.Adeniyi-Jones@arm.com default_vars_file = existing_files[0] 10015877Shsul@eecs.umich.edu sticky_vars.files.append(default_vars_file) 10025877Shsul@eecs.umich.edu print "Variables file %s not found,\n using defaults in %s" \ 10035877Shsul@eecs.umich.edu % (current_vars_file, default_vars_file) 100410027SChris.Adeniyi-Jones@arm.com else: 100510027SChris.Adeniyi-Jones@arm.com print "Error: cannot find variables file %s or " \ 10068601Ssteve.reinhardt@amd.com "default file(s) %s" \ 100710027SChris.Adeniyi-Jones@arm.com % (current_vars_file, ' or '.join(default_vars_files)) 10085877Shsul@eecs.umich.edu Exit(1) 10095877Shsul@eecs.umich.edu 10101999SN/A # Apply current variable settings to env 1011378SN/A sticky_vars.Update(env) 1012360SN/A 10131450SN/A help_texts["local_vars"] += \ 101411851Sbrandon.potter@amd.com "Build variables for %s:\n" % variant_dir \ 10152680Sktlim@umich.edu + sticky_vars.GenerateHelpText(env) 1016360SN/A 1017360SN/A # Process variable settings. 1018360SN/A 10196701Sgblack@eecs.umich.edu if not have_fenv and env['USE_FENV']: 10208852Sandreas.hansson@arm.com print "Warning: <fenv.h> not available; " \ 10216701Sgblack@eecs.umich.edu "forcing USE_FENV to False in", variant_dir + "." 10226701Sgblack@eecs.umich.edu env['USE_FENV'] = False 10236701Sgblack@eecs.umich.edu 10246701Sgblack@eecs.umich.edu if not env['USE_FENV']: 1025360SN/A print "Warning: No IEEE FP rounding mode control in", variant_dir + "." 10263669Sbinkertn@umich.edu print " FP results may deviate slightly from other platforms." 10273669Sbinkertn@umich.edu 10283669Sbinkertn@umich.edu if env['EFENCE']: 1029360SN/A env.Append(LIBS=['efence']) 1030360SN/A 1031360SN/A # Save sticky variable settings back to current variables file 1032360SN/A sticky_vars.Save(current_vars_file, env) 10332218SN/A 1034360SN/A if env['USE_SSE2']: 10358706Sandreas.hansson@arm.com env.Append(CCFLAGS=['-msse2']) 1036360SN/A 10371458SN/A if have_tcmalloc: 1038360SN/A env.Append(LIBS=['tcmalloc_minimal']) 1039360SN/A 1040360SN/A # The src/SConscript file sets up the build rules in 'env' according 10415074Ssaidi@eecs.umich.edu # to the configured variables. It returns a list of environments, 10425074Ssaidi@eecs.umich.edu # one for each variant build (debug, opt, etc.) 10435074Ssaidi@eecs.umich.edu envList = SConscript('src/SConscript', variant_dir = variant_path, 104411851Sbrandon.potter@amd.com exports = 'env') 10455074Ssaidi@eecs.umich.edu 10465074Ssaidi@eecs.umich.edu # Set up the regression tests for each build. 10475074Ssaidi@eecs.umich.edu for e in envList: 10485074Ssaidi@eecs.umich.edu SConscript('tests/SConscript', 10496701Sgblack@eecs.umich.edu variant_dir = joinpath(variant_path, 'tests', e.Label), 10508852Sandreas.hansson@arm.com exports = { 'env' : e }, duplicate = False) 10516701Sgblack@eecs.umich.edu 10525074Ssaidi@eecs.umich.edu# base help text 10536701Sgblack@eecs.umich.eduHelp(''' 10545074Ssaidi@eecs.umich.eduUsage: scons [scons options] [build variables] [target(s)] 10555074Ssaidi@eecs.umich.edu 10565074Ssaidi@eecs.umich.eduExtra scons options: 10575074Ssaidi@eecs.umich.edu%(options)s 10585208Ssaidi@eecs.umich.edu 10595208Ssaidi@eecs.umich.eduGlobal build variables: 10605208Ssaidi@eecs.umich.edu%(global_vars)s 10615208Ssaidi@eecs.umich.edu 10625074Ssaidi@eecs.umich.edu%(local_vars)s 10635074Ssaidi@eecs.umich.edu''' % help_texts) 10645208Ssaidi@eecs.umich.edu