SConstruct revision 5204
1955SN/A# -*- mode:python -*-
2955SN/A
31762SN/A# Copyright (c) 2004-2005 The Regents of The University of Michigan
4955SN/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.
282665Ssaidi@eecs.umich.edu#
292665Ssaidi@eecs.umich.edu# Authors: Steve Reinhardt
30955SN/A
31955SN/A###################################################
32955SN/A#
33955SN/A# SCons top-level build description (SConstruct) file.
34955SN/A#
352632Sstever@eecs.umich.edu# While in this directory ('m5'), just type 'scons' to build the default
362632Sstever@eecs.umich.edu# 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).
39955SN/A#
402632Sstever@eecs.umich.edu# You can build M5 in a different directory as long as there is a
412632Sstever@eecs.umich.edu# 'build/<CONFIG>' somewhere along the target path.  The build system
422761Sstever@eecs.umich.edu# expects that all configs under the same build directory are being
432632Sstever@eecs.umich.edu# built for the same host system.
442632Sstever@eecs.umich.edu#
452632Sstever@eecs.umich.edu# Examples:
462761Sstever@eecs.umich.edu#
472761Sstever@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.
492632Sstever@eecs.umich.edu#   % cd <path-to-src>/m5 ; scons build/ALPHA_FS/m5.debug
502632Sstever@eecs.umich.edu#   % cd <path-to-src>/m5/build/ALPHA_FS; scons -u m5.debug
512761Sstever@eecs.umich.edu#
522761Sstever@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.
562632Sstever@eecs.umich.edu#   % cd <path-to-src>/m5 ; scons /local/foo/build/ALPHA_FS/m5.debug
572632Sstever@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.
63955SN/A#
64955SN/A###################################################
65955SN/A
66955SN/Aimport sys
67955SN/Aimport os
684202Sbinkertn@umich.eduimport subprocess
695342Sstever@gmail.com
70955SN/Afrom os.path import isdir, join as joinpath
715273Sstever@gmail.com
725273Sstever@gmail.com# Check for recent-enough Python and SCons versions.  If your system's
732656Sstever@eecs.umich.edu# default installation of Python is not recent enough, you can use a
742656Sstever@eecs.umich.edu# non-default installation of the Python interpreter by either (1)
752656Sstever@eecs.umich.edu# rearranging your PATH so that scons finds the non-default 'python'
762656Sstever@eecs.umich.edu# first or (2) explicitly invoking an alternative interpreter on the
772656Sstever@eecs.umich.edu# scons script, e.g., "/usr/local/bin/python2.4 `which scons` [args]".
782656Sstever@eecs.umich.eduEnsurePythonVersion(2,4)
792656Sstever@eecs.umich.edu
802653Sstever@eecs.umich.edu# Ironically, SCons 0.96 dies if you give EnsureSconsVersion a
815227Ssaidi@eecs.umich.edu# 3-element version number.
825227Ssaidi@eecs.umich.edumin_scons_version = (0,96,91)
835227Ssaidi@eecs.umich.edutry:
845227Ssaidi@eecs.umich.edu    EnsureSConsVersion(*min_scons_version)
852653Sstever@eecs.umich.eduexcept:
862653Sstever@eecs.umich.edu    print "Error checking current SCons version."
872653Sstever@eecs.umich.edu    print "SCons", ".".join(map(str,min_scons_version)), "or greater required."
882653Sstever@eecs.umich.edu    Exit(2)
892653Sstever@eecs.umich.edu
902653Sstever@eecs.umich.edu
912653Sstever@eecs.umich.edu# The absolute path to the current directory (where this file lives).
922653Sstever@eecs.umich.eduROOT = Dir('.').abspath
932653Sstever@eecs.umich.edu
944781Snate@binkert.org# Path to the M5 source tree.
951852SN/ASRCDIR = joinpath(ROOT, 'src')
96955SN/A
97955SN/A# tell python where to find m5 python code
98955SN/Asys.path.append(joinpath(ROOT, 'src/python'))
993717Sstever@eecs.umich.edu
1003716Sstever@eecs.umich.edudef check_style_hook(ui):
101955SN/A    ui.readconfig(joinpath(ROOT, '.hg', 'hgrc'))
1021533SN/A    style_hook = ui.config('hooks', 'pretxncommit.style', None)
1033716Sstever@eecs.umich.edu
1041533SN/A    if not style_hook:
1054678Snate@binkert.org        print """\
1064678Snate@binkert.orgYou're missing the M5 style hook.
1074678Snate@binkert.orgPlease install the hook so we can ensure that all code fits a common style.
1084678Snate@binkert.org
1094678Snate@binkert.orgAll you'd need to do is add the following lines to your repository .hg/hgrc
1104678Snate@binkert.orgor your personal .hgrc
1114678Snate@binkert.org----------------
1124678Snate@binkert.org
1134678Snate@binkert.org[extensions]
1144678Snate@binkert.orgstyle = %s/util/style.py
1154678Snate@binkert.org
1164678Snate@binkert.org[hooks]
1174678Snate@binkert.orgpretxncommit.style = python:style.check_whitespace
1184678Snate@binkert.org""" % (ROOT)
1194678Snate@binkert.org        sys.exit(1)
1204678Snate@binkert.org
1214678Snate@binkert.orgif ARGUMENTS.get('IGNORE_STYLE') != 'True' and isdir(joinpath(ROOT, '.hg')):
1224678Snate@binkert.org    try:
1234678Snate@binkert.org        from mercurial import ui
1244678Snate@binkert.org        check_style_hook(ui.ui())
1254678Snate@binkert.org    except ImportError:
1264973Ssaidi@eecs.umich.edu        pass
1274678Snate@binkert.org
1284678Snate@binkert.org###################################################
1294678Snate@binkert.org#
1304678Snate@binkert.org# Figure out which configurations to set up based on the path(s) of
1314678Snate@binkert.org# the target(s).
1324678Snate@binkert.org#
133955SN/A###################################################
134955SN/A
1352632Sstever@eecs.umich.edu# Find default configuration & binary.
1362632Sstever@eecs.umich.eduDefault(os.environ.get('M5_DEFAULT_BINARY', 'build/ALPHA_SE/m5.debug'))
137955SN/A
138955SN/A# helper function: find last occurrence of element in list
139955SN/Adef rfind(l, elt, offs = -1):
140955SN/A    for i in range(len(l)+offs, 0, -1):
1412632Sstever@eecs.umich.edu        if l[i] == elt:
142955SN/A            return i
1432632Sstever@eecs.umich.edu    raise ValueError, "element not found"
1442632Sstever@eecs.umich.edu
1452632Sstever@eecs.umich.edu# helper function: compare dotted version numbers.
1462632Sstever@eecs.umich.edu# E.g., compare_version('1.3.25', '1.4.1')
1472632Sstever@eecs.umich.edu# returns -1, 0, 1 if v1 is <, ==, > v2
1482632Sstever@eecs.umich.edudef compare_versions(v1, v2):
1492632Sstever@eecs.umich.edu    # Convert dotted strings to lists
1503053Sstever@eecs.umich.edu    v1 = map(int, v1.split('.'))
1513053Sstever@eecs.umich.edu    v2 = map(int, v2.split('.'))
1523053Sstever@eecs.umich.edu    # Compare corresponding elements of lists
1533053Sstever@eecs.umich.edu    for n1,n2 in zip(v1, v2):
1543053Sstever@eecs.umich.edu        if n1 < n2: return -1
1553053Sstever@eecs.umich.edu        if n1 > n2: return  1
1563053Sstever@eecs.umich.edu    # all corresponding values are equal... see if one has extra values
1573053Sstever@eecs.umich.edu    if len(v1) < len(v2): return -1
1583053Sstever@eecs.umich.edu    if len(v1) > len(v2): return  1
1593053Sstever@eecs.umich.edu    return 0
1603053Sstever@eecs.umich.edu
1613053Sstever@eecs.umich.edu# Each target must have 'build' in the interior of the path; the
1623053Sstever@eecs.umich.edu# directory below this will determine the build parameters.  For
1633053Sstever@eecs.umich.edu# example, for target 'foo/bar/build/ALPHA_SE/arch/alpha/blah.do' we
1643053Sstever@eecs.umich.edu# recognize that ALPHA_SE specifies the configuration because it
1653053Sstever@eecs.umich.edu# follow 'build' in the bulid path.
1662632Sstever@eecs.umich.edu
1672632Sstever@eecs.umich.edu# Generate absolute paths to targets so we can see where the build dir is
1682632Sstever@eecs.umich.eduif COMMAND_LINE_TARGETS:
1692632Sstever@eecs.umich.edu    # Ask SCons which directory it was invoked from
1702632Sstever@eecs.umich.edu    launch_dir = GetLaunchDir()
1712632Sstever@eecs.umich.edu    # Make targets relative to invocation directory
1723718Sstever@eecs.umich.edu    abs_targets = map(lambda x: os.path.normpath(joinpath(launch_dir, str(x))),
1733718Sstever@eecs.umich.edu                      COMMAND_LINE_TARGETS)
1743718Sstever@eecs.umich.eduelse:
1753718Sstever@eecs.umich.edu    # Default targets are relative to root of tree
1763718Sstever@eecs.umich.edu    abs_targets = map(lambda x: os.path.normpath(joinpath(ROOT, str(x))),
1773718Sstever@eecs.umich.edu                      DEFAULT_TARGETS)
1783718Sstever@eecs.umich.edu
1793718Sstever@eecs.umich.edu
1803718Sstever@eecs.umich.edu# Generate a list of the unique build roots and configs that the
1813718Sstever@eecs.umich.edu# collected targets reference.
1823718Sstever@eecs.umich.edubuild_paths = []
1833718Sstever@eecs.umich.edubuild_root = None
1843718Sstever@eecs.umich.edufor t in abs_targets:
1852634Sstever@eecs.umich.edu    path_dirs = t.split('/')
1862634Sstever@eecs.umich.edu    try:
1872632Sstever@eecs.umich.edu        build_top = rfind(path_dirs, 'build', -2)
1882638Sstever@eecs.umich.edu    except:
1892632Sstever@eecs.umich.edu        print "Error: no non-leaf 'build' dir found on target path", t
1902632Sstever@eecs.umich.edu        Exit(1)
1912632Sstever@eecs.umich.edu    this_build_root = joinpath('/',*path_dirs[:build_top+1])
1922632Sstever@eecs.umich.edu    if not build_root:
1932632Sstever@eecs.umich.edu        build_root = this_build_root
1942632Sstever@eecs.umich.edu    else:
1951858SN/A        if this_build_root != build_root:
1963716Sstever@eecs.umich.edu            print "Error: build targets not under same build root\n"\
1972638Sstever@eecs.umich.edu                  "  %s\n  %s" % (build_root, this_build_root)
1982638Sstever@eecs.umich.edu            Exit(1)
1992638Sstever@eecs.umich.edu    build_path = joinpath('/',*path_dirs[:build_top+2])
2002638Sstever@eecs.umich.edu    if build_path not in build_paths:
2012638Sstever@eecs.umich.edu        build_paths.append(build_path)
2022638Sstever@eecs.umich.edu
2032638Sstever@eecs.umich.edu###################################################
2043716Sstever@eecs.umich.edu#
2052634Sstever@eecs.umich.edu# Set up the default build environment.  This environment is copied
2062634Sstever@eecs.umich.edu# and modified according to each selected configuration.
207955SN/A#
2085341Sstever@gmail.com###################################################
2095341Sstever@gmail.com
2105341Sstever@gmail.comenv = Environment(ENV = os.environ,  # inherit user's environment vars
2115341Sstever@gmail.com                  ROOT = ROOT,
212955SN/A                  SRCDIR = SRCDIR)
213955SN/A
214955SN/A#Parse CC/CXX early so that we use the correct compiler for
215955SN/A# to test for dependencies/versions/libraries/includes
216955SN/Aif ARGUMENTS.get('CC', None):
217955SN/A    env['CC'] = ARGUMENTS.get('CC')
218955SN/A
2191858SN/Aif ARGUMENTS.get('CXX', None):
2201858SN/A    env['CXX'] = ARGUMENTS.get('CXX')
2212632Sstever@eecs.umich.edu
222955SN/AExport('env')
2234494Ssaidi@eecs.umich.edu
2244494Ssaidi@eecs.umich.eduenv.SConsignFile(joinpath(build_root,"sconsign"))
2253716Sstever@eecs.umich.edu
2261105SN/A# Default duplicate option is to use hard links, but this messes up
2272667Sstever@eecs.umich.edu# when you use emacs to edit a file in the target dir, as emacs moves
2282667Sstever@eecs.umich.edu# file to file~ then copies to file, breaking the link.  Symbolic
2292667Sstever@eecs.umich.edu# (soft) links work better.
2302667Sstever@eecs.umich.eduenv.SetOption('duplicate', 'soft-copy')
2312667Sstever@eecs.umich.edu
2322667Sstever@eecs.umich.edu# I waffle on this setting... it does avoid a few painful but
2331869SN/A# unnecessary builds, but it also seems to make trivial builds take
2341869SN/A# noticeably longer.
2351869SN/Aif False:
2361869SN/A    env.TargetSignatures('content')
2371869SN/A
2381065SN/A# M5_PLY is used by isa_parser.py to find the PLY package.
2395341Sstever@gmail.comenv.Append(ENV = { 'M5_PLY' : str(Dir('ext/ply')) })
2405341Sstever@gmail.comenv['GCC'] = False
2415341Sstever@gmail.comenv['SUNCC'] = False
2425341Sstever@gmail.comenv['ICC'] = False
2435341Sstever@gmail.comenv['GCC'] = subprocess.Popen(env['CXX'] + ' --version', shell=True,
2445341Sstever@gmail.com        stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
2455341Sstever@gmail.com        close_fds=True).communicate()[0].find('GCC') >= 0
2465341Sstever@gmail.comenv['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
2495341Sstever@gmail.comenv['ICC'] = subprocess.Popen(env['CXX'] + ' -V', shell=True,
2505341Sstever@gmail.com        stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
2515341Sstever@gmail.com        close_fds=True).communicate()[0].find('Intel') >= 0
2525341Sstever@gmail.comif env['GCC'] + env['SUNCC'] + env['ICC'] > 1:
2535341Sstever@gmail.com    print 'Error: How can we have two at the same time?'
2545341Sstever@gmail.com    Exit(1)
2555341Sstever@gmail.com
2565341Sstever@gmail.com
2575341Sstever@gmail.com# Set up default C++ compiler flags
2585341Sstever@gmail.comif env['GCC']:
2595341Sstever@gmail.com    env.Append(CCFLAGS='-pipe')
2605341Sstever@gmail.com    env.Append(CCFLAGS='-fno-strict-aliasing')
2615341Sstever@gmail.com    env.Append(CCFLAGS=Split('-Wall -Wno-sign-compare -Werror -Wundef'))
2625341Sstever@gmail.comelif env['ICC']:
2635341Sstever@gmail.com    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')
2675341Sstever@gmail.com    env.Append(CCFLAGS='-features=extensions')
2685341Sstever@gmail.com    env.Append(CCFLAGS='-library=stlport4')
2695341Sstever@gmail.com    env.Append(CCFLAGS='-xar')
2705341Sstever@gmail.com#    env.Append(CCFLAGS='-instances=semiexplicit')
2715341Sstever@gmail.comelse:
2725341Sstever@gmail.com    print 'Error: Don\'t know what compiler options to use for your compiler.'
2735341Sstever@gmail.com    print '       Please fix SConstruct and src/SConscript and try again.'
2745341Sstever@gmail.com    Exit(1)
2755341Sstever@gmail.com
2765341Sstever@gmail.comif sys.platform == 'cygwin':
2775341Sstever@gmail.com    # cygwin has some header file issues...
2785341Sstever@gmail.com    env.Append(CCFLAGS=Split("-Wno-uninitialized"))
2795341Sstever@gmail.comenv.Append(CPPPATH=[Dir('ext/dnet')])
2805341Sstever@gmail.com
2815341Sstever@gmail.com# Check for SWIG
2825341Sstever@gmail.comif not env.has_key('SWIG'):
2835341Sstever@gmail.com    print 'Error: SWIG utility not found.'
2845341Sstever@gmail.com    print '       Please install (see http://www.swig.org) and retry.'
2855341Sstever@gmail.com    Exit(1)
2865341Sstever@gmail.com
2875341Sstever@gmail.com# Check for appropriate SWIG version
2885341Sstever@gmail.comswig_version = os.popen('swig -version').read().split()
2895341Sstever@gmail.com# First 3 words should be "SWIG Version x.y.z"
2905341Sstever@gmail.comif len(swig_version) < 3 or \
2915341Sstever@gmail.com        swig_version[0] != 'SWIG' or swig_version[1] != 'Version':
2925341Sstever@gmail.com    print 'Error determining SWIG version.'
2935341Sstever@gmail.com    Exit(1)
2942632Sstever@eecs.umich.edu
2955199Sstever@gmail.commin_swig_version = '1.3.28'
2963918Ssaidi@eecs.umich.eduif compare_versions(swig_version[2], min_swig_version) < 0:
2973918Ssaidi@eecs.umich.edu    print 'Error: SWIG version', min_swig_version, 'or newer required.'
2983940Ssaidi@eecs.umich.edu    print '       Installed version:', swig_version[2]
2994781Snate@binkert.org    Exit(1)
3004781Snate@binkert.org
3013918Ssaidi@eecs.umich.edu# Set up SWIG flags & scanner
3024781Snate@binkert.orgswig_flags=Split('-c++ -python -modern -templatereduce $_CPPINCFLAGS')
3034781Snate@binkert.orgenv.Append(SWIGFLAGS=swig_flags)
3043918Ssaidi@eecs.umich.edu
3054781Snate@binkert.org# filter out all existing swig scanners, they mess up the dependency
3064781Snate@binkert.org# stuff for some reason
3073940Ssaidi@eecs.umich.eduscanners = []
3083942Ssaidi@eecs.umich.edufor scanner in env['SCANNERS']:
3093940Ssaidi@eecs.umich.edu    skeys = scanner.skeys
3103918Ssaidi@eecs.umich.edu    if skeys == '.i':
3113918Ssaidi@eecs.umich.edu        continue
312955SN/A
3131858SN/A    if isinstance(skeys, (list, tuple)) and '.i' in skeys:
3143918Ssaidi@eecs.umich.edu        continue
3153918Ssaidi@eecs.umich.edu
3163918Ssaidi@eecs.umich.edu    scanners.append(scanner)
3173918Ssaidi@eecs.umich.edu
3183940Ssaidi@eecs.umich.edu# add the new swig scanner that we like better
3193940Ssaidi@eecs.umich.edufrom SCons.Scanner import ClassicCPP as CPPScanner
3203918Ssaidi@eecs.umich.eduswig_inc_re = '^[ \t]*[%,#][ \t]*(?:include|import)[ \t]*(<|")([^>"]+)(>|")'
3213918Ssaidi@eecs.umich.eduscanners.append(CPPScanner("SwigScan", [ ".i" ], "CPPPATH", swig_inc_re))
3223918Ssaidi@eecs.umich.edu
3233918Ssaidi@eecs.umich.edu# replace the scanners list that has what we want
3243918Ssaidi@eecs.umich.eduenv['SCANNERS'] = scanners
3253918Ssaidi@eecs.umich.edu
3263918Ssaidi@eecs.umich.edu# Platform-specific configuration.  Note again that we assume that all
3273918Ssaidi@eecs.umich.edu# builds under a given build root run on the same host platform.
3283918Ssaidi@eecs.umich.educonf = Configure(env,
3293940Ssaidi@eecs.umich.edu                 conf_dir = joinpath(build_root, '.scons_config'),
3303918Ssaidi@eecs.umich.edu                 log_file = joinpath(build_root, 'scons_config.log'))
3313918Ssaidi@eecs.umich.edu
3321851SN/A# Recent versions of scons substitute a "Null" object for Configure()
3331851SN/A# when configuration isn't necessary, e.g., if the "--help" option is
3341858SN/A# present.  Unfortuantely this Null object always returns false,
3355200Sstever@gmail.com# breaking all our configuration checks.  We replace it with our own
336955SN/A# more optimistic null object that returns True instead.
3373053Sstever@eecs.umich.eduif not conf:
3383053Sstever@eecs.umich.edu    def NullCheck(*args, **kwargs):
3393053Sstever@eecs.umich.edu        return True
3403053Sstever@eecs.umich.edu
3413053Sstever@eecs.umich.edu    class NullConf:
3423053Sstever@eecs.umich.edu        def __init__(self, env):
3433053Sstever@eecs.umich.edu            self.env = env
3443053Sstever@eecs.umich.edu        def Finish(self):
3453053Sstever@eecs.umich.edu            return self.env
3464742Sstever@eecs.umich.edu        def __getattr__(self, mname):
3474742Sstever@eecs.umich.edu            return NullCheck
3483053Sstever@eecs.umich.edu
3493053Sstever@eecs.umich.edu    conf = NullConf(env)
3503053Sstever@eecs.umich.edu
3513053Sstever@eecs.umich.edu# Find Python include and library directories for embedding the
3523053Sstever@eecs.umich.edu# interpreter.  For consistency, we will use the same Python
3533053Sstever@eecs.umich.edu# installation used to run scons (and thus this script).  If you want
3543053Sstever@eecs.umich.edu# to link in an alternate version, see above for instructions on how
3553053Sstever@eecs.umich.edu# to invoke scons with a different copy of the Python interpreter.
3563053Sstever@eecs.umich.edu
3572667Sstever@eecs.umich.edu# Get brief Python version name (e.g., "python2.4") for locating
3584554Sbinkertn@umich.edu# include & library files
3594554Sbinkertn@umich.edupy_version_name = 'python' + sys.version[:3]
3602667Sstever@eecs.umich.edu
3614554Sbinkertn@umich.edu# include path, e.g. /usr/local/include/python2.4
3624554Sbinkertn@umich.edupy_header_path = joinpath(sys.exec_prefix, 'include', py_version_name)
3634554Sbinkertn@umich.eduenv.Append(CPPPATH = py_header_path)
3644554Sbinkertn@umich.edu# verify that it works
3654554Sbinkertn@umich.eduif not conf.CheckHeader('Python.h', '<>'):
3664554Sbinkertn@umich.edu    print "Error: can't find Python.h header in", py_header_path
3674554Sbinkertn@umich.edu    Exit(1)
3684781Snate@binkert.org
3694554Sbinkertn@umich.edu# add library path too if it's not in the default place
3704554Sbinkertn@umich.edupy_lib_path = None
3712667Sstever@eecs.umich.eduif sys.exec_prefix != '/usr':
3724554Sbinkertn@umich.edu    py_lib_path = joinpath(sys.exec_prefix, 'lib')
3734554Sbinkertn@umich.eduelif sys.platform == 'cygwin':
3744554Sbinkertn@umich.edu    # cygwin puts the .dll in /bin for some reason
3754554Sbinkertn@umich.edu    py_lib_path = '/bin'
3762667Sstever@eecs.umich.eduif py_lib_path:
3774554Sbinkertn@umich.edu    env.Append(LIBPATH = py_lib_path)
3782667Sstever@eecs.umich.edu    print 'Adding', py_lib_path, 'to LIBPATH for', py_version_name
3794554Sbinkertn@umich.eduif not conf.CheckLib(py_version_name):
3804554Sbinkertn@umich.edu    print "Error: can't find Python library", py_version_name
3812667Sstever@eecs.umich.edu    Exit(1)
3822638Sstever@eecs.umich.edu
3832638Sstever@eecs.umich.edu# On Solaris you need to use libsocket for socket ops
3842638Sstever@eecs.umich.eduif not conf.CheckLibWithHeader(None, 'sys/socket.h', 'C++', 'accept(0,0,0);'):
3853716Sstever@eecs.umich.edu   if not conf.CheckLibWithHeader('socket', 'sys/socket.h', 'C++', 'accept(0,0,0);'):
3863716Sstever@eecs.umich.edu       print "Can't find library with socket calls (e.g. accept())"
3871858SN/A       Exit(1)
3885227Ssaidi@eecs.umich.edu
3895227Ssaidi@eecs.umich.edu# Check for zlib.  If the check passes, libz will be automatically
3905227Ssaidi@eecs.umich.edu# added to the LIBS environment variable.
3915227Ssaidi@eecs.umich.eduif not conf.CheckLibWithHeader('z', 'zlib.h', 'C++','zlibVersion();'):
3925227Ssaidi@eecs.umich.edu    print 'Error: did not find needed zlib compression library '\
3935227Ssaidi@eecs.umich.edu          'and/or zlib.h header file.'
3945227Ssaidi@eecs.umich.edu    print '       Please install zlib and try again.'
3955227Ssaidi@eecs.umich.edu    Exit(1)
3965227Ssaidi@eecs.umich.edu
3975227Ssaidi@eecs.umich.edu# Check for <fenv.h> (C99 FP environment control)
3985227Ssaidi@eecs.umich.eduhave_fenv = conf.CheckHeader('fenv.h', '<>')
3995227Ssaidi@eecs.umich.eduif not have_fenv:
4005274Ssaidi@eecs.umich.edu    print "Warning: Header file <fenv.h> not found."
4015227Ssaidi@eecs.umich.edu    print "         This host has no IEEE FP rounding mode control."
4025227Ssaidi@eecs.umich.edu
4035227Ssaidi@eecs.umich.edu# Check for mysql.
4045204Sstever@gmail.commysql_config = WhereIs('mysql_config')
4055204Sstever@gmail.comhave_mysql = mysql_config != None
4065204Sstever@gmail.com
4075204Sstever@gmail.com# Check MySQL version.
4085204Sstever@gmail.comif have_mysql:
4095204Sstever@gmail.com    mysql_version = os.popen(mysql_config + ' --version').read()
4105204Sstever@gmail.com    min_mysql_version = '4.1'
4115204Sstever@gmail.com    if compare_versions(mysql_version, min_mysql_version) < 0:
4125204Sstever@gmail.com        print 'Warning: MySQL', min_mysql_version, 'or newer required.'
4135204Sstever@gmail.com        print '         Version', mysql_version, 'detected.'
4145204Sstever@gmail.com        have_mysql = False
4155204Sstever@gmail.com
4165204Sstever@gmail.com# Set up mysql_config commands.
4175204Sstever@gmail.comif have_mysql:
4185204Sstever@gmail.com    mysql_config_include = mysql_config + ' --include'
4195204Sstever@gmail.com    if os.system(mysql_config_include + ' > /dev/null') != 0:
4205204Sstever@gmail.com        # older mysql_config versions don't support --include, use
4215204Sstever@gmail.com        # --cflags instead
4225204Sstever@gmail.com        mysql_config_include = mysql_config + ' --cflags | sed s/\\\'//g'
4233118Sstever@eecs.umich.edu    # This seems to work in all versions
4243118Sstever@eecs.umich.edu    mysql_config_libs = mysql_config + ' --libs'
4253118Sstever@eecs.umich.edu
4263118Sstever@eecs.umich.eduenv = conf.Finish()
4273118Sstever@eecs.umich.edu
4283118Sstever@eecs.umich.edu# Define the universe of supported ISAs
4293118Sstever@eecs.umich.eduall_isa_list = [ ]
4303118Sstever@eecs.umich.eduExport('all_isa_list')
4313118Sstever@eecs.umich.edu
4323118Sstever@eecs.umich.edu# Define the universe of supported CPU models
4333118Sstever@eecs.umich.eduall_cpu_list = [ ]
4343716Sstever@eecs.umich.edudefault_cpus = [ ]
4353118Sstever@eecs.umich.eduExport('all_cpu_list', 'default_cpus')
4363118Sstever@eecs.umich.edu
4373118Sstever@eecs.umich.edu# Sticky options get saved in the options file so they persist from
4383118Sstever@eecs.umich.edu# one invocation to the next (unless overridden, in which case the new
4393118Sstever@eecs.umich.edu# value becomes sticky).
4403118Sstever@eecs.umich.edusticky_opts = Options(args=ARGUMENTS)
4413118Sstever@eecs.umich.eduExport('sticky_opts')
4423118Sstever@eecs.umich.edu
4433118Sstever@eecs.umich.edu# Non-sticky options only apply to the current build.
4443716Sstever@eecs.umich.edunonsticky_opts = Options(args=ARGUMENTS)
4453118Sstever@eecs.umich.eduExport('nonsticky_opts')
4463118Sstever@eecs.umich.edu
4473118Sstever@eecs.umich.edu# Walk the tree and execute all SConsopts scripts that wil add to the
4483118Sstever@eecs.umich.edu# above options
4493118Sstever@eecs.umich.edufor root, dirs, files in os.walk('.'):
4503118Sstever@eecs.umich.edu    if 'SConsopts' in files:
4513118Sstever@eecs.umich.edu        SConscript(os.path.join(root, 'SConsopts'))
4523118Sstever@eecs.umich.edu
4533118Sstever@eecs.umich.eduall_isa_list.sort()
4543118Sstever@eecs.umich.eduall_cpu_list.sort()
4553483Ssaidi@eecs.umich.edudefault_cpus.sort()
4563494Ssaidi@eecs.umich.edu
4573494Ssaidi@eecs.umich.edudef ExtraPathValidator(key, val, env):
4583483Ssaidi@eecs.umich.edu    if not val:
4593483Ssaidi@eecs.umich.edu        return
4603483Ssaidi@eecs.umich.edu    paths = val.split(':')
4613053Sstever@eecs.umich.edu    for path in paths:
4623053Sstever@eecs.umich.edu        path = os.path.expanduser(path)
4633918Ssaidi@eecs.umich.edu        if not isdir(path):
4643053Sstever@eecs.umich.edu            raise AttributeError, "Invalid path: '%s'" % path
4653053Sstever@eecs.umich.edu
4663053Sstever@eecs.umich.edusticky_opts.AddOptions(
4673053Sstever@eecs.umich.edu    EnumOption('TARGET_ISA', 'Target ISA', 'alpha', all_isa_list),
4683053Sstever@eecs.umich.edu    BoolOption('FULL_SYSTEM', 'Full-system support', False),
4691858SN/A    # There's a bug in scons 0.96.1 that causes ListOptions with list
4701858SN/A    # values (more than one value) not to be able to be restored from
4711858SN/A    # a saved option file.  If this causes trouble then upgrade to
4721858SN/A    # scons 0.96.90 or later.
4731858SN/A    ListOption('CPU_MODELS', 'CPU models', default_cpus, all_cpu_list),
4741858SN/A    BoolOption('NO_FAST_ALLOC', 'Disable fast object allocator', False),
4751859SN/A    BoolOption('EFENCE', 'Link with Electric Fence malloc debugger',
4761858SN/A               False),
4771858SN/A    BoolOption('SS_COMPATIBLE_FP',
4781858SN/A               'Make floating-point results compatible with SimpleScalar',
4791859SN/A               False),
4801859SN/A    BoolOption('USE_SSE2',
4811862SN/A               'Compile for SSE2 (-msse2) to get IEEE FP on x86 hosts',
4823053Sstever@eecs.umich.edu               False),
4833053Sstever@eecs.umich.edu    BoolOption('USE_MYSQL', 'Use MySQL for stats output', have_mysql),
4843053Sstever@eecs.umich.edu    BoolOption('USE_FENV', 'Use <fenv.h> IEEE mode control', have_fenv),
4853053Sstever@eecs.umich.edu    BoolOption('USE_CHECKER', 'Use checker for detailed CPU models', False),
4861859SN/A    ('CC', 'C compiler', os.environ.get('CC', env['CC'])),
4871859SN/A    ('CXX', 'C++ compiler', os.environ.get('CXX', env['CXX'])),
4881859SN/A    BoolOption('BATCH', 'Use batch pool for build and tests', False),
4891859SN/A    ('BATCH_CMD', 'Batch pool submission command name', 'qdo'),
4901859SN/A    ('PYTHONHOME',
4911859SN/A     'Override the default PYTHONHOME for this system (use with caution)',
4921859SN/A     '%s:%s' % (sys.prefix, sys.exec_prefix)),
4931859SN/A    ('EXTRAS', 'Add Extra directories to the compilation', '',
4941862SN/A     ExtraPathValidator)
4951859SN/A    )
4961859SN/A
4971859SN/Anonsticky_opts.AddOptions(
4981858SN/A    BoolOption('update_ref', 'Update test reference outputs', False)
4991858SN/A    )
5002139SN/A
5014202Sbinkertn@umich.edu# These options get exported to #defines in config/*.hh (see src/SConscript).
5024202Sbinkertn@umich.eduenv.ExportOptions = ['FULL_SYSTEM', 'ALPHA_TLASER', 'USE_FENV', \
5032139SN/A                     'USE_MYSQL', 'NO_FAST_ALLOC', 'SS_COMPATIBLE_FP', \
5042155SN/A                     'USE_CHECKER', 'PYTHONHOME', 'TARGET_ISA']
5054202Sbinkertn@umich.edu
5064202Sbinkertn@umich.edu# Define a handy 'no-op' action
5074202Sbinkertn@umich.edudef no_action(target, source, env):
5082155SN/A    return 0
5091869SN/A
5101869SN/Aenv.NoAction = Action(no_action, None)
5111869SN/A
5121869SN/A###################################################
5134202Sbinkertn@umich.edu#
5144202Sbinkertn@umich.edu# Define a SCons builder for configuration flag headers.
5154202Sbinkertn@umich.edu#
5164202Sbinkertn@umich.edu###################################################
5174202Sbinkertn@umich.edu
5184202Sbinkertn@umich.edu# This function generates a config header file that #defines the
5194202Sbinkertn@umich.edu# option symbol to the current option setting (0 or 1).  The source
5204202Sbinkertn@umich.edu# operands are the name of the option and a Value node containing the
5215341Sstever@gmail.com# value of the option.
5225341Sstever@gmail.comdef build_config_file(target, source, env):
5235341Sstever@gmail.com    (option, value) = [s.get_contents() for s in source]
5245342Sstever@gmail.com    f = file(str(target[0]), 'w')
5255342Sstever@gmail.com    print >> f, '#define', option, value
5264202Sbinkertn@umich.edu    f.close()
5274202Sbinkertn@umich.edu    return None
5284202Sbinkertn@umich.edu
5294202Sbinkertn@umich.edu# Generate the message to be printed when building the config file.
5304202Sbinkertn@umich.edudef build_config_file_string(target, source, env):
5311869SN/A    (option, value) = [s.get_contents() for s in source]
5324202Sbinkertn@umich.edu    return "Defining %s as %s in %s." % (option, value, target[0])
5331869SN/A
5342508SN/A# Combine the two functions into a scons Action object.
5352508SN/Aconfig_action = Action(build_config_file, build_config_file_string)
5362508SN/A
5372508SN/A# The emitter munges the source & target node lists to reflect what
5384202Sbinkertn@umich.edu# we're really doing.
5391869SN/Adef config_emitter(target, source, env):
5401869SN/A    # extract option name from Builder arg
5411869SN/A    option = str(target[0])
5421869SN/A    # True target is config header file
5431869SN/A    target = joinpath('config', option.lower() + '.hh')
5441869SN/A    val = env[option]
5451965SN/A    if isinstance(val, bool):
5461965SN/A        # Force value to 0/1
5471965SN/A        val = int(val)
5481869SN/A    elif isinstance(val, str):
5491869SN/A        val = '"' + val + '"'
5502733Sktlim@umich.edu
5511884SN/A    # Sources are option name & value (packaged in SCons Value nodes)
5523356Sbinkertn@umich.edu    return ([target], [Value(option), Value(val)])
5533356Sbinkertn@umich.edu
5543356Sbinkertn@umich.educonfig_builder = Builder(emitter = config_emitter, action = config_action)
5554773Snate@binkert.org
5561869SN/Aenv.Append(BUILDERS = { 'ConfigFile' : config_builder })
5571858SN/A
5581869SN/A###################################################
5591869SN/A#
5601869SN/A# Define a SCons builder for copying files.  This is used by the
5611858SN/A# Python zipfile code in src/python/SConscript, but is placed up here
5622761Sstever@eecs.umich.edu# since it's potentially more generally applicable.
5631869SN/A#
5642733Sktlim@umich.edu###################################################
5653584Ssaidi@eecs.umich.edu
5661869SN/Acopy_builder = Builder(action = Copy("$TARGET", "$SOURCE"))
5671869SN/A
5681869SN/Aenv.Append(BUILDERS = { 'CopyFile' : copy_builder })
5691869SN/A
5701869SN/A###################################################
5711869SN/A#
5721858SN/A# Define a simple SCons builder to concatenate files.
573955SN/A#
574955SN/A# Used to append the Python zip archive to the executable.
5751869SN/A#
5761869SN/A###################################################
5771869SN/A
5781869SN/Aconcat_builder = Builder(action = Action(['cat $SOURCES > $TARGET',
5791869SN/A                                          'chmod +x $TARGET']))
5801869SN/A
5811869SN/Aenv.Append(BUILDERS = { 'Concat' : concat_builder })
5821869SN/A
5831869SN/A
5841869SN/A# base help text
5851869SN/Ahelp_text = '''
5861869SN/AUsage: scons [scons options] [build options] [target(s)]
5871869SN/A
5881869SN/A'''
5891869SN/A
5901869SN/A# libelf build is shared across all configs in the build root.
5911869SN/Aenv.SConscript('ext/libelf/SConscript',
5921869SN/A               build_dir = joinpath(build_root, 'libelf'),
5931869SN/A               exports = 'env')
5941869SN/A
5951869SN/A###################################################
5961869SN/A#
5971869SN/A# This function is used to set up a directory with switching headers
5981869SN/A#
5991869SN/A###################################################
6001869SN/A
6011869SN/Aenv['ALL_ISA_LIST'] = all_isa_list
6021869SN/Adef make_switching_dir(dirname, switch_headers, env):
6031869SN/A    # Generate the header.  target[0] is the full path of the output
6043716Sstever@eecs.umich.edu    # header to generate.  'source' is a dummy variable, since we get the
6053356Sbinkertn@umich.edu    # list of ISAs from env['ALL_ISA_LIST'].
6063356Sbinkertn@umich.edu    def gen_switch_hdr(target, source, env):
6073356Sbinkertn@umich.edu        fname = str(target[0])
6083356Sbinkertn@umich.edu        basename = os.path.basename(fname)
6093356Sbinkertn@umich.edu        f = open(fname, 'w')
6103356Sbinkertn@umich.edu        f.write('#include "arch/isa_specific.hh"\n')
6114781Snate@binkert.org        cond = '#if'
6121869SN/A        for isa in all_isa_list:
6131869SN/A            f.write('%s THE_ISA == %s_ISA\n#include "%s/%s/%s"\n'
6141869SN/A                    % (cond, isa.upper(), dirname, isa, basename))
6151869SN/A            cond = '#elif'
6161869SN/A        f.write('#else\n#error "THE_ISA not set"\n#endif\n')
6171869SN/A        f.close()
6181869SN/A        return 0
6192655Sstever@eecs.umich.edu
6202655Sstever@eecs.umich.edu    # String to print when generating header
6212655Sstever@eecs.umich.edu    def gen_switch_hdr_string(target, source, env):
6222655Sstever@eecs.umich.edu        return "Generating switch header " + str(target[0])
6232655Sstever@eecs.umich.edu
6242655Sstever@eecs.umich.edu    # Build SCons Action object. 'varlist' specifies env vars that this
6252655Sstever@eecs.umich.edu    # action depends on; when env['ALL_ISA_LIST'] changes these actions
6262655Sstever@eecs.umich.edu    # should get re-executed.
6272655Sstever@eecs.umich.edu    switch_hdr_action = Action(gen_switch_hdr, gen_switch_hdr_string,
6282655Sstever@eecs.umich.edu                               varlist=['ALL_ISA_LIST'])
6292655Sstever@eecs.umich.edu
6302655Sstever@eecs.umich.edu    # Instantiate actions for each header
6312655Sstever@eecs.umich.edu    for hdr in switch_headers:
6322655Sstever@eecs.umich.edu        env.Command(hdr, [], switch_hdr_action)
6332655Sstever@eecs.umich.eduExport('make_switching_dir')
6342655Sstever@eecs.umich.edu
6352655Sstever@eecs.umich.edu###################################################
6362655Sstever@eecs.umich.edu#
6372655Sstever@eecs.umich.edu# Define build environments for selected configurations.
6382655Sstever@eecs.umich.edu#
6392655Sstever@eecs.umich.edu###################################################
6402655Sstever@eecs.umich.edu
6412655Sstever@eecs.umich.edu# rename base env
6422655Sstever@eecs.umich.edubase_env = env
6432655Sstever@eecs.umich.edu
6442655Sstever@eecs.umich.edufor build_path in build_paths:
6452638Sstever@eecs.umich.edu    print "Building in", build_path
6462638Sstever@eecs.umich.edu    env['BUILDDIR'] = build_path
6473716Sstever@eecs.umich.edu
6482638Sstever@eecs.umich.edu    # build_dir is the tail component of build path, and is used to
6492638Sstever@eecs.umich.edu    # determine the build parameters (e.g., 'ALPHA_SE')
6501869SN/A    (build_root, build_dir) = os.path.split(build_path)
6511869SN/A    # Make a copy of the build-root environment to use for this config.
6523546Sgblack@eecs.umich.edu    env = base_env.Copy()
6533546Sgblack@eecs.umich.edu
6543546Sgblack@eecs.umich.edu    # Set env options according to the build directory config.
6553546Sgblack@eecs.umich.edu    sticky_opts.files = []
6564202Sbinkertn@umich.edu    # Options for $BUILD_ROOT/$BUILD_DIR are stored in
6573546Sgblack@eecs.umich.edu    # $BUILD_ROOT/options/$BUILD_DIR so you can nuke
6583546Sgblack@eecs.umich.edu    # $BUILD_ROOT/$BUILD_DIR without losing your options settings.
6593546Sgblack@eecs.umich.edu    current_opts_file = joinpath(build_root, 'options', build_dir)
6603546Sgblack@eecs.umich.edu    if os.path.isfile(current_opts_file):
6613546Sgblack@eecs.umich.edu        sticky_opts.files.append(current_opts_file)
6624781Snate@binkert.org        print "Using saved options file %s" % current_opts_file
6634781Snate@binkert.org    else:
6644781Snate@binkert.org        # Build dir-specific options file doesn't exist.
6654781Snate@binkert.org
6664781Snate@binkert.org        # Make sure the directory is there so we can create it later
6674781Snate@binkert.org        opt_dir = os.path.dirname(current_opts_file)
6684781Snate@binkert.org        if not os.path.isdir(opt_dir):
6694781Snate@binkert.org            os.mkdir(opt_dir)
6704781Snate@binkert.org
6714781Snate@binkert.org        # Get default build options from source tree.  Options are
6724781Snate@binkert.org        # normally determined by name of $BUILD_DIR, but can be
6734781Snate@binkert.org        # overriden by 'default=' arg on command line.
6743546Sgblack@eecs.umich.edu        default_opts_file = joinpath('build_opts',
6753546Sgblack@eecs.umich.edu                                     ARGUMENTS.get('default', build_dir))
6763546Sgblack@eecs.umich.edu        if os.path.isfile(default_opts_file):
6774781Snate@binkert.org            sticky_opts.files.append(default_opts_file)
6783546Sgblack@eecs.umich.edu            print "Options file %s not found,\n  using defaults in %s" \
6793546Sgblack@eecs.umich.edu                  % (current_opts_file, default_opts_file)
6803546Sgblack@eecs.umich.edu        else:
6813546Sgblack@eecs.umich.edu            print "Error: cannot find options file %s or %s" \
6823546Sgblack@eecs.umich.edu                  % (current_opts_file, default_opts_file)
6833546Sgblack@eecs.umich.edu            Exit(1)
6843546Sgblack@eecs.umich.edu
6853546Sgblack@eecs.umich.edu    # Apply current option settings to env
6863546Sgblack@eecs.umich.edu    sticky_opts.Update(env)
6873546Sgblack@eecs.umich.edu    nonsticky_opts.Update(env)
6884202Sbinkertn@umich.edu
6893546Sgblack@eecs.umich.edu    help_text += "Sticky options for %s:\n" % build_dir \
6903546Sgblack@eecs.umich.edu                 + sticky_opts.GenerateHelpText(env) \
6913546Sgblack@eecs.umich.edu                 + "\nNon-sticky options for %s:\n" % build_dir \
692955SN/A                 + nonsticky_opts.GenerateHelpText(env)
693955SN/A
694955SN/A    # Process option settings.
695955SN/A
6961858SN/A    if not have_fenv and env['USE_FENV']:
6971858SN/A        print "Warning: <fenv.h> not available; " \
6981858SN/A              "forcing USE_FENV to False in", build_dir + "."
6992632Sstever@eecs.umich.edu        env['USE_FENV'] = False
7002632Sstever@eecs.umich.edu
7014773Snate@binkert.org    if not env['USE_FENV']:
7024773Snate@binkert.org        print "Warning: No IEEE FP rounding mode control in", build_dir + "."
7032632Sstever@eecs.umich.edu        print "         FP results may deviate slightly from other platforms."
7042632Sstever@eecs.umich.edu
7052632Sstever@eecs.umich.edu    if env['EFENCE']:
7062634Sstever@eecs.umich.edu        env.Append(LIBS=['efence'])
7072638Sstever@eecs.umich.edu
7082023SN/A    if env['USE_MYSQL']:
7092632Sstever@eecs.umich.edu        if not have_mysql:
7102632Sstever@eecs.umich.edu            print "Warning: MySQL not available; " \
7112632Sstever@eecs.umich.edu                  "forcing USE_MYSQL to False in", build_dir + "."
7122632Sstever@eecs.umich.edu            env['USE_MYSQL'] = False
7132632Sstever@eecs.umich.edu        else:
7143716Sstever@eecs.umich.edu            print "Compiling in", build_dir, "with MySQL support."
7155342Sstever@gmail.com            env.ParseConfig(mysql_config_libs)
7162632Sstever@eecs.umich.edu            env.ParseConfig(mysql_config_include)
7172632Sstever@eecs.umich.edu
7182632Sstever@eecs.umich.edu    # Save sticky option settings back to current options file
7192632Sstever@eecs.umich.edu    sticky_opts.Save(current_opts_file, env)
7202023SN/A
7212632Sstever@eecs.umich.edu    # Do this after we save setting back, or else we'll tack on an
7222632Sstever@eecs.umich.edu    # extra 'qdo' every time we run scons.
7235342Sstever@gmail.com    if env['BATCH']:
7241889SN/A        env['CC']  = env['BATCH_CMD'] + ' ' + env['CC']
7252632Sstever@eecs.umich.edu        env['CXX'] = env['BATCH_CMD'] + ' ' + env['CXX']
7262632Sstever@eecs.umich.edu
7272632Sstever@eecs.umich.edu    if env['USE_SSE2']:
7282632Sstever@eecs.umich.edu        env.Append(CCFLAGS='-msse2')
7293716Sstever@eecs.umich.edu
7303716Sstever@eecs.umich.edu    # The src/SConscript file sets up the build rules in 'env' according
7315342Sstever@gmail.com    # to the configured options.  It returns a list of environments,
7322632Sstever@eecs.umich.edu    # one for each variant build (debug, opt, etc.)
7332632Sstever@eecs.umich.edu    envList = SConscript('src/SConscript', build_dir = build_path,
7342632Sstever@eecs.umich.edu                         exports = 'env')
7352632Sstever@eecs.umich.edu
7362632Sstever@eecs.umich.edu    # Set up the regression tests for each build.
7372632Sstever@eecs.umich.edu    for e in envList:
7382632Sstever@eecs.umich.edu        SConscript('tests/SConscript',
7391888SN/A                   build_dir = joinpath(build_path, 'tests', e.Label),
7401888SN/A                   exports = { 'env' : e }, duplicate = False)
7411869SN/A
7421869SN/AHelp(help_text)
7431858SN/A
7445341Sstever@gmail.com
7452598SN/A###################################################
7462598SN/A#
7472598SN/A# Let SCons do its thing.  At this point SCons will use the defined
7482598SN/A# build environments to build the requested targets.
7491858SN/A#
7501858SN/A###################################################
7511858SN/A
7521858SN/A