SConstruct revision 4773
1955SN/A# -*- mode:python -*- 2955SN/A 312230Sgiacomo.travaglini@arm.com# Copyright (c) 2004-2005 The Regents of The University of Michigan 49812Sandreas.hansson@arm.com# All rights reserved. 59812Sandreas.hansson@arm.com# 69812Sandreas.hansson@arm.com# Redistribution and use in source and binary forms, with or without 79812Sandreas.hansson@arm.com# modification, are permitted provided that the following conditions are 89812Sandreas.hansson@arm.com# met: redistributions of source code must retain the above copyright 99812Sandreas.hansson@arm.com# notice, this list of conditions and the following disclaimer; 109812Sandreas.hansson@arm.com# redistributions in binary form must reproduce the above copyright 119812Sandreas.hansson@arm.com# notice, this list of conditions and the following disclaimer in the 129812Sandreas.hansson@arm.com# documentation and/or other materials provided with the distribution; 139812Sandreas.hansson@arm.com# neither the name of the copyright holders nor the names of its 149812Sandreas.hansson@arm.com# contributors may be used to endorse or promote products derived from 157816Ssteve.reinhardt@amd.com# this software without specific prior written permission. 165871Snate@binkert.org# 171762SN/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 30955SN/A 31955SN/A################################################### 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>' 37955SN/A# to build some other configuration (e.g., 'build/ALPHA_FS/m5.opt' for 38955SN/A# the optimized full-system version). 39955SN/A# 40955SN/A# 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 422665Ssaidi@eecs.umich.edu# expects that all configs under the same build directory are being 432665Ssaidi@eecs.umich.edu# built for the same host system. 445863Snate@binkert.org# 45955SN/A# Examples: 46955SN/A# 47955SN/A# The following two commands are equivalent. The '-u' option tells 48955SN/A# scons to search up the directory tree for this SConstruct file. 49955SN/A# % cd <path-to-src>/m5 ; scons build/ALPHA_FS/m5.debug 508878Ssteve.reinhardt@amd.com# % cd <path-to-src>/m5/build/ALPHA_FS; scons -u m5.debug 512632Sstever@eecs.umich.edu# 528878Ssteve.reinhardt@amd.com# The following two commands are equivalent and demonstrate building 532632Sstever@eecs.umich.edu# in a directory outside of the source tree. The '-C' option tells 54955SN/A# scons to chdir to the specified directory to find this SConstruct 558878Ssteve.reinhardt@amd.com# file. 562632Sstever@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 612761Sstever@eecs.umich.edu# file), you can use 'scons -h' to print all the M5-specific build 622761Sstever@eecs.umich.edu# options as well. 632761Sstever@eecs.umich.edu# 648878Ssteve.reinhardt@amd.com################################################### 658878Ssteve.reinhardt@amd.com 662761Sstever@eecs.umich.eduimport sys 672761Sstever@eecs.umich.eduimport os 682761Sstever@eecs.umich.eduimport subprocess 692761Sstever@eecs.umich.edu 702761Sstever@eecs.umich.edufrom os.path import isdir, join as joinpath 718878Ssteve.reinhardt@amd.com 728878Ssteve.reinhardt@amd.com# Check for recent-enough Python and SCons versions. If your system's 732632Sstever@eecs.umich.edu# default installation of Python is not recent enough, you can use a 742632Sstever@eecs.umich.edu# non-default installation of the Python interpreter by either (1) 758878Ssteve.reinhardt@amd.com# rearranging your PATH so that scons finds the non-default 'python' 768878Ssteve.reinhardt@amd.com# first or (2) explicitly invoking an alternative interpreter on the 772632Sstever@eecs.umich.edu# scons script, e.g., "/usr/local/bin/python2.4 `which scons` [args]". 78955SN/AEnsurePythonVersion(2,4) 79955SN/A 80955SN/A# Ironically, SCons 0.96 dies if you give EnsureSconsVersion a 816654Snate@binkert.org# 3-element version number. 8210196SCurtis.Dunham@arm.commin_scons_version = (0,96,91) 83955SN/Atry: 845396Ssaidi@eecs.umich.edu EnsureSConsVersion(*min_scons_version) 8511401Sandreas.sandberg@arm.comexcept: 865863Snate@binkert.org print "Error checking current SCons version." 875863Snate@binkert.org print "SCons", ".".join(map(str,min_scons_version)), "or greater required." 884202Sbinkertn@umich.edu 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 93955SN/A 946654Snate@binkert.org# Path to the M5 source tree. 955273Sstever@gmail.comSRCDIR = joinpath(ROOT, 'src') 965871Snate@binkert.org 975273Sstever@gmail.com# tell python where to find m5 python code 986654Snate@binkert.orgsys.path.append(joinpath(ROOT, 'src/python')) 995396Ssaidi@eecs.umich.edu 1008120Sgblack@eecs.umich.edudef check_style_hook(ui): 1018120Sgblack@eecs.umich.edu ui.readconfig(joinpath(ROOT, '.hg', 'hgrc')) 1028120Sgblack@eecs.umich.edu style_hook = ui.config('hooks', 'pretxncommit.style', None) 1038120Sgblack@eecs.umich.edu 1048120Sgblack@eecs.umich.edu if not style_hook: 1058120Sgblack@eecs.umich.edu print """\ 1068120Sgblack@eecs.umich.eduYou're missing the M5 style hook. 1078120Sgblack@eecs.umich.eduPlease install the hook so we can ensure that all code fits a common style. 1088879Ssteve.reinhardt@amd.com 1098879Ssteve.reinhardt@amd.comAll you'd need to do is add the following lines to your repository .hg/hgrc 1108879Ssteve.reinhardt@amd.comor your personal .hgrc 1118879Ssteve.reinhardt@amd.com---------------- 1128879Ssteve.reinhardt@amd.com 1138879Ssteve.reinhardt@amd.com[extensions] 1148879Ssteve.reinhardt@amd.comstyle = %s/util/style.py 1158879Ssteve.reinhardt@amd.com 1168879Ssteve.reinhardt@amd.com[hooks] 1178879Ssteve.reinhardt@amd.compretxncommit.style = python:style.check_whitespace 1188879Ssteve.reinhardt@amd.com""" % (ROOT) 1198879Ssteve.reinhardt@amd.com sys.exit(1) 1208879Ssteve.reinhardt@amd.com 1218120Sgblack@eecs.umich.eduif isdir(joinpath(ROOT, '.hg')): 1228120Sgblack@eecs.umich.edu try: 1238120Sgblack@eecs.umich.edu from mercurial import ui 1248120Sgblack@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# 1338120Sgblack@eecs.umich.edu################################################### 1348120Sgblack@eecs.umich.edu 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 13910458Sandreas.hansson@arm.comdef rfind(l, elt, offs = -1): 14010458Sandreas.hansson@arm.com for i in range(len(l)+offs, 0, -1): 14110458Sandreas.hansson@arm.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. 1469227Sandreas.hansson@arm.com# E.g., compare_version('1.3.25', '1.4.1') 1479227Sandreas.hansson@arm.com# returns -1, 0, 1 if v1 is <, ==, > v2 14812063Sgabeblack@google.comdef compare_versions(v1, v2): 14912063Sgabeblack@google.com # Convert dotted strings to lists 15012063Sgabeblack@google.com v1 = map(int, v1.split('.')) 1518879Ssteve.reinhardt@amd.com v2 = map(int, v2.split('.')) 1528879Ssteve.reinhardt@amd.com # Compare corresponding elements of lists 1538879Ssteve.reinhardt@amd.com for n1,n2 in zip(v1, v2): 1548879Ssteve.reinhardt@amd.com if n1 < n2: return -1 15510453SAndrew.Bardsley@arm.com if n1 > n2: return 1 15610453SAndrew.Bardsley@arm.com # all corresponding values are equal... see if one has extra values 15710453SAndrew.Bardsley@arm.com if len(v1) < len(v2): return -1 15810456SCurtis.Dunham@arm.com if len(v1) > len(v2): return 1 15910456SCurtis.Dunham@arm.com return 0 16010456SCurtis.Dunham@arm.com 16110457Sandreas.hansson@arm.com# Each target must have 'build' in the interior of the path; the 16210457Sandreas.hansson@arm.com# directory below this will determine the build parameters. For 16311342Sandreas.hansson@arm.com# example, for target 'foo/bar/build/ALPHA_SE/arch/alpha/blah.do' we 16411342Sandreas.hansson@arm.com# recognize that ALPHA_SE specifies the configuration because it 1658120Sgblack@eecs.umich.edu# follow 'build' in the bulid path. 16612063Sgabeblack@google.com 16712063Sgabeblack@google.com# Generate absolute paths to targets so we can see where the build dir is 16812063Sgabeblack@google.comif COMMAND_LINE_TARGETS: 16912063Sgabeblack@google.com # Ask SCons which directory it was invoked from 1705871Snate@binkert.org launch_dir = GetLaunchDir() 1715871Snate@binkert.org # Make targets relative to invocation directory 1726121Snate@binkert.org abs_targets = map(lambda x: os.path.normpath(joinpath(launch_dir, str(x))), 1735871Snate@binkert.org COMMAND_LINE_TARGETS) 1745871Snate@binkert.orgelse: 1759926Sstan.czerniawski@arm.com # Default targets are relative to root of tree 17612243Sgabeblack@google.com abs_targets = map(lambda x: os.path.normpath(joinpath(ROOT, str(x))), 1771533SN/A DEFAULT_TARGETS) 17812246Sgabeblack@google.com 17912246Sgabeblack@google.com 18012246Sgabeblack@google.com# Generate a list of the unique build roots and configs that the 18112246Sgabeblack@google.com# collected targets reference. 1829239Sandreas.hansson@arm.combuild_paths = [] 1839239Sandreas.hansson@arm.combuild_root = None 1849239Sandreas.hansson@arm.comfor t in abs_targets: 1859239Sandreas.hansson@arm.com path_dirs = t.split('/') 1869239Sandreas.hansson@arm.com try: 1879239Sandreas.hansson@arm.com build_top = rfind(path_dirs, 'build', -2) 1889239Sandreas.hansson@arm.com except: 189955SN/A print "Error: no non-leaf 'build' dir found on target path", t 190955SN/A Exit(1) 1912632Sstever@eecs.umich.edu this_build_root = joinpath('/',*path_dirs[:build_top+1]) 1922632Sstever@eecs.umich.edu if not build_root: 193955SN/A build_root = this_build_root 194955SN/A else: 195955SN/A if this_build_root != build_root: 196955SN/A print "Error: build targets not under same build root\n"\ 1978878Ssteve.reinhardt@amd.com " %s\n %s" % (build_root, this_build_root) 198955SN/A Exit(1) 1992632Sstever@eecs.umich.edu build_path = joinpath('/',*path_dirs[:build_top+2]) 2002632Sstever@eecs.umich.edu if build_path not in build_paths: 2012632Sstever@eecs.umich.edu build_paths.append(build_path) 2022632Sstever@eecs.umich.edu 2032632Sstever@eecs.umich.edu################################################### 2042632Sstever@eecs.umich.edu# 2052632Sstever@eecs.umich.edu# Set up the default build environment. This environment is copied 2068268Ssteve.reinhardt@amd.com# and modified according to each selected configuration. 2078268Ssteve.reinhardt@amd.com# 2088268Ssteve.reinhardt@amd.com################################################### 2098268Ssteve.reinhardt@amd.com 2108268Ssteve.reinhardt@amd.comenv = Environment(ENV = os.environ, # inherit user's environment vars 2118268Ssteve.reinhardt@amd.com ROOT = ROOT, 2128268Ssteve.reinhardt@amd.com SRCDIR = SRCDIR) 2132632Sstever@eecs.umich.edu 2142632Sstever@eecs.umich.edu#Parse CC/CXX early so that we use the correct compiler for 2152632Sstever@eecs.umich.edu# to test for dependencies/versions/libraries/includes 2162632Sstever@eecs.umich.eduif ARGUMENTS.get('CC', None): 2178268Ssteve.reinhardt@amd.com env['CC'] = ARGUMENTS.get('CC') 2182632Sstever@eecs.umich.edu 2198268Ssteve.reinhardt@amd.comif ARGUMENTS.get('CXX', None): 2208268Ssteve.reinhardt@amd.com env['CXX'] = ARGUMENTS.get('CXX') 2218268Ssteve.reinhardt@amd.com 2228268Ssteve.reinhardt@amd.comExport('env') 2233718Sstever@eecs.umich.edu 2242634Sstever@eecs.umich.eduenv.SConsignFile(joinpath(build_root,"sconsign")) 2252634Sstever@eecs.umich.edu 2265863Snate@binkert.org# Default duplicate option is to use hard links, but this messes up 2272638Sstever@eecs.umich.edu# when you use emacs to edit a file in the target dir, as emacs moves 2288268Ssteve.reinhardt@amd.com# file to file~ then copies to file, breaking the link. Symbolic 2292632Sstever@eecs.umich.edu# (soft) links work better. 2302632Sstever@eecs.umich.eduenv.SetOption('duplicate', 'soft-copy') 2312632Sstever@eecs.umich.edu 2322632Sstever@eecs.umich.edu# I waffle on this setting... it does avoid a few painful but 2332632Sstever@eecs.umich.edu# unnecessary builds, but it also seems to make trivial builds take 2341858SN/A# noticeably longer. 2353716Sstever@eecs.umich.eduif False: 2362638Sstever@eecs.umich.edu env.TargetSignatures('content') 2372638Sstever@eecs.umich.edu 2382638Sstever@eecs.umich.edu# M5_PLY is used by isa_parser.py to find the PLY package. 2392638Sstever@eecs.umich.eduenv.Append(ENV = { 'M5_PLY' : Dir('ext/ply') }) 2402638Sstever@eecs.umich.eduenv['GCC'] = False 2412638Sstever@eecs.umich.eduenv['SUNCC'] = False 2422638Sstever@eecs.umich.eduenv['ICC'] = False 2435863Snate@binkert.orgenv['GCC'] = subprocess.Popen(env['CXX'] + ' --version', shell=True, 2445863Snate@binkert.org stdout=subprocess.PIPE, stderr=subprocess.STDOUT, 2455863Snate@binkert.org close_fds=True).communicate()[0].find('GCC') >= 0 246955SN/Aenv['SUNCC'] = subprocess.Popen(env['CXX'] + ' -V', shell=True, 2475341Sstever@gmail.com stdout=subprocess.PIPE, stderr=subprocess.STDOUT, 2485341Sstever@gmail.com close_fds=True).communicate()[0].find('Sun C++') >= 0 2495863Snate@binkert.orgenv['ICC'] = subprocess.Popen(env['CXX'] + ' -V', shell=True, 2507756SAli.Saidi@ARM.com stdout=subprocess.PIPE, stderr=subprocess.STDOUT, 2515341Sstever@gmail.com close_fds=True).communicate()[0].find('Intel') >= 0 2526121Snate@binkert.orgif env['GCC'] + env['SUNCC'] + env['ICC'] > 1: 2534494Ssaidi@eecs.umich.edu print 'Error: How can we have two at the same time?' 2546121Snate@binkert.org Exit(1) 2551105SN/A 2562667Sstever@eecs.umich.edu 2572667Sstever@eecs.umich.edu# Set up default C++ compiler flags 2582667Sstever@eecs.umich.eduif env['GCC']: 2592667Sstever@eecs.umich.edu env.Append(CCFLAGS='-pipe') 2606121Snate@binkert.org env.Append(CCFLAGS='-fno-strict-aliasing') 2612667Sstever@eecs.umich.edu env.Append(CCFLAGS=Split('-Wall -Wno-sign-compare -Werror -Wundef')) 2625341Sstever@gmail.comelif env['ICC']: 2635863Snate@binkert.org pass #Fix me... add warning flags once we clean up icc warnings 2645341Sstever@gmail.comelif env['SUNCC']: 2655341Sstever@gmail.com env.Append(CCFLAGS='-Qoption ccfe') 2665341Sstever@gmail.com env.Append(CCFLAGS='-features=gcc') 2678120Sgblack@eecs.umich.edu env.Append(CCFLAGS='-features=extensions') 2685341Sstever@gmail.com env.Append(CCFLAGS='-library=stlport4') 2698120Sgblack@eecs.umich.edu env.Append(CCFLAGS='-xar') 2705341Sstever@gmail.com# env.Append(CCFLAGS='-instances=semiexplicit') 2718120Sgblack@eecs.umich.eduelse: 2726121Snate@binkert.org print 'Error: Don\'t know what compiler options to use for your compiler.' 2736121Snate@binkert.org print ' Please fix SConstruct and src/SConscript and try again.' 2749396Sandreas.hansson@arm.com Exit(1) 2755397Ssaidi@eecs.umich.edu 2765397Ssaidi@eecs.umich.eduif sys.platform == 'cygwin': 2777727SAli.Saidi@ARM.com # cygwin has some header file issues... 2788268Ssteve.reinhardt@amd.com env.Append(CCFLAGS=Split("-Wno-uninitialized")) 2796168Snate@binkert.orgenv.Append(CPPPATH=[Dir('ext/dnet')]) 2805341Sstever@gmail.com 2818120Sgblack@eecs.umich.edu# Check for SWIG 2828120Sgblack@eecs.umich.eduif not env.has_key('SWIG'): 2838120Sgblack@eecs.umich.edu print 'Error: SWIG utility not found.' 2846814Sgblack@eecs.umich.edu print ' Please install (see http://www.swig.org) and retry.' 2855863Snate@binkert.org Exit(1) 2868120Sgblack@eecs.umich.edu 2875341Sstever@gmail.com# Check for appropriate SWIG version 2885863Snate@binkert.orgswig_version = os.popen('swig -version').read().split() 2898268Ssteve.reinhardt@amd.com# First 3 words should be "SWIG Version x.y.z" 2906121Snate@binkert.orgif len(swig_version) < 3 or \ 2916121Snate@binkert.org swig_version[0] != 'SWIG' or swig_version[1] != 'Version': 2928268Ssteve.reinhardt@amd.com print 'Error determining SWIG version.' 2935742Snate@binkert.org Exit(1) 2945742Snate@binkert.org 2955341Sstever@gmail.commin_swig_version = '1.3.28' 2965742Snate@binkert.orgif compare_versions(swig_version[2], min_swig_version) < 0: 2975742Snate@binkert.org print 'Error: SWIG version', min_swig_version, 'or newer required.' 2985341Sstever@gmail.com print ' Installed version:', swig_version[2] 2996017Snate@binkert.org Exit(1) 3006121Snate@binkert.org 3016017Snate@binkert.org# Set up SWIG flags & scanner 30212158Sandreas.sandberg@arm.comswig_flags=Split('-c++ -python -modern -templatereduce $_CPPINCFLAGS') 30312158Sandreas.sandberg@arm.comenv.Append(SWIGFLAGS=swig_flags) 30412158Sandreas.sandberg@arm.com 3058120Sgblack@eecs.umich.edu# filter out all existing swig scanners, they mess up the dependency 3067756SAli.Saidi@ARM.com# stuff for some reason 3077756SAli.Saidi@ARM.comscanners = [] 3087756SAli.Saidi@ARM.comfor scanner in env['SCANNERS']: 3097756SAli.Saidi@ARM.com skeys = scanner.skeys 3107816Ssteve.reinhardt@amd.com if skeys == '.i': 3117816Ssteve.reinhardt@amd.com continue 3127816Ssteve.reinhardt@amd.com 3137816Ssteve.reinhardt@amd.com if isinstance(skeys, (list, tuple)) and '.i' in skeys: 3147816Ssteve.reinhardt@amd.com continue 31511979Sgabeblack@google.com 3167816Ssteve.reinhardt@amd.com scanners.append(scanner) 3177816Ssteve.reinhardt@amd.com 3187816Ssteve.reinhardt@amd.com# add the new swig scanner that we like better 3197816Ssteve.reinhardt@amd.comfrom SCons.Scanner import ClassicCPP as CPPScanner 3207756SAli.Saidi@ARM.comswig_inc_re = '^[ \t]*[%,#][ \t]*(?:include|import)[ \t]*(<|")([^>"]+)(>|")' 3217756SAli.Saidi@ARM.comscanners.append(CPPScanner("SwigScan", [ ".i" ], "CPPPATH", swig_inc_re)) 3229227Sandreas.hansson@arm.com 3239227Sandreas.hansson@arm.com# replace the scanners list that has what we want 3249227Sandreas.hansson@arm.comenv['SCANNERS'] = scanners 3259227Sandreas.hansson@arm.com 3269590Sandreas@sandberg.pp.se# Platform-specific configuration. Note again that we assume that all 3279590Sandreas@sandberg.pp.se# builds under a given build root run on the same host platform. 3289590Sandreas@sandberg.pp.seconf = Configure(env, 3299590Sandreas@sandberg.pp.se conf_dir = joinpath(build_root, '.scons_config'), 3309590Sandreas@sandberg.pp.se log_file = joinpath(build_root, 'scons_config.log')) 3319590Sandreas@sandberg.pp.se 3326654Snate@binkert.org# Find Python include and library directories for embedding the 3336654Snate@binkert.org# interpreter. For consistency, we will use the same Python 3345871Snate@binkert.org# installation used to run scons (and thus this script). If you want 3356121Snate@binkert.org# to link in an alternate version, see above for instructions on how 3368946Sandreas.hansson@arm.com# to invoke scons with a different copy of the Python interpreter. 3379419Sandreas.hansson@arm.com 3383940Ssaidi@eecs.umich.edu# Get brief Python version name (e.g., "python2.4") for locating 3393918Ssaidi@eecs.umich.edu# include & library files 3403918Ssaidi@eecs.umich.edupy_version_name = 'python' + sys.version[:3] 3411858SN/A 3429556Sandreas.hansson@arm.com# include path, e.g. /usr/local/include/python2.4 3439556Sandreas.hansson@arm.compy_header_path = joinpath(sys.exec_prefix, 'include', py_version_name) 3449556Sandreas.hansson@arm.comenv.Append(CPPPATH = py_header_path) 3459556Sandreas.hansson@arm.com# verify that it works 34611294Sandreas.hansson@arm.comif not conf.CheckHeader('Python.h', '<>'): 34711294Sandreas.hansson@arm.com print "Error: can't find Python.h header in", py_header_path 34811294Sandreas.hansson@arm.com Exit(1) 34911294Sandreas.hansson@arm.com 35010878Sandreas.hansson@arm.com# add library path too if it's not in the default place 35110878Sandreas.hansson@arm.compy_lib_path = None 35211811Sbaz21@cam.ac.ukif sys.exec_prefix != '/usr': 35311811Sbaz21@cam.ac.uk py_lib_path = joinpath(sys.exec_prefix, 'lib') 35411811Sbaz21@cam.ac.ukelif sys.platform == 'cygwin': 35511982Sgabeblack@google.com # cygwin puts the .dll in /bin for some reason 35611982Sgabeblack@google.com py_lib_path = '/bin' 35711982Sgabeblack@google.comif py_lib_path: 35811982Sgabeblack@google.com env.Append(LIBPATH = py_lib_path) 35911992Sgabeblack@google.com print 'Adding', py_lib_path, 'to LIBPATH for', py_version_name 36011982Sgabeblack@google.comif not conf.CheckLib(py_version_name): 36111982Sgabeblack@google.com print "Error: can't find Python library", py_version_name 3629556Sandreas.hansson@arm.com Exit(1) 3639556Sandreas.hansson@arm.com 3649556Sandreas.hansson@arm.com# On Solaris you need to use libsocket for socket ops 3659556Sandreas.hansson@arm.comif not conf.CheckLibWithHeader(None, 'sys/socket.h', 'C++', 'accept(0,0,0);'): 3669556Sandreas.hansson@arm.com if not conf.CheckLibWithHeader('socket', 'sys/socket.h', 'C++', 'accept(0,0,0);'): 3679556Sandreas.hansson@arm.com print "Can't find library with socket calls (e.g. accept())" 3689556Sandreas.hansson@arm.com Exit(1) 3699556Sandreas.hansson@arm.com 3709556Sandreas.hansson@arm.com# Check for zlib. If the check passes, libz will be automatically 3719556Sandreas.hansson@arm.com# added to the LIBS environment variable. 3729556Sandreas.hansson@arm.comif not conf.CheckLibWithHeader('z', 'zlib.h', 'C++','zlibVersion();'): 3739556Sandreas.hansson@arm.com print 'Error: did not find needed zlib compression library '\ 3749556Sandreas.hansson@arm.com 'and/or zlib.h header file.' 3759556Sandreas.hansson@arm.com print ' Please install zlib and try again.' 3769556Sandreas.hansson@arm.com Exit(1) 3779556Sandreas.hansson@arm.com 3789556Sandreas.hansson@arm.com# Check for <fenv.h> (C99 FP environment control) 3799556Sandreas.hansson@arm.comhave_fenv = conf.CheckHeader('fenv.h', '<>') 3809556Sandreas.hansson@arm.comif not have_fenv: 3816121Snate@binkert.org print "Warning: Header file <fenv.h> not found." 38211500Sandreas.hansson@arm.com print " This host has no IEEE FP rounding mode control." 38310238Sandreas.hansson@arm.com 38410878Sandreas.hansson@arm.com# Check for mysql. 3859420Sandreas.hansson@arm.commysql_config = WhereIs('mysql_config') 38611500Sandreas.hansson@arm.comhave_mysql = mysql_config != None 38711500Sandreas.hansson@arm.com 3889420Sandreas.hansson@arm.com# Check MySQL version. 3899420Sandreas.hansson@arm.comif have_mysql: 3909420Sandreas.hansson@arm.com mysql_version = os.popen(mysql_config + ' --version').read() 3919420Sandreas.hansson@arm.com min_mysql_version = '4.1' 3929420Sandreas.hansson@arm.com if compare_versions(mysql_version, min_mysql_version) < 0: 39312063Sgabeblack@google.com print 'Warning: MySQL', min_mysql_version, 'or newer required.' 39412063Sgabeblack@google.com print ' Version', mysql_version, 'detected.' 39512063Sgabeblack@google.com have_mysql = False 39612063Sgabeblack@google.com 39712063Sgabeblack@google.com# Set up mysql_config commands. 39812063Sgabeblack@google.comif have_mysql: 39912063Sgabeblack@google.com mysql_config_include = mysql_config + ' --include' 40012063Sgabeblack@google.com if os.system(mysql_config_include + ' > /dev/null') != 0: 40112063Sgabeblack@google.com # older mysql_config versions don't support --include, use 40212063Sgabeblack@google.com # --cflags instead 40312063Sgabeblack@google.com mysql_config_include = mysql_config + ' --cflags | sed s/\\\'//g' 40412063Sgabeblack@google.com # This seems to work in all versions 40512063Sgabeblack@google.com mysql_config_libs = mysql_config + ' --libs' 40612063Sgabeblack@google.com 40712063Sgabeblack@google.comenv = conf.Finish() 40812063Sgabeblack@google.com 40912063Sgabeblack@google.com# Define the universe of supported ISAs 41012063Sgabeblack@google.comall_isa_list = [ ] 41112063Sgabeblack@google.comExport('all_isa_list') 41212063Sgabeblack@google.com 41312063Sgabeblack@google.com# Define the universe of supported CPU models 41412063Sgabeblack@google.comall_cpu_list = [ ] 41510264Sandreas.hansson@arm.comdefault_cpus = [ ] 41610264Sandreas.hansson@arm.comExport('all_cpu_list', 'default_cpus') 41710264Sandreas.hansson@arm.com 41810264Sandreas.hansson@arm.com# Sticky options get saved in the options file so they persist from 41911925Sgabeblack@google.com# one invocation to the next (unless overridden, in which case the new 42011925Sgabeblack@google.com# value becomes sticky). 42111500Sandreas.hansson@arm.comsticky_opts = Options(args=ARGUMENTS) 42210264Sandreas.hansson@arm.comExport('sticky_opts') 42311500Sandreas.hansson@arm.com 42411500Sandreas.hansson@arm.com# Non-sticky options only apply to the current build. 42511500Sandreas.hansson@arm.comnonsticky_opts = Options(args=ARGUMENTS) 42611500Sandreas.hansson@arm.comExport('nonsticky_opts') 42710866Sandreas.hansson@arm.com 42811500Sandreas.hansson@arm.com# Walk the tree and execute all SConsopts scripts that wil add to the 42911500Sandreas.hansson@arm.com# above options 43011500Sandreas.hansson@arm.comfor root, dirs, files in os.walk('.'): 43111500Sandreas.hansson@arm.com if 'SConsopts' in files: 43211500Sandreas.hansson@arm.com SConscript(os.path.join(root, 'SConsopts')) 43311500Sandreas.hansson@arm.com 43411500Sandreas.hansson@arm.comall_isa_list.sort() 43510264Sandreas.hansson@arm.comall_cpu_list.sort() 43610457Sandreas.hansson@arm.comdefault_cpus.sort() 43710457Sandreas.hansson@arm.com 43810457Sandreas.hansson@arm.comdef ExtraPathValidator(key, val, env): 43910457Sandreas.hansson@arm.com paths = val.split(':') 44010457Sandreas.hansson@arm.com for path in paths: 44110457Sandreas.hansson@arm.com path = os.path.expanduser(path) 44210457Sandreas.hansson@arm.com if not isdir(path): 44310457Sandreas.hansson@arm.com raise AttributeError, "Invalid path: '%s'" % path 44410457Sandreas.hansson@arm.com 44512063Sgabeblack@google.comsticky_opts.AddOptions( 44612063Sgabeblack@google.com EnumOption('TARGET_ISA', 'Target ISA', 'alpha', all_isa_list), 44712063Sgabeblack@google.com BoolOption('FULL_SYSTEM', 'Full-system support', False), 44812063Sgabeblack@google.com # There's a bug in scons 0.96.1 that causes ListOptions with list 44912063Sgabeblack@google.com # values (more than one value) not to be able to be restored from 45012063Sgabeblack@google.com # a saved option file. If this causes trouble then upgrade to 45112063Sgabeblack@google.com # scons 0.96.90 or later. 45212063Sgabeblack@google.com ListOption('CPU_MODELS', 'CPU models', default_cpus, all_cpu_list), 45312063Sgabeblack@google.com BoolOption('NO_FAST_ALLOC', 'Disable fast object allocator', False), 45412063Sgabeblack@google.com BoolOption('EFENCE', 'Link with Electric Fence malloc debugger', 45512063Sgabeblack@google.com False), 45610238Sandreas.hansson@arm.com BoolOption('SS_COMPATIBLE_FP', 45710238Sandreas.hansson@arm.com 'Make floating-point results compatible with SimpleScalar', 45810238Sandreas.hansson@arm.com False), 45912063Sgabeblack@google.com BoolOption('USE_SSE2', 46010238Sandreas.hansson@arm.com 'Compile for SSE2 (-msse2) to get IEEE FP on x86 hosts', 46110238Sandreas.hansson@arm.com False), 46210416Sandreas.hansson@arm.com BoolOption('USE_MYSQL', 'Use MySQL for stats output', have_mysql), 46310238Sandreas.hansson@arm.com BoolOption('USE_FENV', 'Use <fenv.h> IEEE mode control', have_fenv), 4649227Sandreas.hansson@arm.com BoolOption('USE_CHECKER', 'Use checker for detailed CPU models', False), 46510238Sandreas.hansson@arm.com ('CC', 'C compiler', os.environ.get('CC', env['CC'])), 46610416Sandreas.hansson@arm.com ('CXX', 'C++ compiler', os.environ.get('CXX', env['CXX'])), 46710416Sandreas.hansson@arm.com BoolOption('BATCH', 'Use batch pool for build and tests', False), 4689227Sandreas.hansson@arm.com ('BATCH_CMD', 'Batch pool submission command name', 'qdo'), 4699590Sandreas@sandberg.pp.se ('PYTHONHOME', 4709590Sandreas@sandberg.pp.se 'Override the default PYTHONHOME for this system (use with caution)', 4719590Sandreas@sandberg.pp.se '%s:%s' % (sys.prefix, sys.exec_prefix)), 47211497SMatteo.Andreozzi@arm.com ('EXTRAS', 'Add Extra directories to the compilation', '', 47311497SMatteo.Andreozzi@arm.com ExtraPathValidator) 47411497SMatteo.Andreozzi@arm.com ) 47511497SMatteo.Andreozzi@arm.com 4768737Skoansin.tan@gmail.comnonsticky_opts.AddOptions( 47710878Sandreas.hansson@arm.com BoolOption('update_ref', 'Update test reference outputs', False) 47811500Sandreas.hansson@arm.com ) 4799420Sandreas.hansson@arm.com 4808737Skoansin.tan@gmail.com# These options get exported to #defines in config/*.hh (see src/SConscript). 48110106SMitch.Hayenga@arm.comenv.ExportOptions = ['FULL_SYSTEM', 'ALPHA_TLASER', 'USE_FENV', \ 4828737Skoansin.tan@gmail.com 'USE_MYSQL', 'NO_FAST_ALLOC', 'SS_COMPATIBLE_FP', \ 4838737Skoansin.tan@gmail.com 'USE_CHECKER', 'PYTHONHOME', 'TARGET_ISA'] 48410878Sandreas.hansson@arm.com 48510878Sandreas.hansson@arm.com# Define a handy 'no-op' action 4868737Skoansin.tan@gmail.comdef no_action(target, source, env): 4878737Skoansin.tan@gmail.com return 0 4888737Skoansin.tan@gmail.com 4898737Skoansin.tan@gmail.comenv.NoAction = Action(no_action, None) 4908737Skoansin.tan@gmail.com 4918737Skoansin.tan@gmail.com################################################### 49211294Sandreas.hansson@arm.com# 4939556Sandreas.hansson@arm.com# Define a SCons builder for configuration flag headers. 4949556Sandreas.hansson@arm.com# 4959556Sandreas.hansson@arm.com################################################### 49611294Sandreas.hansson@arm.com 49710278SAndreas.Sandberg@ARM.com# This function generates a config header file that #defines the 49810278SAndreas.Sandberg@ARM.com# option symbol to the current option setting (0 or 1). The source 49910278SAndreas.Sandberg@ARM.com# operands are the name of the option and a Value node containing the 50010278SAndreas.Sandberg@ARM.com# value of the option. 50110278SAndreas.Sandberg@ARM.comdef build_config_file(target, source, env): 50210278SAndreas.Sandberg@ARM.com (option, value) = [s.get_contents() for s in source] 5039556Sandreas.hansson@arm.com f = file(str(target[0]), 'w') 5049590Sandreas@sandberg.pp.se print >> f, '#define', option, value 5059590Sandreas@sandberg.pp.se f.close() 5069420Sandreas.hansson@arm.com return None 5079846Sandreas.hansson@arm.com 5089846Sandreas.hansson@arm.com# Generate the message to be printed when building the config file. 5099846Sandreas.hansson@arm.comdef build_config_file_string(target, source, env): 5109846Sandreas.hansson@arm.com (option, value) = [s.get_contents() for s in source] 5118946Sandreas.hansson@arm.com return "Defining %s as %s in %s." % (option, value, target[0]) 51211811Sbaz21@cam.ac.uk 51311811Sbaz21@cam.ac.uk# Combine the two functions into a scons Action object. 51411811Sbaz21@cam.ac.ukconfig_action = Action(build_config_file, build_config_file_string) 51511811Sbaz21@cam.ac.uk 5163918Ssaidi@eecs.umich.edu# The emitter munges the source & target node lists to reflect what 5179068SAli.Saidi@ARM.com# we're really doing. 5189068SAli.Saidi@ARM.comdef config_emitter(target, source, env): 5199068SAli.Saidi@ARM.com # extract option name from Builder arg 5209068SAli.Saidi@ARM.com option = str(target[0]) 5219068SAli.Saidi@ARM.com # True target is config header file 5229068SAli.Saidi@ARM.com target = joinpath('config', option.lower() + '.hh') 5239068SAli.Saidi@ARM.com val = env[option] 5249068SAli.Saidi@ARM.com if isinstance(val, bool): 5259068SAli.Saidi@ARM.com # Force value to 0/1 5269419Sandreas.hansson@arm.com val = int(val) 5279068SAli.Saidi@ARM.com elif isinstance(val, str): 5289068SAli.Saidi@ARM.com val = '"' + val + '"' 5299068SAli.Saidi@ARM.com 5309068SAli.Saidi@ARM.com # Sources are option name & value (packaged in SCons Value nodes) 5319068SAli.Saidi@ARM.com return ([target], [Value(option), Value(val)]) 5329068SAli.Saidi@ARM.com 5333918Ssaidi@eecs.umich.educonfig_builder = Builder(emitter = config_emitter, action = config_action) 5343918Ssaidi@eecs.umich.edu 5356157Snate@binkert.orgenv.Append(BUILDERS = { 'ConfigFile' : config_builder }) 5366157Snate@binkert.org 5376157Snate@binkert.org################################################### 5386157Snate@binkert.org# 5395397Ssaidi@eecs.umich.edu# Define a SCons builder for copying files. This is used by the 5405397Ssaidi@eecs.umich.edu# Python zipfile code in src/python/SConscript, but is placed up here 5416121Snate@binkert.org# since it's potentially more generally applicable. 5426121Snate@binkert.org# 5436121Snate@binkert.org################################################### 5446121Snate@binkert.org 5456121Snate@binkert.orgcopy_builder = Builder(action = Copy("$TARGET", "$SOURCE")) 5466121Snate@binkert.org 5475397Ssaidi@eecs.umich.eduenv.Append(BUILDERS = { 'CopyFile' : copy_builder }) 5481851SN/A 5491851SN/A################################################### 5507739Sgblack@eecs.umich.edu# 551955SN/A# Define a simple SCons builder to concatenate files. 5529396Sandreas.hansson@arm.com# 5539396Sandreas.hansson@arm.com# Used to append the Python zip archive to the executable. 5549396Sandreas.hansson@arm.com# 5559396Sandreas.hansson@arm.com################################################### 5569396Sandreas.hansson@arm.com 5579396Sandreas.hansson@arm.comconcat_builder = Builder(action = Action(['cat $SOURCES > $TARGET', 5589396Sandreas.hansson@arm.com 'chmod +x $TARGET'])) 5599396Sandreas.hansson@arm.com 5609396Sandreas.hansson@arm.comenv.Append(BUILDERS = { 'Concat' : concat_builder }) 5619396Sandreas.hansson@arm.com 5629396Sandreas.hansson@arm.com 5639396Sandreas.hansson@arm.com# base help text 5649396Sandreas.hansson@arm.comhelp_text = ''' 5659396Sandreas.hansson@arm.comUsage: scons [scons options] [build options] [target(s)] 5669396Sandreas.hansson@arm.com 5679396Sandreas.hansson@arm.com''' 5689477Sandreas.hansson@arm.com 5699477Sandreas.hansson@arm.com# libelf build is shared across all configs in the build root. 5709477Sandreas.hansson@arm.comenv.SConscript('ext/libelf/SConscript', 5719477Sandreas.hansson@arm.com build_dir = joinpath(build_root, 'libelf'), 5729477Sandreas.hansson@arm.com exports = 'env') 5739477Sandreas.hansson@arm.com 5749477Sandreas.hansson@arm.com################################################### 5759477Sandreas.hansson@arm.com# 5769477Sandreas.hansson@arm.com# This function is used to set up a directory with switching headers 5779477Sandreas.hansson@arm.com# 5789477Sandreas.hansson@arm.com################################################### 5799477Sandreas.hansson@arm.com 5809477Sandreas.hansson@arm.comenv['ALL_ISA_LIST'] = all_isa_list 5819477Sandreas.hansson@arm.comdef make_switching_dir(dirname, switch_headers, env): 5829477Sandreas.hansson@arm.com # Generate the header. target[0] is the full path of the output 5839477Sandreas.hansson@arm.com # header to generate. 'source' is a dummy variable, since we get the 5849477Sandreas.hansson@arm.com # list of ISAs from env['ALL_ISA_LIST']. 5859477Sandreas.hansson@arm.com def gen_switch_hdr(target, source, env): 5869477Sandreas.hansson@arm.com fname = str(target[0]) 5879477Sandreas.hansson@arm.com basename = os.path.basename(fname) 5889477Sandreas.hansson@arm.com f = open(fname, 'w') 5899477Sandreas.hansson@arm.com f.write('#include "arch/isa_specific.hh"\n') 5909396Sandreas.hansson@arm.com cond = '#if' 5912667Sstever@eecs.umich.edu for isa in all_isa_list: 59210710Sandreas.hansson@arm.com f.write('%s THE_ISA == %s_ISA\n#include "%s/%s/%s"\n' 59310710Sandreas.hansson@arm.com % (cond, isa.upper(), dirname, isa, basename)) 59410710Sandreas.hansson@arm.com cond = '#elif' 59511811Sbaz21@cam.ac.uk f.write('#else\n#error "THE_ISA not set"\n#endif\n') 59611811Sbaz21@cam.ac.uk f.close() 59711811Sbaz21@cam.ac.uk return 0 59811811Sbaz21@cam.ac.uk 59911811Sbaz21@cam.ac.uk # String to print when generating header 60011811Sbaz21@cam.ac.uk def gen_switch_hdr_string(target, source, env): 60110710Sandreas.hansson@arm.com return "Generating switch header " + str(target[0]) 60210710Sandreas.hansson@arm.com 60310710Sandreas.hansson@arm.com # Build SCons Action object. 'varlist' specifies env vars that this 60410710Sandreas.hansson@arm.com # action depends on; when env['ALL_ISA_LIST'] changes these actions 60510384SCurtis.Dunham@arm.com # should get re-executed. 6069986Sandreas@sandberg.pp.se switch_hdr_action = Action(gen_switch_hdr, gen_switch_hdr_string, 6079986Sandreas@sandberg.pp.se varlist=['ALL_ISA_LIST']) 6089986Sandreas@sandberg.pp.se 6099986Sandreas@sandberg.pp.se # Instantiate actions for each header 6109986Sandreas@sandberg.pp.se for hdr in switch_headers: 6119986Sandreas@sandberg.pp.se env.Command(hdr, [], switch_hdr_action) 6129986Sandreas@sandberg.pp.seExport('make_switching_dir') 6139986Sandreas@sandberg.pp.se 6149986Sandreas@sandberg.pp.se################################################### 6159986Sandreas@sandberg.pp.se# 6169986Sandreas@sandberg.pp.se# Define build environments for selected configurations. 6179986Sandreas@sandberg.pp.se# 6189986Sandreas@sandberg.pp.se################################################### 6199986Sandreas@sandberg.pp.se 6209986Sandreas@sandberg.pp.se# rename base env 6219986Sandreas@sandberg.pp.sebase_env = env 6229986Sandreas@sandberg.pp.se 6239986Sandreas@sandberg.pp.sefor build_path in build_paths: 6249986Sandreas@sandberg.pp.se print "Building in", build_path 6259986Sandreas@sandberg.pp.se env['BUILDDIR'] = build_path 6262638Sstever@eecs.umich.edu 6272638Sstever@eecs.umich.edu # build_dir is the tail component of build path, and is used to 6286121Snate@binkert.org # determine the build parameters (e.g., 'ALPHA_SE') 6293716Sstever@eecs.umich.edu (build_root, build_dir) = os.path.split(build_path) 6305522Snate@binkert.org # Make a copy of the build-root environment to use for this config. 6319986Sandreas@sandberg.pp.se env = base_env.Copy() 6329986Sandreas@sandberg.pp.se 6339986Sandreas@sandberg.pp.se # Set env options according to the build directory config. 6345522Snate@binkert.org sticky_opts.files = [] 6355227Ssaidi@eecs.umich.edu # Options for $BUILD_ROOT/$BUILD_DIR are stored in 6365227Ssaidi@eecs.umich.edu # $BUILD_ROOT/options/$BUILD_DIR so you can nuke 6375227Ssaidi@eecs.umich.edu # $BUILD_ROOT/$BUILD_DIR without losing your options settings. 6385227Ssaidi@eecs.umich.edu current_opts_file = joinpath(build_root, 'options', build_dir) 6396654Snate@binkert.org if os.path.isfile(current_opts_file): 6406654Snate@binkert.org sticky_opts.files.append(current_opts_file) 6417769SAli.Saidi@ARM.com print "Using saved options file %s" % current_opts_file 6427769SAli.Saidi@ARM.com else: 6437769SAli.Saidi@ARM.com # Build dir-specific options file doesn't exist. 6447769SAli.Saidi@ARM.com 6455227Ssaidi@eecs.umich.edu # Make sure the directory is there so we can create it later 6465227Ssaidi@eecs.umich.edu opt_dir = os.path.dirname(current_opts_file) 6475227Ssaidi@eecs.umich.edu if not os.path.isdir(opt_dir): 6485204Sstever@gmail.com os.mkdir(opt_dir) 6495204Sstever@gmail.com 6505204Sstever@gmail.com # Get default build options from source tree. Options are 6515204Sstever@gmail.com # normally determined by name of $BUILD_DIR, but can be 6525204Sstever@gmail.com # overriden by 'default=' arg on command line. 6535204Sstever@gmail.com default_opts_file = joinpath('build_opts', 6545204Sstever@gmail.com ARGUMENTS.get('default', build_dir)) 6555204Sstever@gmail.com if os.path.isfile(default_opts_file): 6565204Sstever@gmail.com sticky_opts.files.append(default_opts_file) 6575204Sstever@gmail.com print "Options file %s not found,\n using defaults in %s" \ 6585204Sstever@gmail.com % (current_opts_file, default_opts_file) 6595204Sstever@gmail.com else: 6605204Sstever@gmail.com print "Error: cannot find options file %s or %s" \ 6615204Sstever@gmail.com % (current_opts_file, default_opts_file) 6625204Sstever@gmail.com Exit(1) 6635204Sstever@gmail.com 6645204Sstever@gmail.com # Apply current option settings to env 6656121Snate@binkert.org sticky_opts.Update(env) 6665204Sstever@gmail.com nonsticky_opts.Update(env) 6677727SAli.Saidi@ARM.com 6687727SAli.Saidi@ARM.com help_text += "Sticky options for %s:\n" % build_dir \ 6697727SAli.Saidi@ARM.com + sticky_opts.GenerateHelpText(env) \ 6707727SAli.Saidi@ARM.com + "\nNon-sticky options for %s:\n" % build_dir \ 6717727SAli.Saidi@ARM.com + nonsticky_opts.GenerateHelpText(env) 67211988Sandreas.sandberg@arm.com 67311988Sandreas.sandberg@arm.com # Process option settings. 67410453SAndrew.Bardsley@arm.com 67510453SAndrew.Bardsley@arm.com if not have_fenv and env['USE_FENV']: 67610453SAndrew.Bardsley@arm.com print "Warning: <fenv.h> not available; " \ 67710453SAndrew.Bardsley@arm.com "forcing USE_FENV to False in", build_dir + "." 67810453SAndrew.Bardsley@arm.com env['USE_FENV'] = False 67910453SAndrew.Bardsley@arm.com 68010453SAndrew.Bardsley@arm.com if not env['USE_FENV']: 68110453SAndrew.Bardsley@arm.com print "Warning: No IEEE FP rounding mode control in", build_dir + "." 68210453SAndrew.Bardsley@arm.com print " FP results may deviate slightly from other platforms." 68310453SAndrew.Bardsley@arm.com 68410160Sandreas.hansson@arm.com if env['EFENCE']: 68510453SAndrew.Bardsley@arm.com env.Append(LIBS=['efence']) 68610453SAndrew.Bardsley@arm.com 68710453SAndrew.Bardsley@arm.com if env['USE_MYSQL']: 68810453SAndrew.Bardsley@arm.com if not have_mysql: 68910453SAndrew.Bardsley@arm.com print "Warning: MySQL not available; " \ 69010453SAndrew.Bardsley@arm.com "forcing USE_MYSQL to False in", build_dir + "." 69110453SAndrew.Bardsley@arm.com env['USE_MYSQL'] = False 69210453SAndrew.Bardsley@arm.com else: 6939812Sandreas.hansson@arm.com print "Compiling in", build_dir, "with MySQL support." 69410453SAndrew.Bardsley@arm.com env.ParseConfig(mysql_config_libs) 69510453SAndrew.Bardsley@arm.com env.ParseConfig(mysql_config_include) 69610453SAndrew.Bardsley@arm.com 69710453SAndrew.Bardsley@arm.com # Save sticky option settings back to current options file 69810453SAndrew.Bardsley@arm.com sticky_opts.Save(current_opts_file, env) 69910453SAndrew.Bardsley@arm.com 70010453SAndrew.Bardsley@arm.com # Do this after we save setting back, or else we'll tack on an 70110453SAndrew.Bardsley@arm.com # extra 'qdo' every time we run scons. 70210453SAndrew.Bardsley@arm.com if env['BATCH']: 70310453SAndrew.Bardsley@arm.com env['CC'] = env['BATCH_CMD'] + ' ' + env['CC'] 70410453SAndrew.Bardsley@arm.com env['CXX'] = env['BATCH_CMD'] + ' ' + env['CXX'] 70510453SAndrew.Bardsley@arm.com 7067727SAli.Saidi@ARM.com if env['USE_SSE2']: 70710453SAndrew.Bardsley@arm.com env.Append(CCFLAGS='-msse2') 70810453SAndrew.Bardsley@arm.com 70910453SAndrew.Bardsley@arm.com # The src/SConscript file sets up the build rules in 'env' according 71010453SAndrew.Bardsley@arm.com # to the configured options. It returns a list of environments, 71110453SAndrew.Bardsley@arm.com # one for each variant build (debug, opt, etc.) 7123118Sstever@eecs.umich.edu envList = SConscript('src/SConscript', build_dir = build_path, 71310453SAndrew.Bardsley@arm.com exports = 'env') 71410453SAndrew.Bardsley@arm.com 71510453SAndrew.Bardsley@arm.com # Set up the regression tests for each build. 71610453SAndrew.Bardsley@arm.com for e in envList: 7173118Sstever@eecs.umich.edu SConscript('tests/SConscript', 7183483Ssaidi@eecs.umich.edu build_dir = joinpath(build_path, 'tests', e.Label), 7193494Ssaidi@eecs.umich.edu exports = { 'env' : e }, duplicate = False) 7203494Ssaidi@eecs.umich.edu 7213483Ssaidi@eecs.umich.eduHelp(help_text) 7223483Ssaidi@eecs.umich.edu 7233483Ssaidi@eecs.umich.edu 7243053Sstever@eecs.umich.edu################################################### 7253053Sstever@eecs.umich.edu# 7263918Ssaidi@eecs.umich.edu# Let SCons do its thing. At this point SCons will use the defined 7273053Sstever@eecs.umich.edu# build environments to build the requested targets. 7283053Sstever@eecs.umich.edu# 7293053Sstever@eecs.umich.edu################################################### 7303053Sstever@eecs.umich.edu 7313053Sstever@eecs.umich.edu