SConscript revision 5604:7c58fc1ec5dc
14120Sgblack@eecs.umich.edu# -*- mode:python -*-
24120Sgblack@eecs.umich.edu
34120Sgblack@eecs.umich.edu# Copyright (c) 2004-2005 The Regents of The University of Michigan
44120Sgblack@eecs.umich.edu# All rights reserved.
54120Sgblack@eecs.umich.edu#
64120Sgblack@eecs.umich.edu# Redistribution and use in source and binary forms, with or without
74120Sgblack@eecs.umich.edu# modification, are permitted provided that the following conditions are
84120Sgblack@eecs.umich.edu# met: redistributions of source code must retain the above copyright
94120Sgblack@eecs.umich.edu# notice, this list of conditions and the following disclaimer;
104120Sgblack@eecs.umich.edu# redistributions in binary form must reproduce the above copyright
114120Sgblack@eecs.umich.edu# notice, this list of conditions and the following disclaimer in the
124120Sgblack@eecs.umich.edu# documentation and/or other materials provided with the distribution;
134120Sgblack@eecs.umich.edu# neither the name of the copyright holders nor the names of its
144120Sgblack@eecs.umich.edu# contributors may be used to endorse or promote products derived from
154120Sgblack@eecs.umich.edu# this software without specific prior written permission.
164120Sgblack@eecs.umich.edu#
174120Sgblack@eecs.umich.edu# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
184120Sgblack@eecs.umich.edu# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
194120Sgblack@eecs.umich.edu# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
204120Sgblack@eecs.umich.edu# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
214120Sgblack@eecs.umich.edu# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
224120Sgblack@eecs.umich.edu# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
234120Sgblack@eecs.umich.edu# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
244120Sgblack@eecs.umich.edu# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
254120Sgblack@eecs.umich.edu# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
264120Sgblack@eecs.umich.edu# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
274120Sgblack@eecs.umich.edu# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
284120Sgblack@eecs.umich.edu#
294120Sgblack@eecs.umich.edu# Authors: Nathan Binkert
304120Sgblack@eecs.umich.edu
315334Sgblack@eecs.umich.eduimport array
324120Sgblack@eecs.umich.eduimport imp
334120Sgblack@eecs.umich.eduimport marshal
344120Sgblack@eecs.umich.eduimport os
354120Sgblack@eecs.umich.eduimport re
364120Sgblack@eecs.umich.eduimport sys
374120Sgblack@eecs.umich.eduimport zlib
384120Sgblack@eecs.umich.edu
394120Sgblack@eecs.umich.edufrom os.path import basename, exists, isdir, isfile, join as joinpath
404120Sgblack@eecs.umich.edu
414120Sgblack@eecs.umich.eduimport SCons
424120Sgblack@eecs.umich.edu
434120Sgblack@eecs.umich.edu# This file defines how to build a particular configuration of M5
444120Sgblack@eecs.umich.edu# based on variable settings in the 'env' build environment.
454120Sgblack@eecs.umich.edu
464120Sgblack@eecs.umich.eduImport('*')
474120Sgblack@eecs.umich.edu
484120Sgblack@eecs.umich.edu# Children need to see the environment
494120Sgblack@eecs.umich.eduExport('env')
504120Sgblack@eecs.umich.edu
514120Sgblack@eecs.umich.edubuild_env = dict([(opt, env[opt]) for opt in env.ExportOptions])
524120Sgblack@eecs.umich.edu
534120Sgblack@eecs.umich.edudef sort_list(_list):
544120Sgblack@eecs.umich.edu    """return a sorted copy of '_list'"""
554120Sgblack@eecs.umich.edu    if isinstance(_list, list):
564120Sgblack@eecs.umich.edu        _list = _list[:]
574120Sgblack@eecs.umich.edu    else:
584120Sgblack@eecs.umich.edu        _list = list(_list)
594120Sgblack@eecs.umich.edu    _list.sort()
604120Sgblack@eecs.umich.edu    return _list
614120Sgblack@eecs.umich.edu
624120Sgblack@eecs.umich.educlass PySourceFile(object):
634120Sgblack@eecs.umich.edu    invalid_sym_char = re.compile('[^A-z0-9_]')
644120Sgblack@eecs.umich.edu    def __init__(self, package, tnode):
654120Sgblack@eecs.umich.edu        snode = tnode.srcnode()
664120Sgblack@eecs.umich.edu        filename = str(tnode)
674120Sgblack@eecs.umich.edu        pyname = basename(filename)
684120Sgblack@eecs.umich.edu        assert pyname.endswith('.py')
694120Sgblack@eecs.umich.edu        name = pyname[:-3]
704120Sgblack@eecs.umich.edu        if package:
714120Sgblack@eecs.umich.edu            path = package.split('.')
724120Sgblack@eecs.umich.edu        else:
734120Sgblack@eecs.umich.edu            path = []
744120Sgblack@eecs.umich.edu
754120Sgblack@eecs.umich.edu        modpath = path[:]
764120Sgblack@eecs.umich.edu        if name != '__init__':
774120Sgblack@eecs.umich.edu            modpath += [name]
784120Sgblack@eecs.umich.edu        modpath = '.'.join(modpath)
794120Sgblack@eecs.umich.edu
804120Sgblack@eecs.umich.edu        arcpath = path + [ pyname ]
814120Sgblack@eecs.umich.edu        arcname = joinpath(*arcpath)
824120Sgblack@eecs.umich.edu
834120Sgblack@eecs.umich.edu        debugname = snode.abspath
844120Sgblack@eecs.umich.edu        if not exists(debugname):
854120Sgblack@eecs.umich.edu            debugname = tnode.abspath
864202Sbinkertn@umich.edu
875069Sgblack@eecs.umich.edu        self.tnode = tnode
884202Sbinkertn@umich.edu        self.snode = snode
895659Sgblack@eecs.umich.edu        self.pyname = pyname
904601Sgblack@eecs.umich.edu        self.package = package
914202Sbinkertn@umich.edu        self.modpath = modpath
925124Sgblack@eecs.umich.edu        self.arcname = arcname
935083Sgblack@eecs.umich.edu        self.debugname = debugname
944679Sgblack@eecs.umich.edu        self.compiled = File(filename + 'c')
955083Sgblack@eecs.umich.edu        self.assembly = File(filename + '.s')
964679Sgblack@eecs.umich.edu        self.symname = "PyEMB_" + self.invalid_sym_char.sub('_', modpath)
974679Sgblack@eecs.umich.edu        
984202Sbinkertn@umich.edu
994202Sbinkertn@umich.edu########################################################################
1005124Sgblack@eecs.umich.edu# Code for adding source files of various types
1014249Sgblack@eecs.umich.edu#
1024240Sgblack@eecs.umich.educc_lib_sources = []
1034202Sbinkertn@umich.edudef Source(source):
1044202Sbinkertn@umich.edu    '''Add a source file to the libm5 build'''
1054997Sgblack@eecs.umich.edu    if not isinstance(source, SCons.Node.FS.File):
1065135Sgblack@eecs.umich.edu        source = File(source)
1074997Sgblack@eecs.umich.edu
1084997Sgblack@eecs.umich.edu    cc_lib_sources.append(source)
1095800Snate@binkert.org
1105800Snate@binkert.orgcc_bin_sources = []
1114120Sgblack@eecs.umich.edudef BinSource(source):
1124202Sbinkertn@umich.edu    '''Add a source file to the m5 binary build'''
1135800Snate@binkert.org    if not isinstance(source, SCons.Node.FS.File):
1145904Sgblack@eecs.umich.edu        source = File(source)
1155904Sgblack@eecs.umich.edu
1165909Sgblack@eecs.umich.edu    cc_bin_sources.append(source)
1175649Sgblack@eecs.umich.edu
1185647Sgblack@eecs.umich.edupy_sources = []
1195132Sgblack@eecs.umich.edudef PySource(package, source):
1205132Sgblack@eecs.umich.edu    '''Add a python source file to the named package'''
1214202Sbinkertn@umich.edu    if not isinstance(source, SCons.Node.FS.File):
1225647Sgblack@eecs.umich.edu        source = File(source)
1235299Sgblack@eecs.umich.edu
1245245Sgblack@eecs.umich.edu    source = PySourceFile(package, source)
1255132Sgblack@eecs.umich.edu    py_sources.append(source)
1265086Sgblack@eecs.umich.edu
1275086Sgblack@eecs.umich.edusim_objects_fixed = False
1284202Sbinkertn@umich.edusim_object_modfiles = set()
1294202Sbinkertn@umich.edudef SimObject(source):
1304120Sgblack@eecs.umich.edu    '''Add a SimObject python file as a python source object and add
1314202Sbinkertn@umich.edu    it to a list of sim object modules'''
1324202Sbinkertn@umich.edu
1334202Sbinkertn@umich.edu    if sim_objects_fixed:
1344120Sgblack@eecs.umich.edu        raise AttributeError, "Too late to call SimObject now."
1355069Sgblack@eecs.umich.edu
1365081Sgblack@eecs.umich.edu    if not isinstance(source, SCons.Node.FS.File):
1375081Sgblack@eecs.umich.edu        source = File(source)
1385081Sgblack@eecs.umich.edu
1395081Sgblack@eecs.umich.edu    PySource('m5.objects', source)
1405081Sgblack@eecs.umich.edu    modfile = basename(str(source))
1415081Sgblack@eecs.umich.edu    assert modfile.endswith('.py')
1425081Sgblack@eecs.umich.edu    modname = modfile[:-3]
1435081Sgblack@eecs.umich.edu    sim_object_modfiles.add(modname)
1445081Sgblack@eecs.umich.edu
1455081Sgblack@eecs.umich.eduswig_sources = []
1465081Sgblack@eecs.umich.edudef SwigSource(package, source):
1475081Sgblack@eecs.umich.edu    '''Add a swig file to build'''
1485081Sgblack@eecs.umich.edu    if not isinstance(source, SCons.Node.FS.File):
1495081Sgblack@eecs.umich.edu        source = File(source)
1505081Sgblack@eecs.umich.edu    val = source,package
1515081Sgblack@eecs.umich.edu    swig_sources.append(val)
1525081Sgblack@eecs.umich.edu
1535081Sgblack@eecs.umich.eduunit_tests = []
1545081Sgblack@eecs.umich.edudef UnitTest(target, sources):
1555081Sgblack@eecs.umich.edu    if not isinstance(sources, (list, tuple)):
1565081Sgblack@eecs.umich.edu        sources = [ sources ]
1575081Sgblack@eecs.umich.edu    
1585081Sgblack@eecs.umich.edu    srcs = []
1595081Sgblack@eecs.umich.edu    for source in sources:
1605081Sgblack@eecs.umich.edu        if not isinstance(source, SCons.Node.FS.File):
1615081Sgblack@eecs.umich.edu            source = File(source)
1625081Sgblack@eecs.umich.edu        srcs.append(source)
1635081Sgblack@eecs.umich.edu            
1645081Sgblack@eecs.umich.edu    unit_tests.append((target, srcs))
1655081Sgblack@eecs.umich.edu
1665081Sgblack@eecs.umich.edu# Children should have access
1675081Sgblack@eecs.umich.eduExport('Source')
1685081Sgblack@eecs.umich.eduExport('BinSource')
1695081Sgblack@eecs.umich.eduExport('PySource')
1705081Sgblack@eecs.umich.eduExport('SimObject')
1715081Sgblack@eecs.umich.eduExport('SwigSource')
1725081Sgblack@eecs.umich.eduExport('UnitTest')
1735081Sgblack@eecs.umich.edu
1745081Sgblack@eecs.umich.edu########################################################################
1755081Sgblack@eecs.umich.edu#
1765081Sgblack@eecs.umich.edu# Trace Flags
1775081Sgblack@eecs.umich.edu#
1785081Sgblack@eecs.umich.eduall_flags = {}
1795081Sgblack@eecs.umich.edutrace_flags = []
1805081Sgblack@eecs.umich.edudef TraceFlag(name, desc=''):
1815081Sgblack@eecs.umich.edu    if name in all_flags:
1825081Sgblack@eecs.umich.edu        raise AttributeError, "Flag %s already specified" % name
1835081Sgblack@eecs.umich.edu    flag = (name, (), desc)
1845081Sgblack@eecs.umich.edu    trace_flags.append(flag)
1855081Sgblack@eecs.umich.edu    all_flags[name] = ()
1865081Sgblack@eecs.umich.edu
1875081Sgblack@eecs.umich.edudef CompoundFlag(name, flags, desc=''):
1885081Sgblack@eecs.umich.edu    if name in all_flags:
1895081Sgblack@eecs.umich.edu        raise AttributeError, "Flag %s already specified" % name
1905081Sgblack@eecs.umich.edu
1915680Sgblack@eecs.umich.edu    compound = tuple(flags)
1925081Sgblack@eecs.umich.edu    for flag in compound:
1935933Sgblack@eecs.umich.edu        if flag not in all_flags:
1945173Sgblack@eecs.umich.edu            raise AttributeError, "Trace flag %s not found" % flag
1955359Sgblack@eecs.umich.edu        if all_flags[flag]:
1965081Sgblack@eecs.umich.edu            raise AttributeError, \
1975149Sgblack@eecs.umich.edu                "Compound flag can't point to another compound flag"
1985298Sgblack@eecs.umich.edu
1995081Sgblack@eecs.umich.edu    flag = (name, compound, desc)
2005081Sgblack@eecs.umich.edu    trace_flags.append(flag)
2015081Sgblack@eecs.umich.edu    all_flags[name] = compound
2025081Sgblack@eecs.umich.edu
2035081Sgblack@eecs.umich.eduExport('TraceFlag')
2045081Sgblack@eecs.umich.eduExport('CompoundFlag')
2055081Sgblack@eecs.umich.edu
2065081Sgblack@eecs.umich.edu########################################################################
2075081Sgblack@eecs.umich.edu#
2085081Sgblack@eecs.umich.edu# Set some compiler variables
2095081Sgblack@eecs.umich.edu#
2105081Sgblack@eecs.umich.edu
2115081Sgblack@eecs.umich.edu# Include file paths are rooted in this directory.  SCons will
2125081Sgblack@eecs.umich.edu# automatically expand '.' to refer to both the source directory and
2135081Sgblack@eecs.umich.edu# the corresponding build directory to pick up generated include
2145081Sgblack@eecs.umich.edu# files.
2155081Sgblack@eecs.umich.eduenv.Append(CPPPATH=Dir('.'))
2165081Sgblack@eecs.umich.edu
2175081Sgblack@eecs.umich.edu# Add a flag defining what THE_ISA should be for all compilation
2185081Sgblack@eecs.umich.eduenv.Append(CPPDEFINES=[('THE_ISA','%s_ISA' % env['TARGET_ISA'].upper())])
2195081Sgblack@eecs.umich.edu
2205081Sgblack@eecs.umich.edu########################################################################
2215081Sgblack@eecs.umich.edu#
2225081Sgblack@eecs.umich.edu# Walk the tree and execute all SConscripts in subdirectories
2235081Sgblack@eecs.umich.edu#
2245081Sgblack@eecs.umich.edu
2255081Sgblack@eecs.umich.edufor base_dir in base_dir_list:
2265081Sgblack@eecs.umich.edu    here = Dir('.').srcnode().abspath
2275081Sgblack@eecs.umich.edu    for root, dirs, files in os.walk(base_dir, topdown=True):
2285081Sgblack@eecs.umich.edu        if root == here:
2295081Sgblack@eecs.umich.edu            # we don't want to recurse back into this SConscript
2305081Sgblack@eecs.umich.edu            continue
2315081Sgblack@eecs.umich.edu
2325081Sgblack@eecs.umich.edu        if 'SConscript' in files:
2335081Sgblack@eecs.umich.edu            build_dir = joinpath(env['BUILDDIR'], root[len(base_dir) + 1:])
2345081Sgblack@eecs.umich.edu            SConscript(joinpath(root, 'SConscript'), build_dir=build_dir)
2355081Sgblack@eecs.umich.edu
2365081Sgblack@eecs.umich.edufor opt in env.ExportOptions:
2375081Sgblack@eecs.umich.edu    env.ConfigFile(opt)
2385081Sgblack@eecs.umich.edu
2395081Sgblack@eecs.umich.edu########################################################################
2405081Sgblack@eecs.umich.edu#
2415081Sgblack@eecs.umich.edu# Prevent any SimObjects from being added after this point, they
2425081Sgblack@eecs.umich.edu# should all have been added in the SConscripts above
2435081Sgblack@eecs.umich.edu#
2445081Sgblack@eecs.umich.educlass DictImporter(object):
2455081Sgblack@eecs.umich.edu    '''This importer takes a dictionary of arbitrary module names that
2465081Sgblack@eecs.umich.edu    map to arbitrary filenames.'''
2475081Sgblack@eecs.umich.edu    def __init__(self, modules):
2485081Sgblack@eecs.umich.edu        self.modules = modules
2495081Sgblack@eecs.umich.edu        self.installed = set()
2505081Sgblack@eecs.umich.edu
2515081Sgblack@eecs.umich.edu    def __del__(self):
2525081Sgblack@eecs.umich.edu        self.unload()
2535081Sgblack@eecs.umich.edu
2545081Sgblack@eecs.umich.edu    def unload(self):
2555081Sgblack@eecs.umich.edu        import sys
2565081Sgblack@eecs.umich.edu        for module in self.installed:
2575081Sgblack@eecs.umich.edu            del sys.modules[module]
2585081Sgblack@eecs.umich.edu        self.installed = set()
2595081Sgblack@eecs.umich.edu
2605081Sgblack@eecs.umich.edu    def find_module(self, fullname, path):
2615081Sgblack@eecs.umich.edu        if fullname == '__scons':
2625081Sgblack@eecs.umich.edu            return self
2635081Sgblack@eecs.umich.edu
2645081Sgblack@eecs.umich.edu        if fullname == 'm5.objects':
2655081Sgblack@eecs.umich.edu            return self
2665081Sgblack@eecs.umich.edu
2675081Sgblack@eecs.umich.edu        if fullname.startswith('m5.internal'):
2685081Sgblack@eecs.umich.edu            return None
2695081Sgblack@eecs.umich.edu
2705081Sgblack@eecs.umich.edu        if fullname in self.modules and exists(self.modules[fullname]):
2715081Sgblack@eecs.umich.edu            return self
2725081Sgblack@eecs.umich.edu
2735081Sgblack@eecs.umich.edu        return None
2745081Sgblack@eecs.umich.edu
2755081Sgblack@eecs.umich.edu    def load_module(self, fullname):
2765081Sgblack@eecs.umich.edu        mod = imp.new_module(fullname)
2775081Sgblack@eecs.umich.edu        sys.modules[fullname] = mod
2785081Sgblack@eecs.umich.edu        self.installed.add(fullname)
2795081Sgblack@eecs.umich.edu
2805081Sgblack@eecs.umich.edu        mod.__loader__ = self
2815081Sgblack@eecs.umich.edu        if fullname == 'm5.objects':
2825081Sgblack@eecs.umich.edu            mod.__path__ = fullname.split('.')
2835081Sgblack@eecs.umich.edu            return mod
2845081Sgblack@eecs.umich.edu
2855081Sgblack@eecs.umich.edu        if fullname == '__scons':
2865081Sgblack@eecs.umich.edu            mod.__dict__['m5_build_env'] = build_env
2875081Sgblack@eecs.umich.edu            return mod
2885081Sgblack@eecs.umich.edu
2895081Sgblack@eecs.umich.edu        srcfile = self.modules[fullname]
2905081Sgblack@eecs.umich.edu        if basename(srcfile) == '__init__.py':
2915081Sgblack@eecs.umich.edu            mod.__path__ = fullname.split('.')
2925081Sgblack@eecs.umich.edu        mod.__file__ = srcfile
2935081Sgblack@eecs.umich.edu
2945081Sgblack@eecs.umich.edu        exec file(srcfile, 'r') in mod.__dict__
2955081Sgblack@eecs.umich.edu
2965081Sgblack@eecs.umich.edu        return mod
2975081Sgblack@eecs.umich.edu
2985081Sgblack@eecs.umich.edupy_modules = {}
2995081Sgblack@eecs.umich.edufor source in py_sources:
3005081Sgblack@eecs.umich.edu    py_modules[source.modpath] = source.snode.abspath
3015081Sgblack@eecs.umich.edu
3025081Sgblack@eecs.umich.edu# install the python importer so we can grab stuff from the source
3035081Sgblack@eecs.umich.edu# tree itself.  We can't have SimObjects added after this point or
3045081Sgblack@eecs.umich.edu# else we won't know about them for the rest of the stuff.
3055081Sgblack@eecs.umich.edusim_objects_fixed = True
3065081Sgblack@eecs.umich.eduimporter = DictImporter(py_modules)
3075081Sgblack@eecs.umich.edusys.meta_path[0:0] = [ importer ]
3085081Sgblack@eecs.umich.edu
3095081Sgblack@eecs.umich.eduimport m5
3105081Sgblack@eecs.umich.edu
3115081Sgblack@eecs.umich.edu# import all sim objects so we can populate the all_objects list
3125081Sgblack@eecs.umich.edu# make sure that we're working with a list, then let's sort it
3135081Sgblack@eecs.umich.edusim_objects = list(sim_object_modfiles)
3145081Sgblack@eecs.umich.edusim_objects.sort()
3155081Sgblack@eecs.umich.edufor simobj in sim_objects:
3165081Sgblack@eecs.umich.edu    exec('from m5.objects import %s' % simobj)
3175081Sgblack@eecs.umich.edu
3185081Sgblack@eecs.umich.edu# we need to unload all of the currently imported modules so that they
3195081Sgblack@eecs.umich.edu# will be re-imported the next time the sconscript is run
3205081Sgblack@eecs.umich.eduimporter.unload()
3215081Sgblack@eecs.umich.edusys.meta_path.remove(importer)
3225081Sgblack@eecs.umich.edu
3235081Sgblack@eecs.umich.edusim_objects = m5.SimObject.allClasses
3245081Sgblack@eecs.umich.eduall_enums = m5.params.allEnums
3255081Sgblack@eecs.umich.edu
3265081Sgblack@eecs.umich.eduall_params = {}
3275081Sgblack@eecs.umich.edufor name,obj in sim_objects.iteritems():
3285081Sgblack@eecs.umich.edu    for param in obj._params.local.values():
3295081Sgblack@eecs.umich.edu        if not hasattr(param, 'swig_decl'):
3305081Sgblack@eecs.umich.edu            continue
3315081Sgblack@eecs.umich.edu        pname = param.ptype_str
3325081Sgblack@eecs.umich.edu        if pname not in all_params:
3335081Sgblack@eecs.umich.edu            all_params[pname] = param
3345081Sgblack@eecs.umich.edu
3355081Sgblack@eecs.umich.edu########################################################################
3365081Sgblack@eecs.umich.edu#
3375081Sgblack@eecs.umich.edu# calculate extra dependencies
3385081Sgblack@eecs.umich.edu#
3395081Sgblack@eecs.umich.edumodule_depends = ["m5", "m5.SimObject", "m5.params"]
3405081Sgblack@eecs.umich.edudepends = [ File(py_modules[dep]) for dep in module_depends ]
3415081Sgblack@eecs.umich.edu
3425081Sgblack@eecs.umich.edu########################################################################
3435081Sgblack@eecs.umich.edu#
3445081Sgblack@eecs.umich.edu# Commands for the basic automatically generated python files
3455081Sgblack@eecs.umich.edu#
3465081Sgblack@eecs.umich.edu
3475081Sgblack@eecs.umich.edu# Generate Python file containing a dict specifying the current
3485081Sgblack@eecs.umich.edu# build_env flags.
3495081Sgblack@eecs.umich.edudef makeDefinesPyFile(target, source, env):
3505081Sgblack@eecs.umich.edu    f = file(str(target[0]), 'w')
3515081Sgblack@eecs.umich.edu    print >>f, "m5_build_env = ", source[0]
3525081Sgblack@eecs.umich.edu    f.close()
3535081Sgblack@eecs.umich.edu
3545069Sgblack@eecs.umich.edu# Generate python file containing info about the M5 source code
3554202Sbinkertn@umich.edudef makeInfoPyFile(target, source, env):
3564202Sbinkertn@umich.edu    f = file(str(target[0]), 'w')
3574202Sbinkertn@umich.edu    for src in source:
3585069Sgblack@eecs.umich.edu        data = ''.join(file(src.srcnode().abspath, 'r').xreadlines())
3595069Sgblack@eecs.umich.edu        print >>f, "%s = %s" % (src, repr(data))
3605069Sgblack@eecs.umich.edu    f.close()
3615069Sgblack@eecs.umich.edu
3624202Sbinkertn@umich.edu# Generate the __init__.py file for m5.objects
3634202Sbinkertn@umich.edudef makeObjectsInitFile(target, source, env):
364    f = file(str(target[0]), 'w')
365    print >>f, 'from params import *'
366    print >>f, 'from m5.SimObject import *'
367    for module in source:
368        print >>f, 'from %s import *' % module.get_contents()
369    f.close()
370
371# Generate a file with all of the compile options in it
372env.Command('python/m5/defines.py', Value(build_env), makeDefinesPyFile)
373PySource('m5', 'python/m5/defines.py')
374
375# Generate a file that wraps the basic top level files
376env.Command('python/m5/info.py',
377            [ '#/AUTHORS', '#/LICENSE', '#/README', '#/RELEASE_NOTES' ],
378            makeInfoPyFile)
379PySource('m5', 'python/m5/info.py')
380
381# Generate an __init__.py file for the objects package
382env.Command('python/m5/objects/__init__.py',
383            [ Value(o) for o in sort_list(sim_object_modfiles) ],
384            makeObjectsInitFile)
385PySource('m5.objects', 'python/m5/objects/__init__.py')
386
387########################################################################
388#
389# Create all of the SimObject param headers and enum headers
390#
391
392def createSimObjectParam(target, source, env):
393    assert len(target) == 1 and len(source) == 1
394
395    hh_file = file(target[0].abspath, 'w')
396    name = str(source[0].get_contents())
397    obj = sim_objects[name]
398
399    print >>hh_file, obj.cxx_decl()
400
401def createSwigParam(target, source, env):
402    assert len(target) == 1 and len(source) == 1
403
404    i_file = file(target[0].abspath, 'w')
405    name = str(source[0].get_contents())
406    param = all_params[name]
407
408    for line in param.swig_decl():
409        print >>i_file, line
410
411def createEnumStrings(target, source, env):
412    assert len(target) == 1 and len(source) == 1
413
414    cc_file = file(target[0].abspath, 'w')
415    name = str(source[0].get_contents())
416    obj = all_enums[name]
417
418    print >>cc_file, obj.cxx_def()
419    cc_file.close()
420
421def createEnumParam(target, source, env):
422    assert len(target) == 1 and len(source) == 1
423
424    hh_file = file(target[0].abspath, 'w')
425    name = str(source[0].get_contents())
426    obj = all_enums[name]
427
428    print >>hh_file, obj.cxx_decl()
429
430# Generate all of the SimObject param struct header files
431params_hh_files = []
432for name,simobj in sim_objects.iteritems():
433    extra_deps = [ File(py_modules[simobj.__module__]) ]
434
435    hh_file = File('params/%s.hh' % name)
436    params_hh_files.append(hh_file)
437    env.Command(hh_file, Value(name), createSimObjectParam)
438    env.Depends(hh_file, depends + extra_deps)
439
440# Generate any parameter header files needed
441params_i_files = []
442for name,param in all_params.iteritems():
443    if isinstance(param, m5.params.VectorParamDesc):
444        ext = 'vptype'
445    else:
446        ext = 'ptype'
447
448    i_file = File('params/%s_%s.i' % (name, ext))
449    params_i_files.append(i_file)
450    env.Command(i_file, Value(name), createSwigParam)
451    env.Depends(i_file, depends)
452
453# Generate all enum header files
454for name,enum in all_enums.iteritems():
455    extra_deps = [ File(py_modules[enum.__module__]) ]
456
457    cc_file = File('enums/%s.cc' % name)
458    env.Command(cc_file, Value(name), createEnumStrings)
459    env.Depends(cc_file, depends + extra_deps)
460    Source(cc_file)
461
462    hh_file = File('enums/%s.hh' % name)
463    env.Command(hh_file, Value(name), createEnumParam)
464    env.Depends(hh_file, depends + extra_deps)
465
466# Build the big monolithic swigged params module (wraps all SimObject
467# param structs and enum structs)
468def buildParams(target, source, env):
469    names = [ s.get_contents() for s in source ]
470    objs = [ sim_objects[name] for name in names ]
471    out = file(target[0].abspath, 'w')
472
473    ordered_objs = []
474    obj_seen = set()
475    def order_obj(obj):
476        name = str(obj)
477        if name in obj_seen:
478            return
479
480        obj_seen.add(name)
481        if str(obj) != 'SimObject':
482            order_obj(obj.__bases__[0])
483
484        ordered_objs.append(obj)
485
486    for obj in objs:
487        order_obj(obj)
488
489    enums = set()
490    predecls = []
491    pd_seen = set()
492
493    def add_pds(*pds):
494        for pd in pds:
495            if pd not in pd_seen:
496                predecls.append(pd)
497                pd_seen.add(pd)
498
499    for obj in ordered_objs:
500        params = obj._params.local.values()
501        for param in params:
502            ptype = param.ptype
503            if issubclass(ptype, m5.params.Enum):
504                if ptype not in enums:
505                    enums.add(ptype)
506            pds = param.swig_predecls()
507            if isinstance(pds, (list, tuple)):
508                add_pds(*pds)
509            else:
510                add_pds(pds)
511
512    print >>out, '%module params'
513
514    print >>out, '%{'
515    for obj in ordered_objs:
516        print >>out, '#include "params/%s.hh"' % obj
517    print >>out, '%}'
518
519    for pd in predecls:
520        print >>out, pd
521
522    enums = list(enums)
523    enums.sort()
524    for enum in enums:
525        print >>out, '%%include "enums/%s.hh"' % enum.__name__
526    print >>out
527
528    for obj in ordered_objs:
529        if obj.swig_objdecls:
530            for decl in obj.swig_objdecls:
531                print >>out, decl
532            continue
533
534        code = ''
535        base = obj.get_base()
536
537        code += '// stop swig from creating/wrapping default ctor/dtor\n'
538        code += '%%nodefault %s;\n' % obj.cxx_class
539        code += 'class %s ' % obj.cxx_class
540        if base:
541            code += ': public %s' % base
542        code += ' {};\n'
543
544        klass = obj.cxx_class;
545        if hasattr(obj, 'cxx_namespace'):
546            new_code = 'namespace %s {\n' % obj.cxx_namespace
547            new_code += code
548            new_code += '}\n'
549            code = new_code
550            klass = '%s::%s' % (obj.cxx_namespace, klass)
551
552        print >>out, code
553
554    print >>out, '%%include "src/sim/sim_object_params.hh"' % obj
555    for obj in ordered_objs:
556        print >>out, '%%include "params/%s.hh"' % obj
557
558params_file = File('params/params.i')
559names = sort_list(sim_objects.keys())
560env.Command(params_file, [ Value(v) for v in names ], buildParams)
561env.Depends(params_file, params_hh_files + params_i_files + depends)
562SwigSource('m5.objects', params_file)
563
564# Build all swig modules
565swig_modules = []
566cc_swig_sources = []
567for source,package in swig_sources:
568    filename = str(source)
569    assert filename.endswith('.i')
570
571    base = '.'.join(filename.split('.')[:-1])
572    module = basename(base)
573    cc_file = base + '_wrap.cc'
574    py_file = base + '.py'
575
576    env.Command([cc_file, py_file], source,
577                '$SWIG $SWIGFLAGS -outdir ${TARGETS[1].dir} '
578                '-o ${TARGETS[0]} $SOURCES')
579    env.Depends(py_file, source)
580    env.Depends(cc_file, source)
581
582    swig_modules.append(Value(module))
583    cc_swig_sources.append(File(cc_file))
584    PySource(package, py_file)
585
586# Generate the main swig init file
587def makeSwigInit(target, source, env):
588    f = file(str(target[0]), 'w')
589    print >>f, 'extern "C" {'
590    for module in source:
591        print >>f, '    void init_%s();' % module.get_contents()
592    print >>f, '}'
593    print >>f, 'void initSwig() {'
594    for module in source:
595        print >>f, '    init_%s();' % module.get_contents()
596    print >>f, '}'
597    f.close()
598
599env.Command('python/swig/init.cc', swig_modules, makeSwigInit)
600Source('python/swig/init.cc')
601
602# Generate traceflags.py
603def traceFlagsPy(target, source, env):
604    assert(len(target) == 1)
605
606    f = file(str(target[0]), 'w')
607
608    allFlags = []
609    for s in source:
610        val = eval(s.get_contents())
611        allFlags.append(val)
612
613    print >>f, 'baseFlags = ['
614    for flag, compound, desc in allFlags:
615        if not compound:
616            print >>f, "    '%s'," % flag
617    print >>f, "    ]"
618    print >>f
619
620    print >>f, 'compoundFlags = ['
621    print >>f, "    'All',"
622    for flag, compound, desc in allFlags:
623        if compound:
624            print >>f, "    '%s'," % flag
625    print >>f, "    ]"
626    print >>f
627
628    print >>f, "allFlags = frozenset(baseFlags + compoundFlags)"
629    print >>f
630
631    print >>f, 'compoundFlagMap = {'
632    all = tuple([flag for flag,compound,desc in allFlags if not compound])
633    print >>f, "    'All' : %s," % (all, )
634    for flag, compound, desc in allFlags:
635        if compound:
636            print >>f, "    '%s' : %s," % (flag, compound)
637    print >>f, "    }"
638    print >>f
639
640    print >>f, 'flagDescriptions = {'
641    print >>f, "    'All' : 'All flags',"
642    for flag, compound, desc in allFlags:
643        print >>f, "    '%s' : '%s'," % (flag, desc)
644    print >>f, "    }"
645
646    f.close()
647
648def traceFlagsCC(target, source, env):
649    assert(len(target) == 1)
650
651    f = file(str(target[0]), 'w')
652
653    allFlags = []
654    for s in source:
655        val = eval(s.get_contents())
656        allFlags.append(val)
657
658    # file header
659    print >>f, '''
660/*
661 * DO NOT EDIT THIS FILE! Automatically generated
662 */
663
664#include "base/traceflags.hh"
665
666using namespace Trace;
667
668const char *Trace::flagStrings[] =
669{'''
670
671    # The string array is used by SimpleEnumParam to map the strings
672    # provided by the user to enum values.
673    for flag, compound, desc in allFlags:
674        if not compound:
675            print >>f, '    "%s",' % flag
676
677    print >>f, '    "All",'
678    for flag, compound, desc in allFlags:
679        if compound:
680            print >>f, '    "%s",' % flag
681
682    print >>f, '};'
683    print >>f
684    print >>f, 'const int Trace::numFlagStrings = %d;' % (len(allFlags) + 1)
685    print >>f
686
687    #
688    # Now define the individual compound flag arrays.  There is an array
689    # for each compound flag listing the component base flags.
690    #
691    all = tuple([flag for flag,compound,desc in allFlags if not compound])
692    print >>f, 'static const Flags AllMap[] = {'
693    for flag, compound, desc in allFlags:
694        if not compound:
695            print >>f, "    %s," % flag
696    print >>f, '};'
697    print >>f
698
699    for flag, compound, desc in allFlags:
700        if not compound:
701            continue
702        print >>f, 'static const Flags %sMap[] = {' % flag
703        for flag in compound:
704            print >>f, "    %s," % flag
705        print >>f, "    (Flags)-1"
706        print >>f, '};'
707        print >>f
708
709    #
710    # Finally the compoundFlags[] array maps the compound flags
711    # to their individual arrays/
712    #
713    print >>f, 'const Flags *Trace::compoundFlags[] ='
714    print >>f, '{'
715    print >>f, '    AllMap,'
716    for flag, compound, desc in allFlags:
717        if compound:
718            print >>f, '    %sMap,' % flag
719    # file trailer
720    print >>f, '};'
721
722    f.close()
723
724def traceFlagsHH(target, source, env):
725    assert(len(target) == 1)
726
727    f = file(str(target[0]), 'w')
728
729    allFlags = []
730    for s in source:
731        val = eval(s.get_contents())
732        allFlags.append(val)
733
734    # file header boilerplate
735    print >>f, '''
736/*
737 * DO NOT EDIT THIS FILE!
738 *
739 * Automatically generated from traceflags.py
740 */
741
742#ifndef __BASE_TRACE_FLAGS_HH__
743#define __BASE_TRACE_FLAGS_HH__
744
745namespace Trace {
746
747enum Flags {'''
748
749    # Generate the enum.  Base flags come first, then compound flags.
750    idx = 0
751    for flag, compound, desc in allFlags:
752        if not compound:
753            print >>f, '    %s = %d,' % (flag, idx)
754            idx += 1
755
756    numBaseFlags = idx
757    print >>f, '    NumFlags = %d,' % idx
758
759    # put a comment in here to separate base from compound flags
760    print >>f, '''
761// The remaining enum values are *not* valid indices for Trace::flags.
762// They are "compound" flags, which correspond to sets of base
763// flags, and are used by changeFlag.'''
764
765    print >>f, '    All = %d,' % idx
766    idx += 1
767    for flag, compound, desc in allFlags:
768        if compound:
769            print >>f, '    %s = %d,' % (flag, idx)
770            idx += 1
771
772    numCompoundFlags = idx - numBaseFlags
773    print >>f, '    NumCompoundFlags = %d' % numCompoundFlags
774
775    # trailer boilerplate
776    print >>f, '''\
777}; // enum Flags
778
779// Array of strings for SimpleEnumParam
780extern const char *flagStrings[];
781extern const int numFlagStrings;
782
783// Array of arraay pointers: for each compound flag, gives the list of
784// base flags to set.  Inidividual flag arrays are terminated by -1.
785extern const Flags *compoundFlags[];
786
787/* namespace Trace */ }
788
789#endif // __BASE_TRACE_FLAGS_HH__
790'''
791
792    f.close()
793
794flags = [ Value(f) for f in trace_flags ]
795env.Command('base/traceflags.py', flags, traceFlagsPy)
796PySource('m5', 'base/traceflags.py')
797
798env.Command('base/traceflags.hh', flags, traceFlagsHH)
799env.Command('base/traceflags.cc', flags, traceFlagsCC)
800Source('base/traceflags.cc')
801
802# Generate program_info.cc
803def programInfo(target, source, env):
804    def gen_file(target, rev, node, date):
805        pi_stats = file(target, 'w')
806        print >>pi_stats, 'const char *hgRev = "%s:%s";' %  (rev, node)
807        print >>pi_stats, 'const char *hgDate = "%s";' % date
808        pi_stats.close()
809
810    target = str(target[0])
811    scons_dir = str(source[0].get_contents())
812    try:
813        import mercurial.demandimport, mercurial.hg, mercurial.ui
814        import mercurial.util, mercurial.node
815        if not exists(scons_dir) or not isdir(scons_dir) or \
816               not exists(joinpath(scons_dir, ".hg")):
817            raise ValueError
818        repo = mercurial.hg.repository(mercurial.ui.ui(), scons_dir)
819        rev = mercurial.node.nullrev + repo.changelog.count()
820        changenode = repo.changelog.node(rev)
821        changes = repo.changelog.read(changenode)
822        date = mercurial.util.datestr(changes[2])
823
824        gen_file(target, rev, mercurial.node.hex(changenode), date)
825
826        mercurial.demandimport.disable()
827    except ImportError:
828        gen_file(target, "Unknown", "Unknown", "Unknown")
829
830    except:
831        print "in except"
832        gen_file(target, "Unknown", "Unknown", "Unknown")
833        mercurial.demandimport.disable()
834
835env.Command('base/program_info.cc',
836            Value(str(SCons.Node.FS.default_fs.SConstruct_dir)),
837            programInfo)
838
839# embed python files.  All .py files that have been indicated by a
840# PySource() call in a SConscript need to be embedded into the M5
841# library.  To do that, we compile the file to byte code, marshal the
842# byte code, compress it, and then generate an assembly file that
843# inserts the result into the data section with symbols indicating the
844# beginning, and end (and with the size at the end)
845py_sources_tnodes = {}
846for pysource in py_sources:
847    py_sources_tnodes[pysource.tnode] = pysource
848
849def objectifyPyFile(target, source, env):
850    '''Action function to compile a .py into a code object, marshal
851    it, compress it, and stick it into an asm file so the code appears
852    as just bytes with a label in the data section'''
853
854    src = file(str(source[0]), 'r').read()
855    dst = file(str(target[0]), 'w')
856
857    pysource = py_sources_tnodes[source[0]]
858    compiled = compile(src, pysource.debugname, 'exec')
859    marshalled = marshal.dumps(compiled)
860    compressed = zlib.compress(marshalled)
861    data = compressed
862
863    # Some C/C++ compilers prepend an underscore to global symbol
864    # names, so if they're going to do that, we need to prepend that
865    # leading underscore to globals in the assembly file.
866    if env['LEADING_UNDERSCORE']:
867        sym = '_' + pysource.symname
868    else:
869        sym = pysource.symname
870
871    step = 16
872    print >>dst, ".data"
873    print >>dst, ".globl %s_beg" % sym
874    print >>dst, ".globl %s_end" % sym
875    print >>dst, "%s_beg:" % sym
876    for i in xrange(0, len(data), step):
877        x = array.array('B', data[i:i+step])
878        print >>dst, ".byte", ','.join([str(d) for d in x])
879    print >>dst, "%s_end:" % sym
880    print >>dst, ".long %d" % len(marshalled)
881
882for source in py_sources:
883    env.Command(source.assembly, source.tnode, objectifyPyFile)
884    Source(source.assembly)
885
886# Generate init_python.cc which creates a bunch of EmbeddedPyModule
887# structs that describe the embedded python code.  One such struct
888# contains information about the importer that python uses to get at
889# the embedded files, and then there's a list of all of the rest that
890# the importer uses to load the rest on demand.
891py_sources_symbols = {}
892for pysource in py_sources:
893    py_sources_symbols[pysource.symname] = pysource
894def pythonInit(target, source, env):
895    dst = file(str(target[0]), 'w')
896
897    def dump_mod(sym, endchar=','):
898        pysource = py_sources_symbols[sym]
899        print >>dst, '    { "%s",' % pysource.arcname
900        print >>dst, '      "%s",' % pysource.modpath
901        print >>dst, '       %s_beg, %s_end,' % (sym, sym)
902        print >>dst, '       %s_end - %s_beg,' % (sym, sym)
903        print >>dst, '       *(int *)%s_end }%s'  % (sym, endchar)
904    
905    print >>dst, '#include "sim/init.hh"'
906
907    for sym in source:
908        sym = sym.get_contents()
909        print >>dst, "extern const char %s_beg[], %s_end[];" % (sym, sym)
910
911    print >>dst, "const EmbeddedPyModule embeddedPyImporter = "
912    dump_mod("PyEMB_importer", endchar=';');
913    print >>dst
914
915    print >>dst, "const EmbeddedPyModule embeddedPyModules[] = {"
916    for i,sym in enumerate(source):
917        sym = sym.get_contents()
918        if sym == "PyEMB_importer":
919            # Skip the importer since we've already exported it
920            continue
921        dump_mod(sym)
922    print >>dst, "    { 0, 0, 0, 0, 0, 0 }"
923    print >>dst, "};"
924
925symbols = [Value(s.symname) for s in py_sources]
926env.Command('sim/init_python.cc', symbols, pythonInit)
927Source('sim/init_python.cc')
928
929########################################################################
930#
931# Define binaries.  Each different build type (debug, opt, etc.) gets
932# a slightly different build environment.
933#
934
935# List of constructed environments to pass back to SConstruct
936envList = []
937
938# This function adds the specified sources to the given build
939# environment, and returns a list of all the corresponding SCons
940# Object nodes (including an extra one for date.cc).  We explicitly
941# add the Object nodes so we can set up special dependencies for
942# date.cc.
943def make_objs(sources, env, static):
944    if static:
945        XObject = env.StaticObject
946    else:
947        XObject = env.SharedObject
948
949    objs = [ XObject(s) for s in sources ]
950  
951    # make date.cc depend on all other objects so it always gets
952    # recompiled whenever anything else does
953    date_obj = XObject('base/date.cc')
954
955    # Make the generation of program_info.cc dependend on all 
956    # the other cc files and the compiling of program_info.cc 
957    # dependent on all the objects but program_info.o 
958    pinfo_obj = XObject('base/program_info.cc')
959    env.Depends('base/program_info.cc', sources)
960    env.Depends(date_obj, objs)
961    env.Depends(pinfo_obj, objs)
962    objs.extend([date_obj, pinfo_obj])
963    return objs
964
965# Function to create a new build environment as clone of current
966# environment 'env' with modified object suffix and optional stripped
967# binary.  Additional keyword arguments are appended to corresponding
968# build environment vars.
969def makeEnv(label, objsfx, strip = False, **kwargs):
970    # SCons doesn't know to append a library suffix when there is a '.' in the
971    # name.  Use '_' instead.
972    libname = 'm5_' + label
973    exename = 'm5.' + label
974
975    new_env = env.Copy(OBJSUFFIX=objsfx, SHOBJSUFFIX=objsfx + 's')
976    new_env.Label = label
977    new_env.Append(**kwargs)
978
979    swig_env = new_env.Copy()
980    if env['GCC']:
981        swig_env.Append(CCFLAGS='-Wno-uninitialized')
982        swig_env.Append(CCFLAGS='-Wno-sign-compare')
983        swig_env.Append(CCFLAGS='-Wno-parentheses')
984
985    static_objs = make_objs(cc_lib_sources, new_env, static=True)
986    shared_objs = make_objs(cc_lib_sources, new_env, static=False)
987    static_objs += [ swig_env.StaticObject(s) for s in cc_swig_sources ]
988    shared_objs += [ swig_env.SharedObject(s) for s in cc_swig_sources ]
989
990    # First make a library of everything but main() so other programs can
991    # link against m5.
992    static_lib = new_env.StaticLibrary(libname, static_objs + static_objs)
993    shared_lib = new_env.SharedLibrary(libname, shared_objs + shared_objs)
994
995    for target, sources in unit_tests:
996        objs = [ new_env.StaticObject(s) for s in sources ]
997        new_env.Program("unittest/%s.%s" % (target, label), objs + static_lib)
998
999    # Now link a stub with main() and the static library.
1000    objects = [new_env.Object(s) for s in cc_bin_sources] + static_lib
1001    if strip:
1002        unstripped_exe = exename + '.unstripped'
1003        new_env.Program(unstripped_exe, objects)
1004        if sys.platform == 'sunos5':
1005            cmd = 'cp $SOURCE $TARGET; strip $TARGET'
1006        else:
1007            cmd = 'strip $SOURCE -o $TARGET'
1008        targets = new_env.Command(exename, unstripped_exe, cmd)
1009    else:
1010        targets = new_env.Program(exename, objects)
1011            
1012    new_env.M5Binary = targets[0]
1013    envList.append(new_env)
1014
1015# Debug binary
1016ccflags = {}
1017if env['GCC']:
1018    if sys.platform == 'sunos5':
1019        ccflags['debug'] = '-gstabs+'
1020    else:
1021        ccflags['debug'] = '-ggdb3'
1022    ccflags['opt'] = '-g -O3'
1023    ccflags['fast'] = '-O3'
1024    ccflags['prof'] = '-O3 -g -pg'
1025elif env['SUNCC']:
1026    ccflags['debug'] = '-g0'
1027    ccflags['opt'] = '-g -O'
1028    ccflags['fast'] = '-fast'
1029    ccflags['prof'] = '-fast -g -pg'
1030elif env['ICC']:
1031    ccflags['debug'] = '-g -O0'
1032    ccflags['opt'] = '-g -O'
1033    ccflags['fast'] = '-fast'
1034    ccflags['prof'] = '-fast -g -pg'
1035else:
1036    print 'Unknown compiler, please fix compiler options'
1037    Exit(1)
1038
1039makeEnv('debug', '.do',
1040        CCFLAGS = Split(ccflags['debug']),
1041        CPPDEFINES = ['DEBUG', 'TRACING_ON=1'])
1042
1043# Optimized binary
1044makeEnv('opt', '.o',
1045        CCFLAGS = Split(ccflags['opt']),
1046        CPPDEFINES = ['TRACING_ON=1'])
1047
1048# "Fast" binary
1049makeEnv('fast', '.fo', strip = True,
1050        CCFLAGS = Split(ccflags['fast']),
1051        CPPDEFINES = ['NDEBUG', 'TRACING_ON=0'])
1052
1053# Profiled binary
1054makeEnv('prof', '.po',
1055        CCFLAGS = Split(ccflags['prof']),
1056        CPPDEFINES = ['NDEBUG', 'TRACING_ON=0'],
1057        LINKFLAGS = '-pg')
1058
1059Return('envList')
1060