SConstruct revision 5588:d8b246a665c1
17087Snate@binkert.org# -*- mode:python -*- 27087Snate@binkert.org 37087Snate@binkert.org# Copyright (c) 2004-2005 The Regents of The University of Michigan 47087Snate@binkert.org# All rights reserved. 57087Snate@binkert.org# 67087Snate@binkert.org# Redistribution and use in source and binary forms, with or without 77087Snate@binkert.org# modification, are permitted provided that the following conditions are 87087Snate@binkert.org# met: redistributions of source code must retain the above copyright 97087Snate@binkert.org# notice, this list of conditions and the following disclaimer; 107087Snate@binkert.org# redistributions in binary form must reproduce the above copyright 117087Snate@binkert.org# notice, this list of conditions and the following disclaimer in the 127087Snate@binkert.org# documentation and/or other materials provided with the distribution; 135326Sgblack@eecs.umich.edu# neither the name of the copyright holders nor the names of its 145326Sgblack@eecs.umich.edu# contributors may be used to endorse or promote products derived from 155326Sgblack@eecs.umich.edu# this software without specific prior written permission. 165326Sgblack@eecs.umich.edu# 175326Sgblack@eecs.umich.edu# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 185326Sgblack@eecs.umich.edu# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 195326Sgblack@eecs.umich.edu# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 205326Sgblack@eecs.umich.edu# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 215326Sgblack@eecs.umich.edu# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 225326Sgblack@eecs.umich.edu# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 235326Sgblack@eecs.umich.edu# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 245326Sgblack@eecs.umich.edu# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 255326Sgblack@eecs.umich.edu# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 265326Sgblack@eecs.umich.edu# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 275326Sgblack@eecs.umich.edu# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 285326Sgblack@eecs.umich.edu# 295326Sgblack@eecs.umich.edu# Authors: Steve Reinhardt 305326Sgblack@eecs.umich.edu 315326Sgblack@eecs.umich.edu################################################### 325326Sgblack@eecs.umich.edu# 335326Sgblack@eecs.umich.edu# SCons top-level build description (SConstruct) file. 345326Sgblack@eecs.umich.edu# 355326Sgblack@eecs.umich.edu# While in this directory ('m5'), just type 'scons' to build the default 365326Sgblack@eecs.umich.edu# configuration (see below), or type 'scons build/<CONFIG>/<binary>' 375326Sgblack@eecs.umich.edu# to build some other configuration (e.g., 'build/ALPHA_FS/m5.opt' for 385326Sgblack@eecs.umich.edu# the optimized full-system version). 395326Sgblack@eecs.umich.edu# 405326Sgblack@eecs.umich.edu# You can build M5 in a different directory as long as there is a 415240Sgblack@eecs.umich.edu# 'build/<CONFIG>' somewhere along the target path. The build system 425240Sgblack@eecs.umich.edu# expects that all configs under the same build directory are being 435240Sgblack@eecs.umich.edu# built for the same host system. 445240Sgblack@eecs.umich.edu# 455240Sgblack@eecs.umich.edu# Examples: 465240Sgblack@eecs.umich.edu# 475306Sgblack@eecs.umich.edu# The following two commands are equivalent. The '-u' option tells 485240Sgblack@eecs.umich.edu# scons to search up the directory tree for this SConstruct file. 495240Sgblack@eecs.umich.edu# % cd <path-to-src>/m5 ; scons build/ALPHA_FS/m5.debug 505240Sgblack@eecs.umich.edu# % cd <path-to-src>/m5/build/ALPHA_FS; scons -u m5.debug 515326Sgblack@eecs.umich.edu# 525240Sgblack@eecs.umich.edu# The following two commands are equivalent and demonstrate building 535240Sgblack@eecs.umich.edu# in a directory outside of the source tree. The '-C' option tells 545240Sgblack@eecs.umich.edu# scons to chdir to the specified directory to find this SConstruct 555240Sgblack@eecs.umich.edu# file. 565240Sgblack@eecs.umich.edu# % cd <path-to-src>/m5 ; scons /local/foo/build/ALPHA_FS/m5.debug 575306Sgblack@eecs.umich.edu# % cd /local/foo/build/ALPHA_FS; scons -C <path-to-src>/m5 m5.debug 585326Sgblack@eecs.umich.edu# 595240Sgblack@eecs.umich.edu# You can use 'scons -H' to print scons options. If you're in this 605240Sgblack@eecs.umich.edu# 'm5' directory (or use -u or -C to tell scons where to find this 615240Sgblack@eecs.umich.edu# file), you can use 'scons -h' to print all the M5-specific build 625240Sgblack@eecs.umich.edu# options as well. 635240Sgblack@eecs.umich.edu# 645240Sgblack@eecs.umich.edu################################################### 655240Sgblack@eecs.umich.edu 665240Sgblack@eecs.umich.eduimport sys 675326Sgblack@eecs.umich.eduimport os 685326Sgblack@eecs.umich.eduimport re 695326Sgblack@eecs.umich.edu 705326Sgblack@eecs.umich.edufrom os.path import isdir, isfile, join as joinpath 715240Sgblack@eecs.umich.edu 725240Sgblack@eecs.umich.eduimport SCons 735240Sgblack@eecs.umich.edu 745240Sgblack@eecs.umich.edu# Check for recent-enough Python and SCons versions. If your system's 755240Sgblack@eecs.umich.edu# default installation of Python is not recent enough, you can use a 765326Sgblack@eecs.umich.edu# non-default installation of the Python interpreter by either (1) 775326Sgblack@eecs.umich.edu# rearranging your PATH so that scons finds the non-default 'python' 787690Sgblack@eecs.umich.edu# first or (2) explicitly invoking an alternative interpreter on the 795240Sgblack@eecs.umich.edu# scons script, e.g., "/usr/local/bin/python2.4 `which scons` [args]". 805240Sgblack@eecs.umich.eduEnsurePythonVersion(2,4) 815240Sgblack@eecs.umich.edu 825240Sgblack@eecs.umich.edu# Import subprocess after we check the version since it doesn't exist in 835240Sgblack@eecs.umich.edu# Python < 2.4. 845240Sgblack@eecs.umich.eduimport subprocess 855240Sgblack@eecs.umich.edu 865240Sgblack@eecs.umich.edu# helper function: compare arrays or strings of version numbers. 875240Sgblack@eecs.umich.edu# E.g., compare_version((1,3,25), (1,4,1)') 885240Sgblack@eecs.umich.edu# returns -1, 0, 1 if v1 is <, ==, > v2 895240Sgblack@eecs.umich.edudef compare_versions(v1, v2): 905306Sgblack@eecs.umich.edu def make_version_list(v): 915240Sgblack@eecs.umich.edu if isinstance(v, (list,tuple)): 925240Sgblack@eecs.umich.edu return v 935240Sgblack@eecs.umich.edu elif isinstance(v, str): 945326Sgblack@eecs.umich.edu return map(lambda x: int(re.match('\d+', x).group()), v.split('.')) 955326Sgblack@eecs.umich.edu else: 965326Sgblack@eecs.umich.edu raise TypeError 975240Sgblack@eecs.umich.edu 985326Sgblack@eecs.umich.edu v1 = make_version_list(v1) 995326Sgblack@eecs.umich.edu v2 = make_version_list(v2) 1005240Sgblack@eecs.umich.edu # Compare corresponding elements of lists 1015240Sgblack@eecs.umich.edu for n1,n2 in zip(v1, v2): 1025240Sgblack@eecs.umich.edu if n1 < n2: return -1 1035306Sgblack@eecs.umich.edu if n1 > n2: return 1 1045306Sgblack@eecs.umich.edu # all corresponding values are equal... see if one has extra values 1055326Sgblack@eecs.umich.edu if len(v1) < len(v2): return -1 1065326Sgblack@eecs.umich.edu if len(v1) > len(v2): return 1 1075326Sgblack@eecs.umich.edu return 0 1085240Sgblack@eecs.umich.edu 1095326Sgblack@eecs.umich.edu# SCons version numbers need special processing because they can have 1105326Sgblack@eecs.umich.edu# charecters and an release date embedded in them. This function does 1115240Sgblack@eecs.umich.edu# the magic to extract them in a similar way to the SCons internal function 1125240Sgblack@eecs.umich.edu# function does and then checks that the current version is not contained in 1136096Sgblack@eecs.umich.edu# a list of version tuples (bad_ver_strs) 1146096Sgblack@eecs.umich.edudef CheckSCons(bad_ver_strs): 1156096Sgblack@eecs.umich.edu def scons_ver(v): 1166096Sgblack@eecs.umich.edu num_parts = v.split(' ')[0].split('.') 1178610Snilay@cs.wisc.edu major = int(num_parts[0]) 1186096Sgblack@eecs.umich.edu minor = int(re.match('\d+', num_parts[1]).group()) 1196096Sgblack@eecs.umich.edu rev = 0 1206096Sgblack@eecs.umich.edu rdate = 0 1216096Sgblack@eecs.umich.edu if len(num_parts) > 2: 1228610Snilay@cs.wisc.edu try: rev = int(re.match('\d+', num_parts[2]).group()) 1236096Sgblack@eecs.umich.edu except: pass 1246096Sgblack@eecs.umich.edu rev_parts = num_parts[2].split('d') 1256096Sgblack@eecs.umich.edu if len(rev_parts) > 1: 1266096Sgblack@eecs.umich.edu rdate = int(re.match('\d+', rev_parts[1]).group()) 1276096Sgblack@eecs.umich.edu 1286096Sgblack@eecs.umich.edu return (major, minor, rev, rdate) 1296096Sgblack@eecs.umich.edu 1308610Snilay@cs.wisc.edu sc_ver = scons_ver(SCons.__version__) 1316096Sgblack@eecs.umich.edu for bad_ver in bad_ver_strs: 1326096Sgblack@eecs.umich.edu bv = (scons_ver(bad_ver[0]), scons_ver(bad_ver[1])) 1336096Sgblack@eecs.umich.edu if compare_versions(sc_ver, bv[0]) != -1 and\ 1346096Sgblack@eecs.umich.edu compare_versions(sc_ver, bv[1]) != 1: 1358610Snilay@cs.wisc.edu print "The version of SCons that you have installed: ", SCons.__version__ 1366096Sgblack@eecs.umich.edu print "has a bug that prevents it from working correctly with M5." 1376096Sgblack@eecs.umich.edu print "Please install a version NOT contained within the following", 1385240Sgblack@eecs.umich.edu print "ranges (inclusive):" 1395240Sgblack@eecs.umich.edu for bad_ver in bad_ver_strs: 1405240Sgblack@eecs.umich.edu print " %s - %s" % bad_ver 1415240Sgblack@eecs.umich.edu Exit(2) 1425240Sgblack@eecs.umich.edu 1435240Sgblack@eecs.umich.eduCheckSCons(( 1445240Sgblack@eecs.umich.edu # We need a version that is 0.96.91 or newer 1455240Sgblack@eecs.umich.edu ('0.0.0', '0.96.90'), 1465326Sgblack@eecs.umich.edu )) 1475326Sgblack@eecs.umich.edu 1485326Sgblack@eecs.umich.edu 1495326Sgblack@eecs.umich.edu# The absolute path to the current directory (where this file lives). 1505326Sgblack@eecs.umich.eduROOT = Dir('.').abspath 1515326Sgblack@eecs.umich.edu 1525240Sgblack@eecs.umich.edu# Path to the M5 source tree. 1535326Sgblack@eecs.umich.eduSRCDIR = joinpath(ROOT, 'src') 1545326Sgblack@eecs.umich.edu 1555240Sgblack@eecs.umich.edu# tell python where to find m5 python code 1565240Sgblack@eecs.umich.edusys.path.append(joinpath(ROOT, 'src/python')) 1575240Sgblack@eecs.umich.edu 1585306Sgblack@eecs.umich.edudef check_style_hook(ui): 1595326Sgblack@eecs.umich.edu ui.readconfig(joinpath(ROOT, '.hg', 'hgrc')) 1605326Sgblack@eecs.umich.edu style_hook = ui.config('hooks', 'pretxncommit.style', None) 1615326Sgblack@eecs.umich.edu 1625326Sgblack@eecs.umich.edu if not style_hook: 1637690Sgblack@eecs.umich.edu print """\ 1645240Sgblack@eecs.umich.eduYou're missing the M5 style hook. 1655326Sgblack@eecs.umich.eduPlease install the hook so we can ensure that all code fits a common style. 1667690Sgblack@eecs.umich.edu 1675240Sgblack@eecs.umich.eduAll you'd need to do is add the following lines to your repository .hg/hgrc 1685240Sgblack@eecs.umich.eduor your personal .hgrc 1696096Sgblack@eecs.umich.edu---------------- 1706096Sgblack@eecs.umich.edu 1716096Sgblack@eecs.umich.edu[extensions] 1726096Sgblack@eecs.umich.edustyle = %s/util/style.py 1736096Sgblack@eecs.umich.edu 1746096Sgblack@eecs.umich.edu[hooks] 1758610Snilay@cs.wisc.edupretxncommit.style = python:style.check_whitespace 1766096Sgblack@eecs.umich.edu""" % (ROOT) 1776096Sgblack@eecs.umich.edu sys.exit(1) 1786096Sgblack@eecs.umich.edu 1796096Sgblack@eecs.umich.eduif ARGUMENTS.get('IGNORE_STYLE') != 'True' and isdir(joinpath(ROOT, '.hg')): 1808610Snilay@cs.wisc.edu try: 1816096Sgblack@eecs.umich.edu from mercurial import ui 1826096Sgblack@eecs.umich.edu check_style_hook(ui.ui()) 1836096Sgblack@eecs.umich.edu except ImportError: 1846096Sgblack@eecs.umich.edu pass 1856096Sgblack@eecs.umich.edu 1866096Sgblack@eecs.umich.edu################################################### 1876096Sgblack@eecs.umich.edu# 1886096Sgblack@eecs.umich.edu# Figure out which configurations to set up based on the path(s) of 1898610Snilay@cs.wisc.edu# the target(s). 1907690Sgblack@eecs.umich.edu# 1916096Sgblack@eecs.umich.edu################################################### 1926096Sgblack@eecs.umich.edu 1937690Sgblack@eecs.umich.edu# Find default configuration & binary. 1948610Snilay@cs.wisc.eduDefault(os.environ.get('M5_DEFAULT_BINARY', 'build/ALPHA_SE/m5.debug')) 1956096Sgblack@eecs.umich.edu 1966096Sgblack@eecs.umich.edu# helper function: find last occurrence of element in list 1975240Sgblack@eecs.umich.edudef rfind(l, elt, offs = -1): 1985240Sgblack@eecs.umich.edu for i in range(len(l)+offs, 0, -1): 1995240Sgblack@eecs.umich.edu if l[i] == elt: 2005240Sgblack@eecs.umich.edu return i 2015240Sgblack@eecs.umich.edu raise ValueError, "element not found" 2025240Sgblack@eecs.umich.edu 2035240Sgblack@eecs.umich.edu# Each target must have 'build' in the interior of the path; the 2045240Sgblack@eecs.umich.edu# directory below this will determine the build parameters. For 2055306Sgblack@eecs.umich.edu# example, for target 'foo/bar/build/ALPHA_SE/arch/alpha/blah.do' we 2065326Sgblack@eecs.umich.edu# recognize that ALPHA_SE specifies the configuration because it 2075326Sgblack@eecs.umich.edu# follow 'build' in the bulid path. 2085326Sgblack@eecs.umich.edu 2095240Sgblack@eecs.umich.edu# Generate absolute paths to targets so we can see where the build dir is 2105326Sgblack@eecs.umich.eduif COMMAND_LINE_TARGETS: 2115326Sgblack@eecs.umich.edu # Ask SCons which directory it was invoked from 2125240Sgblack@eecs.umich.edu launch_dir = GetLaunchDir() 2135240Sgblack@eecs.umich.edu # Make targets relative to invocation directory 2145240Sgblack@eecs.umich.edu abs_targets = map(lambda x: os.path.normpath(joinpath(launch_dir, str(x))), 2155306Sgblack@eecs.umich.edu COMMAND_LINE_TARGETS) 2165306Sgblack@eecs.umich.eduelse: 2175326Sgblack@eecs.umich.edu # Default targets are relative to root of tree 2185326Sgblack@eecs.umich.edu abs_targets = map(lambda x: os.path.normpath(joinpath(ROOT, str(x))), 2195326Sgblack@eecs.umich.edu DEFAULT_TARGETS) 2205240Sgblack@eecs.umich.edu 2215326Sgblack@eecs.umich.edu 2225326Sgblack@eecs.umich.edu# Generate a list of the unique build roots and configs that the 2235240Sgblack@eecs.umich.edu# collected targets reference. 2245240Sgblack@eecs.umich.edubuild_paths = [] 2256095Sgblack@eecs.umich.edubuild_root = None 2266095Sgblack@eecs.umich.edufor t in abs_targets: 2276095Sgblack@eecs.umich.edu path_dirs = t.split('/') 2286095Sgblack@eecs.umich.edu try: 2298610Snilay@cs.wisc.edu build_top = rfind(path_dirs, 'build', -2) 2306095Sgblack@eecs.umich.edu except: 2316095Sgblack@eecs.umich.edu print "Error: no non-leaf 'build' dir found on target path", t 2326095Sgblack@eecs.umich.edu Exit(1) 2336095Sgblack@eecs.umich.edu this_build_root = joinpath('/',*path_dirs[:build_top+1]) 2348610Snilay@cs.wisc.edu if not build_root: 2356095Sgblack@eecs.umich.edu build_root = this_build_root 2366095Sgblack@eecs.umich.edu else: 2376095Sgblack@eecs.umich.edu if this_build_root != build_root: 2386095Sgblack@eecs.umich.edu print "Error: build targets not under same build root\n"\ 2396095Sgblack@eecs.umich.edu " %s\n %s" % (build_root, this_build_root) 2406095Sgblack@eecs.umich.edu Exit(1) 2416095Sgblack@eecs.umich.edu build_path = joinpath('/',*path_dirs[:build_top+2]) 2428610Snilay@cs.wisc.edu if build_path not in build_paths: 2436095Sgblack@eecs.umich.edu build_paths.append(build_path) 2446095Sgblack@eecs.umich.edu 2456095Sgblack@eecs.umich.edu# Make sure build_root exists (might not if this is the first build there) 2466095Sgblack@eecs.umich.eduif not isdir(build_root): 2478610Snilay@cs.wisc.edu os.mkdir(build_root) 2486095Sgblack@eecs.umich.edu 2496095Sgblack@eecs.umich.edu################################################### 2505240Sgblack@eecs.umich.edu# 2515240Sgblack@eecs.umich.edu# Set up the default build environment. This environment is copied 2525240Sgblack@eecs.umich.edu# and modified according to each selected configuration. 2535240Sgblack@eecs.umich.edu# 2545240Sgblack@eecs.umich.edu################################################### 2555240Sgblack@eecs.umich.edu 2565240Sgblack@eecs.umich.eduenv = Environment(ENV = os.environ, # inherit user's environment vars 2575240Sgblack@eecs.umich.edu ROOT = ROOT, 2585326Sgblack@eecs.umich.edu SRCDIR = SRCDIR) 2595326Sgblack@eecs.umich.edu 2605326Sgblack@eecs.umich.eduExport('env') 2615326Sgblack@eecs.umich.edu 2625326Sgblack@eecs.umich.eduenv.SConsignFile(joinpath(build_root,"sconsign")) 2635326Sgblack@eecs.umich.edu 2645240Sgblack@eecs.umich.edu# Default duplicate option is to use hard links, but this messes up 2655326Sgblack@eecs.umich.edu# when you use emacs to edit a file in the target dir, as emacs moves 2665326Sgblack@eecs.umich.edu# file to file~ then copies to file, breaking the link. Symbolic 2675240Sgblack@eecs.umich.edu# (soft) links work better. 2685240Sgblack@eecs.umich.eduenv.SetOption('duplicate', 'soft-copy') 2695240Sgblack@eecs.umich.edu 2705306Sgblack@eecs.umich.edu# I waffle on this setting... it does avoid a few painful but 2715326Sgblack@eecs.umich.edu# unnecessary builds, but it also seems to make trivial builds take 2725326Sgblack@eecs.umich.edu# noticeably longer. 2735326Sgblack@eecs.umich.eduif False: 2745326Sgblack@eecs.umich.edu env.TargetSignatures('content') 2757690Sgblack@eecs.umich.edu 2765240Sgblack@eecs.umich.edu# 2775326Sgblack@eecs.umich.edu# Set up global sticky options... these are common to an entire build 2787690Sgblack@eecs.umich.edu# tree (not specific to a particular build like ALPHA_SE) 2795240Sgblack@eecs.umich.edu# 2805240Sgblack@eecs.umich.edu 2816095Sgblack@eecs.umich.edu# Option validators & converters for global sticky options 2826095Sgblack@eecs.umich.edudef PathListMakeAbsolute(val): 2836095Sgblack@eecs.umich.edu if not val: 2846095Sgblack@eecs.umich.edu return val 2856095Sgblack@eecs.umich.edu f = lambda p: os.path.abspath(os.path.expanduser(p)) 2866095Sgblack@eecs.umich.edu return ':'.join(map(f, val.split(':'))) 2878610Snilay@cs.wisc.edu 2886095Sgblack@eecs.umich.edudef PathListAllExist(key, val, env): 2896095Sgblack@eecs.umich.edu if not val: 2906095Sgblack@eecs.umich.edu return 2916095Sgblack@eecs.umich.edu paths = val.split(':') 2928610Snilay@cs.wisc.edu for path in paths: 2936095Sgblack@eecs.umich.edu if not isdir(path): 2946095Sgblack@eecs.umich.edu raise SCons.Errors.UserError("Path does not exist: '%s'" % path) 2956095Sgblack@eecs.umich.edu 2966095Sgblack@eecs.umich.eduglobal_sticky_opts_file = joinpath(build_root, 'options.global') 2976095Sgblack@eecs.umich.edu 2986095Sgblack@eecs.umich.eduglobal_sticky_opts = Options(global_sticky_opts_file, args=ARGUMENTS) 2996095Sgblack@eecs.umich.edu 3006095Sgblack@eecs.umich.eduglobal_sticky_opts.AddOptions( 3018610Snilay@cs.wisc.edu ('CC', 'C compiler', os.environ.get('CC', env['CC'])), 3027690Sgblack@eecs.umich.edu ('CXX', 'C++ compiler', os.environ.get('CXX', env['CXX'])), 3036095Sgblack@eecs.umich.edu ('BATCH', 'Use batch pool for build and tests', False), 3046095Sgblack@eecs.umich.edu ('BATCH_CMD', 'Batch pool submission command name', 'qdo'), 3057690Sgblack@eecs.umich.edu ('EXTRAS', 'Add Extra directories to the compilation', '', 3068610Snilay@cs.wisc.edu PathListAllExist, PathListMakeAbsolute) 3076095Sgblack@eecs.umich.edu ) 3086095Sgblack@eecs.umich.edu 3095240Sgblack@eecs.umich.edu 3105240Sgblack@eecs.umich.edu# base help text 3115240Sgblack@eecs.umich.eduhelp_text = ''' 3125240Sgblack@eecs.umich.eduUsage: scons [scons options] [build options] [target(s)] 3135240Sgblack@eecs.umich.edu 3145240Sgblack@eecs.umich.edu''' 3155240Sgblack@eecs.umich.edu 3165240Sgblack@eecs.umich.eduhelp_text += "Global sticky options:\n" \ 3175306Sgblack@eecs.umich.edu + global_sticky_opts.GenerateHelpText(env) 3185326Sgblack@eecs.umich.edu 3195326Sgblack@eecs.umich.edu# Update env with values from ARGUMENTS & file global_sticky_opts_file 3205326Sgblack@eecs.umich.eduglobal_sticky_opts.Update(env) 3215240Sgblack@eecs.umich.edu 3225326Sgblack@eecs.umich.edu# Save sticky option settings back to current options file 3235326Sgblack@eecs.umich.eduglobal_sticky_opts.Save(global_sticky_opts_file, env) 3245240Sgblack@eecs.umich.edu 3255240Sgblack@eecs.umich.edu# Parse EXTRAS option to build list of all directories where we're 3265240Sgblack@eecs.umich.edu# look for sources etc. This list is exported as base_dir_list. 3275306Sgblack@eecs.umich.edubase_dir_list = [joinpath(ROOT, 'src')] 3285306Sgblack@eecs.umich.eduif env['EXTRAS']: 3295326Sgblack@eecs.umich.edu base_dir_list += env['EXTRAS'].split(':') 3305326Sgblack@eecs.umich.edu 3315326Sgblack@eecs.umich.eduExport('base_dir_list') 3325240Sgblack@eecs.umich.edu 3335326Sgblack@eecs.umich.edu# M5_PLY is used by isa_parser.py to find the PLY package. 3345326Sgblack@eecs.umich.eduenv.Append(ENV = { 'M5_PLY' : str(Dir('ext/ply')) }) 3355240Sgblack@eecs.umich.eduenv['GCC'] = subprocess.Popen(env['CXX'] + ' --version', shell=True, 3365240Sgblack@eecs.umich.edu stdout=subprocess.PIPE, stderr=subprocess.STDOUT, 3376093Sgblack@eecs.umich.edu close_fds=True).communicate()[0].find('g++') >= 0 3386093Sgblack@eecs.umich.eduenv['SUNCC'] = subprocess.Popen(env['CXX'] + ' -V', shell=True, 3396093Sgblack@eecs.umich.edu stdout=subprocess.PIPE, stderr=subprocess.STDOUT, 3406093Sgblack@eecs.umich.edu close_fds=True).communicate()[0].find('Sun C++') >= 0 3418610Snilay@cs.wisc.eduenv['ICC'] = subprocess.Popen(env['CXX'] + ' -V', shell=True, 3426093Sgblack@eecs.umich.edu stdout=subprocess.PIPE, stderr=subprocess.STDOUT, 3436093Sgblack@eecs.umich.edu close_fds=True).communicate()[0].find('Intel') >= 0 3446093Sgblack@eecs.umich.eduif env['GCC'] + env['SUNCC'] + env['ICC'] > 1: 3456093Sgblack@eecs.umich.edu print 'Error: How can we have two at the same time?' 3468610Snilay@cs.wisc.edu Exit(1) 3476093Sgblack@eecs.umich.edu 3486093Sgblack@eecs.umich.edu 3496093Sgblack@eecs.umich.edu# Set up default C++ compiler flags 3506093Sgblack@eecs.umich.eduif env['GCC']: 3516093Sgblack@eecs.umich.edu env.Append(CCFLAGS='-pipe') 3526093Sgblack@eecs.umich.edu env.Append(CCFLAGS='-fno-strict-aliasing') 3536093Sgblack@eecs.umich.edu env.Append(CCFLAGS=Split('-Wall -Wno-sign-compare -Werror -Wundef')) 3548610Snilay@cs.wisc.edu env.Append(CXXFLAGS='-Wno-deprecated') 3556093Sgblack@eecs.umich.eduelif env['ICC']: 3566093Sgblack@eecs.umich.edu pass #Fix me... add warning flags once we clean up icc warnings 3576093Sgblack@eecs.umich.eduelif env['SUNCC']: 3586093Sgblack@eecs.umich.edu env.Append(CCFLAGS='-Qoption ccfe') 3598610Snilay@cs.wisc.edu env.Append(CCFLAGS='-features=gcc') 3606093Sgblack@eecs.umich.edu env.Append(CCFLAGS='-features=extensions') 3616093Sgblack@eecs.umich.edu env.Append(CCFLAGS='-library=stlport4') 3625240Sgblack@eecs.umich.edu env.Append(CCFLAGS='-xar') 3635240Sgblack@eecs.umich.edu# env.Append(CCFLAGS='-instances=semiexplicit') 3645240Sgblack@eecs.umich.eduelse: 3655240Sgblack@eecs.umich.edu print 'Error: Don\'t know what compiler options to use for your compiler.' 3665240Sgblack@eecs.umich.edu print ' Please fix SConstruct and src/SConscript and try again.' 3675240Sgblack@eecs.umich.edu Exit(1) 3685240Sgblack@eecs.umich.edu 3695240Sgblack@eecs.umich.edu# Do this after we save setting back, or else we'll tack on an 3705326Sgblack@eecs.umich.edu# extra 'qdo' every time we run scons. 3715326Sgblack@eecs.umich.eduif env['BATCH']: 3725326Sgblack@eecs.umich.edu env['CC'] = env['BATCH_CMD'] + ' ' + env['CC'] 3735326Sgblack@eecs.umich.edu env['CXX'] = env['BATCH_CMD'] + ' ' + env['CXX'] 3745326Sgblack@eecs.umich.edu 3755326Sgblack@eecs.umich.eduif sys.platform == 'cygwin': 3765240Sgblack@eecs.umich.edu # cygwin has some header file issues... 3775326Sgblack@eecs.umich.edu env.Append(CCFLAGS=Split("-Wno-uninitialized")) 3785326Sgblack@eecs.umich.eduenv.Append(CPPPATH=[Dir('ext/dnet')]) 3795240Sgblack@eecs.umich.edu 3805240Sgblack@eecs.umich.edu# Check for SWIG 3815240Sgblack@eecs.umich.eduif not env.has_key('SWIG'): 3825306Sgblack@eecs.umich.edu print 'Error: SWIG utility not found.' 3835326Sgblack@eecs.umich.edu print ' Please install (see http://www.swig.org) and retry.' 3845326Sgblack@eecs.umich.edu Exit(1) 3855326Sgblack@eecs.umich.edu 3865326Sgblack@eecs.umich.edu# Check for appropriate SWIG version 3875326Sgblack@eecs.umich.eduswig_version = os.popen('swig -version').read().split() 3885326Sgblack@eecs.umich.edu# First 3 words should be "SWIG Version x.y.z" 3895240Sgblack@eecs.umich.eduif len(swig_version) < 3 or \ 3905326Sgblack@eecs.umich.edu swig_version[0] != 'SWIG' or swig_version[1] != 'Version': 3915326Sgblack@eecs.umich.edu print 'Error determining SWIG version.' 3925240Sgblack@eecs.umich.edu Exit(1) 3936093Sgblack@eecs.umich.edu 3946093Sgblack@eecs.umich.edumin_swig_version = '1.3.28' 3956093Sgblack@eecs.umich.eduif compare_versions(swig_version[2], min_swig_version) < 0: 3966093Sgblack@eecs.umich.edu print 'Error: SWIG version', min_swig_version, 'or newer required.' 3976093Sgblack@eecs.umich.edu print ' Installed version:', swig_version[2] 3986093Sgblack@eecs.umich.edu Exit(1) 3996093Sgblack@eecs.umich.edu 4008610Snilay@cs.wisc.edu# Set up SWIG flags & scanner 4016093Sgblack@eecs.umich.eduswig_flags=Split('-c++ -python -modern -templatereduce $_CPPINCFLAGS') 4026093Sgblack@eecs.umich.eduenv.Append(SWIGFLAGS=swig_flags) 4036093Sgblack@eecs.umich.edu 4046093Sgblack@eecs.umich.edu# filter out all existing swig scanners, they mess up the dependency 4058610Snilay@cs.wisc.edu# stuff for some reason 4066093Sgblack@eecs.umich.eduscanners = [] 4076093Sgblack@eecs.umich.edufor scanner in env['SCANNERS']: 4086093Sgblack@eecs.umich.edu skeys = scanner.skeys 4096093Sgblack@eecs.umich.edu if skeys == '.i': 4106093Sgblack@eecs.umich.edu continue 4116093Sgblack@eecs.umich.edu 4126093Sgblack@eecs.umich.edu if isinstance(skeys, (list, tuple)) and '.i' in skeys: 4136093Sgblack@eecs.umich.edu continue 4146093Sgblack@eecs.umich.edu 4158610Snilay@cs.wisc.edu scanners.append(scanner) 4166093Sgblack@eecs.umich.edu 4176093Sgblack@eecs.umich.edu# add the new swig scanner that we like better 4186093Sgblack@eecs.umich.edufrom SCons.Scanner import ClassicCPP as CPPScanner 4196093Sgblack@eecs.umich.eduswig_inc_re = '^[ \t]*[%,#][ \t]*(?:include|import)[ \t]*(<|")([^>"]+)(>|")' 4208610Snilay@cs.wisc.eduscanners.append(CPPScanner("SwigScan", [ ".i" ], "CPPPATH", swig_inc_re)) 4216093Sgblack@eecs.umich.edu 4225240Sgblack@eecs.umich.edu# replace the scanners list that has what we want 423env['SCANNERS'] = scanners 424 425# Add a custom Check function to the Configure context so that we can 426# figure out if the compiler adds leading underscores to global 427# variables. This is needed for the autogenerated asm files that we 428# use for embedding the python code. 429def CheckLeading(context): 430 context.Message("Checking for leading underscore in global variables...") 431 # 1) Define a global variable called x from asm so the C compiler 432 # won't change the symbol at all. 433 # 2) Declare that variable. 434 # 3) Use the variable 435 # 436 # If the compiler prepends an underscore, this will successfully 437 # link because the external symbol 'x' will be called '_x' which 438 # was defined by the asm statement. If the compiler does not 439 # prepend an underscore, this will not successfully link because 440 # '_x' will have been defined by assembly, while the C portion of 441 # the code will be trying to use 'x' 442 ret = context.TryLink(''' 443 asm(".globl _x; _x: .byte 0"); 444 extern int x; 445 int main() { return x; } 446 ''', extension=".c") 447 context.env.Append(LEADING_UNDERSCORE=ret) 448 context.Result(ret) 449 return ret 450 451# Platform-specific configuration. Note again that we assume that all 452# builds under a given build root run on the same host platform. 453conf = Configure(env, 454 conf_dir = joinpath(build_root, '.scons_config'), 455 log_file = joinpath(build_root, 'scons_config.log'), 456 custom_tests = { 'CheckLeading' : CheckLeading }) 457 458# Check for leading underscores. Don't really need to worry either 459# way so don't need to check the return code. 460conf.CheckLeading() 461 462# Check if we should compile a 64 bit binary on Mac OS X/Darwin 463try: 464 import platform 465 uname = platform.uname() 466 if uname[0] == 'Darwin' and compare_versions(uname[2], '9.0.0') >= 0: 467 if int(subprocess.Popen('sysctl -n hw.cpu64bit_capable', shell=True, 468 stdout=subprocess.PIPE, stderr=subprocess.STDOUT, 469 close_fds=True).communicate()[0][0]): 470 env.Append(CCFLAGS='-arch x86_64') 471 env.Append(CFLAGS='-arch x86_64') 472 env.Append(LINKFLAGS='-arch x86_64') 473 env.Append(ASFLAGS='-arch x86_64') 474except: 475 pass 476 477# Recent versions of scons substitute a "Null" object for Configure() 478# when configuration isn't necessary, e.g., if the "--help" option is 479# present. Unfortuantely this Null object always returns false, 480# breaking all our configuration checks. We replace it with our own 481# more optimistic null object that returns True instead. 482if not conf: 483 def NullCheck(*args, **kwargs): 484 return True 485 486 class NullConf: 487 def __init__(self, env): 488 self.env = env 489 def Finish(self): 490 return self.env 491 def __getattr__(self, mname): 492 return NullCheck 493 494 conf = NullConf(env) 495 496# Find Python include and library directories for embedding the 497# interpreter. For consistency, we will use the same Python 498# installation used to run scons (and thus this script). If you want 499# to link in an alternate version, see above for instructions on how 500# to invoke scons with a different copy of the Python interpreter. 501 502# Get brief Python version name (e.g., "python2.4") for locating 503# include & library files 504py_version_name = 'python' + sys.version[:3] 505 506# include path, e.g. /usr/local/include/python2.4 507py_header_path = joinpath(sys.exec_prefix, 'include', py_version_name) 508env.Append(CPPPATH = py_header_path) 509# verify that it works 510if not conf.CheckHeader('Python.h', '<>'): 511 print "Error: can't find Python.h header in", py_header_path 512 Exit(1) 513 514# add library path too if it's not in the default place 515py_lib_path = None 516if sys.exec_prefix != '/usr': 517 py_lib_path = joinpath(sys.exec_prefix, 'lib') 518elif sys.platform == 'cygwin': 519 # cygwin puts the .dll in /bin for some reason 520 py_lib_path = '/bin' 521if py_lib_path: 522 env.Append(LIBPATH = py_lib_path) 523 print 'Adding', py_lib_path, 'to LIBPATH for', py_version_name 524if not conf.CheckLib(py_version_name): 525 print "Error: can't find Python library", py_version_name 526 Exit(1) 527 528# On Solaris you need to use libsocket for socket ops 529if not conf.CheckLibWithHeader(None, 'sys/socket.h', 'C++', 'accept(0,0,0);'): 530 if not conf.CheckLibWithHeader('socket', 'sys/socket.h', 'C++', 'accept(0,0,0);'): 531 print "Can't find library with socket calls (e.g. accept())" 532 Exit(1) 533 534# Check for zlib. If the check passes, libz will be automatically 535# added to the LIBS environment variable. 536if not conf.CheckLibWithHeader('z', 'zlib.h', 'C++','zlibVersion();'): 537 print 'Error: did not find needed zlib compression library '\ 538 'and/or zlib.h header file.' 539 print ' Please install zlib and try again.' 540 Exit(1) 541 542# Check for <fenv.h> (C99 FP environment control) 543have_fenv = conf.CheckHeader('fenv.h', '<>') 544if not have_fenv: 545 print "Warning: Header file <fenv.h> not found." 546 print " This host has no IEEE FP rounding mode control." 547 548# Check for mysql. 549mysql_config = WhereIs('mysql_config') 550have_mysql = mysql_config != None 551 552# Check MySQL version. 553if have_mysql: 554 mysql_version = os.popen(mysql_config + ' --version').read() 555 min_mysql_version = '4.1' 556 if compare_versions(mysql_version, min_mysql_version) < 0: 557 print 'Warning: MySQL', min_mysql_version, 'or newer required.' 558 print ' Version', mysql_version, 'detected.' 559 have_mysql = False 560 561# Set up mysql_config commands. 562if have_mysql: 563 mysql_config_include = mysql_config + ' --include' 564 if os.system(mysql_config_include + ' > /dev/null') != 0: 565 # older mysql_config versions don't support --include, use 566 # --cflags instead 567 mysql_config_include = mysql_config + ' --cflags | sed s/\\\'//g' 568 # This seems to work in all versions 569 mysql_config_libs = mysql_config + ' --libs' 570 571env = conf.Finish() 572 573# Define the universe of supported ISAs 574all_isa_list = [ ] 575Export('all_isa_list') 576 577# Define the universe of supported CPU models 578all_cpu_list = [ ] 579default_cpus = [ ] 580Export('all_cpu_list', 'default_cpus') 581 582# Sticky options get saved in the options file so they persist from 583# one invocation to the next (unless overridden, in which case the new 584# value becomes sticky). 585sticky_opts = Options(args=ARGUMENTS) 586Export('sticky_opts') 587 588# Non-sticky options only apply to the current build. 589nonsticky_opts = Options(args=ARGUMENTS) 590Export('nonsticky_opts') 591 592# Walk the tree and execute all SConsopts scripts that wil add to the 593# above options 594for base_dir in base_dir_list: 595 for root, dirs, files in os.walk(base_dir): 596 if 'SConsopts' in files: 597 print "Reading", joinpath(root, 'SConsopts') 598 SConscript(joinpath(root, 'SConsopts')) 599 600all_isa_list.sort() 601all_cpu_list.sort() 602default_cpus.sort() 603 604sticky_opts.AddOptions( 605 EnumOption('TARGET_ISA', 'Target ISA', 'alpha', all_isa_list), 606 BoolOption('FULL_SYSTEM', 'Full-system support', False), 607 # There's a bug in scons 0.96.1 that causes ListOptions with list 608 # values (more than one value) not to be able to be restored from 609 # a saved option file. If this causes trouble then upgrade to 610 # scons 0.96.90 or later. 611 ListOption('CPU_MODELS', 'CPU models', default_cpus, all_cpu_list), 612 BoolOption('NO_FAST_ALLOC', 'Disable fast object allocator', False), 613 BoolOption('FAST_ALLOC_DEBUG', 'Enable fast object allocator debugging', 614 False), 615 BoolOption('FAST_ALLOC_STATS', 'Enable fast object allocator statistics', 616 False), 617 BoolOption('EFENCE', 'Link with Electric Fence malloc debugger', 618 False), 619 BoolOption('SS_COMPATIBLE_FP', 620 'Make floating-point results compatible with SimpleScalar', 621 False), 622 BoolOption('USE_SSE2', 623 'Compile for SSE2 (-msse2) to get IEEE FP on x86 hosts', 624 False), 625 BoolOption('USE_MYSQL', 'Use MySQL for stats output', have_mysql), 626 BoolOption('USE_FENV', 'Use <fenv.h> IEEE mode control', have_fenv), 627 BoolOption('USE_CHECKER', 'Use checker for detailed CPU models', False), 628 ) 629 630nonsticky_opts.AddOptions( 631 BoolOption('update_ref', 'Update test reference outputs', False) 632 ) 633 634# These options get exported to #defines in config/*.hh (see src/SConscript). 635env.ExportOptions = ['FULL_SYSTEM', 'ALPHA_TLASER', 'USE_FENV', \ 636 'USE_MYSQL', 'NO_FAST_ALLOC', 'FAST_ALLOC_DEBUG', \ 637 'FAST_ALLOC_STATS', 'SS_COMPATIBLE_FP', \ 638 'USE_CHECKER', 'TARGET_ISA'] 639 640# Define a handy 'no-op' action 641def no_action(target, source, env): 642 return 0 643 644env.NoAction = Action(no_action, None) 645 646################################################### 647# 648# Define a SCons builder for configuration flag headers. 649# 650################################################### 651 652# This function generates a config header file that #defines the 653# option symbol to the current option setting (0 or 1). The source 654# operands are the name of the option and a Value node containing the 655# value of the option. 656def build_config_file(target, source, env): 657 (option, value) = [s.get_contents() for s in source] 658 f = file(str(target[0]), 'w') 659 print >> f, '#define', option, value 660 f.close() 661 return None 662 663# Generate the message to be printed when building the config file. 664def build_config_file_string(target, source, env): 665 (option, value) = [s.get_contents() for s in source] 666 return "Defining %s as %s in %s." % (option, value, target[0]) 667 668# Combine the two functions into a scons Action object. 669config_action = Action(build_config_file, build_config_file_string) 670 671# The emitter munges the source & target node lists to reflect what 672# we're really doing. 673def config_emitter(target, source, env): 674 # extract option name from Builder arg 675 option = str(target[0]) 676 # True target is config header file 677 target = joinpath('config', option.lower() + '.hh') 678 val = env[option] 679 if isinstance(val, bool): 680 # Force value to 0/1 681 val = int(val) 682 elif isinstance(val, str): 683 val = '"' + val + '"' 684 685 # Sources are option name & value (packaged in SCons Value nodes) 686 return ([target], [Value(option), Value(val)]) 687 688config_builder = Builder(emitter = config_emitter, action = config_action) 689 690env.Append(BUILDERS = { 'ConfigFile' : config_builder }) 691 692################################################### 693# 694# Define a SCons builder for copying files. This is used by the 695# Python zipfile code in src/python/SConscript, but is placed up here 696# since it's potentially more generally applicable. 697# 698################################################### 699 700copy_builder = Builder(action = Copy("$TARGET", "$SOURCE")) 701 702env.Append(BUILDERS = { 'CopyFile' : copy_builder }) 703 704################################################### 705# 706# Define a simple SCons builder to concatenate files. 707# 708# Used to append the Python zip archive to the executable. 709# 710################################################### 711 712concat_builder = Builder(action = Action(['cat $SOURCES > $TARGET', 713 'chmod +x $TARGET'])) 714 715env.Append(BUILDERS = { 'Concat' : concat_builder }) 716 717 718# libelf build is shared across all configs in the build root. 719env.SConscript('ext/libelf/SConscript', 720 build_dir = joinpath(build_root, 'libelf'), 721 exports = 'env') 722 723################################################### 724# 725# This function is used to set up a directory with switching headers 726# 727################################################### 728 729env['ALL_ISA_LIST'] = all_isa_list 730def make_switching_dir(dirname, switch_headers, env): 731 # Generate the header. target[0] is the full path of the output 732 # header to generate. 'source' is a dummy variable, since we get the 733 # list of ISAs from env['ALL_ISA_LIST']. 734 def gen_switch_hdr(target, source, env): 735 fname = str(target[0]) 736 basename = os.path.basename(fname) 737 f = open(fname, 'w') 738 f.write('#include "arch/isa_specific.hh"\n') 739 cond = '#if' 740 for isa in all_isa_list: 741 f.write('%s THE_ISA == %s_ISA\n#include "%s/%s/%s"\n' 742 % (cond, isa.upper(), dirname, isa, basename)) 743 cond = '#elif' 744 f.write('#else\n#error "THE_ISA not set"\n#endif\n') 745 f.close() 746 return 0 747 748 # String to print when generating header 749 def gen_switch_hdr_string(target, source, env): 750 return "Generating switch header " + str(target[0]) 751 752 # Build SCons Action object. 'varlist' specifies env vars that this 753 # action depends on; when env['ALL_ISA_LIST'] changes these actions 754 # should get re-executed. 755 switch_hdr_action = Action(gen_switch_hdr, gen_switch_hdr_string, 756 varlist=['ALL_ISA_LIST']) 757 758 # Instantiate actions for each header 759 for hdr in switch_headers: 760 env.Command(hdr, [], switch_hdr_action) 761Export('make_switching_dir') 762 763################################################### 764# 765# Define build environments for selected configurations. 766# 767################################################### 768 769# rename base env 770base_env = env 771 772for build_path in build_paths: 773 print "Building in", build_path 774 775 # Make a copy of the build-root environment to use for this config. 776 env = base_env.Copy() 777 env['BUILDDIR'] = build_path 778 779 # build_dir is the tail component of build path, and is used to 780 # determine the build parameters (e.g., 'ALPHA_SE') 781 (build_root, build_dir) = os.path.split(build_path) 782 783 # Set env options according to the build directory config. 784 sticky_opts.files = [] 785 # Options for $BUILD_ROOT/$BUILD_DIR are stored in 786 # $BUILD_ROOT/options/$BUILD_DIR so you can nuke 787 # $BUILD_ROOT/$BUILD_DIR without losing your options settings. 788 current_opts_file = joinpath(build_root, 'options', build_dir) 789 if isfile(current_opts_file): 790 sticky_opts.files.append(current_opts_file) 791 print "Using saved options file %s" % current_opts_file 792 else: 793 # Build dir-specific options file doesn't exist. 794 795 # Make sure the directory is there so we can create it later 796 opt_dir = os.path.dirname(current_opts_file) 797 if not isdir(opt_dir): 798 os.mkdir(opt_dir) 799 800 # Get default build options from source tree. Options are 801 # normally determined by name of $BUILD_DIR, but can be 802 # overriden by 'default=' arg on command line. 803 default_opts_file = joinpath('build_opts', 804 ARGUMENTS.get('default', build_dir)) 805 if isfile(default_opts_file): 806 sticky_opts.files.append(default_opts_file) 807 print "Options file %s not found,\n using defaults in %s" \ 808 % (current_opts_file, default_opts_file) 809 else: 810 print "Error: cannot find options file %s or %s" \ 811 % (current_opts_file, default_opts_file) 812 Exit(1) 813 814 # Apply current option settings to env 815 sticky_opts.Update(env) 816 nonsticky_opts.Update(env) 817 818 help_text += "\nSticky options for %s:\n" % build_dir \ 819 + sticky_opts.GenerateHelpText(env) \ 820 + "\nNon-sticky options for %s:\n" % build_dir \ 821 + nonsticky_opts.GenerateHelpText(env) 822 823 # Process option settings. 824 825 if not have_fenv and env['USE_FENV']: 826 print "Warning: <fenv.h> not available; " \ 827 "forcing USE_FENV to False in", build_dir + "." 828 env['USE_FENV'] = False 829 830 if not env['USE_FENV']: 831 print "Warning: No IEEE FP rounding mode control in", build_dir + "." 832 print " FP results may deviate slightly from other platforms." 833 834 if env['EFENCE']: 835 env.Append(LIBS=['efence']) 836 837 if env['USE_MYSQL']: 838 if not have_mysql: 839 print "Warning: MySQL not available; " \ 840 "forcing USE_MYSQL to False in", build_dir + "." 841 env['USE_MYSQL'] = False 842 else: 843 print "Compiling in", build_dir, "with MySQL support." 844 env.ParseConfig(mysql_config_libs) 845 env.ParseConfig(mysql_config_include) 846 847 # Save sticky option settings back to current options file 848 sticky_opts.Save(current_opts_file, env) 849 850 if env['USE_SSE2']: 851 env.Append(CCFLAGS='-msse2') 852 853 # The src/SConscript file sets up the build rules in 'env' according 854 # to the configured options. It returns a list of environments, 855 # one for each variant build (debug, opt, etc.) 856 envList = SConscript('src/SConscript', build_dir = build_path, 857 exports = 'env') 858 859 # Set up the regression tests for each build. 860 for e in envList: 861 SConscript('tests/SConscript', 862 build_dir = joinpath(build_path, 'tests', e.Label), 863 exports = { 'env' : e }, duplicate = False) 864 865Help(help_text) 866 867 868################################################### 869# 870# Let SCons do its thing. At this point SCons will use the defined 871# build environments to build the requested targets. 872# 873################################################### 874 875