SConstruct revision 4973
1955SN/A# -*- mode:python -*- 2955SN/A 37816Ssteve.reinhardt@amd.com# Copyright (c) 2004-2005 The Regents of The University of Michigan 45871Snate@binkert.org# All rights reserved. 51762SN/A# 6955SN/A# Redistribution and use in source and binary forms, with or without 7955SN/A# modification, are permitted provided that the following conditions are 8955SN/A# met: redistributions of source code must retain the above copyright 9955SN/A# notice, this list of conditions and the following disclaimer; 10955SN/A# redistributions in binary form must reproduce the above copyright 11955SN/A# notice, this list of conditions and the following disclaimer in the 12955SN/A# documentation and/or other materials provided with the distribution; 13955SN/A# neither the name of the copyright holders nor the names of its 14955SN/A# contributors may be used to endorse or promote products derived from 15955SN/A# this software without specific prior written permission. 16955SN/A# 17955SN/A# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18955SN/A# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19955SN/A# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20955SN/A# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21955SN/A# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22955SN/A# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23955SN/A# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24955SN/A# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25955SN/A# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26955SN/A# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27955SN/A# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28955SN/A# 29955SN/A# Authors: Steve Reinhardt 302665Ssaidi@eecs.umich.edu 312665Ssaidi@eecs.umich.edu################################################### 325863Snate@binkert.org# 33955SN/A# SCons top-level build description (SConstruct) file. 34955SN/A# 35955SN/A# While in this directory ('m5'), just type 'scons' to build the default 36955SN/A# configuration (see below), or type 'scons build/<CONFIG>/<binary>' 37955SN/A# to build some other configuration (e.g., 'build/ALPHA_FS/m5.opt' for 388878Ssteve.reinhardt@amd.com# the optimized full-system version). 392632Sstever@eecs.umich.edu# 408878Ssteve.reinhardt@amd.com# You can build M5 in a different directory as long as there is a 412632Sstever@eecs.umich.edu# 'build/<CONFIG>' somewhere along the target path. The build system 42955SN/A# expects that all configs under the same build directory are being 438878Ssteve.reinhardt@amd.com# built for the same host system. 442632Sstever@eecs.umich.edu# 452761Sstever@eecs.umich.edu# Examples: 462632Sstever@eecs.umich.edu# 472632Sstever@eecs.umich.edu# The following two commands are equivalent. The '-u' option tells 482632Sstever@eecs.umich.edu# scons to search up the directory tree for this SConstruct file. 492761Sstever@eecs.umich.edu# % cd <path-to-src>/m5 ; scons build/ALPHA_FS/m5.debug 502761Sstever@eecs.umich.edu# % cd <path-to-src>/m5/build/ALPHA_FS; scons -u m5.debug 512761Sstever@eecs.umich.edu# 528878Ssteve.reinhardt@amd.com# The following two commands are equivalent and demonstrate building 538878Ssteve.reinhardt@amd.com# in a directory outside of the source tree. The '-C' option tells 542761Sstever@eecs.umich.edu# scons to chdir to the specified directory to find this SConstruct 552761Sstever@eecs.umich.edu# file. 562761Sstever@eecs.umich.edu# % cd <path-to-src>/m5 ; scons /local/foo/build/ALPHA_FS/m5.debug 572761Sstever@eecs.umich.edu# % cd /local/foo/build/ALPHA_FS; scons -C <path-to-src>/m5 m5.debug 582761Sstever@eecs.umich.edu# 598878Ssteve.reinhardt@amd.com# You can use 'scons -H' to print scons options. If you're in this 608878Ssteve.reinhardt@amd.com# 'm5' directory (or use -u or -C to tell scons where to find this 612632Sstever@eecs.umich.edu# file), you can use 'scons -h' to print all the M5-specific build 622632Sstever@eecs.umich.edu# options as well. 638878Ssteve.reinhardt@amd.com# 648878Ssteve.reinhardt@amd.com################################################### 652632Sstever@eecs.umich.edu 66955SN/Aimport sys 67955SN/Aimport os 68955SN/Aimport subprocess 695863Snate@binkert.org 705863Snate@binkert.orgfrom os.path import isdir, join as joinpath 715863Snate@binkert.org 725863Snate@binkert.org# Check for recent-enough Python and SCons versions. If your system's 735863Snate@binkert.org# default installation of Python is not recent enough, you can use a 745863Snate@binkert.org# non-default installation of the Python interpreter by either (1) 755863Snate@binkert.org# rearranging your PATH so that scons finds the non-default 'python' 765863Snate@binkert.org# first or (2) explicitly invoking an alternative interpreter on the 775863Snate@binkert.org# scons script, e.g., "/usr/local/bin/python2.4 `which scons` [args]". 785863Snate@binkert.orgEnsurePythonVersion(2,4) 795863Snate@binkert.org 808878Ssteve.reinhardt@amd.com# Ironically, SCons 0.96 dies if you give EnsureSconsVersion a 815863Snate@binkert.org# 3-element version number. 825863Snate@binkert.orgmin_scons_version = (0,96,91) 835863Snate@binkert.orgtry: 845863Snate@binkert.org EnsureSConsVersion(*min_scons_version) 855863Snate@binkert.orgexcept: 865863Snate@binkert.org print "Error checking current SCons version." 875863Snate@binkert.org print "SCons", ".".join(map(str,min_scons_version)), "or greater required." 885863Snate@binkert.org Exit(2) 895863Snate@binkert.org 905863Snate@binkert.org 915863Snate@binkert.org# The absolute path to the current directory (where this file lives). 925863Snate@binkert.orgROOT = Dir('.').abspath 935863Snate@binkert.org 945863Snate@binkert.org# Path to the M5 source tree. 955863Snate@binkert.orgSRCDIR = joinpath(ROOT, 'src') 968878Ssteve.reinhardt@amd.com 975863Snate@binkert.org# tell python where to find m5 python code 985863Snate@binkert.orgsys.path.append(joinpath(ROOT, 'src/python')) 995863Snate@binkert.org 1006654Snate@binkert.orgdef check_style_hook(ui): 101955SN/A ui.readconfig(joinpath(ROOT, '.hg', 'hgrc')) 1025396Ssaidi@eecs.umich.edu style_hook = ui.config('hooks', 'pretxncommit.style', None) 1035863Snate@binkert.org 1045863Snate@binkert.org if not style_hook: 1054202Sbinkertn@umich.edu print """\ 1065863Snate@binkert.orgYou're missing the M5 style hook. 1075863Snate@binkert.orgPlease install the hook so we can ensure that all code fits a common style. 1085863Snate@binkert.org 1095863Snate@binkert.orgAll you'd need to do is add the following lines to your repository .hg/hgrc 110955SN/Aor your personal .hgrc 1116654Snate@binkert.org---------------- 1125273Sstever@gmail.com 1135871Snate@binkert.org[extensions] 1145273Sstever@gmail.comstyle = %s/util/style.py 1156655Snate@binkert.org 1168878Ssteve.reinhardt@amd.com[hooks] 1176655Snate@binkert.orgpretxncommit.style = python:style.check_whitespace 1186655Snate@binkert.org""" % (ROOT) 1199219Spower.jg@gmail.com sys.exit(1) 1206655Snate@binkert.org 1215871Snate@binkert.orgif ARGUMENTS.get('IGNORE_STYLE') != 'True' and isdir(joinpath(ROOT, '.hg')): 1226654Snate@binkert.org try: 1238947Sandreas.hansson@arm.com from mercurial import ui 1245396Ssaidi@eecs.umich.edu check_style_hook(ui.ui()) 1258120Sgblack@eecs.umich.edu except ImportError: 1268120Sgblack@eecs.umich.edu pass 1278120Sgblack@eecs.umich.edu 1288120Sgblack@eecs.umich.edu################################################### 1298120Sgblack@eecs.umich.edu# 1308120Sgblack@eecs.umich.edu# Figure out which configurations to set up based on the path(s) of 1318120Sgblack@eecs.umich.edu# the target(s). 1328120Sgblack@eecs.umich.edu# 1338879Ssteve.reinhardt@amd.com################################################### 1348879Ssteve.reinhardt@amd.com 1358879Ssteve.reinhardt@amd.com# Find default configuration & binary. 1368879Ssteve.reinhardt@amd.comDefault(os.environ.get('M5_DEFAULT_BINARY', 'build/ALPHA_SE/m5.debug')) 1378879Ssteve.reinhardt@amd.com 1388879Ssteve.reinhardt@amd.com# helper function: find last occurrence of element in list 1398879Ssteve.reinhardt@amd.comdef rfind(l, elt, offs = -1): 1408879Ssteve.reinhardt@amd.com for i in range(len(l)+offs, 0, -1): 1418879Ssteve.reinhardt@amd.com if l[i] == elt: 1428879Ssteve.reinhardt@amd.com return i 1438879Ssteve.reinhardt@amd.com raise ValueError, "element not found" 1448879Ssteve.reinhardt@amd.com 1458879Ssteve.reinhardt@amd.com# helper function: compare dotted version numbers. 1468120Sgblack@eecs.umich.edu# E.g., compare_version('1.3.25', '1.4.1') 1478120Sgblack@eecs.umich.edu# returns -1, 0, 1 if v1 is <, ==, > v2 1488120Sgblack@eecs.umich.edudef compare_versions(v1, v2): 1498120Sgblack@eecs.umich.edu # Convert dotted strings to lists 1508120Sgblack@eecs.umich.edu v1 = map(int, v1.split('.')) 1518120Sgblack@eecs.umich.edu v2 = map(int, v2.split('.')) 1528120Sgblack@eecs.umich.edu # Compare corresponding elements of lists 1538120Sgblack@eecs.umich.edu for n1,n2 in zip(v1, v2): 1548120Sgblack@eecs.umich.edu if n1 < n2: return -1 1558120Sgblack@eecs.umich.edu if n1 > n2: return 1 1568120Sgblack@eecs.umich.edu # all corresponding values are equal... see if one has extra values 1578120Sgblack@eecs.umich.edu if len(v1) < len(v2): return -1 1588120Sgblack@eecs.umich.edu if len(v1) > len(v2): return 1 1598120Sgblack@eecs.umich.edu return 0 1608879Ssteve.reinhardt@amd.com 1618879Ssteve.reinhardt@amd.com# Each target must have 'build' in the interior of the path; the 1628879Ssteve.reinhardt@amd.com# directory below this will determine the build parameters. For 1638879Ssteve.reinhardt@amd.com# example, for target 'foo/bar/build/ALPHA_SE/arch/alpha/blah.do' we 1648879Ssteve.reinhardt@amd.com# recognize that ALPHA_SE specifies the configuration because it 1658879Ssteve.reinhardt@amd.com# follow 'build' in the bulid path. 1668879Ssteve.reinhardt@amd.com 1678879Ssteve.reinhardt@amd.com# Generate absolute paths to targets so we can see where the build dir is 1689227Sandreas.hansson@arm.comif COMMAND_LINE_TARGETS: 1699227Sandreas.hansson@arm.com # Ask SCons which directory it was invoked from 1708879Ssteve.reinhardt@amd.com launch_dir = GetLaunchDir() 1718879Ssteve.reinhardt@amd.com # Make targets relative to invocation directory 1728879Ssteve.reinhardt@amd.com abs_targets = map(lambda x: os.path.normpath(joinpath(launch_dir, str(x))), 1738879Ssteve.reinhardt@amd.com COMMAND_LINE_TARGETS) 1748120Sgblack@eecs.umich.eduelse: 1758947Sandreas.hansson@arm.com # Default targets are relative to root of tree 1767816Ssteve.reinhardt@amd.com abs_targets = map(lambda x: os.path.normpath(joinpath(ROOT, str(x))), 1775871Snate@binkert.org DEFAULT_TARGETS) 1785871Snate@binkert.org 1796121Snate@binkert.org 1805871Snate@binkert.org# Generate a list of the unique build roots and configs that the 1815871Snate@binkert.org# collected targets reference. 1829119Sandreas.hansson@arm.combuild_paths = [] 1839396Sandreas.hansson@arm.combuild_root = None 1849396Sandreas.hansson@arm.comfor t in abs_targets: 185955SN/A path_dirs = t.split('/') 1869416SAndreas.Sandberg@ARM.com try: 1879416SAndreas.Sandberg@ARM.com build_top = rfind(path_dirs, 'build', -2) 1889416SAndreas.Sandberg@ARM.com except: 1899416SAndreas.Sandberg@ARM.com print "Error: no non-leaf 'build' dir found on target path", t 1909416SAndreas.Sandberg@ARM.com Exit(1) 1919416SAndreas.Sandberg@ARM.com this_build_root = joinpath('/',*path_dirs[:build_top+1]) 1929416SAndreas.Sandberg@ARM.com if not build_root: 1935871Snate@binkert.org build_root = this_build_root 1945871Snate@binkert.org else: 1959416SAndreas.Sandberg@ARM.com if this_build_root != build_root: 1969416SAndreas.Sandberg@ARM.com print "Error: build targets not under same build root\n"\ 1975871Snate@binkert.org " %s\n %s" % (build_root, this_build_root) 198955SN/A Exit(1) 1996121Snate@binkert.org build_path = joinpath('/',*path_dirs[:build_top+2]) 2008881Smarc.orr@gmail.com if build_path not in build_paths: 2016121Snate@binkert.org build_paths.append(build_path) 2026121Snate@binkert.org 2031533SN/A################################################### 2049239Sandreas.hansson@arm.com# 2059239Sandreas.hansson@arm.com# Set up the default build environment. This environment is copied 2069239Sandreas.hansson@arm.com# and modified according to each selected configuration. 2079239Sandreas.hansson@arm.com# 2089239Sandreas.hansson@arm.com################################################### 2099239Sandreas.hansson@arm.com 2109239Sandreas.hansson@arm.comenv = Environment(ENV = os.environ, # inherit user's environment vars 2119239Sandreas.hansson@arm.com ROOT = ROOT, 2129239Sandreas.hansson@arm.com SRCDIR = SRCDIR) 2139239Sandreas.hansson@arm.com 2149239Sandreas.hansson@arm.com#Parse CC/CXX early so that we use the correct compiler for 2159239Sandreas.hansson@arm.com# to test for dependencies/versions/libraries/includes 2166655Snate@binkert.orgif ARGUMENTS.get('CC', None): 2176655Snate@binkert.org env['CC'] = ARGUMENTS.get('CC') 2186655Snate@binkert.org 2196655Snate@binkert.orgif ARGUMENTS.get('CXX', None): 2205871Snate@binkert.org env['CXX'] = ARGUMENTS.get('CXX') 2215871Snate@binkert.org 2225863Snate@binkert.orgExport('env') 2235871Snate@binkert.org 2248878Ssteve.reinhardt@amd.comenv.SConsignFile(joinpath(build_root,"sconsign")) 2255871Snate@binkert.org 2265871Snate@binkert.org# Default duplicate option is to use hard links, but this messes up 2275871Snate@binkert.org# when you use emacs to edit a file in the target dir, as emacs moves 2285863Snate@binkert.org# file to file~ then copies to file, breaking the link. Symbolic 2296121Snate@binkert.org# (soft) links work better. 2305863Snate@binkert.orgenv.SetOption('duplicate', 'soft-copy') 2315871Snate@binkert.org 2328336Ssteve.reinhardt@amd.com# I waffle on this setting... it does avoid a few painful but 2338336Ssteve.reinhardt@amd.com# unnecessary builds, but it also seems to make trivial builds take 2348336Ssteve.reinhardt@amd.com# noticeably longer. 2358336Ssteve.reinhardt@amd.comif False: 2364678Snate@binkert.org env.TargetSignatures('content') 2378336Ssteve.reinhardt@amd.com 2388336Ssteve.reinhardt@amd.com# M5_PLY is used by isa_parser.py to find the PLY package. 2398336Ssteve.reinhardt@amd.comenv.Append(ENV = { 'M5_PLY' : Dir('ext/ply') }) 2404678Snate@binkert.orgenv['GCC'] = False 2414678Snate@binkert.orgenv['SUNCC'] = False 2424678Snate@binkert.orgenv['ICC'] = False 2434678Snate@binkert.orgenv['GCC'] = subprocess.Popen(env['CXX'] + ' --version', shell=True, 2447827Snate@binkert.org stdout=subprocess.PIPE, stderr=subprocess.STDOUT, 2457827Snate@binkert.org close_fds=True).communicate()[0].find('GCC') >= 0 2468336Ssteve.reinhardt@amd.comenv['SUNCC'] = subprocess.Popen(env['CXX'] + ' -V', shell=True, 2474678Snate@binkert.org stdout=subprocess.PIPE, stderr=subprocess.STDOUT, 2488336Ssteve.reinhardt@amd.com close_fds=True).communicate()[0].find('Sun C++') >= 0 2498336Ssteve.reinhardt@amd.comenv['ICC'] = subprocess.Popen(env['CXX'] + ' -V', shell=True, 2508336Ssteve.reinhardt@amd.com stdout=subprocess.PIPE, stderr=subprocess.STDOUT, 2518336Ssteve.reinhardt@amd.com close_fds=True).communicate()[0].find('Intel') >= 0 2528336Ssteve.reinhardt@amd.comif env['GCC'] + env['SUNCC'] + env['ICC'] > 1: 2538336Ssteve.reinhardt@amd.com print 'Error: How can we have two at the same time?' 2545871Snate@binkert.org Exit(1) 2555871Snate@binkert.org 2568336Ssteve.reinhardt@amd.com 2578336Ssteve.reinhardt@amd.com# Set up default C++ compiler flags 2588336Ssteve.reinhardt@amd.comif env['GCC']: 2598336Ssteve.reinhardt@amd.com env.Append(CCFLAGS='-pipe') 2608336Ssteve.reinhardt@amd.com env.Append(CCFLAGS='-fno-strict-aliasing') 2615871Snate@binkert.org env.Append(CCFLAGS=Split('-Wall -Wno-sign-compare -Werror -Wundef')) 2628336Ssteve.reinhardt@amd.comelif env['ICC']: 2638336Ssteve.reinhardt@amd.com pass #Fix me... add warning flags once we clean up icc warnings 2648336Ssteve.reinhardt@amd.comelif env['SUNCC']: 2658336Ssteve.reinhardt@amd.com env.Append(CCFLAGS='-Qoption ccfe') 2668336Ssteve.reinhardt@amd.com env.Append(CCFLAGS='-features=gcc') 2674678Snate@binkert.org env.Append(CCFLAGS='-features=extensions') 2685871Snate@binkert.org env.Append(CCFLAGS='-library=stlport4') 2694678Snate@binkert.org env.Append(CCFLAGS='-xar') 2708336Ssteve.reinhardt@amd.com# env.Append(CCFLAGS='-instances=semiexplicit') 2718336Ssteve.reinhardt@amd.comelse: 2728336Ssteve.reinhardt@amd.com print 'Error: Don\'t know what compiler options to use for your compiler.' 2738336Ssteve.reinhardt@amd.com print ' Please fix SConstruct and src/SConscript and try again.' 2748336Ssteve.reinhardt@amd.com Exit(1) 2758336Ssteve.reinhardt@amd.com 2768336Ssteve.reinhardt@amd.comif sys.platform == 'cygwin': 2778336Ssteve.reinhardt@amd.com # cygwin has some header file issues... 2788336Ssteve.reinhardt@amd.com env.Append(CCFLAGS=Split("-Wno-uninitialized")) 2798336Ssteve.reinhardt@amd.comenv.Append(CPPPATH=[Dir('ext/dnet')]) 2808336Ssteve.reinhardt@amd.com 2818336Ssteve.reinhardt@amd.com# Check for SWIG 2828336Ssteve.reinhardt@amd.comif not env.has_key('SWIG'): 2838336Ssteve.reinhardt@amd.com print 'Error: SWIG utility not found.' 2848336Ssteve.reinhardt@amd.com print ' Please install (see http://www.swig.org) and retry.' 2858336Ssteve.reinhardt@amd.com Exit(1) 2868336Ssteve.reinhardt@amd.com 2875871Snate@binkert.org# Check for appropriate SWIG version 2886121Snate@binkert.orgswig_version = os.popen('swig -version').read().split() 289955SN/A# First 3 words should be "SWIG Version x.y.z" 290955SN/Aif len(swig_version) < 3 or \ 2912632Sstever@eecs.umich.edu swig_version[0] != 'SWIG' or swig_version[1] != 'Version': 2922632Sstever@eecs.umich.edu print 'Error determining SWIG version.' 293955SN/A Exit(1) 294955SN/A 295955SN/Amin_swig_version = '1.3.28' 296955SN/Aif compare_versions(swig_version[2], min_swig_version) < 0: 2978878Ssteve.reinhardt@amd.com print 'Error: SWIG version', min_swig_version, 'or newer required.' 298955SN/A print ' Installed version:', swig_version[2] 2992632Sstever@eecs.umich.edu Exit(1) 3002632Sstever@eecs.umich.edu 3012632Sstever@eecs.umich.edu# Set up SWIG flags & scanner 3022632Sstever@eecs.umich.eduswig_flags=Split('-c++ -python -modern -templatereduce $_CPPINCFLAGS') 3032632Sstever@eecs.umich.eduenv.Append(SWIGFLAGS=swig_flags) 3042632Sstever@eecs.umich.edu 3052632Sstever@eecs.umich.edu# filter out all existing swig scanners, they mess up the dependency 3068268Ssteve.reinhardt@amd.com# stuff for some reason 3078268Ssteve.reinhardt@amd.comscanners = [] 3088268Ssteve.reinhardt@amd.comfor scanner in env['SCANNERS']: 3098268Ssteve.reinhardt@amd.com skeys = scanner.skeys 3108268Ssteve.reinhardt@amd.com if skeys == '.i': 3118268Ssteve.reinhardt@amd.com continue 3128268Ssteve.reinhardt@amd.com 3132632Sstever@eecs.umich.edu if isinstance(skeys, (list, tuple)) and '.i' in skeys: 3142632Sstever@eecs.umich.edu continue 3152632Sstever@eecs.umich.edu 3162632Sstever@eecs.umich.edu scanners.append(scanner) 3178268Ssteve.reinhardt@amd.com 3182632Sstever@eecs.umich.edu# add the new swig scanner that we like better 3198268Ssteve.reinhardt@amd.comfrom SCons.Scanner import ClassicCPP as CPPScanner 3208268Ssteve.reinhardt@amd.comswig_inc_re = '^[ \t]*[%,#][ \t]*(?:include|import)[ \t]*(<|")([^>"]+)(>|")' 3218268Ssteve.reinhardt@amd.comscanners.append(CPPScanner("SwigScan", [ ".i" ], "CPPPATH", swig_inc_re)) 3228268Ssteve.reinhardt@amd.com 3233718Sstever@eecs.umich.edu# replace the scanners list that has what we want 3242634Sstever@eecs.umich.eduenv['SCANNERS'] = scanners 3252634Sstever@eecs.umich.edu 3265863Snate@binkert.org# Platform-specific configuration. Note again that we assume that all 3272638Sstever@eecs.umich.edu# builds under a given build root run on the same host platform. 3288268Ssteve.reinhardt@amd.comconf = Configure(env, 3292632Sstever@eecs.umich.edu conf_dir = joinpath(build_root, '.scons_config'), 3302632Sstever@eecs.umich.edu log_file = joinpath(build_root, 'scons_config.log')) 3312632Sstever@eecs.umich.edu 3322632Sstever@eecs.umich.edu# Find Python include and library directories for embedding the 3332632Sstever@eecs.umich.edu# interpreter. For consistency, we will use the same Python 3341858SN/A# installation used to run scons (and thus this script). If you want 3353716Sstever@eecs.umich.edu# to link in an alternate version, see above for instructions on how 3362638Sstever@eecs.umich.edu# to invoke scons with a different copy of the Python interpreter. 3372638Sstever@eecs.umich.edu 3382638Sstever@eecs.umich.edu# Get brief Python version name (e.g., "python2.4") for locating 3392638Sstever@eecs.umich.edu# include & library files 3402638Sstever@eecs.umich.edupy_version_name = 'python' + sys.version[:3] 3412638Sstever@eecs.umich.edu 3422638Sstever@eecs.umich.edu# include path, e.g. /usr/local/include/python2.4 3435863Snate@binkert.orgpy_header_path = joinpath(sys.exec_prefix, 'include', py_version_name) 3445863Snate@binkert.orgenv.Append(CPPPATH = py_header_path) 3455863Snate@binkert.org# verify that it works 346955SN/Aif not conf.CheckHeader('Python.h', '<>'): 3475341Sstever@gmail.com print "Error: can't find Python.h header in", py_header_path 3485341Sstever@gmail.com Exit(1) 3495863Snate@binkert.org 3507756SAli.Saidi@ARM.com# add library path too if it's not in the default place 3515341Sstever@gmail.compy_lib_path = None 3526121Snate@binkert.orgif sys.exec_prefix != '/usr': 3534494Ssaidi@eecs.umich.edu py_lib_path = joinpath(sys.exec_prefix, 'lib') 3546121Snate@binkert.orgelif sys.platform == 'cygwin': 3551105SN/A # cygwin puts the .dll in /bin for some reason 3562667Sstever@eecs.umich.edu py_lib_path = '/bin' 3572667Sstever@eecs.umich.eduif py_lib_path: 3582667Sstever@eecs.umich.edu env.Append(LIBPATH = py_lib_path) 3592667Sstever@eecs.umich.edu print 'Adding', py_lib_path, 'to LIBPATH for', py_version_name 3606121Snate@binkert.orgif not conf.CheckLib(py_version_name): 3612667Sstever@eecs.umich.edu print "Error: can't find Python library", py_version_name 3625341Sstever@gmail.com Exit(1) 3635863Snate@binkert.org 3645341Sstever@gmail.com# On Solaris you need to use libsocket for socket ops 3655341Sstever@gmail.comif not conf.CheckLibWithHeader(None, 'sys/socket.h', 'C++', 'accept(0,0,0);'): 3665341Sstever@gmail.com if not conf.CheckLibWithHeader('socket', 'sys/socket.h', 'C++', 'accept(0,0,0);'): 3678120Sgblack@eecs.umich.edu print "Can't find library with socket calls (e.g. accept())" 3685341Sstever@gmail.com Exit(1) 3698120Sgblack@eecs.umich.edu 3705341Sstever@gmail.com# Check for zlib. If the check passes, libz will be automatically 3718120Sgblack@eecs.umich.edu# added to the LIBS environment variable. 3726121Snate@binkert.orgif not conf.CheckLibWithHeader('z', 'zlib.h', 'C++','zlibVersion();'): 3736121Snate@binkert.org print 'Error: did not find needed zlib compression library '\ 3748980Ssteve.reinhardt@amd.com 'and/or zlib.h header file.' 3759396Sandreas.hansson@arm.com print ' Please install zlib and try again.' 3765397Ssaidi@eecs.umich.edu Exit(1) 3775397Ssaidi@eecs.umich.edu 3787727SAli.Saidi@ARM.com# Check for <fenv.h> (C99 FP environment control) 3798268Ssteve.reinhardt@amd.comhave_fenv = conf.CheckHeader('fenv.h', '<>') 3806168Snate@binkert.orgif not have_fenv: 3815341Sstever@gmail.com print "Warning: Header file <fenv.h> not found." 3828120Sgblack@eecs.umich.edu print " This host has no IEEE FP rounding mode control." 3838120Sgblack@eecs.umich.edu 3848120Sgblack@eecs.umich.edu# Check for mysql. 3856814Sgblack@eecs.umich.edumysql_config = WhereIs('mysql_config') 3865863Snate@binkert.orghave_mysql = mysql_config != None 3878120Sgblack@eecs.umich.edu 3885341Sstever@gmail.com# Check MySQL version. 3895863Snate@binkert.orgif have_mysql: 3908268Ssteve.reinhardt@amd.com mysql_version = os.popen(mysql_config + ' --version').read() 3916121Snate@binkert.org min_mysql_version = '4.1' 3926121Snate@binkert.org if compare_versions(mysql_version, min_mysql_version) < 0: 3938268Ssteve.reinhardt@amd.com print 'Warning: MySQL', min_mysql_version, 'or newer required.' 3945742Snate@binkert.org print ' Version', mysql_version, 'detected.' 3955742Snate@binkert.org have_mysql = False 3965341Sstever@gmail.com 3975742Snate@binkert.org# Set up mysql_config commands. 3985742Snate@binkert.orgif have_mysql: 3995341Sstever@gmail.com mysql_config_include = mysql_config + ' --include' 4006017Snate@binkert.org if os.system(mysql_config_include + ' > /dev/null') != 0: 4016121Snate@binkert.org # older mysql_config versions don't support --include, use 4026017Snate@binkert.org # --cflags instead 4037816Ssteve.reinhardt@amd.com mysql_config_include = mysql_config + ' --cflags | sed s/\\\'//g' 4047756SAli.Saidi@ARM.com # This seems to work in all versions 4057756SAli.Saidi@ARM.com mysql_config_libs = mysql_config + ' --libs' 4067756SAli.Saidi@ARM.com 4077756SAli.Saidi@ARM.comenv = conf.Finish() 4087756SAli.Saidi@ARM.com 4097756SAli.Saidi@ARM.com# Define the universe of supported ISAs 4107756SAli.Saidi@ARM.comall_isa_list = [ ] 4117756SAli.Saidi@ARM.comExport('all_isa_list') 4127816Ssteve.reinhardt@amd.com 4137816Ssteve.reinhardt@amd.com# Define the universe of supported CPU models 4147816Ssteve.reinhardt@amd.comall_cpu_list = [ ] 4157816Ssteve.reinhardt@amd.comdefault_cpus = [ ] 4167816Ssteve.reinhardt@amd.comExport('all_cpu_list', 'default_cpus') 4177816Ssteve.reinhardt@amd.com 4187816Ssteve.reinhardt@amd.com# Sticky options get saved in the options file so they persist from 4197816Ssteve.reinhardt@amd.com# one invocation to the next (unless overridden, in which case the new 4207816Ssteve.reinhardt@amd.com# value becomes sticky). 4217816Ssteve.reinhardt@amd.comsticky_opts = Options(args=ARGUMENTS) 4227756SAli.Saidi@ARM.comExport('sticky_opts') 4237816Ssteve.reinhardt@amd.com 4247816Ssteve.reinhardt@amd.com# Non-sticky options only apply to the current build. 4257816Ssteve.reinhardt@amd.comnonsticky_opts = Options(args=ARGUMENTS) 4267816Ssteve.reinhardt@amd.comExport('nonsticky_opts') 4277816Ssteve.reinhardt@amd.com 4287816Ssteve.reinhardt@amd.com# Walk the tree and execute all SConsopts scripts that wil add to the 4297816Ssteve.reinhardt@amd.com# above options 4307816Ssteve.reinhardt@amd.comfor root, dirs, files in os.walk('.'): 4317816Ssteve.reinhardt@amd.com if 'SConsopts' in files: 4327816Ssteve.reinhardt@amd.com SConscript(os.path.join(root, 'SConsopts')) 4337816Ssteve.reinhardt@amd.com 4347816Ssteve.reinhardt@amd.comall_isa_list.sort() 4357816Ssteve.reinhardt@amd.comall_cpu_list.sort() 4367816Ssteve.reinhardt@amd.comdefault_cpus.sort() 4377816Ssteve.reinhardt@amd.com 4387816Ssteve.reinhardt@amd.comdef ExtraPathValidator(key, val, env): 4397816Ssteve.reinhardt@amd.com if not val: 4407816Ssteve.reinhardt@amd.com return 4417816Ssteve.reinhardt@amd.com paths = val.split(':') 4427816Ssteve.reinhardt@amd.com for path in paths: 4437816Ssteve.reinhardt@amd.com path = os.path.expanduser(path) 4447816Ssteve.reinhardt@amd.com if not isdir(path): 4457816Ssteve.reinhardt@amd.com raise AttributeError, "Invalid path: '%s'" % path 4467816Ssteve.reinhardt@amd.com 4477816Ssteve.reinhardt@amd.comsticky_opts.AddOptions( 4487816Ssteve.reinhardt@amd.com EnumOption('TARGET_ISA', 'Target ISA', 'alpha', all_isa_list), 4497816Ssteve.reinhardt@amd.com BoolOption('FULL_SYSTEM', 'Full-system support', False), 4507816Ssteve.reinhardt@amd.com # There's a bug in scons 0.96.1 that causes ListOptions with list 4517816Ssteve.reinhardt@amd.com # values (more than one value) not to be able to be restored from 4527816Ssteve.reinhardt@amd.com # a saved option file. If this causes trouble then upgrade to 4537816Ssteve.reinhardt@amd.com # scons 0.96.90 or later. 4547816Ssteve.reinhardt@amd.com ListOption('CPU_MODELS', 'CPU models', default_cpus, all_cpu_list), 4557816Ssteve.reinhardt@amd.com BoolOption('NO_FAST_ALLOC', 'Disable fast object allocator', False), 4567816Ssteve.reinhardt@amd.com BoolOption('EFENCE', 'Link with Electric Fence malloc debugger', 4577816Ssteve.reinhardt@amd.com False), 4587816Ssteve.reinhardt@amd.com BoolOption('SS_COMPATIBLE_FP', 4597816Ssteve.reinhardt@amd.com 'Make floating-point results compatible with SimpleScalar', 4607816Ssteve.reinhardt@amd.com False), 4617816Ssteve.reinhardt@amd.com BoolOption('USE_SSE2', 4627816Ssteve.reinhardt@amd.com 'Compile for SSE2 (-msse2) to get IEEE FP on x86 hosts', 4637816Ssteve.reinhardt@amd.com False), 4647816Ssteve.reinhardt@amd.com BoolOption('USE_MYSQL', 'Use MySQL for stats output', have_mysql), 4657816Ssteve.reinhardt@amd.com BoolOption('USE_FENV', 'Use <fenv.h> IEEE mode control', have_fenv), 4667816Ssteve.reinhardt@amd.com BoolOption('USE_CHECKER', 'Use checker for detailed CPU models', False), 4677816Ssteve.reinhardt@amd.com ('CC', 'C compiler', os.environ.get('CC', env['CC'])), 4687816Ssteve.reinhardt@amd.com ('CXX', 'C++ compiler', os.environ.get('CXX', env['CXX'])), 4697816Ssteve.reinhardt@amd.com BoolOption('BATCH', 'Use batch pool for build and tests', False), 4707816Ssteve.reinhardt@amd.com ('BATCH_CMD', 'Batch pool submission command name', 'qdo'), 4717816Ssteve.reinhardt@amd.com ('PYTHONHOME', 4727816Ssteve.reinhardt@amd.com 'Override the default PYTHONHOME for this system (use with caution)', 4737816Ssteve.reinhardt@amd.com '%s:%s' % (sys.prefix, sys.exec_prefix)), 4747816Ssteve.reinhardt@amd.com ('EXTRAS', 'Add Extra directories to the compilation', '', 4757816Ssteve.reinhardt@amd.com ExtraPathValidator) 4767816Ssteve.reinhardt@amd.com ) 4777816Ssteve.reinhardt@amd.com 4787816Ssteve.reinhardt@amd.comnonsticky_opts.AddOptions( 4797816Ssteve.reinhardt@amd.com BoolOption('update_ref', 'Update test reference outputs', False) 4807816Ssteve.reinhardt@amd.com ) 4817816Ssteve.reinhardt@amd.com 4827816Ssteve.reinhardt@amd.com# These options get exported to #defines in config/*.hh (see src/SConscript). 4837816Ssteve.reinhardt@amd.comenv.ExportOptions = ['FULL_SYSTEM', 'ALPHA_TLASER', 'USE_FENV', \ 4848947Sandreas.hansson@arm.com 'USE_MYSQL', 'NO_FAST_ALLOC', 'SS_COMPATIBLE_FP', \ 4858947Sandreas.hansson@arm.com 'USE_CHECKER', 'PYTHONHOME', 'TARGET_ISA'] 4867756SAli.Saidi@ARM.com 4878120Sgblack@eecs.umich.edu# Define a handy 'no-op' action 4887756SAli.Saidi@ARM.comdef no_action(target, source, env): 4897756SAli.Saidi@ARM.com return 0 4907756SAli.Saidi@ARM.com 4917756SAli.Saidi@ARM.comenv.NoAction = Action(no_action, None) 4927816Ssteve.reinhardt@amd.com 4937816Ssteve.reinhardt@amd.com################################################### 4947816Ssteve.reinhardt@amd.com# 4957816Ssteve.reinhardt@amd.com# Define a SCons builder for configuration flag headers. 4967816Ssteve.reinhardt@amd.com# 4977816Ssteve.reinhardt@amd.com################################################### 4987816Ssteve.reinhardt@amd.com 4997816Ssteve.reinhardt@amd.com# This function generates a config header file that #defines the 5007816Ssteve.reinhardt@amd.com# option symbol to the current option setting (0 or 1). The source 5017816Ssteve.reinhardt@amd.com# operands are the name of the option and a Value node containing the 5027756SAli.Saidi@ARM.com# value of the option. 5037756SAli.Saidi@ARM.comdef build_config_file(target, source, env): 5049227Sandreas.hansson@arm.com (option, value) = [s.get_contents() for s in source] 5059227Sandreas.hansson@arm.com f = file(str(target[0]), 'w') 5069227Sandreas.hansson@arm.com print >> f, '#define', option, value 5079227Sandreas.hansson@arm.com f.close() 5086654Snate@binkert.org return None 5096654Snate@binkert.org 5105871Snate@binkert.org# Generate the message to be printed when building the config file. 5116121Snate@binkert.orgdef build_config_file_string(target, source, env): 5128946Sandreas.hansson@arm.com (option, value) = [s.get_contents() for s in source] 5139419Sandreas.hansson@arm.com return "Defining %s as %s in %s." % (option, value, target[0]) 5143940Ssaidi@eecs.umich.edu 5153918Ssaidi@eecs.umich.edu# Combine the two functions into a scons Action object. 5163918Ssaidi@eecs.umich.educonfig_action = Action(build_config_file, build_config_file_string) 5171858SN/A 5186121Snate@binkert.org# The emitter munges the source & target node lists to reflect what 5199420Sandreas.hansson@arm.com# we're really doing. 5209420Sandreas.hansson@arm.comdef config_emitter(target, source, env): 5219420Sandreas.hansson@arm.com # extract option name from Builder arg 5229420Sandreas.hansson@arm.com option = str(target[0]) 5239420Sandreas.hansson@arm.com # True target is config header file 5249420Sandreas.hansson@arm.com target = joinpath('config', option.lower() + '.hh') 5259420Sandreas.hansson@arm.com val = env[option] 5269420Sandreas.hansson@arm.com if isinstance(val, bool): 5279420Sandreas.hansson@arm.com # Force value to 0/1 5287739Sgblack@eecs.umich.edu val = int(val) 5297739Sgblack@eecs.umich.edu elif isinstance(val, str): 5306143Snate@binkert.org val = '"' + val + '"' 5319420Sandreas.hansson@arm.com 5329420Sandreas.hansson@arm.com # Sources are option name & value (packaged in SCons Value nodes) 5339420Sandreas.hansson@arm.com return ([target], [Value(option), Value(val)]) 5347618SAli.Saidi@arm.com 5357618SAli.Saidi@arm.comconfig_builder = Builder(emitter = config_emitter, action = config_action) 5367618SAli.Saidi@arm.com 5377739Sgblack@eecs.umich.eduenv.Append(BUILDERS = { 'ConfigFile' : config_builder }) 5389227Sandreas.hansson@arm.com 5399227Sandreas.hansson@arm.com################################################### 5409227Sandreas.hansson@arm.com# 5419227Sandreas.hansson@arm.com# Define a SCons builder for copying files. This is used by the 5429227Sandreas.hansson@arm.com# Python zipfile code in src/python/SConscript, but is placed up here 5439227Sandreas.hansson@arm.com# since it's potentially more generally applicable. 5449227Sandreas.hansson@arm.com# 5459227Sandreas.hansson@arm.com################################################### 5469227Sandreas.hansson@arm.com 5479227Sandreas.hansson@arm.comcopy_builder = Builder(action = Copy("$TARGET", "$SOURCE")) 5489227Sandreas.hansson@arm.com 5499227Sandreas.hansson@arm.comenv.Append(BUILDERS = { 'CopyFile' : copy_builder }) 5509227Sandreas.hansson@arm.com 5519227Sandreas.hansson@arm.com################################################### 5529227Sandreas.hansson@arm.com# 5539227Sandreas.hansson@arm.com# Define a simple SCons builder to concatenate files. 5549227Sandreas.hansson@arm.com# 5559227Sandreas.hansson@arm.com# Used to append the Python zip archive to the executable. 5568737Skoansin.tan@gmail.com# 5579420Sandreas.hansson@arm.com################################################### 5589420Sandreas.hansson@arm.com 5599420Sandreas.hansson@arm.comconcat_builder = Builder(action = Action(['cat $SOURCES > $TARGET', 5608737Skoansin.tan@gmail.com 'chmod +x $TARGET'])) 5618737Skoansin.tan@gmail.com 5628737Skoansin.tan@gmail.comenv.Append(BUILDERS = { 'Concat' : concat_builder }) 5638737Skoansin.tan@gmail.com 5648737Skoansin.tan@gmail.com 5658737Skoansin.tan@gmail.com# base help text 5668737Skoansin.tan@gmail.comhelp_text = ''' 5678737Skoansin.tan@gmail.comUsage: scons [scons options] [build options] [target(s)] 5688737Skoansin.tan@gmail.com 5698737Skoansin.tan@gmail.com''' 5708737Skoansin.tan@gmail.com 5718737Skoansin.tan@gmail.com# libelf build is shared across all configs in the build root. 5728737Skoansin.tan@gmail.comenv.SConscript('ext/libelf/SConscript', 5738737Skoansin.tan@gmail.com build_dir = joinpath(build_root, 'libelf'), 5748737Skoansin.tan@gmail.com exports = 'env') 5758737Skoansin.tan@gmail.com 5768737Skoansin.tan@gmail.com################################################### 5778946Sandreas.hansson@arm.com# 5788946Sandreas.hansson@arm.com# This function is used to set up a directory with switching headers 5798946Sandreas.hansson@arm.com# 5809420Sandreas.hansson@arm.com################################################### 5819420Sandreas.hansson@arm.com 5829420Sandreas.hansson@arm.comenv['ALL_ISA_LIST'] = all_isa_list 5839420Sandreas.hansson@arm.comdef make_switching_dir(dirname, switch_headers, env): 5849420Sandreas.hansson@arm.com # Generate the header. target[0] is the full path of the output 5859420Sandreas.hansson@arm.com # header to generate. 'source' is a dummy variable, since we get the 5869420Sandreas.hansson@arm.com # list of ISAs from env['ALL_ISA_LIST']. 5879420Sandreas.hansson@arm.com def gen_switch_hdr(target, source, env): 5889420Sandreas.hansson@arm.com fname = str(target[0]) 5899420Sandreas.hansson@arm.com basename = os.path.basename(fname) 5909420Sandreas.hansson@arm.com f = open(fname, 'w') 5918946Sandreas.hansson@arm.com f.write('#include "arch/isa_specific.hh"\n') 5923918Ssaidi@eecs.umich.edu cond = '#if' 5939068SAli.Saidi@ARM.com for isa in all_isa_list: 5949068SAli.Saidi@ARM.com f.write('%s THE_ISA == %s_ISA\n#include "%s/%s/%s"\n' 5959068SAli.Saidi@ARM.com % (cond, isa.upper(), dirname, isa, basename)) 5969068SAli.Saidi@ARM.com cond = '#elif' 5979068SAli.Saidi@ARM.com f.write('#else\n#error "THE_ISA not set"\n#endif\n') 5989068SAli.Saidi@ARM.com f.close() 5999068SAli.Saidi@ARM.com return 0 6009068SAli.Saidi@ARM.com 6019068SAli.Saidi@ARM.com # String to print when generating header 6029419Sandreas.hansson@arm.com def gen_switch_hdr_string(target, source, env): 6039068SAli.Saidi@ARM.com return "Generating switch header " + str(target[0]) 6049068SAli.Saidi@ARM.com 6059068SAli.Saidi@ARM.com # Build SCons Action object. 'varlist' specifies env vars that this 6069068SAli.Saidi@ARM.com # action depends on; when env['ALL_ISA_LIST'] changes these actions 6079068SAli.Saidi@ARM.com # should get re-executed. 6089068SAli.Saidi@ARM.com switch_hdr_action = Action(gen_switch_hdr, gen_switch_hdr_string, 6093918Ssaidi@eecs.umich.edu varlist=['ALL_ISA_LIST']) 6103918Ssaidi@eecs.umich.edu 6116157Snate@binkert.org # Instantiate actions for each header 6126157Snate@binkert.org for hdr in switch_headers: 6136157Snate@binkert.org env.Command(hdr, [], switch_hdr_action) 6146157Snate@binkert.orgExport('make_switching_dir') 6155397Ssaidi@eecs.umich.edu 6165397Ssaidi@eecs.umich.edu################################################### 6176121Snate@binkert.org# 6186121Snate@binkert.org# Define build environments for selected configurations. 6196121Snate@binkert.org# 6206121Snate@binkert.org################################################### 6216121Snate@binkert.org 6226121Snate@binkert.org# rename base env 6235397Ssaidi@eecs.umich.edubase_env = env 6241851SN/A 6251851SN/Afor build_path in build_paths: 6267739Sgblack@eecs.umich.edu print "Building in", build_path 627955SN/A env['BUILDDIR'] = build_path 6289396Sandreas.hansson@arm.com 6299396Sandreas.hansson@arm.com # build_dir is the tail component of build path, and is used to 6309396Sandreas.hansson@arm.com # determine the build parameters (e.g., 'ALPHA_SE') 6319396Sandreas.hansson@arm.com (build_root, build_dir) = os.path.split(build_path) 6329396Sandreas.hansson@arm.com # Make a copy of the build-root environment to use for this config. 6339396Sandreas.hansson@arm.com env = base_env.Copy() 6349396Sandreas.hansson@arm.com 6359396Sandreas.hansson@arm.com # Set env options according to the build directory config. 6369396Sandreas.hansson@arm.com sticky_opts.files = [] 6379396Sandreas.hansson@arm.com # Options for $BUILD_ROOT/$BUILD_DIR are stored in 6389396Sandreas.hansson@arm.com # $BUILD_ROOT/options/$BUILD_DIR so you can nuke 6399396Sandreas.hansson@arm.com # $BUILD_ROOT/$BUILD_DIR without losing your options settings. 6409396Sandreas.hansson@arm.com current_opts_file = joinpath(build_root, 'options', build_dir) 6419396Sandreas.hansson@arm.com if os.path.isfile(current_opts_file): 6429396Sandreas.hansson@arm.com sticky_opts.files.append(current_opts_file) 6439396Sandreas.hansson@arm.com print "Using saved options file %s" % current_opts_file 6449396Sandreas.hansson@arm.com else: 6459396Sandreas.hansson@arm.com # Build dir-specific options file doesn't exist. 6469396Sandreas.hansson@arm.com 6479396Sandreas.hansson@arm.com # Make sure the directory is there so we can create it later 6489396Sandreas.hansson@arm.com opt_dir = os.path.dirname(current_opts_file) 6499396Sandreas.hansson@arm.com if not os.path.isdir(opt_dir): 6509396Sandreas.hansson@arm.com os.mkdir(opt_dir) 6519396Sandreas.hansson@arm.com 6529396Sandreas.hansson@arm.com # Get default build options from source tree. Options are 6539396Sandreas.hansson@arm.com # normally determined by name of $BUILD_DIR, but can be 6549396Sandreas.hansson@arm.com # overriden by 'default=' arg on command line. 6559396Sandreas.hansson@arm.com default_opts_file = joinpath('build_opts', 6563053Sstever@eecs.umich.edu ARGUMENTS.get('default', build_dir)) 6576121Snate@binkert.org if os.path.isfile(default_opts_file): 6583053Sstever@eecs.umich.edu sticky_opts.files.append(default_opts_file) 6593053Sstever@eecs.umich.edu print "Options file %s not found,\n using defaults in %s" \ 6603053Sstever@eecs.umich.edu % (current_opts_file, default_opts_file) 6613053Sstever@eecs.umich.edu else: 6623053Sstever@eecs.umich.edu print "Error: cannot find options file %s or %s" \ 6639072Sandreas.hansson@arm.com % (current_opts_file, default_opts_file) 6643053Sstever@eecs.umich.edu Exit(1) 6654742Sstever@eecs.umich.edu 6664742Sstever@eecs.umich.edu # Apply current option settings to env 6673053Sstever@eecs.umich.edu sticky_opts.Update(env) 6683053Sstever@eecs.umich.edu nonsticky_opts.Update(env) 6693053Sstever@eecs.umich.edu 6708960Ssteve.reinhardt@amd.com help_text += "Sticky options for %s:\n" % build_dir \ 6716654Snate@binkert.org + sticky_opts.GenerateHelpText(env) \ 6723053Sstever@eecs.umich.edu + "\nNon-sticky options for %s:\n" % build_dir \ 6733053Sstever@eecs.umich.edu + nonsticky_opts.GenerateHelpText(env) 6743053Sstever@eecs.umich.edu 6753053Sstever@eecs.umich.edu # Process option settings. 6762667Sstever@eecs.umich.edu 6774554Sbinkertn@umich.edu if not have_fenv and env['USE_FENV']: 6786121Snate@binkert.org print "Warning: <fenv.h> not available; " \ 6792667Sstever@eecs.umich.edu "forcing USE_FENV to False in", build_dir + "." 6804554Sbinkertn@umich.edu env['USE_FENV'] = False 6814554Sbinkertn@umich.edu 6824554Sbinkertn@umich.edu if not env['USE_FENV']: 6836121Snate@binkert.org print "Warning: No IEEE FP rounding mode control in", build_dir + "." 6844554Sbinkertn@umich.edu print " FP results may deviate slightly from other platforms." 6854554Sbinkertn@umich.edu 6864554Sbinkertn@umich.edu if env['EFENCE']: 6874781Snate@binkert.org env.Append(LIBS=['efence']) 6884554Sbinkertn@umich.edu 6894554Sbinkertn@umich.edu if env['USE_MYSQL']: 6902667Sstever@eecs.umich.edu if not have_mysql: 6914554Sbinkertn@umich.edu print "Warning: MySQL not available; " \ 6924554Sbinkertn@umich.edu "forcing USE_MYSQL to False in", build_dir + "." 6934554Sbinkertn@umich.edu env['USE_MYSQL'] = False 6944554Sbinkertn@umich.edu else: 6952667Sstever@eecs.umich.edu print "Compiling in", build_dir, "with MySQL support." 6964554Sbinkertn@umich.edu env.ParseConfig(mysql_config_libs) 6972667Sstever@eecs.umich.edu env.ParseConfig(mysql_config_include) 6984554Sbinkertn@umich.edu 6996121Snate@binkert.org # Save sticky option settings back to current options file 7002667Sstever@eecs.umich.edu sticky_opts.Save(current_opts_file, env) 7015522Snate@binkert.org 7025522Snate@binkert.org # Do this after we save setting back, or else we'll tack on an 7035522Snate@binkert.org # extra 'qdo' every time we run scons. 7045522Snate@binkert.org if env['BATCH']: 7055522Snate@binkert.org env['CC'] = env['BATCH_CMD'] + ' ' + env['CC'] 7065522Snate@binkert.org env['CXX'] = env['BATCH_CMD'] + ' ' + env['CXX'] 7075522Snate@binkert.org 7085522Snate@binkert.org if env['USE_SSE2']: 7095522Snate@binkert.org env.Append(CCFLAGS='-msse2') 7105522Snate@binkert.org 7115522Snate@binkert.org # The src/SConscript file sets up the build rules in 'env' according 7125522Snate@binkert.org # to the configured options. It returns a list of environments, 7135522Snate@binkert.org # one for each variant build (debug, opt, etc.) 7145522Snate@binkert.org envList = SConscript('src/SConscript', build_dir = build_path, 7155522Snate@binkert.org exports = 'env') 7165522Snate@binkert.org 7175522Snate@binkert.org # Set up the regression tests for each build. 7185522Snate@binkert.org for e in envList: 7195522Snate@binkert.org SConscript('tests/SConscript', 7205522Snate@binkert.org build_dir = joinpath(build_path, 'tests', e.Label), 7215522Snate@binkert.org exports = { 'env' : e }, duplicate = False) 7225522Snate@binkert.org 7235522Snate@binkert.orgHelp(help_text) 7245522Snate@binkert.org 7255522Snate@binkert.org 7265522Snate@binkert.org################################################### 7272638Sstever@eecs.umich.edu# 7282638Sstever@eecs.umich.edu# Let SCons do its thing. At this point SCons will use the defined 7296121Snate@binkert.org# build environments to build the requested targets. 7303716Sstever@eecs.umich.edu# 7315522Snate@binkert.org################################################### 7329420Sandreas.hansson@arm.com 7335522Snate@binkert.org