SConscript revision 5344
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#
294762Snate@binkert.org# Authors: Nathan Binkert
30955SN/A
315522Snate@binkert.orgimport imp
326143Snate@binkert.orgimport os
334762Snate@binkert.orgimport sys
345522Snate@binkert.org
35955SN/Afrom os.path import basename, exists, isdir, isfile, join as joinpath
365522Snate@binkert.org
3711974Sgabeblack@google.comimport SCons
38955SN/A
395522Snate@binkert.org# This file defines how to build a particular configuration of M5
404202Sbinkertn@umich.edu# based on variable settings in the 'env' build environment.
415742Snate@binkert.org
42955SN/AImport('*')
434381Sbinkertn@umich.edu
444381Sbinkertn@umich.edu# Children need to see the environment
4512246Sgabeblack@google.comExport('env')
4612246Sgabeblack@google.com
478334Snate@binkert.orgdef sort_list(_list):
48955SN/A    """return a sorted copy of '_list'"""
49955SN/A    if isinstance(_list, list):
504202Sbinkertn@umich.edu        _list = _list[:]
51955SN/A    else:
524382Sbinkertn@umich.edu        _list = list(_list)
534382Sbinkertn@umich.edu    _list.sort()
544382Sbinkertn@umich.edu    return _list
556654Snate@binkert.org
565517Snate@binkert.orgclass PySourceFile(object):
578614Sgblack@eecs.umich.edu    def __init__(self, package, source):
587674Snate@binkert.org        filename = str(source)
596143Snate@binkert.org        pyname = basename(filename)
606143Snate@binkert.org        assert pyname.endswith('.py')
616143Snate@binkert.org        name = pyname[:-3]
6212302Sgabeblack@google.com        path = package.split('.')
6312302Sgabeblack@google.com        modpath = path
6412302Sgabeblack@google.com        if name != '__init__':
6512302Sgabeblack@google.com            modpath += [name]
6612302Sgabeblack@google.com        modpath = '.'.join(modpath)
6712302Sgabeblack@google.com
6812302Sgabeblack@google.com        arcpath = package.split('.') + [ pyname + 'c' ]
6912302Sgabeblack@google.com        arcname = joinpath(*arcpath)
7012302Sgabeblack@google.com
7112302Sgabeblack@google.com        self.source = source
7212302Sgabeblack@google.com        self.pyname = pyname
7312302Sgabeblack@google.com        self.srcpath = source.srcnode().abspath
7412302Sgabeblack@google.com        self.package = package
7512302Sgabeblack@google.com        self.modpath = modpath
7612302Sgabeblack@google.com        self.arcname = arcname
7712302Sgabeblack@google.com        self.filename = filename
7812302Sgabeblack@google.com        self.compiled = File(filename + 'c')
7912302Sgabeblack@google.com
8012302Sgabeblack@google.com########################################################################
8112302Sgabeblack@google.com# Code for adding source files of various types
8212302Sgabeblack@google.com#
8312302Sgabeblack@google.comcc_sources = []
8412302Sgabeblack@google.comdef Source(source):
8512302Sgabeblack@google.com    '''Add a C/C++ source file to the build'''
8612302Sgabeblack@google.com    if not isinstance(source, SCons.Node.FS.File):
8712302Sgabeblack@google.com        source = File(source)
8812302Sgabeblack@google.com
8912302Sgabeblack@google.com    cc_sources.append(source)
9012302Sgabeblack@google.com
9111983Sgabeblack@google.compy_sources = []
926143Snate@binkert.orgdef PySource(package, source):
938233Snate@binkert.org    '''Add a python source file to the named package'''
9412302Sgabeblack@google.com    if not isinstance(source, SCons.Node.FS.File):
956143Snate@binkert.org        source = File(source)
966143Snate@binkert.org
9712302Sgabeblack@google.com    source = PySourceFile(package, source)
984762Snate@binkert.org    py_sources.append(source)
996143Snate@binkert.org
1008233Snate@binkert.orgsim_objects_fixed = False
1018233Snate@binkert.orgsim_object_modfiles = set()
10212302Sgabeblack@google.comdef SimObject(source):
10312302Sgabeblack@google.com    '''Add a SimObject python file as a python source object and add
1046143Snate@binkert.org    it to a list of sim object modules'''
10512302Sgabeblack@google.com
10612302Sgabeblack@google.com    if sim_objects_fixed:
10712302Sgabeblack@google.com        raise AttributeError, "Too late to call SimObject now."
10812302Sgabeblack@google.com
10912302Sgabeblack@google.com    if not isinstance(source, SCons.Node.FS.File):
11012302Sgabeblack@google.com        source = File(source)
11112302Sgabeblack@google.com
11212302Sgabeblack@google.com    PySource('m5.objects', source)
11312302Sgabeblack@google.com    modfile = basename(str(source))
11412302Sgabeblack@google.com    assert modfile.endswith('.py')
1158233Snate@binkert.org    modname = modfile[:-3]
1166143Snate@binkert.org    sim_object_modfiles.add(modname)
1176143Snate@binkert.org
1186143Snate@binkert.orgswig_sources = []
1196143Snate@binkert.orgdef SwigSource(package, source):
1206143Snate@binkert.org    '''Add a swig file to build'''
1216143Snate@binkert.org    if not isinstance(source, SCons.Node.FS.File):
1226143Snate@binkert.org        source = File(source)
1236143Snate@binkert.org    val = source,package
1246143Snate@binkert.org    swig_sources.append(val)
1257065Snate@binkert.org
1266143Snate@binkert.org# Children should have access
1278233Snate@binkert.orgExport('Source')
1288233Snate@binkert.orgExport('PySource')
1298233Snate@binkert.orgExport('SimObject')
1308233Snate@binkert.orgExport('SwigSource')
1318233Snate@binkert.org
1328233Snate@binkert.org########################################################################
1338233Snate@binkert.org#
1348233Snate@binkert.org# Trace Flags
1358233Snate@binkert.org#
1368233Snate@binkert.orgall_flags = {}
1378233Snate@binkert.orgtrace_flags = []
1388233Snate@binkert.orgdef TraceFlag(name, desc=''):
1398233Snate@binkert.org    if name in all_flags:
1408233Snate@binkert.org        raise AttributeError, "Flag %s already specified" % name
1418233Snate@binkert.org    flag = (name, (), desc)
1428233Snate@binkert.org    trace_flags.append(flag)
1438233Snate@binkert.org    all_flags[name] = ()
1448233Snate@binkert.org
1458233Snate@binkert.orgdef CompoundFlag(name, flags, desc=''):
1468233Snate@binkert.org    if name in all_flags:
1478233Snate@binkert.org        raise AttributeError, "Flag %s already specified" % name
1486143Snate@binkert.org
1496143Snate@binkert.org    compound = tuple(flags)
1506143Snate@binkert.org    for flag in compound:
1516143Snate@binkert.org        if flag not in all_flags:
1526143Snate@binkert.org            raise AttributeError, "Trace flag %s not found" % flag
1536143Snate@binkert.org        if all_flags[flag]:
1549982Satgutier@umich.edu            raise AttributeError, \
1556143Snate@binkert.org                "Compound flag can't point to another compound flag"
15612302Sgabeblack@google.com
15712302Sgabeblack@google.com    flag = (name, compound, desc)
15812302Sgabeblack@google.com    trace_flags.append(flag)
15912302Sgabeblack@google.com    all_flags[name] = compound
16012302Sgabeblack@google.com
16112302Sgabeblack@google.comExport('TraceFlag')
16212302Sgabeblack@google.comExport('CompoundFlag')
16312302Sgabeblack@google.com
16411983Sgabeblack@google.com########################################################################
16511983Sgabeblack@google.com#
16611983Sgabeblack@google.com# Set some compiler variables
16712302Sgabeblack@google.com#
16812302Sgabeblack@google.com
16912302Sgabeblack@google.com# Include file paths are rooted in this directory.  SCons will
17012302Sgabeblack@google.com# automatically expand '.' to refer to both the source directory and
17112302Sgabeblack@google.com# the corresponding build directory to pick up generated include
17212302Sgabeblack@google.com# files.
17311983Sgabeblack@google.comenv.Append(CPPPATH=Dir('.'))
1746143Snate@binkert.org
17512305Sgabeblack@google.com# Add a flag defining what THE_ISA should be for all compilation
17612302Sgabeblack@google.comenv.Append(CPPDEFINES=[('THE_ISA','%s_ISA' % env['TARGET_ISA'].upper())])
17712302Sgabeblack@google.com
17812302Sgabeblack@google.com########################################################################
1796143Snate@binkert.org#
1806143Snate@binkert.org# Walk the tree and execute all SConscripts in subdirectories
1816143Snate@binkert.org#
1825522Snate@binkert.org
1836143Snate@binkert.orgfor base_dir in base_dir_list:
1846143Snate@binkert.org    here = Dir('.').srcnode().abspath
1856143Snate@binkert.org    for root, dirs, files in os.walk(base_dir, topdown=True):
1869982Satgutier@umich.edu        if root == here:
18712302Sgabeblack@google.com            # we don't want to recurse back into this SConscript
18812302Sgabeblack@google.com            continue
18912302Sgabeblack@google.com
1906143Snate@binkert.org        if 'SConscript' in files:
1916143Snate@binkert.org            build_dir = joinpath(env['BUILDDIR'], root[len(base_dir) + 1:])
1926143Snate@binkert.org            SConscript(joinpath(root, 'SConscript'), build_dir=build_dir)
1936143Snate@binkert.org
1945522Snate@binkert.orgfor opt in env.ExportOptions:
1955522Snate@binkert.org    env.ConfigFile(opt)
1965522Snate@binkert.org
1975522Snate@binkert.org########################################################################
1985604Snate@binkert.org#
1995604Snate@binkert.org# Prevent any SimObjects from being added after this point, they
2006143Snate@binkert.org# should all have been added in the SConscripts above
2016143Snate@binkert.org#
2024762Snate@binkert.orgsim_objects_fixed = True
2034762Snate@binkert.org
2046143Snate@binkert.org########################################################################
2056727Ssteve.reinhardt@amd.com#
2066727Ssteve.reinhardt@amd.com# Manually turn python/generate.py into a python module and import it
2076727Ssteve.reinhardt@amd.com#
2084762Snate@binkert.orggenerate_file = File('python/generate.py')
2096143Snate@binkert.orggenerate_module = imp.new_module('generate')
2106143Snate@binkert.orgsys.modules['generate'] = generate_module
2116143Snate@binkert.orgexec file(generate_file.srcnode().abspath, 'r') in generate_module.__dict__
2126143Snate@binkert.org
2136727Ssteve.reinhardt@amd.com########################################################################
2146143Snate@binkert.org#
2157674Snate@binkert.org# build a generate
2167674Snate@binkert.org#
2175604Snate@binkert.orgfrom generate import Generate
2186143Snate@binkert.orgoptionDict = dict([(opt, env[opt]) for opt in env.ExportOptions])
2196143Snate@binkert.orggenerate = Generate(py_sources, sim_object_modfiles, optionDict)
2206143Snate@binkert.orgm5 = generate.m5
2214762Snate@binkert.org
2226143Snate@binkert.org########################################################################
2234762Snate@binkert.org#
2244762Snate@binkert.org# calculate extra dependencies
2254762Snate@binkert.org#
2266143Snate@binkert.orgmodule_depends = ["m5", "m5.SimObject", "m5.params"]
2276143Snate@binkert.orgmodule_depends = [ File(generate.py_modules[dep]) for dep in module_depends ]
2284762Snate@binkert.orgfile_depends = [ generate_file ]
22912302Sgabeblack@google.comdepends = module_depends + file_depends
23012302Sgabeblack@google.com
2318233Snate@binkert.org########################################################################
23212302Sgabeblack@google.com#
2336143Snate@binkert.org# Commands for the basic automatically generated python files
2346143Snate@binkert.org#
2354762Snate@binkert.org
2366143Snate@binkert.org# Generate a file with all of the compile options in it
2374762Snate@binkert.orgenv.Command('python/m5/defines.py', Value(optionDict),
2389396Sandreas.hansson@arm.com            generate.makeDefinesPyFile)
2399396Sandreas.hansson@arm.comPySource('m5', 'python/m5/defines.py')
2409396Sandreas.hansson@arm.com
24112302Sgabeblack@google.com# Generate a file that wraps the basic top level files
24212302Sgabeblack@google.comenv.Command('python/m5/info.py',
24312302Sgabeblack@google.com            [ '#/AUTHORS', '#/LICENSE', '#/README', '#/RELEASE_NOTES' ],
2449396Sandreas.hansson@arm.com            generate.makeInfoPyFile)
2459396Sandreas.hansson@arm.comPySource('m5', 'python/m5/info.py')
2469396Sandreas.hansson@arm.com
2479396Sandreas.hansson@arm.com# Generate an __init__.py file for the objects package
2489396Sandreas.hansson@arm.comenv.Command('python/m5/objects/__init__.py',
2499396Sandreas.hansson@arm.com            [ Value(o) for o in sort_list(sim_object_modfiles) ],
2509396Sandreas.hansson@arm.com            generate.makeObjectsInitFile)
2519930Sandreas.hansson@arm.comPySource('m5.objects', 'python/m5/objects/__init__.py')
2529930Sandreas.hansson@arm.com
2539396Sandreas.hansson@arm.com########################################################################
2548235Snate@binkert.org#
2558235Snate@binkert.org# Create all of the SimObject param headers and enum headers
2566143Snate@binkert.org#
2578235Snate@binkert.org
2589003SAli.Saidi@ARM.com# Generate all of the SimObject param struct header files
2598235Snate@binkert.orgparams_hh_files = []
2608235Snate@binkert.orgfor name,simobj in generate.sim_objects.iteritems():
26112302Sgabeblack@google.com    extra_deps = [ File(generate.py_modules[simobj.__module__]) ]
2628235Snate@binkert.org
26312302Sgabeblack@google.com    hh_file = File('params/%s.hh' % name)
2648235Snate@binkert.org    params_hh_files.append(hh_file)
2658235Snate@binkert.org    env.Command(hh_file, Value(name), generate.createSimObjectParam)
26612302Sgabeblack@google.com    env.Depends(hh_file, depends + extra_deps)
2678235Snate@binkert.org
2688235Snate@binkert.org# Generate any parameter header files needed
2698235Snate@binkert.orgfor name,param in generate.params.iteritems():
2708235Snate@binkert.org    if isinstance(param, m5.params.VectorParamDesc):
2719003SAli.Saidi@ARM.com        ext = 'vptype'
2728235Snate@binkert.org    else:
2735584Snate@binkert.org        ext = 'ptype'
2744382Sbinkertn@umich.edu
2754202Sbinkertn@umich.edu    i_file = File('params/%s_%s.i' % (name, ext))
2764382Sbinkertn@umich.edu    env.Command(i_file, Value(name), generate.createSwigParam)
2774382Sbinkertn@umich.edu    env.Depends(i_file, depends)
2789396Sandreas.hansson@arm.com
2795584Snate@binkert.org# Generate all enum header files
2804382Sbinkertn@umich.edufor name,enum in generate.enums.iteritems():
2814382Sbinkertn@umich.edu    extra_deps = [ File(generate.py_modules[enum.__module__]) ]
2824382Sbinkertn@umich.edu
2838232Snate@binkert.org    cc_file = File('enums/%s.cc' % name)
2845192Ssaidi@eecs.umich.edu    env.Command(cc_file, Value(name), generate.createEnumStrings)
2858232Snate@binkert.org    env.Depends(cc_file, depends + extra_deps)
2868232Snate@binkert.org    Source(cc_file)
2878232Snate@binkert.org
2885192Ssaidi@eecs.umich.edu    hh_file = File('enums/%s.hh' % name)
2898232Snate@binkert.org    env.Command(hh_file, Value(name), generate.createEnumParam)
2905192Ssaidi@eecs.umich.edu    env.Depends(hh_file, depends + extra_deps)
2915799Snate@binkert.org
2928232Snate@binkert.org# Build the big monolithic swigged params module (wraps all SimObject
2935192Ssaidi@eecs.umich.edu# param structs and enum structs)
2945192Ssaidi@eecs.umich.eduparams_file = File('params/params.i')
2955192Ssaidi@eecs.umich.edunames = sort_list(generate.sim_objects.keys())
2968232Snate@binkert.orgenv.Command(params_file, [ Value(v) for v in names ],
2975192Ssaidi@eecs.umich.edu            generate.buildParams)
2988232Snate@binkert.orgenv.Depends(params_file, params_hh_files + depends)
2995192Ssaidi@eecs.umich.eduSwigSource('m5.objects', params_file)
3005192Ssaidi@eecs.umich.edu
3015192Ssaidi@eecs.umich.edu# Build all swig modules
3025192Ssaidi@eecs.umich.eduswig_modules = []
3034382Sbinkertn@umich.edufor source,package in swig_sources:
3044382Sbinkertn@umich.edu    filename = str(source)
3054382Sbinkertn@umich.edu    assert filename.endswith('.i')
3062667Sstever@eecs.umich.edu
3072667Sstever@eecs.umich.edu    base = '.'.join(filename.split('.')[:-1])
3082667Sstever@eecs.umich.edu    module = basename(base)
3092667Sstever@eecs.umich.edu    cc_file = base + '_wrap.cc'
3102667Sstever@eecs.umich.edu    py_file = base + '.py'
3112667Sstever@eecs.umich.edu
3125742Snate@binkert.org    env.Command([cc_file, py_file], source,
3135742Snate@binkert.org                '$SWIG $SWIGFLAGS -outdir ${TARGETS[1].dir} '
3145742Snate@binkert.org                '-o ${TARGETS[0]} $SOURCES')
3155793Snate@binkert.org    env.Depends(py_file, source)
3168334Snate@binkert.org    env.Depends(cc_file, source)
3175793Snate@binkert.org
3185793Snate@binkert.org    swig_modules.append(Value(module))
3195793Snate@binkert.org    Source(cc_file)
3204382Sbinkertn@umich.edu    PySource(package, py_file)
3214762Snate@binkert.org
3225344Sstever@gmail.com# Generate the main swig init file
3234382Sbinkertn@umich.eduenv.Command('swig/init.cc', swig_modules, generate.makeSwigInit)
3245341Sstever@gmail.comSource('swig/init.cc')
3255742Snate@binkert.org
3265742Snate@binkert.org# Generate traceflags.py
3275742Snate@binkert.orgflags = [ Value(f) for f in trace_flags ]
3285742Snate@binkert.orgenv.Command('base/traceflags.py', flags, generate.traceFlagsPy)
3295742Snate@binkert.orgPySource('m5', 'base/traceflags.py')
3304762Snate@binkert.org
3315742Snate@binkert.orgenv.Command('base/traceflags.hh', flags, generate.traceFlagsHH)
3325742Snate@binkert.orgenv.Command('base/traceflags.cc', flags, generate.traceFlagsCC)
33311984Sgabeblack@google.comSource('base/traceflags.cc')
3347722Sgblack@eecs.umich.edu
3355742Snate@binkert.org# Build the zip file
3365742Snate@binkert.orgpy_compiled = []
3375742Snate@binkert.orgpy_zip_depends = []
3389930Sandreas.hansson@arm.comfor source in py_sources:
3399930Sandreas.hansson@arm.com    env.Command(source.compiled, source.source, generate.compilePyFile)
3409930Sandreas.hansson@arm.com    py_compiled.append(source.compiled)
3419930Sandreas.hansson@arm.com
3429930Sandreas.hansson@arm.com    # make the zipfile depend on the archive name so that the archive
3435742Snate@binkert.org    # is rebuilt if the name changes
3448242Sbradley.danofsky@amd.com    py_zip_depends.append(Value(source.arcname))
3458242Sbradley.danofsky@amd.com
3468242Sbradley.danofsky@amd.com# Add the zip file target to the environment.
3478242Sbradley.danofsky@amd.comm5zip = File('m5py.zip')
3485341Sstever@gmail.comenv.Command(m5zip, py_compiled, generate.buildPyZip)
3495742Snate@binkert.orgenv.Depends(m5zip, py_zip_depends)
3507722Sgblack@eecs.umich.edu
3514773Snate@binkert.org########################################################################
3526108Snate@binkert.org#
3531858SN/A# Define binaries.  Each different build type (debug, opt, etc.) gets
3541085SN/A# a slightly different build environment.
3556658Snate@binkert.org#
3566658Snate@binkert.org
3577673Snate@binkert.org# List of constructed environments to pass back to SConstruct
3586658Snate@binkert.orgenvList = []
3596658Snate@binkert.org
36011308Santhony.gutierrez@amd.com# This function adds the specified sources to the given build
3616658Snate@binkert.org# environment, and returns a list of all the corresponding SCons
36211308Santhony.gutierrez@amd.com# Object nodes (including an extra one for date.cc).  We explicitly
3636658Snate@binkert.org# add the Object nodes so we can set up special dependencies for
3646658Snate@binkert.org# date.cc.
3657673Snate@binkert.orgdef make_objs(sources, env):
3667673Snate@binkert.org    objs = [env.Object(s) for s in sources]
3677673Snate@binkert.org    # make date.cc depend on all other objects so it always gets
3687673Snate@binkert.org    # recompiled whenever anything else does
3697673Snate@binkert.org    date_obj = env.Object('base/date.cc')
3707673Snate@binkert.org    env.Depends(date_obj, objs)
3717673Snate@binkert.org    objs.append(date_obj)
37210467Sandreas.hansson@arm.com    return objs
3736658Snate@binkert.org
3747673Snate@binkert.org# Function to create a new build environment as clone of current
37510467Sandreas.hansson@arm.com# environment 'env' with modified object suffix and optional stripped
37610467Sandreas.hansson@arm.com# binary.  Additional keyword arguments are appended to corresponding
37710467Sandreas.hansson@arm.com# build environment vars.
37810467Sandreas.hansson@arm.comdef makeEnv(label, objsfx, strip = False, **kwargs):
37910467Sandreas.hansson@arm.com    newEnv = env.Copy(OBJSUFFIX=objsfx)
38010467Sandreas.hansson@arm.com    newEnv.Label = label
38110467Sandreas.hansson@arm.com    newEnv.Append(**kwargs)
38210467Sandreas.hansson@arm.com    exe = 'm5.' + label  # final executable
38310467Sandreas.hansson@arm.com    bin = exe + '.bin'   # executable w/o appended Python zip archive
38410467Sandreas.hansson@arm.com    newEnv.Program(bin, make_objs(cc_sources, newEnv))
38510467Sandreas.hansson@arm.com    if strip:
3867673Snate@binkert.org        stripped_bin = bin + '.stripped'
3877673Snate@binkert.org        if sys.platform == 'sunos5':
3887673Snate@binkert.org            cmd = 'cp $SOURCE $TARGET; strip $TARGET'
3897673Snate@binkert.org        else:
3907673Snate@binkert.org            cmd = 'strip $SOURCE -o $TARGET'
3919048SAli.Saidi@ARM.com        newEnv.Command(stripped_bin, bin, cmd)
3927673Snate@binkert.org        bin = stripped_bin
3937673Snate@binkert.org    targets = newEnv.Concat(exe, [bin, 'm5py.zip'])
3947673Snate@binkert.org    newEnv.M5Binary = targets[0]
3957673Snate@binkert.org    envList.append(newEnv)
3966658Snate@binkert.org
3977756SAli.Saidi@ARM.com# Debug binary
3987816Ssteve.reinhardt@amd.comccflags = {}
3996658Snate@binkert.orgif env['GCC']:
40011308Santhony.gutierrez@amd.com    if sys.platform == 'sunos5':
40111308Santhony.gutierrez@amd.com        ccflags['debug'] = '-gstabs+'
40211308Santhony.gutierrez@amd.com    else:
40311308Santhony.gutierrez@amd.com        ccflags['debug'] = '-ggdb3'
40411308Santhony.gutierrez@amd.com    ccflags['opt'] = '-g -O3'
40511308Santhony.gutierrez@amd.com    ccflags['fast'] = '-O3'
40611308Santhony.gutierrez@amd.com    ccflags['prof'] = '-O3 -g -pg'
40711308Santhony.gutierrez@amd.comelif env['SUNCC']:
40811308Santhony.gutierrez@amd.com    ccflags['debug'] = '-g0'
40911308Santhony.gutierrez@amd.com    ccflags['opt'] = '-g -O'
41011308Santhony.gutierrez@amd.com    ccflags['fast'] = '-fast'
41111308Santhony.gutierrez@amd.com    ccflags['prof'] = '-fast -g -pg'
41211308Santhony.gutierrez@amd.comelif env['ICC']:
41311308Santhony.gutierrez@amd.com    ccflags['debug'] = '-g -O0'
41411308Santhony.gutierrez@amd.com    ccflags['opt'] = '-g -O'
41511308Santhony.gutierrez@amd.com    ccflags['fast'] = '-fast'
41611308Santhony.gutierrez@amd.com    ccflags['prof'] = '-fast -g -pg'
41711308Santhony.gutierrez@amd.comelse:
41811308Santhony.gutierrez@amd.com    print 'Unknown compiler, please fix compiler options'
41911308Santhony.gutierrez@amd.com    Exit(1)
42011308Santhony.gutierrez@amd.com
42111308Santhony.gutierrez@amd.commakeEnv('debug', '.do',
42211308Santhony.gutierrez@amd.com        CCFLAGS = Split(ccflags['debug']),
42311308Santhony.gutierrez@amd.com        CPPDEFINES = ['DEBUG', 'TRACING_ON=1'])
42411308Santhony.gutierrez@amd.com
42511308Santhony.gutierrez@amd.com# Optimized binary
42611308Santhony.gutierrez@amd.commakeEnv('opt', '.o',
42711308Santhony.gutierrez@amd.com        CCFLAGS = Split(ccflags['opt']),
42811308Santhony.gutierrez@amd.com        CPPDEFINES = ['TRACING_ON=1'])
42911308Santhony.gutierrez@amd.com
43011308Santhony.gutierrez@amd.com# "Fast" binary
43111308Santhony.gutierrez@amd.commakeEnv('fast', '.fo', strip = True,
43211308Santhony.gutierrez@amd.com        CCFLAGS = Split(ccflags['fast']),
43311308Santhony.gutierrez@amd.com        CPPDEFINES = ['NDEBUG', 'TRACING_ON=0'])
43411308Santhony.gutierrez@amd.com
43511308Santhony.gutierrez@amd.com# Profiled binary
43611308Santhony.gutierrez@amd.commakeEnv('prof', '.po',
43711308Santhony.gutierrez@amd.com        CCFLAGS = Split(ccflags['prof']),
43811308Santhony.gutierrez@amd.com        CPPDEFINES = ['NDEBUG', 'TRACING_ON=0'],
43911308Santhony.gutierrez@amd.com        LINKFLAGS = '-pg')
44011308Santhony.gutierrez@amd.com
44111308Santhony.gutierrez@amd.comReturn('envList')
44211308Santhony.gutierrez@amd.com