SConstruct revision 5343
1955SN/A# -*- mode:python -*- 2955SN/A 35871Snate@binkert.org# Copyright (c) 2004-2005 The Regents of The University of Michigan 41762SN/A# All rights reserved. 5955SN/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# 292665Ssaidi@eecs.umich.edu# Authors: Steve Reinhardt 302665Ssaidi@eecs.umich.edu 315863Snate@binkert.org################################################### 32955SN/A# 33955SN/A# SCons top-level build description (SConstruct) file. 34955SN/A# 35955SN/A# While in this directory ('m5'), just type 'scons' to build the default 36955SN/A# configuration (see below), or type 'scons build/<CONFIG>/<binary>' 372632Sstever@eecs.umich.edu# to build some other configuration (e.g., 'build/ALPHA_FS/m5.opt' for 382632Sstever@eecs.umich.edu# the optimized full-system version). 392632Sstever@eecs.umich.edu# 402632Sstever@eecs.umich.edu# You can build M5 in a different directory as long as there is a 41955SN/A# 'build/<CONFIG>' somewhere along the target path. The build system 422632Sstever@eecs.umich.edu# expects that all configs under the same build directory are being 432632Sstever@eecs.umich.edu# built for the same host system. 442761Sstever@eecs.umich.edu# 452632Sstever@eecs.umich.edu# Examples: 462632Sstever@eecs.umich.edu# 472632Sstever@eecs.umich.edu# The following two commands are equivalent. The '-u' option tells 482761Sstever@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 512632Sstever@eecs.umich.edu# 522632Sstever@eecs.umich.edu# The following two commands are equivalent and demonstrate building 532761Sstever@eecs.umich.edu# 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 582632Sstever@eecs.umich.edu# 592632Sstever@eecs.umich.edu# You can use 'scons -H' to print scons options. If you're in this 602632Sstever@eecs.umich.edu# 'm5' directory (or use -u or -C to tell scons where to find this 612632Sstever@eecs.umich.edu# file), you can use 'scons -h' to print all the M5-specific build 622632Sstever@eecs.umich.edu# options as well. 632632Sstever@eecs.umich.edu# 642632Sstever@eecs.umich.edu################################################### 65955SN/A 66955SN/Aimport sys 67955SN/Aimport os 685863Snate@binkert.org 695863Snate@binkert.orgfrom os.path import isdir, isfile, join as joinpath 705863Snate@binkert.org 715863Snate@binkert.orgimport SCons 725863Snate@binkert.org 735863Snate@binkert.org# Check for recent-enough Python and SCons versions. If your system's 745863Snate@binkert.org# default installation of Python is not recent enough, you can use a 755863Snate@binkert.org# non-default installation of the Python interpreter by either (1) 765863Snate@binkert.org# rearranging your PATH so that scons finds the non-default 'python' 775863Snate@binkert.org# first or (2) explicitly invoking an alternative interpreter on the 785863Snate@binkert.org# scons script, e.g., "/usr/local/bin/python2.4 `which scons` [args]". 795863Snate@binkert.orgEnsurePythonVersion(2,4) 805863Snate@binkert.org 815863Snate@binkert.org# Import subprocess after we check the version since it doesn't exist in 825863Snate@binkert.org# Python < 2.4. 835863Snate@binkert.orgimport subprocess 845863Snate@binkert.org 855863Snate@binkert.org# Ironically, SCons 0.96 dies if you give EnsureSconsVersion a 865863Snate@binkert.org# 3-element version number. 875863Snate@binkert.orgmin_scons_version = (0,96,91) 885863Snate@binkert.orgtry: 895863Snate@binkert.org EnsureSConsVersion(*min_scons_version) 905863Snate@binkert.orgexcept: 915863Snate@binkert.org print "Error checking current SCons version." 925863Snate@binkert.org print "SCons", ".".join(map(str,min_scons_version)), "or greater required." 935863Snate@binkert.org Exit(2) 945863Snate@binkert.org 955863Snate@binkert.org 965863Snate@binkert.org# The absolute path to the current directory (where this file lives). 975863Snate@binkert.orgROOT = Dir('.').abspath 985863Snate@binkert.org 99955SN/A# Path to the M5 source tree. 1005396Ssaidi@eecs.umich.eduSRCDIR = joinpath(ROOT, 'src') 1015863Snate@binkert.org 1025863Snate@binkert.org# tell python where to find m5 python code 1034202Sbinkertn@umich.edusys.path.append(joinpath(ROOT, 'src/python')) 1045863Snate@binkert.org 1055863Snate@binkert.orgdef check_style_hook(ui): 1065863Snate@binkert.org ui.readconfig(joinpath(ROOT, '.hg', 'hgrc')) 1075863Snate@binkert.org style_hook = ui.config('hooks', 'pretxncommit.style', None) 108955SN/A 1095273Sstever@gmail.com if not style_hook: 1105871Snate@binkert.org print """\ 1115273Sstever@gmail.comYou're missing the M5 style hook. 1125871Snate@binkert.orgPlease install the hook so we can ensure that all code fits a common style. 1135863Snate@binkert.org 1145863Snate@binkert.orgAll you'd need to do is add the following lines to your repository .hg/hgrc 1155863Snate@binkert.orgor your personal .hgrc 1165871Snate@binkert.org---------------- 1175871Snate@binkert.org 1185871Snate@binkert.org[extensions] 1195871Snate@binkert.orgstyle = %s/util/style.py 1205871Snate@binkert.org 1215871Snate@binkert.org[hooks] 1225871Snate@binkert.orgpretxncommit.style = python:style.check_whitespace 1235871Snate@binkert.org""" % (ROOT) 1245871Snate@binkert.org sys.exit(1) 1255871Snate@binkert.org 1265871Snate@binkert.orgif ARGUMENTS.get('IGNORE_STYLE') != 'True' and isdir(joinpath(ROOT, '.hg')): 1275871Snate@binkert.org try: 1285871Snate@binkert.org from mercurial import ui 1295871Snate@binkert.org check_style_hook(ui.ui()) 1305871Snate@binkert.org except ImportError: 1315863Snate@binkert.org pass 1325227Ssaidi@eecs.umich.edu 1335396Ssaidi@eecs.umich.edu################################################### 1345396Ssaidi@eecs.umich.edu# 1355396Ssaidi@eecs.umich.edu# Figure out which configurations to set up based on the path(s) of 1365396Ssaidi@eecs.umich.edu# the target(s). 1375396Ssaidi@eecs.umich.edu# 1385396Ssaidi@eecs.umich.edu################################################### 1395396Ssaidi@eecs.umich.edu 1405396Ssaidi@eecs.umich.edu# Find default configuration & binary. 1415588Ssaidi@eecs.umich.eduDefault(os.environ.get('M5_DEFAULT_BINARY', 'build/ALPHA_SE/m5.debug')) 1425396Ssaidi@eecs.umich.edu 1435396Ssaidi@eecs.umich.edu# helper function: find last occurrence of element in list 1445396Ssaidi@eecs.umich.edudef rfind(l, elt, offs = -1): 1455396Ssaidi@eecs.umich.edu for i in range(len(l)+offs, 0, -1): 1465396Ssaidi@eecs.umich.edu if l[i] == elt: 1475396Ssaidi@eecs.umich.edu return i 1485396Ssaidi@eecs.umich.edu raise ValueError, "element not found" 1495396Ssaidi@eecs.umich.edu 1505396Ssaidi@eecs.umich.edu# helper function: compare dotted version numbers. 1515396Ssaidi@eecs.umich.edu# E.g., compare_version('1.3.25', '1.4.1') 1525396Ssaidi@eecs.umich.edu# returns -1, 0, 1 if v1 is <, ==, > v2 1535396Ssaidi@eecs.umich.edudef compare_versions(v1, v2): 1545396Ssaidi@eecs.umich.edu # Convert dotted strings to lists 1555396Ssaidi@eecs.umich.edu v1 = map(int, v1.split('.')) 1565871Snate@binkert.org v2 = map(int, v2.split('.')) 1575871Snate@binkert.org # Compare corresponding elements of lists 1585871Snate@binkert.org for n1,n2 in zip(v1, v2): 1595871Snate@binkert.org if n1 < n2: return -1 1605871Snate@binkert.org if n1 > n2: return 1 1615871Snate@binkert.org # all corresponding values are equal... see if one has extra values 162955SN/A if len(v1) < len(v2): return -1 1635871Snate@binkert.org if len(v1) > len(v2): return 1 1645871Snate@binkert.org return 0 1655871Snate@binkert.org 1665871Snate@binkert.org# Each target must have 'build' in the interior of the path; the 167955SN/A# directory below this will determine the build parameters. For 1685871Snate@binkert.org# example, for target 'foo/bar/build/ALPHA_SE/arch/alpha/blah.do' we 1695871Snate@binkert.org# recognize that ALPHA_SE specifies the configuration because it 1705871Snate@binkert.org# follow 'build' in the bulid path. 1711533SN/A 1725871Snate@binkert.org# Generate absolute paths to targets so we can see where the build dir is 1735871Snate@binkert.orgif COMMAND_LINE_TARGETS: 1745863Snate@binkert.org # Ask SCons which directory it was invoked from 1755871Snate@binkert.org launch_dir = GetLaunchDir() 1765871Snate@binkert.org # Make targets relative to invocation directory 1775871Snate@binkert.org abs_targets = map(lambda x: os.path.normpath(joinpath(launch_dir, str(x))), 1785871Snate@binkert.org COMMAND_LINE_TARGETS) 1795871Snate@binkert.orgelse: 1805863Snate@binkert.org # Default targets are relative to root of tree 1815871Snate@binkert.org abs_targets = map(lambda x: os.path.normpath(joinpath(ROOT, str(x))), 1825863Snate@binkert.org DEFAULT_TARGETS) 1835871Snate@binkert.org 1844678Snate@binkert.org 1854678Snate@binkert.org# Generate a list of the unique build roots and configs that the 1864678Snate@binkert.org# collected targets reference. 1874678Snate@binkert.orgbuild_paths = [] 1884678Snate@binkert.orgbuild_root = None 1894678Snate@binkert.orgfor t in abs_targets: 1904678Snate@binkert.org path_dirs = t.split('/') 1914678Snate@binkert.org try: 1924678Snate@binkert.org build_top = rfind(path_dirs, 'build', -2) 1934678Snate@binkert.org except: 1944678Snate@binkert.org print "Error: no non-leaf 'build' dir found on target path", t 1954678Snate@binkert.org Exit(1) 1965871Snate@binkert.org this_build_root = joinpath('/',*path_dirs[:build_top+1]) 1974678Snate@binkert.org if not build_root: 1985871Snate@binkert.org build_root = this_build_root 1995871Snate@binkert.org else: 2005871Snate@binkert.org if this_build_root != build_root: 2015871Snate@binkert.org print "Error: build targets not under same build root\n"\ 2025871Snate@binkert.org " %s\n %s" % (build_root, this_build_root) 2035871Snate@binkert.org Exit(1) 2045871Snate@binkert.org build_path = joinpath('/',*path_dirs[:build_top+2]) 2055871Snate@binkert.org if build_path not in build_paths: 2065871Snate@binkert.org build_paths.append(build_path) 2075871Snate@binkert.org 2085871Snate@binkert.org# Make sure build_root exists (might not if this is the first build there) 2095871Snate@binkert.orgif not isdir(build_root): 2105871Snate@binkert.org os.mkdir(build_root) 2115871Snate@binkert.org 2125871Snate@binkert.org################################################### 2135871Snate@binkert.org# 2144678Snate@binkert.org# Set up the default build environment. This environment is copied 2155871Snate@binkert.org# and modified according to each selected configuration. 2165871Snate@binkert.org# 2175871Snate@binkert.org################################################### 2185871Snate@binkert.org 2195871Snate@binkert.orgenv = Environment(ENV = os.environ, # inherit user's environment vars 2205871Snate@binkert.org ROOT = ROOT, 2215871Snate@binkert.org SRCDIR = SRCDIR) 2225871Snate@binkert.org 2235871Snate@binkert.orgExport('env') 2245871Snate@binkert.org 2255871Snate@binkert.orgenv.SConsignFile(joinpath(build_root,"sconsign")) 2265871Snate@binkert.org 2275871Snate@binkert.org# Default duplicate option is to use hard links, but this messes up 2284678Snate@binkert.org# when you use emacs to edit a file in the target dir, as emacs moves 2295871Snate@binkert.org# file to file~ then copies to file, breaking the link. Symbolic 2304678Snate@binkert.org# (soft) links work better. 2315871Snate@binkert.orgenv.SetOption('duplicate', 'soft-copy') 2325871Snate@binkert.org 2335871Snate@binkert.org# I waffle on this setting... it does avoid a few painful but 2345871Snate@binkert.org# unnecessary builds, but it also seems to make trivial builds take 2355871Snate@binkert.org# noticeably longer. 2365871Snate@binkert.orgif False: 2375871Snate@binkert.org env.TargetSignatures('content') 2385871Snate@binkert.org 2395871Snate@binkert.org# 2405863Snate@binkert.org# Set up global sticky options... these are common to an entire build 241955SN/A# tree (not specific to a particular build like ALPHA_SE) 242955SN/A# 2432632Sstever@eecs.umich.edu 2442632Sstever@eecs.umich.edu# Option validators & converters for global sticky options 245955SN/Adef PathListMakeAbsolute(val): 246955SN/A if not val: 247955SN/A return val 248955SN/A f = lambda p: os.path.abspath(os.path.expanduser(p)) 2495863Snate@binkert.org return ':'.join(map(f, val.split(':'))) 250955SN/A 2512632Sstever@eecs.umich.edudef PathListAllExist(key, val, env): 2522632Sstever@eecs.umich.edu if not val: 2532632Sstever@eecs.umich.edu return 2542632Sstever@eecs.umich.edu paths = val.split(':') 2552632Sstever@eecs.umich.edu for path in paths: 2562632Sstever@eecs.umich.edu if not isdir(path): 2572632Sstever@eecs.umich.edu raise SCons.Errors.UserError("Path does not exist: '%s'" % path) 2582632Sstever@eecs.umich.edu 2592632Sstever@eecs.umich.eduglobal_sticky_opts_file = joinpath(build_root, 'options.global') 2602632Sstever@eecs.umich.edu 2612632Sstever@eecs.umich.eduglobal_sticky_opts = Options(global_sticky_opts_file, args=ARGUMENTS) 2622632Sstever@eecs.umich.edu 2632632Sstever@eecs.umich.eduglobal_sticky_opts.AddOptions( 2643718Sstever@eecs.umich.edu ('CC', 'C compiler', os.environ.get('CC', env['CC'])), 2653718Sstever@eecs.umich.edu ('CXX', 'C++ compiler', os.environ.get('CXX', env['CXX'])), 2663718Sstever@eecs.umich.edu ('EXTRAS', 'Add Extra directories to the compilation', '', 2673718Sstever@eecs.umich.edu PathListAllExist, PathListMakeAbsolute) 2683718Sstever@eecs.umich.edu ) 2695863Snate@binkert.org 2705863Snate@binkert.org 2713718Sstever@eecs.umich.edu# base help text 2723718Sstever@eecs.umich.eduhelp_text = ''' 2735863Snate@binkert.orgUsage: scons [scons options] [build options] [target(s)] 2745863Snate@binkert.org 2753718Sstever@eecs.umich.edu''' 2763718Sstever@eecs.umich.edu 2772634Sstever@eecs.umich.eduhelp_text += "Global sticky options:\n" \ 2782634Sstever@eecs.umich.edu + global_sticky_opts.GenerateHelpText(env) 2795863Snate@binkert.org 2802638Sstever@eecs.umich.edu# Update env with values from ARGUMENTS & file global_sticky_opts_file 2812632Sstever@eecs.umich.eduglobal_sticky_opts.Update(env) 2822632Sstever@eecs.umich.edu 2832632Sstever@eecs.umich.edu# Save sticky option settings back to current options file 2842632Sstever@eecs.umich.eduglobal_sticky_opts.Save(global_sticky_opts_file, env) 2852632Sstever@eecs.umich.edu 2862632Sstever@eecs.umich.edu# Parse EXTRAS option to build list of all directories where we're 2871858SN/A# look for sources etc. This list is exported as base_dir_list. 2883716Sstever@eecs.umich.edubase_dir_list = [ROOT] 2892638Sstever@eecs.umich.eduif env['EXTRAS']: 2902638Sstever@eecs.umich.edu base_dir_list += env['EXTRAS'].split(':') 2912638Sstever@eecs.umich.edu 2922638Sstever@eecs.umich.eduExport('base_dir_list') 2932638Sstever@eecs.umich.edu 2942638Sstever@eecs.umich.edu# M5_PLY is used by isa_parser.py to find the PLY package. 2952638Sstever@eecs.umich.eduenv.Append(ENV = { 'M5_PLY' : str(Dir('ext/ply')) }) 2965863Snate@binkert.orgenv['GCC'] = False 2975863Snate@binkert.orgenv['SUNCC'] = False 2985863Snate@binkert.orgenv['ICC'] = False 299955SN/Aenv['GCC'] = subprocess.Popen(env['CXX'] + ' --version', shell=True, 3005341Sstever@gmail.com stdout=subprocess.PIPE, stderr=subprocess.STDOUT, 3015341Sstever@gmail.com close_fds=True).communicate()[0].find('GCC') >= 0 3025863Snate@binkert.orgenv['SUNCC'] = subprocess.Popen(env['CXX'] + ' -V', shell=True, 3035341Sstever@gmail.com stdout=subprocess.PIPE, stderr=subprocess.STDOUT, 3044494Ssaidi@eecs.umich.edu close_fds=True).communicate()[0].find('Sun C++') >= 0 3054494Ssaidi@eecs.umich.eduenv['ICC'] = subprocess.Popen(env['CXX'] + ' -V', shell=True, 3065863Snate@binkert.org stdout=subprocess.PIPE, stderr=subprocess.STDOUT, 3071105SN/A close_fds=True).communicate()[0].find('Intel') >= 0 3082667Sstever@eecs.umich.eduif env['GCC'] + env['SUNCC'] + env['ICC'] > 1: 3092667Sstever@eecs.umich.edu print 'Error: How can we have two at the same time?' 3102667Sstever@eecs.umich.edu Exit(1) 3112667Sstever@eecs.umich.edu 3122667Sstever@eecs.umich.edu 3132667Sstever@eecs.umich.edu# Set up default C++ compiler flags 3145341Sstever@gmail.comif env['GCC']: 3155863Snate@binkert.org env.Append(CCFLAGS='-pipe') 3165341Sstever@gmail.com env.Append(CCFLAGS='-fno-strict-aliasing') 3175341Sstever@gmail.com env.Append(CCFLAGS=Split('-Wall -Wno-sign-compare -Werror -Wundef')) 3185341Sstever@gmail.comelif env['ICC']: 3195863Snate@binkert.org pass #Fix me... add warning flags once we clean up icc warnings 3205341Sstever@gmail.comelif env['SUNCC']: 3215341Sstever@gmail.com env.Append(CCFLAGS='-Qoption ccfe') 3225341Sstever@gmail.com env.Append(CCFLAGS='-features=gcc') 3235863Snate@binkert.org env.Append(CCFLAGS='-features=extensions') 3245341Sstever@gmail.com env.Append(CCFLAGS='-library=stlport4') 3255341Sstever@gmail.com env.Append(CCFLAGS='-xar') 3265341Sstever@gmail.com# env.Append(CCFLAGS='-instances=semiexplicit') 3275341Sstever@gmail.comelse: 3285341Sstever@gmail.com print 'Error: Don\'t know what compiler options to use for your compiler.' 3295341Sstever@gmail.com print ' Please fix SConstruct and src/SConscript and try again.' 3305341Sstever@gmail.com Exit(1) 3315341Sstever@gmail.com 3325341Sstever@gmail.comif sys.platform == 'cygwin': 3335341Sstever@gmail.com # cygwin has some header file issues... 3345863Snate@binkert.org env.Append(CCFLAGS=Split("-Wno-uninitialized")) 3355341Sstever@gmail.comenv.Append(CPPPATH=[Dir('ext/dnet')]) 3365863Snate@binkert.org 3375341Sstever@gmail.com# Check for SWIG 3385863Snate@binkert.orgif not env.has_key('SWIG'): 3395863Snate@binkert.org print 'Error: SWIG utility not found.' 3405863Snate@binkert.org print ' Please install (see http://www.swig.org) and retry.' 3415397Ssaidi@eecs.umich.edu Exit(1) 3425397Ssaidi@eecs.umich.edu 3435341Sstever@gmail.com# Check for appropriate SWIG version 3445341Sstever@gmail.comswig_version = os.popen('swig -version').read().split() 3455341Sstever@gmail.com# First 3 words should be "SWIG Version x.y.z" 3465341Sstever@gmail.comif len(swig_version) < 3 or \ 3475341Sstever@gmail.com swig_version[0] != 'SWIG' or swig_version[1] != 'Version': 3485341Sstever@gmail.com print 'Error determining SWIG version.' 3495341Sstever@gmail.com Exit(1) 3505341Sstever@gmail.com 3515863Snate@binkert.orgmin_swig_version = '1.3.28' 3525341Sstever@gmail.comif compare_versions(swig_version[2], min_swig_version) < 0: 3535341Sstever@gmail.com print 'Error: SWIG version', min_swig_version, 'or newer required.' 3545863Snate@binkert.org print ' Installed version:', swig_version[2] 3555341Sstever@gmail.com Exit(1) 3565863Snate@binkert.org 3575863Snate@binkert.org# Set up SWIG flags & scanner 3585341Sstever@gmail.comswig_flags=Split('-c++ -python -modern -templatereduce $_CPPINCFLAGS') 3595863Snate@binkert.orgenv.Append(SWIGFLAGS=swig_flags) 3605863Snate@binkert.org 3615341Sstever@gmail.com# filter out all existing swig scanners, they mess up the dependency 3625863Snate@binkert.org# stuff for some reason 3635341Sstever@gmail.comscanners = [] 3645871Snate@binkert.orgfor scanner in env['SCANNERS']: 3655341Sstever@gmail.com skeys = scanner.skeys 3665742Snate@binkert.org if skeys == '.i': 3675742Snate@binkert.org continue 3685742Snate@binkert.org 3695341Sstever@gmail.com if isinstance(skeys, (list, tuple)) and '.i' in skeys: 3705742Snate@binkert.org continue 3715742Snate@binkert.org 3725341Sstever@gmail.com scanners.append(scanner) 3732632Sstever@eecs.umich.edu 3745199Sstever@gmail.com# add the new swig scanner that we like better 3755871Snate@binkert.orgfrom SCons.Scanner import ClassicCPP as CPPScanner 3765871Snate@binkert.orgswig_inc_re = '^[ \t]*[%,#][ \t]*(?:include|import)[ \t]*(<|")([^>"]+)(>|")' 3775871Snate@binkert.orgscanners.append(CPPScanner("SwigScan", [ ".i" ], "CPPPATH", swig_inc_re)) 3785871Snate@binkert.org 3795871Snate@binkert.org# replace the scanners list that has what we want 3805871Snate@binkert.orgenv['SCANNERS'] = scanners 3815871Snate@binkert.org 3823942Ssaidi@eecs.umich.edu# Platform-specific configuration. Note again that we assume that all 3833940Ssaidi@eecs.umich.edu# builds under a given build root run on the same host platform. 3843918Ssaidi@eecs.umich.educonf = Configure(env, 3853918Ssaidi@eecs.umich.edu conf_dir = joinpath(build_root, '.scons_config'), 3861858SN/A log_file = joinpath(build_root, 'scons_config.log')) 3873918Ssaidi@eecs.umich.edu 3883918Ssaidi@eecs.umich.edu# Check if we should compile a 64 bit binary on Mac OS X/Darwin 3893918Ssaidi@eecs.umich.edutry: 3903918Ssaidi@eecs.umich.edu import platform 3915571Snate@binkert.org uname = platform.uname() 3923940Ssaidi@eecs.umich.edu if uname[0] == 'Darwin' and compare_versions(uname[2], '9.0.0') >= 0: 3933940Ssaidi@eecs.umich.edu if int(subprocess.Popen('sysctl -n hw.cpu64bit_capable', shell=True, 3943918Ssaidi@eecs.umich.edu stdout=subprocess.PIPE, stderr=subprocess.STDOUT, 3953918Ssaidi@eecs.umich.edu close_fds=True).communicate()[0][0]): 3963918Ssaidi@eecs.umich.edu env.Append(CCFLAGS='-arch x86_64') 3973918Ssaidi@eecs.umich.edu env.Append(CFLAGS='-arch x86_64') 3983918Ssaidi@eecs.umich.edu env.Append(LINKFLAGS='-arch x86_64') 3993918Ssaidi@eecs.umich.edu env.Append(ASFLAGS='-arch x86_64') 4005871Snate@binkert.org env['OSX64bit'] = True 4013918Ssaidi@eecs.umich.eduexcept: 4023918Ssaidi@eecs.umich.edu pass 4033940Ssaidi@eecs.umich.edu 4043918Ssaidi@eecs.umich.edu# Recent versions of scons substitute a "Null" object for Configure() 4053918Ssaidi@eecs.umich.edu# when configuration isn't necessary, e.g., if the "--help" option is 4065397Ssaidi@eecs.umich.edu# present. Unfortuantely this Null object always returns false, 4075397Ssaidi@eecs.umich.edu# breaking all our configuration checks. We replace it with our own 4085397Ssaidi@eecs.umich.edu# more optimistic null object that returns True instead. 4095708Ssaidi@eecs.umich.eduif not conf: 4105708Ssaidi@eecs.umich.edu def NullCheck(*args, **kwargs): 4115708Ssaidi@eecs.umich.edu return True 4125708Ssaidi@eecs.umich.edu 4135708Ssaidi@eecs.umich.edu class NullConf: 4145397Ssaidi@eecs.umich.edu def __init__(self, env): 4151851SN/A self.env = env 4161851SN/A def Finish(self): 4171858SN/A return self.env 4185200Sstever@gmail.com def __getattr__(self, mname): 419955SN/A return NullCheck 4203053Sstever@eecs.umich.edu 4213053Sstever@eecs.umich.edu conf = NullConf(env) 4223053Sstever@eecs.umich.edu 4233053Sstever@eecs.umich.edu# Find Python include and library directories for embedding the 4243053Sstever@eecs.umich.edu# interpreter. For consistency, we will use the same Python 4253053Sstever@eecs.umich.edu# installation used to run scons (and thus this script). If you want 4263053Sstever@eecs.umich.edu# to link in an alternate version, see above for instructions on how 4275871Snate@binkert.org# to invoke scons with a different copy of the Python interpreter. 4283053Sstever@eecs.umich.edu 4294742Sstever@eecs.umich.edu# Get brief Python version name (e.g., "python2.4") for locating 4304742Sstever@eecs.umich.edu# include & library files 4313053Sstever@eecs.umich.edupy_version_name = 'python' + sys.version[:3] 4323053Sstever@eecs.umich.edu 4333053Sstever@eecs.umich.edu# include path, e.g. /usr/local/include/python2.4 4343053Sstever@eecs.umich.edupy_header_path = joinpath(sys.exec_prefix, 'include', py_version_name) 4353053Sstever@eecs.umich.eduenv.Append(CPPPATH = py_header_path) 4363053Sstever@eecs.umich.edu# verify that it works 4373053Sstever@eecs.umich.eduif not conf.CheckHeader('Python.h', '<>'): 4383053Sstever@eecs.umich.edu print "Error: can't find Python.h header in", py_header_path 4393053Sstever@eecs.umich.edu Exit(1) 4402667Sstever@eecs.umich.edu 4414554Sbinkertn@umich.edu# add library path too if it's not in the default place 4424554Sbinkertn@umich.edupy_lib_path = None 4432667Sstever@eecs.umich.eduif sys.exec_prefix != '/usr': 4444554Sbinkertn@umich.edu py_lib_path = joinpath(sys.exec_prefix, 'lib') 4454554Sbinkertn@umich.eduelif sys.platform == 'cygwin': 4464554Sbinkertn@umich.edu # cygwin puts the .dll in /bin for some reason 4474554Sbinkertn@umich.edu py_lib_path = '/bin' 4484554Sbinkertn@umich.eduif py_lib_path: 4494554Sbinkertn@umich.edu env.Append(LIBPATH = py_lib_path) 4504554Sbinkertn@umich.edu print 'Adding', py_lib_path, 'to LIBPATH for', py_version_name 4514781Snate@binkert.orgif not conf.CheckLib(py_version_name): 4524554Sbinkertn@umich.edu print "Error: can't find Python library", py_version_name 4534554Sbinkertn@umich.edu Exit(1) 4542667Sstever@eecs.umich.edu 4554554Sbinkertn@umich.edu# On Solaris you need to use libsocket for socket ops 4564554Sbinkertn@umich.eduif not conf.CheckLibWithHeader(None, 'sys/socket.h', 'C++', 'accept(0,0,0);'): 4574554Sbinkertn@umich.edu if not conf.CheckLibWithHeader('socket', 'sys/socket.h', 'C++', 'accept(0,0,0);'): 4584554Sbinkertn@umich.edu print "Can't find library with socket calls (e.g. accept())" 4592667Sstever@eecs.umich.edu Exit(1) 4604554Sbinkertn@umich.edu 4612667Sstever@eecs.umich.edu# Check for zlib. If the check passes, libz will be automatically 4624554Sbinkertn@umich.edu# added to the LIBS environment variable. 4634554Sbinkertn@umich.eduif not conf.CheckLibWithHeader('z', 'zlib.h', 'C++','zlibVersion();'): 4642667Sstever@eecs.umich.edu print 'Error: did not find needed zlib compression library '\ 4655522Snate@binkert.org 'and/or zlib.h header file.' 4665522Snate@binkert.org print ' Please install zlib and try again.' 4675522Snate@binkert.org Exit(1) 4685522Snate@binkert.org 4695522Snate@binkert.org# Check for <fenv.h> (C99 FP environment control) 4705522Snate@binkert.orghave_fenv = conf.CheckHeader('fenv.h', '<>') 4715522Snate@binkert.orgif not have_fenv: 4725522Snate@binkert.org print "Warning: Header file <fenv.h> not found." 4735522Snate@binkert.org print " This host has no IEEE FP rounding mode control." 4745522Snate@binkert.org 4755522Snate@binkert.org# Check for mysql. 4765522Snate@binkert.orgmysql_config = WhereIs('mysql_config') 4775522Snate@binkert.orghave_mysql = mysql_config != None 4785522Snate@binkert.org 4795522Snate@binkert.org# Check MySQL version. 4805522Snate@binkert.orgif have_mysql: 4815522Snate@binkert.org mysql_version = os.popen(mysql_config + ' --version').read() 4825522Snate@binkert.org min_mysql_version = '4.1' 4835522Snate@binkert.org if compare_versions(mysql_version, min_mysql_version) < 0: 4845522Snate@binkert.org print 'Warning: MySQL', min_mysql_version, 'or newer required.' 4855522Snate@binkert.org print ' Version', mysql_version, 'detected.' 4865522Snate@binkert.org have_mysql = False 4875522Snate@binkert.org 4885522Snate@binkert.org# Set up mysql_config commands. 4895522Snate@binkert.orgif have_mysql: 4905522Snate@binkert.org mysql_config_include = mysql_config + ' --include' 4912638Sstever@eecs.umich.edu if os.system(mysql_config_include + ' > /dev/null') != 0: 4922638Sstever@eecs.umich.edu # older mysql_config versions don't support --include, use 4932638Sstever@eecs.umich.edu # --cflags instead 4943716Sstever@eecs.umich.edu mysql_config_include = mysql_config + ' --cflags | sed s/\\\'//g' 4955522Snate@binkert.org # This seems to work in all versions 4965522Snate@binkert.org mysql_config_libs = mysql_config + ' --libs' 4975522Snate@binkert.org 4985522Snate@binkert.orgenv = conf.Finish() 4995522Snate@binkert.org 5005522Snate@binkert.org# Define the universe of supported ISAs 5011858SN/Aall_isa_list = [ ] 5025227Ssaidi@eecs.umich.eduExport('all_isa_list') 5035227Ssaidi@eecs.umich.edu 5045227Ssaidi@eecs.umich.edu# Define the universe of supported CPU models 5055227Ssaidi@eecs.umich.eduall_cpu_list = [ ] 5065227Ssaidi@eecs.umich.edudefault_cpus = [ ] 5075863Snate@binkert.orgExport('all_cpu_list', 'default_cpus') 5085227Ssaidi@eecs.umich.edu 5095227Ssaidi@eecs.umich.edu# Sticky options get saved in the options file so they persist from 5105227Ssaidi@eecs.umich.edu# one invocation to the next (unless overridden, in which case the new 5115227Ssaidi@eecs.umich.edu# value becomes sticky). 5125227Ssaidi@eecs.umich.edusticky_opts = Options(args=ARGUMENTS) 5135227Ssaidi@eecs.umich.eduExport('sticky_opts') 5145227Ssaidi@eecs.umich.edu 5155204Sstever@gmail.com# Non-sticky options only apply to the current build. 5165204Sstever@gmail.comnonsticky_opts = Options(args=ARGUMENTS) 5175204Sstever@gmail.comExport('nonsticky_opts') 5185204Sstever@gmail.com 5195204Sstever@gmail.com# Walk the tree and execute all SConsopts scripts that wil add to the 5205204Sstever@gmail.com# above options 5215204Sstever@gmail.comfor base_dir in base_dir_list: 5225204Sstever@gmail.com for root, dirs, files in os.walk(base_dir): 5235204Sstever@gmail.com if 'SConsopts' in files: 5245204Sstever@gmail.com print "Reading", joinpath(root, 'SConsopts') 5255204Sstever@gmail.com SConscript(joinpath(root, 'SConsopts')) 5265204Sstever@gmail.com 5275204Sstever@gmail.comall_isa_list.sort() 5285204Sstever@gmail.comall_cpu_list.sort() 5295204Sstever@gmail.comdefault_cpus.sort() 5305204Sstever@gmail.com 5315204Sstever@gmail.comsticky_opts.AddOptions( 5325204Sstever@gmail.com EnumOption('TARGET_ISA', 'Target ISA', 'alpha', all_isa_list), 5335204Sstever@gmail.com BoolOption('FULL_SYSTEM', 'Full-system support', False), 5343118Sstever@eecs.umich.edu # There's a bug in scons 0.96.1 that causes ListOptions with list 5353118Sstever@eecs.umich.edu # values (more than one value) not to be able to be restored from 5363118Sstever@eecs.umich.edu # a saved option file. If this causes trouble then upgrade to 5373118Sstever@eecs.umich.edu # scons 0.96.90 or later. 5383118Sstever@eecs.umich.edu ListOption('CPU_MODELS', 'CPU models', default_cpus, all_cpu_list), 5395863Snate@binkert.org BoolOption('NO_FAST_ALLOC', 'Disable fast object allocator', False), 5403118Sstever@eecs.umich.edu BoolOption('EFENCE', 'Link with Electric Fence malloc debugger', 5415863Snate@binkert.org False), 5423118Sstever@eecs.umich.edu BoolOption('SS_COMPATIBLE_FP', 5435863Snate@binkert.org 'Make floating-point results compatible with SimpleScalar', 5445863Snate@binkert.org False), 5455863Snate@binkert.org BoolOption('USE_SSE2', 5465863Snate@binkert.org 'Compile for SSE2 (-msse2) to get IEEE FP on x86 hosts', 5475863Snate@binkert.org False), 5485863Snate@binkert.org BoolOption('USE_MYSQL', 'Use MySQL for stats output', have_mysql), 5495863Snate@binkert.org BoolOption('USE_FENV', 'Use <fenv.h> IEEE mode control', have_fenv), 5505863Snate@binkert.org BoolOption('USE_CHECKER', 'Use checker for detailed CPU models', False), 5515863Snate@binkert.org BoolOption('BATCH', 'Use batch pool for build and tests', False), 5525863Snate@binkert.org ('BATCH_CMD', 'Batch pool submission command name', 'qdo'), 5535863Snate@binkert.org ('PYTHONHOME', 5545863Snate@binkert.org 'Override the default PYTHONHOME for this system (use with caution)', 5555863Snate@binkert.org '%s:%s' % (sys.prefix, sys.exec_prefix)), 5565863Snate@binkert.org ) 5575863Snate@binkert.org 5585863Snate@binkert.orgnonsticky_opts.AddOptions( 5595863Snate@binkert.org BoolOption('update_ref', 'Update test reference outputs', False) 5605863Snate@binkert.org ) 5615863Snate@binkert.org 5625863Snate@binkert.org# These options get exported to #defines in config/*.hh (see src/SConscript). 5635863Snate@binkert.orgenv.ExportOptions = ['FULL_SYSTEM', 'ALPHA_TLASER', 'USE_FENV', \ 5645863Snate@binkert.org 'USE_MYSQL', 'NO_FAST_ALLOC', 'SS_COMPATIBLE_FP', \ 5655863Snate@binkert.org 'USE_CHECKER', 'PYTHONHOME', 'TARGET_ISA'] 5665863Snate@binkert.org 5675863Snate@binkert.org# Define a handy 'no-op' action 5683118Sstever@eecs.umich.edudef no_action(target, source, env): 5695863Snate@binkert.org return 0 5703118Sstever@eecs.umich.edu 5713118Sstever@eecs.umich.eduenv.NoAction = Action(no_action, None) 5725863Snate@binkert.org 5735863Snate@binkert.org################################################### 5745863Snate@binkert.org# 5755863Snate@binkert.org# Define a SCons builder for configuration flag headers. 5765863Snate@binkert.org# 5775863Snate@binkert.org################################################### 5783118Sstever@eecs.umich.edu 5793483Ssaidi@eecs.umich.edu# This function generates a config header file that #defines the 5803494Ssaidi@eecs.umich.edu# option symbol to the current option setting (0 or 1). The source 5813494Ssaidi@eecs.umich.edu# operands are the name of the option and a Value node containing the 5823483Ssaidi@eecs.umich.edu# value of the option. 5833483Ssaidi@eecs.umich.edudef build_config_file(target, source, env): 5843483Ssaidi@eecs.umich.edu (option, value) = [s.get_contents() for s in source] 5853053Sstever@eecs.umich.edu f = file(str(target[0]), 'w') 5863053Sstever@eecs.umich.edu print >> f, '#define', option, value 5873918Ssaidi@eecs.umich.edu f.close() 5883053Sstever@eecs.umich.edu return None 5893053Sstever@eecs.umich.edu 5903053Sstever@eecs.umich.edu# Generate the message to be printed when building the config file. 5913053Sstever@eecs.umich.edudef build_config_file_string(target, source, env): 5923053Sstever@eecs.umich.edu (option, value) = [s.get_contents() for s in source] 5931858SN/A return "Defining %s as %s in %s." % (option, value, target[0]) 5941858SN/A 5951858SN/A# Combine the two functions into a scons Action object. 5961858SN/Aconfig_action = Action(build_config_file, build_config_file_string) 5971858SN/A 5981858SN/A# The emitter munges the source & target node lists to reflect what 5995863Snate@binkert.org# we're really doing. 6005863Snate@binkert.orgdef config_emitter(target, source, env): 6011859SN/A # extract option name from Builder arg 6025863Snate@binkert.org option = str(target[0]) 6031858SN/A # True target is config header file 6045863Snate@binkert.org target = joinpath('config', option.lower() + '.hh') 6051858SN/A val = env[option] 6061859SN/A if isinstance(val, bool): 6071859SN/A # Force value to 0/1 6085863Snate@binkert.org val = int(val) 6093053Sstever@eecs.umich.edu elif isinstance(val, str): 6103053Sstever@eecs.umich.edu val = '"' + val + '"' 6113053Sstever@eecs.umich.edu 6123053Sstever@eecs.umich.edu # Sources are option name & value (packaged in SCons Value nodes) 6131859SN/A return ([target], [Value(option), Value(val)]) 6141859SN/A 6151859SN/Aconfig_builder = Builder(emitter = config_emitter, action = config_action) 6161859SN/A 6171859SN/Aenv.Append(BUILDERS = { 'ConfigFile' : config_builder }) 6181859SN/A 6191859SN/A################################################### 6201859SN/A# 6211862SN/A# Define a SCons builder for copying files. This is used by the 6221859SN/A# Python zipfile code in src/python/SConscript, but is placed up here 6231859SN/A# since it's potentially more generally applicable. 6241859SN/A# 6255863Snate@binkert.org################################################### 6265863Snate@binkert.org 6275863Snate@binkert.orgcopy_builder = Builder(action = Copy("$TARGET", "$SOURCE")) 6285863Snate@binkert.org 6291858SN/Aenv.Append(BUILDERS = { 'CopyFile' : copy_builder }) 6301858SN/A 6315863Snate@binkert.org################################################### 6325863Snate@binkert.org# 6335863Snate@binkert.org# Define a simple SCons builder to concatenate files. 6345863Snate@binkert.org# 6355863Snate@binkert.org# Used to append the Python zip archive to the executable. 6365871Snate@binkert.org# 6375871Snate@binkert.org################################################### 6382139SN/A 6394202Sbinkertn@umich.educoncat_builder = Builder(action = Action(['cat $SOURCES > $TARGET', 6404202Sbinkertn@umich.edu 'chmod +x $TARGET'])) 6412139SN/A 6422155SN/Aenv.Append(BUILDERS = { 'Concat' : concat_builder }) 6434202Sbinkertn@umich.edu 6444202Sbinkertn@umich.edu 6454202Sbinkertn@umich.edu# libelf build is shared across all configs in the build root. 6462155SN/Aenv.SConscript('ext/libelf/SConscript', 6475863Snate@binkert.org build_dir = joinpath(build_root, 'libelf'), 6481869SN/A exports = 'env') 6491869SN/A 6505863Snate@binkert.org################################################### 6515863Snate@binkert.org# 6524202Sbinkertn@umich.edu# This function is used to set up a directory with switching headers 6535863Snate@binkert.org# 6545863Snate@binkert.org################################################### 6555863Snate@binkert.org 6564202Sbinkertn@umich.eduenv['ALL_ISA_LIST'] = all_isa_list 6574202Sbinkertn@umich.edudef make_switching_dir(dirname, switch_headers, env): 6585863Snate@binkert.org # Generate the header. target[0] is the full path of the output 6595742Snate@binkert.org # header to generate. 'source' is a dummy variable, since we get the 6605742Snate@binkert.org # list of ISAs from env['ALL_ISA_LIST']. 6615341Sstever@gmail.com def gen_switch_hdr(target, source, env): 6625342Sstever@gmail.com fname = str(target[0]) 6635342Sstever@gmail.com basename = os.path.basename(fname) 6644202Sbinkertn@umich.edu f = open(fname, 'w') 6654202Sbinkertn@umich.edu f.write('#include "arch/isa_specific.hh"\n') 6664202Sbinkertn@umich.edu cond = '#if' 6674202Sbinkertn@umich.edu for isa in all_isa_list: 6684202Sbinkertn@umich.edu f.write('%s THE_ISA == %s_ISA\n#include "%s/%s/%s"\n' 6695863Snate@binkert.org % (cond, isa.upper(), dirname, isa, basename)) 6705863Snate@binkert.org cond = '#elif' 6715863Snate@binkert.org f.write('#else\n#error "THE_ISA not set"\n#endif\n') 6725863Snate@binkert.org f.close() 6735863Snate@binkert.org return 0 6745863Snate@binkert.org 6755863Snate@binkert.org # String to print when generating header 6765863Snate@binkert.org def gen_switch_hdr_string(target, source, env): 6775863Snate@binkert.org return "Generating switch header " + str(target[0]) 6785863Snate@binkert.org 6795863Snate@binkert.org # Build SCons Action object. 'varlist' specifies env vars that this 6805863Snate@binkert.org # action depends on; when env['ALL_ISA_LIST'] changes these actions 6815863Snate@binkert.org # should get re-executed. 6825863Snate@binkert.org switch_hdr_action = Action(gen_switch_hdr, gen_switch_hdr_string, 6835863Snate@binkert.org varlist=['ALL_ISA_LIST']) 6845863Snate@binkert.org 6855863Snate@binkert.org # Instantiate actions for each header 6865863Snate@binkert.org for hdr in switch_headers: 6875863Snate@binkert.org env.Command(hdr, [], switch_hdr_action) 6885863Snate@binkert.orgExport('make_switching_dir') 6891869SN/A 6901858SN/A################################################### 6915863Snate@binkert.org# 6925863Snate@binkert.org# Define build environments for selected configurations. 6931869SN/A# 6941858SN/A################################################### 6955863Snate@binkert.org 6965863Snate@binkert.org# rename base env 6975863Snate@binkert.orgbase_env = env 6985863Snate@binkert.org 6995863Snate@binkert.orgfor build_path in build_paths: 7001858SN/A print "Building in", build_path 701955SN/A 702955SN/A # Make a copy of the build-root environment to use for this config. 7031869SN/A env = base_env.Copy() 7041869SN/A env['BUILDDIR'] = build_path 7051869SN/A 7061869SN/A # build_dir is the tail component of build path, and is used to 7071869SN/A # determine the build parameters (e.g., 'ALPHA_SE') 7085863Snate@binkert.org (build_root, build_dir) = os.path.split(build_path) 7095863Snate@binkert.org 7105863Snate@binkert.org # Set env options according to the build directory config. 7111869SN/A sticky_opts.files = [] 7125863Snate@binkert.org # Options for $BUILD_ROOT/$BUILD_DIR are stored in 7131869SN/A # $BUILD_ROOT/options/$BUILD_DIR so you can nuke 7145863Snate@binkert.org # $BUILD_ROOT/$BUILD_DIR without losing your options settings. 7151869SN/A current_opts_file = joinpath(build_root, 'options', build_dir) 7161869SN/A if isfile(current_opts_file): 7171869SN/A sticky_opts.files.append(current_opts_file) 7181869SN/A print "Using saved options file %s" % current_opts_file 7191869SN/A else: 7205863Snate@binkert.org # Build dir-specific options file doesn't exist. 7215863Snate@binkert.org 7221869SN/A # Make sure the directory is there so we can create it later 7231869SN/A opt_dir = os.path.dirname(current_opts_file) 7241869SN/A if not isdir(opt_dir): 7251869SN/A os.mkdir(opt_dir) 7261869SN/A 7271869SN/A # Get default build options from source tree. Options are 7281869SN/A # normally determined by name of $BUILD_DIR, but can be 7295863Snate@binkert.org # overriden by 'default=' arg on command line. 7305863Snate@binkert.org default_opts_file = joinpath('build_opts', 7311869SN/A ARGUMENTS.get('default', build_dir)) 7325863Snate@binkert.org if isfile(default_opts_file): 7335863Snate@binkert.org sticky_opts.files.append(default_opts_file) 7343356Sbinkertn@umich.edu print "Options file %s not found,\n using defaults in %s" \ 7353356Sbinkertn@umich.edu % (current_opts_file, default_opts_file) 7363356Sbinkertn@umich.edu else: 7373356Sbinkertn@umich.edu print "Error: cannot find options file %s or %s" \ 7383356Sbinkertn@umich.edu % (current_opts_file, default_opts_file) 7394781Snate@binkert.org Exit(1) 7405863Snate@binkert.org 7415863Snate@binkert.org # Apply current option settings to env 7421869SN/A sticky_opts.Update(env) 7431869SN/A nonsticky_opts.Update(env) 7441869SN/A 7451869SN/A help_text += "\nSticky options for %s:\n" % build_dir \ 7461869SN/A + sticky_opts.GenerateHelpText(env) \ 7472638Sstever@eecs.umich.edu + "\nNon-sticky options for %s:\n" % build_dir \ 7482638Sstever@eecs.umich.edu + nonsticky_opts.GenerateHelpText(env) 7495871Snate@binkert.org 7502638Sstever@eecs.umich.edu # Process option settings. 7515749Scws3k@cs.virginia.edu 7525749Scws3k@cs.virginia.edu if not have_fenv and env['USE_FENV']: 7535871Snate@binkert.org print "Warning: <fenv.h> not available; " \ 7545749Scws3k@cs.virginia.edu "forcing USE_FENV to False in", build_dir + "." 7551869SN/A env['USE_FENV'] = False 7561869SN/A 7573546Sgblack@eecs.umich.edu if not env['USE_FENV']: 7583546Sgblack@eecs.umich.edu print "Warning: No IEEE FP rounding mode control in", build_dir + "." 7593546Sgblack@eecs.umich.edu print " FP results may deviate slightly from other platforms." 7603546Sgblack@eecs.umich.edu 7614202Sbinkertn@umich.edu if env['EFENCE']: 7625863Snate@binkert.org env.Append(LIBS=['efence']) 7633546Sgblack@eecs.umich.edu 7643546Sgblack@eecs.umich.edu if env['USE_MYSQL']: 7653546Sgblack@eecs.umich.edu if not have_mysql: 7663546Sgblack@eecs.umich.edu print "Warning: MySQL not available; " \ 7674781Snate@binkert.org "forcing USE_MYSQL to False in", build_dir + "." 7685863Snate@binkert.org env['USE_MYSQL'] = False 7694781Snate@binkert.org else: 7704781Snate@binkert.org print "Compiling in", build_dir, "with MySQL support." 7714781Snate@binkert.org env.ParseConfig(mysql_config_libs) 7724781Snate@binkert.org env.ParseConfig(mysql_config_include) 7734781Snate@binkert.org 7745863Snate@binkert.org # Save sticky option settings back to current options file 7754781Snate@binkert.org sticky_opts.Save(current_opts_file, env) 7764781Snate@binkert.org 7774781Snate@binkert.org # Do this after we save setting back, or else we'll tack on an 7784781Snate@binkert.org # extra 'qdo' every time we run scons. 7793546Sgblack@eecs.umich.edu if env['BATCH']: 7803546Sgblack@eecs.umich.edu env['CC'] = env['BATCH_CMD'] + ' ' + env['CC'] 7813546Sgblack@eecs.umich.edu env['CXX'] = env['BATCH_CMD'] + ' ' + env['CXX'] 7824781Snate@binkert.org 7833546Sgblack@eecs.umich.edu if env['USE_SSE2']: 7843546Sgblack@eecs.umich.edu env.Append(CCFLAGS='-msse2') 7853546Sgblack@eecs.umich.edu 7863546Sgblack@eecs.umich.edu # The src/SConscript file sets up the build rules in 'env' according 7873546Sgblack@eecs.umich.edu # to the configured options. It returns a list of environments, 7883546Sgblack@eecs.umich.edu # one for each variant build (debug, opt, etc.) 7893546Sgblack@eecs.umich.edu envList = SConscript('src/SConscript', build_dir = build_path, 7903546Sgblack@eecs.umich.edu exports = 'env') 7913546Sgblack@eecs.umich.edu 7923546Sgblack@eecs.umich.edu # Set up the regression tests for each build. 7934202Sbinkertn@umich.edu for e in envList: 7943546Sgblack@eecs.umich.edu SConscript('tests/SConscript', 7953546Sgblack@eecs.umich.edu build_dir = joinpath(build_path, 'tests', e.Label), 7963546Sgblack@eecs.umich.edu exports = { 'env' : e }, duplicate = False) 797955SN/A 798955SN/AHelp(help_text) 799955SN/A 800955SN/A 8011858SN/A################################################### 8021858SN/A# 8031858SN/A# Let SCons do its thing. At this point SCons will use the defined 8045863Snate@binkert.org# build environments to build the requested targets. 8055863Snate@binkert.org# 8065343Sstever@gmail.com################################################### 8075343Sstever@gmail.com 8085863Snate@binkert.org