SConscript revision 5456
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
37955SN/Aimport SCons
385522Snate@binkert.org
394202Sbinkertn@umich.edu# This file defines how to build a particular configuration of M5
405742Snate@binkert.org# based on variable settings in the 'env' build environment.
41955SN/A
424381Sbinkertn@umich.eduImport('*')
434381Sbinkertn@umich.edu
448334Snate@binkert.org# Children need to see the environment
45955SN/AExport('env')
46955SN/A
474202Sbinkertn@umich.edudef sort_list(_list):
48955SN/A    """return a sorted copy of '_list'"""
494382Sbinkertn@umich.edu    if isinstance(_list, list):
504382Sbinkertn@umich.edu        _list = _list[:]
514382Sbinkertn@umich.edu    else:
526654Snate@binkert.org        _list = list(_list)
535517Snate@binkert.org    _list.sort()
548614Sgblack@eecs.umich.edu    return _list
557674Snate@binkert.org
566143Snate@binkert.orgclass PySourceFile(object):
576143Snate@binkert.org    def __init__(self, package, source):
586143Snate@binkert.org        filename = str(source)
598233Snate@binkert.org        pyname = basename(filename)
608233Snate@binkert.org        assert pyname.endswith('.py')
618233Snate@binkert.org        name = pyname[:-3]
628233Snate@binkert.org        path = package.split('.')
638233Snate@binkert.org        modpath = path
648334Snate@binkert.org        if name != '__init__':
658334Snate@binkert.org            modpath += [name]
6610453SAndrew.Bardsley@arm.com        modpath = '.'.join(modpath)
6710453SAndrew.Bardsley@arm.com
688233Snate@binkert.org        arcpath = package.split('.') + [ pyname + 'c' ]
698233Snate@binkert.org        arcname = joinpath(*arcpath)
708233Snate@binkert.org
718233Snate@binkert.org        self.source = source
728233Snate@binkert.org        self.pyname = pyname
738233Snate@binkert.org        self.srcpath = source.srcnode().abspath
746143Snate@binkert.org        self.package = package
758233Snate@binkert.org        self.modpath = modpath
768233Snate@binkert.org        self.arcname = arcname
778233Snate@binkert.org        self.filename = filename
786143Snate@binkert.org        self.compiled = File(filename + 'c')
796143Snate@binkert.org
806143Snate@binkert.org########################################################################
8111308Santhony.gutierrez@amd.com# Code for adding source files of various types
828233Snate@binkert.org#
838233Snate@binkert.orgcc_sources = []
848233Snate@binkert.orgdef Source(source):
856143Snate@binkert.org    '''Add a C/C++ source file to the build'''
868233Snate@binkert.org    if not isinstance(source, SCons.Node.FS.File):
878233Snate@binkert.org        source = File(source)
888233Snate@binkert.org
898233Snate@binkert.org    cc_sources.append(source)
906143Snate@binkert.org
916143Snate@binkert.orgpy_sources = []
926143Snate@binkert.orgdef PySource(package, source):
934762Snate@binkert.org    '''Add a python source file to the named package'''
946143Snate@binkert.org    if not isinstance(source, SCons.Node.FS.File):
958233Snate@binkert.org        source = File(source)
968233Snate@binkert.org
978233Snate@binkert.org    source = PySourceFile(package, source)
988233Snate@binkert.org    py_sources.append(source)
998233Snate@binkert.org
1006143Snate@binkert.orgsim_objects_fixed = False
1018233Snate@binkert.orgsim_object_modfiles = set()
1028233Snate@binkert.orgdef SimObject(source):
1038233Snate@binkert.org    '''Add a SimObject python file as a python source object and add
1048233Snate@binkert.org    it to a list of sim object modules'''
1056143Snate@binkert.org
1066143Snate@binkert.org    if sim_objects_fixed:
1076143Snate@binkert.org        raise AttributeError, "Too late to call SimObject now."
1086143Snate@binkert.org
1096143Snate@binkert.org    if not isinstance(source, SCons.Node.FS.File):
1106143Snate@binkert.org        source = File(source)
1116143Snate@binkert.org
1126143Snate@binkert.org    PySource('m5.objects', source)
1136143Snate@binkert.org    modfile = basename(str(source))
1147065Snate@binkert.org    assert modfile.endswith('.py')
1156143Snate@binkert.org    modname = modfile[:-3]
1168233Snate@binkert.org    sim_object_modfiles.add(modname)
1178233Snate@binkert.org
1188233Snate@binkert.orgswig_sources = []
1198233Snate@binkert.orgdef SwigSource(package, source):
1208233Snate@binkert.org    '''Add a swig file to build'''
1218233Snate@binkert.org    if not isinstance(source, SCons.Node.FS.File):
1228233Snate@binkert.org        source = File(source)
1238233Snate@binkert.org    val = source,package
1248233Snate@binkert.org    swig_sources.append(val)
1258233Snate@binkert.org
1268233Snate@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:
1476143Snate@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
1539982Satgutier@umich.edu        if all_flags[flag]:
15410196SCurtis.Dunham@arm.com            raise AttributeError, \
15510196SCurtis.Dunham@arm.com                "Compound flag can't point to another compound flag"
15610196SCurtis.Dunham@arm.com
15710196SCurtis.Dunham@arm.com    flag = (name, compound, desc)
15810196SCurtis.Dunham@arm.com    trace_flags.append(flag)
15910196SCurtis.Dunham@arm.com    all_flags[name] = compound
16010196SCurtis.Dunham@arm.com
16110196SCurtis.Dunham@arm.comExport('TraceFlag')
1626143Snate@binkert.orgExport('CompoundFlag')
1636143Snate@binkert.org
1648945Ssteve.reinhardt@amd.com########################################################################
1658233Snate@binkert.org#
1668233Snate@binkert.org# Set some compiler variables
1676143Snate@binkert.org#
1688945Ssteve.reinhardt@amd.com
1696143Snate@binkert.org# Include file paths are rooted in this directory.  SCons will
1706143Snate@binkert.org# automatically expand '.' to refer to both the source directory and
1716143Snate@binkert.org# the corresponding build directory to pick up generated include
1726143Snate@binkert.org# files.
1735522Snate@binkert.orgenv.Append(CPPPATH=Dir('.'))
1746143Snate@binkert.org
1756143Snate@binkert.org# Add a flag defining what THE_ISA should be for all compilation
1766143Snate@binkert.orgenv.Append(CPPDEFINES=[('THE_ISA','%s_ISA' % env['TARGET_ISA'].upper())])
1779982Satgutier@umich.edu
1788233Snate@binkert.org########################################################################
1798233Snate@binkert.org#
1808233Snate@binkert.org# Walk the tree and execute all SConscripts in subdirectories
1816143Snate@binkert.org#
1826143Snate@binkert.org
1836143Snate@binkert.orgfor base_dir in base_dir_list:
1846143Snate@binkert.org    here = Dir('.').srcnode().abspath
1855522Snate@binkert.org    for root, dirs, files in os.walk(base_dir, topdown=True):
1865522Snate@binkert.org        if root == here:
1875522Snate@binkert.org            # we don't want to recurse back into this SConscript
1885522Snate@binkert.org            continue
1895604Snate@binkert.org
1905604Snate@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)
1934762Snate@binkert.org
1944762Snate@binkert.orgfor opt in env.ExportOptions:
1956143Snate@binkert.org    env.ConfigFile(opt)
1966727Ssteve.reinhardt@amd.com
1976727Ssteve.reinhardt@amd.com########################################################################
1986727Ssteve.reinhardt@amd.com#
1994762Snate@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#
2026143Snate@binkert.orgsim_objects_fixed = True
2036143Snate@binkert.org
2046727Ssteve.reinhardt@amd.com########################################################################
2056143Snate@binkert.org#
2067674Snate@binkert.org# Manually turn python/generate.py into a python module and import it
2077674Snate@binkert.org#
2085604Snate@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__
2124762Snate@binkert.org
2136143Snate@binkert.org########################################################################
2144762Snate@binkert.org#
2154762Snate@binkert.org# build a generate
2164762Snate@binkert.org#
2176143Snate@binkert.orgfrom generate import Generate
2186143Snate@binkert.orgoptionDict = dict([(opt, env[opt]) for opt in env.ExportOptions])
2194762Snate@binkert.orggenerate = Generate(py_sources, sim_object_modfiles, optionDict)
2208233Snate@binkert.orgm5 = generate.m5
2218233Snate@binkert.org
2228233Snate@binkert.org########################################################################
2238233Snate@binkert.org#
2246143Snate@binkert.org# calculate extra dependencies
2256143Snate@binkert.org#
2264762Snate@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 ]
2296143Snate@binkert.orgdepends = module_depends + file_depends
2304762Snate@binkert.org
2316143Snate@binkert.org########################################################################
2328233Snate@binkert.org#
2338233Snate@binkert.org# Commands for the basic automatically generated python files
23410453SAndrew.Bardsley@arm.com#
2356143Snate@binkert.org
2366143Snate@binkert.org# Generate a file with all of the compile options in it
2376143Snate@binkert.orgenv.Command('python/m5/defines.py', Value(optionDict),
2386143Snate@binkert.org            generate.makeDefinesPyFile)
2396143Snate@binkert.orgPySource('m5', 'python/m5/defines.py')
2406143Snate@binkert.org
2416143Snate@binkert.org# Generate a file that wraps the basic top level files
2426143Snate@binkert.orgenv.Command('python/m5/info.py',
24310453SAndrew.Bardsley@arm.com            [ '#/AUTHORS', '#/LICENSE', '#/README', '#/RELEASE_NOTES' ],
24410453SAndrew.Bardsley@arm.com            generate.makeInfoPyFile)
245955SN/APySource('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)
2519396Sandreas.hansson@arm.comPySource('m5.objects', 'python/m5/objects/__init__.py')
2529396Sandreas.hansson@arm.com
2539396Sandreas.hansson@arm.com########################################################################
2549396Sandreas.hansson@arm.com#
2559396Sandreas.hansson@arm.com# Create all of the SimObject param headers and enum headers
2569396Sandreas.hansson@arm.com#
2579396Sandreas.hansson@arm.com
2589396Sandreas.hansson@arm.com# Generate all of the SimObject param struct header files
2599930Sandreas.hansson@arm.comparams_hh_files = []
2609930Sandreas.hansson@arm.comfor name,simobj in generate.sim_objects.iteritems():
2619396Sandreas.hansson@arm.com    extra_deps = [ File(generate.py_modules[simobj.__module__]) ]
2628235Snate@binkert.org
2638235Snate@binkert.org    hh_file = File('params/%s.hh' % name)
2646143Snate@binkert.org    params_hh_files.append(hh_file)
2658235Snate@binkert.org    env.Command(hh_file, Value(name), generate.createSimObjectParam)
2669003SAli.Saidi@ARM.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):
2718235Snate@binkert.org        ext = 'vptype'
2728235Snate@binkert.org    else:
2738235Snate@binkert.org        ext = 'ptype'
2748235Snate@binkert.org
2758235Snate@binkert.org    i_file = File('params/%s_%s.i' % (name, ext))
2768235Snate@binkert.org    env.Command(i_file, Value(name), generate.createSwigParam)
2778235Snate@binkert.org    env.Depends(i_file, depends)
2788235Snate@binkert.org
2798235Snate@binkert.org# Generate all enum header files
2808235Snate@binkert.orgfor name,enum in generate.enums.iteritems():
2819003SAli.Saidi@ARM.com    extra_deps = [ File(generate.py_modules[enum.__module__]) ]
2828235Snate@binkert.org
2835584Snate@binkert.org    cc_file = File('enums/%s.cc' % name)
2844382Sbinkertn@umich.edu    env.Command(cc_file, Value(name), generate.createEnumStrings)
2854202Sbinkertn@umich.edu    env.Depends(cc_file, depends + extra_deps)
2864382Sbinkertn@umich.edu    Source(cc_file)
2874382Sbinkertn@umich.edu
2884382Sbinkertn@umich.edu    hh_file = File('enums/%s.hh' % name)
2899396Sandreas.hansson@arm.com    env.Command(hh_file, Value(name), generate.createEnumParam)
2905584Snate@binkert.org    env.Depends(hh_file, depends + extra_deps)
2914382Sbinkertn@umich.edu
2924382Sbinkertn@umich.edu# Build the big monolithic swigged params module (wraps all SimObject
2934382Sbinkertn@umich.edu# param structs and enum structs)
2948232Snate@binkert.orgparams_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 ],
2978232Snate@binkert.org            generate.buildParams)
2988232Snate@binkert.orgenv.Depends(params_file, params_hh_files + depends)
2995192Ssaidi@eecs.umich.eduSwigSource('m5.objects', params_file)
3008232Snate@binkert.org
3015192Ssaidi@eecs.umich.edu# Build all swig modules
3025799Snate@binkert.orgswig_modules = []
3038232Snate@binkert.orgfor source,package in swig_sources:
3045192Ssaidi@eecs.umich.edu    filename = str(source)
3055192Ssaidi@eecs.umich.edu    assert filename.endswith('.i')
3065192Ssaidi@eecs.umich.edu
3078232Snate@binkert.org    base = '.'.join(filename.split('.')[:-1])
3085192Ssaidi@eecs.umich.edu    module = basename(base)
3098232Snate@binkert.org    cc_file = base + '_wrap.cc'
3105192Ssaidi@eecs.umich.edu    py_file = base + '.py'
3115192Ssaidi@eecs.umich.edu
3125192Ssaidi@eecs.umich.edu    env.Command([cc_file, py_file], source,
3135192Ssaidi@eecs.umich.edu                '$SWIG $SWIGFLAGS -outdir ${TARGETS[1].dir} '
3144382Sbinkertn@umich.edu                '-o ${TARGETS[0]} $SOURCES')
3154382Sbinkertn@umich.edu    env.Depends(py_file, source)
3164382Sbinkertn@umich.edu    env.Depends(cc_file, source)
3172667Sstever@eecs.umich.edu
3182667Sstever@eecs.umich.edu    swig_modules.append(Value(module))
3192667Sstever@eecs.umich.edu    Source(cc_file)
3202667Sstever@eecs.umich.edu    PySource(package, py_file)
3212667Sstever@eecs.umich.edu
3222667Sstever@eecs.umich.edu# Generate the main swig init file
3235742Snate@binkert.orgenv.Command('swig/init.cc', swig_modules, generate.makeSwigInit)
3245742Snate@binkert.orgSource('swig/init.cc')
3255742Snate@binkert.org
3265793Snate@binkert.org# Generate traceflags.py
3278334Snate@binkert.orgflags = [ Value(f) for f in trace_flags ]
3285793Snate@binkert.orgenv.Command('base/traceflags.py', flags, generate.traceFlagsPy)
3295793Snate@binkert.orgPySource('m5', 'base/traceflags.py')
3305793Snate@binkert.org
3314382Sbinkertn@umich.eduenv.Command('base/traceflags.hh', flags, generate.traceFlagsHH)
3324762Snate@binkert.orgenv.Command('base/traceflags.cc', flags, generate.traceFlagsCC)
3335344Sstever@gmail.comSource('base/traceflags.cc')
3344382Sbinkertn@umich.edu
3355341Sstever@gmail.com# Generate program_info.cc
3365742Snate@binkert.orgenv.Command('base/program_info.cc',
3375742Snate@binkert.org            Value(str(SCons.Node.FS.default_fs.SConstruct_dir)), generate.programInfo)
3385742Snate@binkert.org
3395742Snate@binkert.org# Build the zip file
3405742Snate@binkert.orgpy_compiled = []
3414762Snate@binkert.orgpy_zip_depends = []
3425742Snate@binkert.orgfor source in py_sources:
3435742Snate@binkert.org    env.Command(source.compiled, source.source, generate.compilePyFile)
3447722Sgblack@eecs.umich.edu    py_compiled.append(source.compiled)
3455742Snate@binkert.org
3465742Snate@binkert.org    # make the zipfile depend on the archive name so that the archive
3475742Snate@binkert.org    # is rebuilt if the name changes
3489930Sandreas.hansson@arm.com    py_zip_depends.append(Value(source.arcname))
3499930Sandreas.hansson@arm.com
3509930Sandreas.hansson@arm.com# Add the zip file target to the environment.
3519930Sandreas.hansson@arm.comm5zip = File('m5py.zip')
3529930Sandreas.hansson@arm.comenv.Command(m5zip, py_compiled, generate.buildPyZip)
3535742Snate@binkert.orgenv.Depends(m5zip, py_zip_depends)
3548242Sbradley.danofsky@amd.com
3558242Sbradley.danofsky@amd.com########################################################################
3568242Sbradley.danofsky@amd.com#
3578242Sbradley.danofsky@amd.com# Define binaries.  Each different build type (debug, opt, etc.) gets
3585341Sstever@gmail.com# a slightly different build environment.
3595742Snate@binkert.org#
3607722Sgblack@eecs.umich.edu
3614773Snate@binkert.org# List of constructed environments to pass back to SConstruct
3626108Snate@binkert.orgenvList = []
3631858SN/A
3641085SN/A# This function adds the specified sources to the given build
3656658Snate@binkert.org# environment, and returns a list of all the corresponding SCons
3666658Snate@binkert.org# Object nodes (including an extra one for date.cc).  We explicitly
3677673Snate@binkert.org# add the Object nodes so we can set up special dependencies for
3686658Snate@binkert.org# date.cc.
3696658Snate@binkert.orgdef make_objs(sources, env):
37011308Santhony.gutierrez@amd.com    objs = [env.Object(s) for s in sources]
3716658Snate@binkert.org  
37211308Santhony.gutierrez@amd.com    # make date.cc depend on all other objects so it always gets
3736658Snate@binkert.org    # recompiled whenever anything else does
3746658Snate@binkert.org    date_obj = env.Object('base/date.cc')
3757673Snate@binkert.org
3767673Snate@binkert.org    # Make the generation of program_info.cc dependend on all 
3777673Snate@binkert.org    # the other cc files and the compiling of program_info.cc 
3787673Snate@binkert.org    # dependent on all the objects but program_info.o 
3797673Snate@binkert.org    pinfo_obj = env.Object('base/program_info.cc')
3807673Snate@binkert.org    env.Depends('base/program_info.cc', sources)
3817673Snate@binkert.org    env.Depends(date_obj, objs)
38210467Sandreas.hansson@arm.com    env.Depends(pinfo_obj, objs)
3836658Snate@binkert.org    objs.extend([date_obj,pinfo_obj])
3847673Snate@binkert.org    return objs
38510467Sandreas.hansson@arm.com
38610467Sandreas.hansson@arm.com# Function to create a new build environment as clone of current
38710467Sandreas.hansson@arm.com# environment 'env' with modified object suffix and optional stripped
38810467Sandreas.hansson@arm.com# binary.  Additional keyword arguments are appended to corresponding
38910467Sandreas.hansson@arm.com# build environment vars.
39010467Sandreas.hansson@arm.comdef makeEnv(label, objsfx, strip = False, **kwargs):
39110467Sandreas.hansson@arm.com    newEnv = env.Copy(OBJSUFFIX=objsfx)
39210467Sandreas.hansson@arm.com    newEnv.Label = label
39310467Sandreas.hansson@arm.com    newEnv.Append(**kwargs)
39410467Sandreas.hansson@arm.com    exe = 'm5.' + label  # final executable
39510467Sandreas.hansson@arm.com    bin = exe + '.bin'   # executable w/o appended Python zip archive
3967673Snate@binkert.org    newEnv.Program(bin, make_objs(cc_sources, newEnv))
3977673Snate@binkert.org    if strip:
3987673Snate@binkert.org        stripped_bin = bin + '.stripped'
3997673Snate@binkert.org        if sys.platform == 'sunos5':
4007673Snate@binkert.org            cmd = 'cp $SOURCE $TARGET; strip $TARGET'
4019048SAli.Saidi@ARM.com        else:
4027673Snate@binkert.org            cmd = 'strip $SOURCE -o $TARGET'
4037673Snate@binkert.org        newEnv.Command(stripped_bin, bin, cmd)
4047673Snate@binkert.org        bin = stripped_bin
4057673Snate@binkert.org    targets = newEnv.Concat(exe, [bin, 'm5py.zip'])
4066658Snate@binkert.org    newEnv.M5Binary = targets[0]
4077756SAli.Saidi@ARM.com    envList.append(newEnv)
4087816Ssteve.reinhardt@amd.com
4096658Snate@binkert.org# Debug binary
41011308Santhony.gutierrez@amd.comccflags = {}
41111308Santhony.gutierrez@amd.comif env['GCC']:
41211308Santhony.gutierrez@amd.com    if sys.platform == 'sunos5':
41311308Santhony.gutierrez@amd.com        ccflags['debug'] = '-gstabs+'
41411308Santhony.gutierrez@amd.com    else:
41511308Santhony.gutierrez@amd.com        ccflags['debug'] = '-ggdb3'
41611308Santhony.gutierrez@amd.com    ccflags['opt'] = '-g -O3'
41711308Santhony.gutierrez@amd.com    ccflags['fast'] = '-O3'
41811308Santhony.gutierrez@amd.com    ccflags['prof'] = '-O3 -g -pg'
41911308Santhony.gutierrez@amd.comelif env['SUNCC']:
42011308Santhony.gutierrez@amd.com    ccflags['debug'] = '-g0'
42111308Santhony.gutierrez@amd.com    ccflags['opt'] = '-g -O'
42211308Santhony.gutierrez@amd.com    ccflags['fast'] = '-fast'
42311308Santhony.gutierrez@amd.com    ccflags['prof'] = '-fast -g -pg'
42411308Santhony.gutierrez@amd.comelif env['ICC']:
42511308Santhony.gutierrez@amd.com    ccflags['debug'] = '-g -O0'
42611308Santhony.gutierrez@amd.com    ccflags['opt'] = '-g -O'
42711308Santhony.gutierrez@amd.com    ccflags['fast'] = '-fast'
42811308Santhony.gutierrez@amd.com    ccflags['prof'] = '-fast -g -pg'
42911308Santhony.gutierrez@amd.comelse:
43011308Santhony.gutierrez@amd.com    print 'Unknown compiler, please fix compiler options'
43111308Santhony.gutierrez@amd.com    Exit(1)
43211308Santhony.gutierrez@amd.com
43311308Santhony.gutierrez@amd.commakeEnv('debug', '.do',
43411308Santhony.gutierrez@amd.com        CCFLAGS = Split(ccflags['debug']),
43511308Santhony.gutierrez@amd.com        CPPDEFINES = ['DEBUG', 'TRACING_ON=1'])
43611308Santhony.gutierrez@amd.com
43711308Santhony.gutierrez@amd.com# Optimized binary
43811308Santhony.gutierrez@amd.commakeEnv('opt', '.o',
43911308Santhony.gutierrez@amd.com        CCFLAGS = Split(ccflags['opt']),
44011308Santhony.gutierrez@amd.com        CPPDEFINES = ['TRACING_ON=1'])
44111308Santhony.gutierrez@amd.com
44211308Santhony.gutierrez@amd.com# "Fast" binary
44311308Santhony.gutierrez@amd.commakeEnv('fast', '.fo', strip = True,
44411308Santhony.gutierrez@amd.com        CCFLAGS = Split(ccflags['fast']),
44511308Santhony.gutierrez@amd.com        CPPDEFINES = ['NDEBUG', 'TRACING_ON=0'])
44611308Santhony.gutierrez@amd.com
44711308Santhony.gutierrez@amd.com# Profiled binary
44811308Santhony.gutierrez@amd.commakeEnv('prof', '.po',
44911308Santhony.gutierrez@amd.com        CCFLAGS = Split(ccflags['prof']),
45011308Santhony.gutierrez@amd.com        CPPDEFINES = ['NDEBUG', 'TRACING_ON=0'],
45111308Santhony.gutierrez@amd.com        LINKFLAGS = '-pg')
45211308Santhony.gutierrez@amd.com
45311308Santhony.gutierrez@amd.comReturn('envList')
45411308Santhony.gutierrez@amd.com