SConscript revision 5228
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 314762Snate@binkert.orgimport imp 32955SN/Aimport os 33955SN/Aimport sys 344202Sbinkertn@umich.edu 354382Sbinkertn@umich.edufrom os.path import basename 364202Sbinkertn@umich.edufrom os.path import join as joinpath 374762Snate@binkert.orgfrom os.path import exists 384762Snate@binkert.orgfrom os.path import isdir 394762Snate@binkert.orgfrom os.path import isfile 40955SN/A 414381Sbinkertn@umich.eduimport SCons 424381Sbinkertn@umich.edu 43955SN/A# This file defines how to build a particular configuration of M5 44955SN/A# based on variable settings in the 'env' build environment. 45955SN/A 464202Sbinkertn@umich.eduImport('*') 47955SN/A 484382Sbinkertn@umich.edu# Children need to see the environment 494382Sbinkertn@umich.eduExport('env') 504382Sbinkertn@umich.edu 514762Snate@binkert.orgdef sort_list(_list): 524762Snate@binkert.org """return a sorted copy of '_list'""" 534762Snate@binkert.org if isinstance(_list, list): 544762Snate@binkert.org _list = _list[:] 554762Snate@binkert.org else: 564762Snate@binkert.org _list = list(_list) 574762Snate@binkert.org _list.sort() 584762Snate@binkert.org return _list 594762Snate@binkert.org 604762Snate@binkert.orgclass PySourceFile(object): 614762Snate@binkert.org def __init__(self, package, source): 624762Snate@binkert.org filename = str(source) 634762Snate@binkert.org pyname = basename(filename) 644762Snate@binkert.org assert pyname.endswith('.py') 654762Snate@binkert.org name = pyname[:-3] 664762Snate@binkert.org path = package.split('.') 674762Snate@binkert.org modpath = path 684762Snate@binkert.org if name != '__init__': 694762Snate@binkert.org modpath += [name] 704762Snate@binkert.org modpath = '.'.join(modpath) 714762Snate@binkert.org 724762Snate@binkert.org arcpath = package.split('.') + [ pyname + 'c' ] 734762Snate@binkert.org arcname = joinpath(*arcpath) 744762Snate@binkert.org 754762Snate@binkert.org self.source = source 764762Snate@binkert.org self.pyname = pyname 774762Snate@binkert.org self.srcpath = source.srcnode().abspath 784762Snate@binkert.org self.package = package 794762Snate@binkert.org self.modpath = modpath 804762Snate@binkert.org self.arcname = arcname 814762Snate@binkert.org self.filename = filename 824762Snate@binkert.org self.compiled = File(filename + 'c') 834762Snate@binkert.org 844382Sbinkertn@umich.edu######################################################################## 854762Snate@binkert.org# Code for adding source files of various types 864382Sbinkertn@umich.edu# 874762Snate@binkert.orgcc_sources = [] 884381Sbinkertn@umich.edudef Source(source): 894762Snate@binkert.org '''Add a C/C++ source file to the build''' 904762Snate@binkert.org if not isinstance(source, SCons.Node.FS.File): 914762Snate@binkert.org source = File(source) 924762Snate@binkert.org 934762Snate@binkert.org cc_sources.append(source) 944762Snate@binkert.org 954762Snate@binkert.orgpy_sources = [] 964762Snate@binkert.orgdef PySource(package, source): 974762Snate@binkert.org '''Add a python source file to the named package''' 984762Snate@binkert.org if not isinstance(source, SCons.Node.FS.File): 994762Snate@binkert.org source = File(source) 1004762Snate@binkert.org 1014762Snate@binkert.org source = PySourceFile(package, source) 1024762Snate@binkert.org py_sources.append(source) 1034762Snate@binkert.org 1044762Snate@binkert.orgsim_objects_fixed = False 1054762Snate@binkert.orgsim_object_modfiles = set() 1064762Snate@binkert.orgdef SimObject(source): 1074762Snate@binkert.org '''Add a SimObject python file as a python source object and add 1084762Snate@binkert.org it to a list of sim object modules''' 1094762Snate@binkert.org 1104762Snate@binkert.org if sim_objects_fixed: 1114762Snate@binkert.org raise AttributeError, "Too late to call SimObject now." 1124762Snate@binkert.org 1134762Snate@binkert.org if not isinstance(source, SCons.Node.FS.File): 1144762Snate@binkert.org source = File(source) 1154762Snate@binkert.org 1164762Snate@binkert.org PySource('m5.objects', source) 1174762Snate@binkert.org modfile = basename(str(source)) 1184762Snate@binkert.org assert modfile.endswith('.py') 1194762Snate@binkert.org modname = modfile[:-3] 1204762Snate@binkert.org sim_object_modfiles.add(modname) 1214762Snate@binkert.org 1224762Snate@binkert.orgswig_sources = [] 1234762Snate@binkert.orgdef SwigSource(package, source): 1244762Snate@binkert.org '''Add a swig file to build''' 1254762Snate@binkert.org if not isinstance(source, SCons.Node.FS.File): 1264762Snate@binkert.org source = File(source) 1274762Snate@binkert.org val = source,package 1284762Snate@binkert.org swig_sources.append(val) 129955SN/A 1304382Sbinkertn@umich.edu# Children should have access 1314202Sbinkertn@umich.eduExport('Source') 1324382Sbinkertn@umich.eduExport('PySource') 1334382Sbinkertn@umich.eduExport('SimObject') 1344382Sbinkertn@umich.eduExport('SwigSource') 1354382Sbinkertn@umich.edu 1364382Sbinkertn@umich.edu######################################################################## 1374382Sbinkertn@umich.edu# 1385192Ssaidi@eecs.umich.edu# Trace Flags 1395192Ssaidi@eecs.umich.edu# 1405192Ssaidi@eecs.umich.eduall_flags = {} 1415192Ssaidi@eecs.umich.edutrace_flags = [] 1425192Ssaidi@eecs.umich.edudef TraceFlag(name, desc=''): 1435192Ssaidi@eecs.umich.edu if name in all_flags: 1445192Ssaidi@eecs.umich.edu raise AttributeError, "Flag %s already specified" % name 1455192Ssaidi@eecs.umich.edu flag = (name, (), desc) 1465192Ssaidi@eecs.umich.edu trace_flags.append(flag) 1475192Ssaidi@eecs.umich.edu all_flags[name] = () 1485192Ssaidi@eecs.umich.edu 1495192Ssaidi@eecs.umich.edudef CompoundFlag(name, flags, desc=''): 1505192Ssaidi@eecs.umich.edu if name in all_flags: 1515192Ssaidi@eecs.umich.edu raise AttributeError, "Flag %s already specified" % name 1525192Ssaidi@eecs.umich.edu 1535192Ssaidi@eecs.umich.edu compound = tuple(flags) 1545192Ssaidi@eecs.umich.edu for flag in compound: 1555192Ssaidi@eecs.umich.edu if flag not in all_flags: 1565192Ssaidi@eecs.umich.edu raise AttributeError, "Trace flag %s not found" % flag 1575192Ssaidi@eecs.umich.edu if all_flags[flag]: 1585192Ssaidi@eecs.umich.edu raise AttributeError, \ 1595192Ssaidi@eecs.umich.edu "Compound flag can't point to another compound flag" 1605192Ssaidi@eecs.umich.edu 1615192Ssaidi@eecs.umich.edu flag = (name, compound, desc) 1625192Ssaidi@eecs.umich.edu trace_flags.append(flag) 1635192Ssaidi@eecs.umich.edu all_flags[name] = compound 1645192Ssaidi@eecs.umich.edu 1655192Ssaidi@eecs.umich.eduExport('TraceFlag') 1665192Ssaidi@eecs.umich.eduExport('CompoundFlag') 1675192Ssaidi@eecs.umich.edu 1685192Ssaidi@eecs.umich.edu######################################################################## 1695192Ssaidi@eecs.umich.edu# 1704382Sbinkertn@umich.edu# Set some compiler variables 1714382Sbinkertn@umich.edu# 1724382Sbinkertn@umich.edu 1732667Sstever@eecs.umich.edu# Include file paths are rooted in this directory. SCons will 1742667Sstever@eecs.umich.edu# automatically expand '.' to refer to both the source directory and 1752667Sstever@eecs.umich.edu# the corresponding build directory to pick up generated include 1762667Sstever@eecs.umich.edu# files. 1772667Sstever@eecs.umich.eduenv.Append(CPPPATH=Dir('.')) 1782667Sstever@eecs.umich.edu 1792037SN/A# Add a flag defining what THE_ISA should be for all compilation 1802037SN/Aenv.Append(CPPDEFINES=[('THE_ISA','%s_ISA' % env['TARGET_ISA'].upper())]) 1812037SN/A 1824382Sbinkertn@umich.edu######################################################################## 1834762Snate@binkert.org# 1844202Sbinkertn@umich.edu# Walk the tree and execute all SConscripts 1854382Sbinkertn@umich.edu# 1864202Sbinkertn@umich.edusrcdir = env['SRCDIR'] 1874202Sbinkertn@umich.edufor root, dirs, files in os.walk(srcdir, topdown=True): 1884202Sbinkertn@umich.edu if root == srcdir: 1894202Sbinkertn@umich.edu # we don't want to recurse back into this SConscript 1904202Sbinkertn@umich.edu continue 1914762Snate@binkert.org 1924202Sbinkertn@umich.edu if 'SConscript' in files: 1934202Sbinkertn@umich.edu # strip off the srcdir part since scons will try to find the 1944202Sbinkertn@umich.edu # script in the build directory 1954202Sbinkertn@umich.edu base = root[len(srcdir) + 1:] 1964202Sbinkertn@umich.edu SConscript(joinpath(base, 'SConscript')) 1971858SN/A 1985068Sgblack@eecs.umich.eduextra_string = env['EXTRAS'] 1995068Sgblack@eecs.umich.eduif extra_string and extra_string != '' and not extra_string.isspace(): 2005068Sgblack@eecs.umich.edu for extra in extra_string.split(':'): 2015068Sgblack@eecs.umich.edu extra = os.path.expanduser(extra) 2025068Sgblack@eecs.umich.edu extra = os.path.normpath(extra) 2035068Sgblack@eecs.umich.edu env.Append(CPPPATH=[Dir(extra)]) 2045068Sgblack@eecs.umich.edu for root, dirs, files in os.walk(extra, topdown=True): 2055068Sgblack@eecs.umich.edu if 'SConscript' in files: 2065068Sgblack@eecs.umich.edu subdir = root[len(os.path.dirname(extra))+1:] 2075068Sgblack@eecs.umich.edu build_dir = joinpath(env['BUILDDIR'], subdir) 2085068Sgblack@eecs.umich.edu SConscript(joinpath(root, 'SConscript'), build_dir=build_dir) 2094773Snate@binkert.org 2101858SN/Afor opt in env.ExportOptions: 2111858SN/A env.ConfigFile(opt) 2121085SN/A 2134382Sbinkertn@umich.edu######################################################################## 2144382Sbinkertn@umich.edu# 2154762Snate@binkert.org# Prevent any SimObjects from being added after this point, they 2164762Snate@binkert.org# should all have been added in the SConscripts above 2174762Snate@binkert.org# 2184762Snate@binkert.orgsim_objects_fixed = True 2194762Snate@binkert.org 2204762Snate@binkert.org######################################################################## 2214762Snate@binkert.org# 2224762Snate@binkert.org# Manually turn python/generate.py into a python module and import it 2234762Snate@binkert.org# 2244762Snate@binkert.orggenerate_file = File('python/generate.py') 2254762Snate@binkert.orggenerate_module = imp.new_module('generate') 2264762Snate@binkert.orgsys.modules['generate'] = generate_module 2274762Snate@binkert.orgexec file(generate_file.srcnode().abspath, 'r') in generate_module.__dict__ 2284762Snate@binkert.org 2294762Snate@binkert.org######################################################################## 2304762Snate@binkert.org# 2314762Snate@binkert.org# build a generate 2324762Snate@binkert.org# 2334762Snate@binkert.orgfrom generate import Generate 2344762Snate@binkert.orgoptionDict = dict([(opt, env[opt]) for opt in env.ExportOptions]) 2354762Snate@binkert.orggenerate = Generate(py_sources, sim_object_modfiles, optionDict) 2364762Snate@binkert.orgm5 = generate.m5 2374762Snate@binkert.org 2384762Snate@binkert.org######################################################################## 2394762Snate@binkert.org# 2404762Snate@binkert.org# calculate extra dependencies 2414762Snate@binkert.org# 2424762Snate@binkert.orgmodule_depends = ["m5", "m5.SimObject", "m5.params"] 2434762Snate@binkert.orgmodule_depends = [ File(generate.py_modules[dep]) for dep in module_depends ] 2444762Snate@binkert.orgfile_depends = [ generate_file ] 2454762Snate@binkert.orgdepends = module_depends + file_depends 2464762Snate@binkert.org 2474762Snate@binkert.org######################################################################## 2484762Snate@binkert.org# 2494762Snate@binkert.org# Commands for the basic automatically generated python files 2504382Sbinkertn@umich.edu# 2514382Sbinkertn@umich.edu 2524762Snate@binkert.org# Generate a file with all of the compile options in it 2534762Snate@binkert.orgenv.Command('python/m5/defines.py', Value(optionDict), 2544762Snate@binkert.org generate.makeDefinesPyFile) 2554382Sbinkertn@umich.eduPySource('m5', 'python/m5/defines.py') 2564382Sbinkertn@umich.edu 2574762Snate@binkert.org# Generate a file that wraps the basic top level files 2584382Sbinkertn@umich.eduenv.Command('python/m5/info.py', 2594382Sbinkertn@umich.edu [ '#/AUTHORS', '#/LICENSE', '#/README', '#/RELEASE_NOTES' ], 2604762Snate@binkert.org generate.makeInfoPyFile) 2614382Sbinkertn@umich.eduPySource('m5', 'python/m5/info.py') 2624382Sbinkertn@umich.edu 2634762Snate@binkert.org# Generate an __init__.py file for the objects package 2644382Sbinkertn@umich.eduenv.Command('python/m5/objects/__init__.py', 2654762Snate@binkert.org [ Value(o) for o in sort_list(sim_object_modfiles) ], 2664762Snate@binkert.org generate.makeObjectsInitFile) 2674382Sbinkertn@umich.eduPySource('m5.objects', 'python/m5/objects/__init__.py') 2684382Sbinkertn@umich.edu 2694762Snate@binkert.org######################################################################## 2704762Snate@binkert.org# 2714762Snate@binkert.org# Create all of the SimObject param headers and enum headers 2724762Snate@binkert.org# 2734762Snate@binkert.org 2744762Snate@binkert.org# Generate all of the SimObject param struct header files 2754762Snate@binkert.orgparams_hh_files = [] 2764762Snate@binkert.orgfor name,simobj in generate.sim_objects.iteritems(): 2774762Snate@binkert.org extra_deps = [ File(generate.py_modules[simobj.__module__]) ] 2784762Snate@binkert.org 2794762Snate@binkert.org hh_file = File('params/%s.hh' % name) 2804762Snate@binkert.org params_hh_files.append(hh_file) 2814762Snate@binkert.org env.Command(hh_file, Value(name), generate.createSimObjectParam) 2824762Snate@binkert.org env.Depends(hh_file, depends + extra_deps) 2834762Snate@binkert.org 2844762Snate@binkert.org# Generate any parameter header files needed 2854762Snate@binkert.orgfor name,param in generate.params.iteritems(): 2864762Snate@binkert.org if isinstance(param, m5.params.VectorParamDesc): 2874762Snate@binkert.org ext = 'vptype' 2884762Snate@binkert.org else: 2894762Snate@binkert.org ext = 'ptype' 2904762Snate@binkert.org 2914762Snate@binkert.org i_file = File('params/%s_%s.i' % (name, ext)) 2924762Snate@binkert.org env.Command(i_file, Value(name), generate.createSwigParam) 2934762Snate@binkert.org env.Depends(i_file, depends) 2944762Snate@binkert.org 2954762Snate@binkert.org# Generate all enum header files 2964762Snate@binkert.orgfor name,enum in generate.enums.iteritems(): 2974762Snate@binkert.org extra_deps = [ File(generate.py_modules[enum.__module__]) ] 2984762Snate@binkert.org 2994762Snate@binkert.org cc_file = File('enums/%s.cc' % name) 3004762Snate@binkert.org env.Command(cc_file, Value(name), generate.createEnumStrings) 3014762Snate@binkert.org env.Depends(cc_file, depends + extra_deps) 3024762Snate@binkert.org Source(cc_file) 3034762Snate@binkert.org 3044762Snate@binkert.org hh_file = File('enums/%s.hh' % name) 3054762Snate@binkert.org env.Command(hh_file, Value(name), generate.createEnumParam) 3064762Snate@binkert.org env.Depends(hh_file, depends + extra_deps) 3074762Snate@binkert.org 3084762Snate@binkert.org# Build the big monolithic swigged params module (wraps all SimObject 3094762Snate@binkert.org# param structs and enum structs) 3104762Snate@binkert.orgparams_file = File('params/params.i') 3114762Snate@binkert.orgnames = sort_list(generate.sim_objects.keys()) 3124762Snate@binkert.orgenv.Command(params_file, [ Value(v) for v in names ], 3134762Snate@binkert.org generate.buildParams) 3144762Snate@binkert.orgenv.Depends(params_file, params_hh_files + depends) 3154762Snate@binkert.orgSwigSource('m5.objects', params_file) 3164762Snate@binkert.org 3174762Snate@binkert.org# Build all swig modules 3184382Sbinkertn@umich.eduswig_modules = [] 3194762Snate@binkert.orgfor source,package in swig_sources: 3204382Sbinkertn@umich.edu filename = str(source) 3214762Snate@binkert.org assert filename.endswith('.i') 3224382Sbinkertn@umich.edu 3234762Snate@binkert.org base = '.'.join(filename.split('.')[:-1]) 3244762Snate@binkert.org module = basename(base) 3254762Snate@binkert.org cc_file = base + '_wrap.cc' 3264762Snate@binkert.org py_file = base + '.py' 3274382Sbinkertn@umich.edu 3284382Sbinkertn@umich.edu env.Command([cc_file, py_file], source, 3294382Sbinkertn@umich.edu '$SWIG $SWIGFLAGS -outdir ${TARGETS[1].dir} ' 3304382Sbinkertn@umich.edu '-o ${TARGETS[0]} $SOURCES') 3314382Sbinkertn@umich.edu env.Depends(py_file, source) 3324382Sbinkertn@umich.edu env.Depends(cc_file, source) 3334762Snate@binkert.org 3344382Sbinkertn@umich.edu swig_modules.append(Value(module)) 3354382Sbinkertn@umich.edu Source(cc_file) 3364382Sbinkertn@umich.edu PySource(package, py_file) 3374382Sbinkertn@umich.edu 3384762Snate@binkert.org# Generate the main swig init file 3394762Snate@binkert.orgenv.Command('swig/init.cc', swig_modules, generate.makeSwigInit) 3404762Snate@binkert.orgSource('swig/init.cc') 3414382Sbinkertn@umich.edu 3425192Ssaidi@eecs.umich.edu# Generate traceflags.py 3435192Ssaidi@eecs.umich.eduflags = [ Value(f) for f in trace_flags ] 3445192Ssaidi@eecs.umich.eduenv.Command('base/traceflags.py', flags, generate.traceFlagsPy) 3455192Ssaidi@eecs.umich.eduPySource('m5', 'base/traceflags.py') 3465192Ssaidi@eecs.umich.edu 3475192Ssaidi@eecs.umich.eduenv.Command('base/traceflags.hh', flags, generate.traceFlagsHH) 3485192Ssaidi@eecs.umich.eduenv.Command('base/traceflags.cc', flags, generate.traceFlagsCC) 3495192Ssaidi@eecs.umich.eduSource('base/traceflags.cc') 3505192Ssaidi@eecs.umich.edu 3514762Snate@binkert.org# Build the zip file 3524382Sbinkertn@umich.edupy_compiled = [] 3534382Sbinkertn@umich.edupy_zip_depends = [] 3544382Sbinkertn@umich.edufor source in py_sources: 3554762Snate@binkert.org env.Command(source.compiled, source.source, generate.compilePyFile) 3564762Snate@binkert.org py_compiled.append(source.compiled) 3574382Sbinkertn@umich.edu 3584382Sbinkertn@umich.edu # make the zipfile depend on the archive name so that the archive 3594382Sbinkertn@umich.edu # is rebuilt if the name changes 3604762Snate@binkert.org py_zip_depends.append(Value(source.arcname)) 3614382Sbinkertn@umich.edu 3624382Sbinkertn@umich.edu# Add the zip file target to the environment. 3634762Snate@binkert.orgm5zip = File('m5py.zip') 3644762Snate@binkert.orgenv.Command(m5zip, py_compiled, generate.buildPyZip) 3654762Snate@binkert.orgenv.Depends(m5zip, py_zip_depends) 3664382Sbinkertn@umich.edu 3674382Sbinkertn@umich.edu######################################################################## 3684382Sbinkertn@umich.edu# 3694382Sbinkertn@umich.edu# Define binaries. Each different build type (debug, opt, etc.) gets 3704382Sbinkertn@umich.edu# a slightly different build environment. 3714382Sbinkertn@umich.edu# 3724382Sbinkertn@umich.edu 3734382Sbinkertn@umich.edu# List of constructed environments to pass back to SConstruct 3744382Sbinkertn@umich.eduenvList = [] 3754382Sbinkertn@umich.edu 376955SN/A# This function adds the specified sources to the given build 377955SN/A# environment, and returns a list of all the corresponding SCons 378955SN/A# Object nodes (including an extra one for date.cc). We explicitly 379955SN/A# add the Object nodes so we can set up special dependencies for 3801108SN/A# date.cc. 381955SN/Adef make_objs(sources, env): 382955SN/A objs = [env.Object(s) for s in sources] 383955SN/A # make date.cc depend on all other objects so it always gets 384955SN/A # recompiled whenever anything else does 385955SN/A date_obj = env.Object('base/date.cc') 386955SN/A env.Depends(date_obj, objs) 387955SN/A objs.append(date_obj) 388955SN/A return objs 389955SN/A 3902655Sstever@eecs.umich.edu# Function to create a new build environment as clone of current 3912655Sstever@eecs.umich.edu# environment 'env' with modified object suffix and optional stripped 3922655Sstever@eecs.umich.edu# binary. Additional keyword arguments are appended to corresponding 3932655Sstever@eecs.umich.edu# build environment vars. 3942655Sstever@eecs.umich.edudef makeEnv(label, objsfx, strip = False, **kwargs): 3952655Sstever@eecs.umich.edu newEnv = env.Copy(OBJSUFFIX=objsfx) 3962655Sstever@eecs.umich.edu newEnv.Label = label 3972655Sstever@eecs.umich.edu newEnv.Append(**kwargs) 3982655Sstever@eecs.umich.edu exe = 'm5.' + label # final executable 3992655Sstever@eecs.umich.edu bin = exe + '.bin' # executable w/o appended Python zip archive 4004762Snate@binkert.org newEnv.Program(bin, make_objs(cc_sources, newEnv)) 4012655Sstever@eecs.umich.edu if strip: 4022655Sstever@eecs.umich.edu stripped_bin = bin + '.stripped' 4034007Ssaidi@eecs.umich.edu if sys.platform == 'sunos5': 4044596Sbinkertn@umich.edu cmd = 'cp $SOURCE $TARGET; strip $TARGET' 4054007Ssaidi@eecs.umich.edu else: 4064596Sbinkertn@umich.edu cmd = 'strip $SOURCE -o $TARGET' 4074596Sbinkertn@umich.edu newEnv.Command(stripped_bin, bin, cmd) 4082655Sstever@eecs.umich.edu bin = stripped_bin 4094382Sbinkertn@umich.edu targets = newEnv.Concat(exe, [bin, 'm5py.zip']) 4102655Sstever@eecs.umich.edu newEnv.M5Binary = targets[0] 4112655Sstever@eecs.umich.edu envList.append(newEnv) 4122655Sstever@eecs.umich.edu 413955SN/A# Debug binary 4143918Ssaidi@eecs.umich.educcflags = {} 4153918Ssaidi@eecs.umich.eduif env['GCC']: 4163918Ssaidi@eecs.umich.edu if sys.platform == 'sunos5': 4173918Ssaidi@eecs.umich.edu ccflags['debug'] = '-gstabs+' 4183918Ssaidi@eecs.umich.edu else: 4193918Ssaidi@eecs.umich.edu ccflags['debug'] = '-ggdb3' 4203918Ssaidi@eecs.umich.edu ccflags['opt'] = '-g -O3' 4213918Ssaidi@eecs.umich.edu ccflags['fast'] = '-O3' 4223918Ssaidi@eecs.umich.edu ccflags['prof'] = '-O3 -g -pg' 4233918Ssaidi@eecs.umich.eduelif env['SUNCC']: 4243918Ssaidi@eecs.umich.edu ccflags['debug'] = '-g0' 4253918Ssaidi@eecs.umich.edu ccflags['opt'] = '-g -O' 4263918Ssaidi@eecs.umich.edu ccflags['fast'] = '-fast' 4273918Ssaidi@eecs.umich.edu ccflags['prof'] = '-fast -g -pg' 4283940Ssaidi@eecs.umich.eduelif env['ICC']: 4293940Ssaidi@eecs.umich.edu ccflags['debug'] = '-g -O0' 4303940Ssaidi@eecs.umich.edu ccflags['opt'] = '-g -O' 4313942Ssaidi@eecs.umich.edu ccflags['fast'] = '-fast' 4323940Ssaidi@eecs.umich.edu ccflags['prof'] = '-fast -g -pg' 4333515Ssaidi@eecs.umich.eduelse: 4343918Ssaidi@eecs.umich.edu print 'Unknown compiler, please fix compiler options' 4354762Snate@binkert.org Exit(1) 4363515Ssaidi@eecs.umich.edu 4372655Sstever@eecs.umich.edumakeEnv('debug', '.do', 4383918Ssaidi@eecs.umich.edu CCFLAGS = Split(ccflags['debug']), 4393619Sbinkertn@umich.edu CPPDEFINES = ['DEBUG', 'TRACING_ON=1']) 440955SN/A 441955SN/A# Optimized binary 4422655Sstever@eecs.umich.edumakeEnv('opt', '.o', 4433918Ssaidi@eecs.umich.edu CCFLAGS = Split(ccflags['opt']), 4443619Sbinkertn@umich.edu CPPDEFINES = ['TRACING_ON=1']) 445955SN/A 446955SN/A# "Fast" binary 4472655Sstever@eecs.umich.edumakeEnv('fast', '.fo', strip = True, 4483918Ssaidi@eecs.umich.edu CCFLAGS = Split(ccflags['fast']), 4493619Sbinkertn@umich.edu CPPDEFINES = ['NDEBUG', 'TRACING_ON=0']) 450955SN/A 451955SN/A# Profiled binary 4522655Sstever@eecs.umich.edumakeEnv('prof', '.po', 4533918Ssaidi@eecs.umich.edu CCFLAGS = Split(ccflags['prof']), 4543683Sstever@eecs.umich.edu CPPDEFINES = ['NDEBUG', 'TRACING_ON=0'], 4552655Sstever@eecs.umich.edu LINKFLAGS = '-pg') 4561869SN/A 4571869SN/AReturn('envList') 458