SConscript revision 5344
1955SN/A# -*- mode:python -*- 2955SN/A 310841Sandreas.sandberg@arm.com# Copyright (c) 2004-2005 The Regents of The University of Michigan 49812Sandreas.hansson@arm.com# All rights reserved. 59812Sandreas.hansson@arm.com# 69812Sandreas.hansson@arm.com# Redistribution and use in source and binary forms, with or without 79812Sandreas.hansson@arm.com# modification, are permitted provided that the following conditions are 89812Sandreas.hansson@arm.com# met: redistributions of source code must retain the above copyright 99812Sandreas.hansson@arm.com# notice, this list of conditions and the following disclaimer; 109812Sandreas.hansson@arm.com# redistributions in binary form must reproduce the above copyright 119812Sandreas.hansson@arm.com# notice, this list of conditions and the following disclaimer in the 129812Sandreas.hansson@arm.com# documentation and/or other materials provided with the distribution; 139812Sandreas.hansson@arm.com# neither the name of the copyright holders nor the names of its 149812Sandreas.hansson@arm.com# contributors may be used to endorse or promote products derived from 157816Ssteve.reinhardt@amd.com# this software without specific prior written permission. 165871Snate@binkert.org# 171762SN/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. 28955SN/A# 29955SN/A# Authors: Nathan Binkert 30955SN/A 31955SN/Aimport imp 32955SN/Aimport os 33955SN/Aimport sys 34955SN/A 35955SN/Afrom os.path import basename, exists, isdir, isfile, join as joinpath 36955SN/A 37955SN/Aimport SCons 38955SN/A 39955SN/A# This file defines how to build a particular configuration of M5 40955SN/A# based on variable settings in the 'env' build environment. 41955SN/A 422665Ssaidi@eecs.umich.eduImport('*') 432665Ssaidi@eecs.umich.edu 445863Snate@binkert.org# Children need to see the environment 45955SN/AExport('env') 46955SN/A 47955SN/Adef sort_list(_list): 48955SN/A """return a sorted copy of '_list'""" 49955SN/A if isinstance(_list, list): 508878Ssteve.reinhardt@amd.com _list = _list[:] 512632Sstever@eecs.umich.edu else: 528878Ssteve.reinhardt@amd.com _list = list(_list) 532632Sstever@eecs.umich.edu _list.sort() 54955SN/A return _list 558878Ssteve.reinhardt@amd.com 562632Sstever@eecs.umich.educlass PySourceFile(object): 572761Sstever@eecs.umich.edu def __init__(self, package, source): 582632Sstever@eecs.umich.edu filename = str(source) 592632Sstever@eecs.umich.edu pyname = basename(filename) 602632Sstever@eecs.umich.edu assert pyname.endswith('.py') 612761Sstever@eecs.umich.edu name = pyname[:-3] 622761Sstever@eecs.umich.edu path = package.split('.') 632761Sstever@eecs.umich.edu modpath = path 648878Ssteve.reinhardt@amd.com if name != '__init__': 658878Ssteve.reinhardt@amd.com modpath += [name] 662761Sstever@eecs.umich.edu modpath = '.'.join(modpath) 672761Sstever@eecs.umich.edu 682761Sstever@eecs.umich.edu arcpath = package.split('.') + [ pyname + 'c' ] 692761Sstever@eecs.umich.edu arcname = joinpath(*arcpath) 702761Sstever@eecs.umich.edu 718878Ssteve.reinhardt@amd.com self.source = source 728878Ssteve.reinhardt@amd.com self.pyname = pyname 732632Sstever@eecs.umich.edu self.srcpath = source.srcnode().abspath 742632Sstever@eecs.umich.edu self.package = package 758878Ssteve.reinhardt@amd.com self.modpath = modpath 768878Ssteve.reinhardt@amd.com self.arcname = arcname 772632Sstever@eecs.umich.edu self.filename = filename 78955SN/A self.compiled = File(filename + 'c') 79955SN/A 80955SN/A######################################################################## 815863Snate@binkert.org# Code for adding source files of various types 825863Snate@binkert.org# 835863Snate@binkert.orgcc_sources = [] 845863Snate@binkert.orgdef Source(source): 855863Snate@binkert.org '''Add a C/C++ source file to the build''' 865863Snate@binkert.org if not isinstance(source, SCons.Node.FS.File): 875863Snate@binkert.org source = File(source) 885863Snate@binkert.org 895863Snate@binkert.org cc_sources.append(source) 905863Snate@binkert.org 915863Snate@binkert.orgpy_sources = [] 928878Ssteve.reinhardt@amd.comdef PySource(package, source): 935863Snate@binkert.org '''Add a python source file to the named package''' 945863Snate@binkert.org if not isinstance(source, SCons.Node.FS.File): 955863Snate@binkert.org source = File(source) 969812Sandreas.hansson@arm.com 979812Sandreas.hansson@arm.com source = PySourceFile(package, source) 985863Snate@binkert.org py_sources.append(source) 999812Sandreas.hansson@arm.com 1005863Snate@binkert.orgsim_objects_fixed = False 1015863Snate@binkert.orgsim_object_modfiles = set() 1025863Snate@binkert.orgdef SimObject(source): 1039812Sandreas.hansson@arm.com '''Add a SimObject python file as a python source object and add 1049812Sandreas.hansson@arm.com it to a list of sim object modules''' 1055863Snate@binkert.org 1065863Snate@binkert.org if sim_objects_fixed: 1078878Ssteve.reinhardt@amd.com raise AttributeError, "Too late to call SimObject now." 1085863Snate@binkert.org 1095863Snate@binkert.org if not isinstance(source, SCons.Node.FS.File): 1105863Snate@binkert.org source = File(source) 1116654Snate@binkert.org 11210196SCurtis.Dunham@arm.com PySource('m5.objects', source) 113955SN/A modfile = basename(str(source)) 1145396Ssaidi@eecs.umich.edu assert modfile.endswith('.py') 11511401Sandreas.sandberg@arm.com modname = modfile[:-3] 1165863Snate@binkert.org sim_object_modfiles.add(modname) 1175863Snate@binkert.org 1184202Sbinkertn@umich.eduswig_sources = [] 1195863Snate@binkert.orgdef SwigSource(package, source): 1205863Snate@binkert.org '''Add a swig file to build''' 1215863Snate@binkert.org if not isinstance(source, SCons.Node.FS.File): 1225863Snate@binkert.org source = File(source) 123955SN/A val = source,package 1246654Snate@binkert.org swig_sources.append(val) 1255273Sstever@gmail.com 1265871Snate@binkert.org# Children should have access 1275273Sstever@gmail.comExport('Source') 1286655Snate@binkert.orgExport('PySource') 1298878Ssteve.reinhardt@amd.comExport('SimObject') 1306655Snate@binkert.orgExport('SwigSource') 1316655Snate@binkert.org 1329219Spower.jg@gmail.com######################################################################## 1336655Snate@binkert.org# 1345871Snate@binkert.org# Trace Flags 1356654Snate@binkert.org# 1368947Sandreas.hansson@arm.comall_flags = {} 1375396Ssaidi@eecs.umich.edutrace_flags = [] 1388120Sgblack@eecs.umich.edudef TraceFlag(name, desc=''): 1398120Sgblack@eecs.umich.edu if name in all_flags: 1408120Sgblack@eecs.umich.edu raise AttributeError, "Flag %s already specified" % name 1418120Sgblack@eecs.umich.edu flag = (name, (), desc) 1428120Sgblack@eecs.umich.edu trace_flags.append(flag) 1438120Sgblack@eecs.umich.edu all_flags[name] = () 1448120Sgblack@eecs.umich.edu 1458120Sgblack@eecs.umich.edudef CompoundFlag(name, flags, desc=''): 1468879Ssteve.reinhardt@amd.com if name in all_flags: 1478879Ssteve.reinhardt@amd.com raise AttributeError, "Flag %s already specified" % name 1488879Ssteve.reinhardt@amd.com 1498879Ssteve.reinhardt@amd.com compound = tuple(flags) 1508879Ssteve.reinhardt@amd.com for flag in compound: 1518879Ssteve.reinhardt@amd.com if flag not in all_flags: 1528879Ssteve.reinhardt@amd.com raise AttributeError, "Trace flag %s not found" % flag 1538879Ssteve.reinhardt@amd.com if all_flags[flag]: 1548879Ssteve.reinhardt@amd.com raise AttributeError, \ 1558879Ssteve.reinhardt@amd.com "Compound flag can't point to another compound flag" 1568879Ssteve.reinhardt@amd.com 1578879Ssteve.reinhardt@amd.com flag = (name, compound, desc) 1588879Ssteve.reinhardt@amd.com trace_flags.append(flag) 1598120Sgblack@eecs.umich.edu all_flags[name] = compound 1608120Sgblack@eecs.umich.edu 1618120Sgblack@eecs.umich.eduExport('TraceFlag') 1628120Sgblack@eecs.umich.eduExport('CompoundFlag') 1638120Sgblack@eecs.umich.edu 1648120Sgblack@eecs.umich.edu######################################################################## 1658120Sgblack@eecs.umich.edu# 1668120Sgblack@eecs.umich.edu# Set some compiler variables 1678120Sgblack@eecs.umich.edu# 1688120Sgblack@eecs.umich.edu 1698120Sgblack@eecs.umich.edu# Include file paths are rooted in this directory. SCons will 1708120Sgblack@eecs.umich.edu# automatically expand '.' to refer to both the source directory and 1718120Sgblack@eecs.umich.edu# the corresponding build directory to pick up generated include 1728120Sgblack@eecs.umich.edu# files. 1738879Ssteve.reinhardt@amd.comenv.Append(CPPPATH=Dir('.')) 1748879Ssteve.reinhardt@amd.com 1758879Ssteve.reinhardt@amd.com# Add a flag defining what THE_ISA should be for all compilation 1768879Ssteve.reinhardt@amd.comenv.Append(CPPDEFINES=[('THE_ISA','%s_ISA' % env['TARGET_ISA'].upper())]) 17710458Sandreas.hansson@arm.com 17810458Sandreas.hansson@arm.com######################################################################## 17910458Sandreas.hansson@arm.com# 1808879Ssteve.reinhardt@amd.com# Walk the tree and execute all SConscripts in subdirectories 1818879Ssteve.reinhardt@amd.com# 1828879Ssteve.reinhardt@amd.com 1838879Ssteve.reinhardt@amd.comfor base_dir in base_dir_list: 1849227Sandreas.hansson@arm.com here = Dir('.').srcnode().abspath 1859227Sandreas.hansson@arm.com for root, dirs, files in os.walk(base_dir, topdown=True): 1868879Ssteve.reinhardt@amd.com if root == here: 1878879Ssteve.reinhardt@amd.com # we don't want to recurse back into this SConscript 1888879Ssteve.reinhardt@amd.com continue 1898879Ssteve.reinhardt@amd.com 19010453SAndrew.Bardsley@arm.com if 'SConscript' in files: 19110453SAndrew.Bardsley@arm.com build_dir = joinpath(env['BUILDDIR'], root[len(base_dir) + 1:]) 19210453SAndrew.Bardsley@arm.com SConscript(joinpath(root, 'SConscript'), build_dir=build_dir) 19310456SCurtis.Dunham@arm.com 19410456SCurtis.Dunham@arm.comfor opt in env.ExportOptions: 19510456SCurtis.Dunham@arm.com env.ConfigFile(opt) 19610457Sandreas.hansson@arm.com 19710457Sandreas.hansson@arm.com######################################################################## 19811342Sandreas.hansson@arm.com# 19911342Sandreas.hansson@arm.com# Prevent any SimObjects from being added after this point, they 2008120Sgblack@eecs.umich.edu# should all have been added in the SConscripts above 2018947Sandreas.hansson@arm.com# 2027816Ssteve.reinhardt@amd.comsim_objects_fixed = True 2035871Snate@binkert.org 2045871Snate@binkert.org######################################################################## 2056121Snate@binkert.org# 2065871Snate@binkert.org# Manually turn python/generate.py into a python module and import it 2075871Snate@binkert.org# 2089926Sstan.czerniawski@arm.comgenerate_file = File('python/generate.py') 2099926Sstan.czerniawski@arm.comgenerate_module = imp.new_module('generate') 2109119Sandreas.hansson@arm.comsys.modules['generate'] = generate_module 21110068Sandreas.hansson@arm.comexec file(generate_file.srcnode().abspath, 'r') in generate_module.__dict__ 21210068Sandreas.hansson@arm.com 213955SN/A######################################################################## 2149416SAndreas.Sandberg@ARM.com# 21511342Sandreas.hansson@arm.com# build a generate 21611212Sjoseph.gross@amd.com# 21711212Sjoseph.gross@amd.comfrom generate import Generate 21811212Sjoseph.gross@amd.comoptionDict = dict([(opt, env[opt]) for opt in env.ExportOptions]) 21911212Sjoseph.gross@amd.comgenerate = Generate(py_sources, sim_object_modfiles, optionDict) 22011212Sjoseph.gross@amd.comm5 = generate.m5 2219416SAndreas.Sandberg@ARM.com 2229416SAndreas.Sandberg@ARM.com######################################################################## 2235871Snate@binkert.org# 22410584Sandreas.hansson@arm.com# calculate extra dependencies 2259416SAndreas.Sandberg@ARM.com# 2269416SAndreas.Sandberg@ARM.commodule_depends = ["m5", "m5.SimObject", "m5.params"] 2275871Snate@binkert.orgmodule_depends = [ File(generate.py_modules[dep]) for dep in module_depends ] 228955SN/Afile_depends = [ generate_file ] 22910671Sandreas.hansson@arm.comdepends = module_depends + file_depends 23010671Sandreas.hansson@arm.com 23110671Sandreas.hansson@arm.com######################################################################## 23210671Sandreas.hansson@arm.com# 2338881Smarc.orr@gmail.com# Commands for the basic automatically generated python files 2346121Snate@binkert.org# 2356121Snate@binkert.org 2361533SN/A# Generate a file with all of the compile options in it 2379239Sandreas.hansson@arm.comenv.Command('python/m5/defines.py', Value(optionDict), 2389239Sandreas.hansson@arm.com generate.makeDefinesPyFile) 2399239Sandreas.hansson@arm.comPySource('m5', 'python/m5/defines.py') 2409239Sandreas.hansson@arm.com 2419239Sandreas.hansson@arm.com# Generate a file that wraps the basic top level files 2429239Sandreas.hansson@arm.comenv.Command('python/m5/info.py', 2439239Sandreas.hansson@arm.com [ '#/AUTHORS', '#/LICENSE', '#/README', '#/RELEASE_NOTES' ], 2449239Sandreas.hansson@arm.com generate.makeInfoPyFile) 2459239Sandreas.hansson@arm.comPySource('m5', 'python/m5/info.py') 2469239Sandreas.hansson@arm.com 2479239Sandreas.hansson@arm.com# Generate an __init__.py file for the objects package 2489239Sandreas.hansson@arm.comenv.Command('python/m5/objects/__init__.py', 2496655Snate@binkert.org [ Value(o) for o in sort_list(sim_object_modfiles) ], 2506655Snate@binkert.org generate.makeObjectsInitFile) 2516655Snate@binkert.orgPySource('m5.objects', 'python/m5/objects/__init__.py') 2526655Snate@binkert.org 2535871Snate@binkert.org######################################################################## 2545871Snate@binkert.org# 2555863Snate@binkert.org# Create all of the SimObject param headers and enum headers 2565871Snate@binkert.org# 2578878Ssteve.reinhardt@amd.com 2585871Snate@binkert.org# Generate all of the SimObject param struct header files 2595871Snate@binkert.orgparams_hh_files = [] 2605871Snate@binkert.orgfor name,simobj in generate.sim_objects.iteritems(): 2615863Snate@binkert.org extra_deps = [ File(generate.py_modules[simobj.__module__]) ] 2626121Snate@binkert.org 2635863Snate@binkert.org hh_file = File('params/%s.hh' % name) 2645871Snate@binkert.org params_hh_files.append(hh_file) 2658336Ssteve.reinhardt@amd.com env.Command(hh_file, Value(name), generate.createSimObjectParam) 2668336Ssteve.reinhardt@amd.com env.Depends(hh_file, depends + extra_deps) 2678336Ssteve.reinhardt@amd.com 2688336Ssteve.reinhardt@amd.com# Generate any parameter header files needed 2694678Snate@binkert.orgfor name,param in generate.params.iteritems(): 27011401Sandreas.sandberg@arm.com if isinstance(param, m5.params.VectorParamDesc): 27111401Sandreas.sandberg@arm.com ext = 'vptype' 27211401Sandreas.sandberg@arm.com else: 27311401Sandreas.sandberg@arm.com ext = 'ptype' 27411401Sandreas.sandberg@arm.com 27511401Sandreas.sandberg@arm.com i_file = File('params/%s_%s.i' % (name, ext)) 2768336Ssteve.reinhardt@amd.com env.Command(i_file, Value(name), generate.createSwigParam) 2778336Ssteve.reinhardt@amd.com env.Depends(i_file, depends) 2788336Ssteve.reinhardt@amd.com 2794678Snate@binkert.org# Generate all enum header files 28011401Sandreas.sandberg@arm.comfor name,enum in generate.enums.iteritems(): 2814678Snate@binkert.org extra_deps = [ File(generate.py_modules[enum.__module__]) ] 2824678Snate@binkert.org 28311401Sandreas.sandberg@arm.com cc_file = File('enums/%s.cc' % name) 28411401Sandreas.sandberg@arm.com env.Command(cc_file, Value(name), generate.createEnumStrings) 2858336Ssteve.reinhardt@amd.com env.Depends(cc_file, depends + extra_deps) 2864678Snate@binkert.org Source(cc_file) 2878336Ssteve.reinhardt@amd.com 2888336Ssteve.reinhardt@amd.com hh_file = File('enums/%s.hh' % name) 2898336Ssteve.reinhardt@amd.com env.Command(hh_file, Value(name), generate.createEnumParam) 2908336Ssteve.reinhardt@amd.com env.Depends(hh_file, depends + extra_deps) 2918336Ssteve.reinhardt@amd.com 2928336Ssteve.reinhardt@amd.com# Build the big monolithic swigged params module (wraps all SimObject 2935871Snate@binkert.org# param structs and enum structs) 2945871Snate@binkert.orgparams_file = File('params/params.i') 2958336Ssteve.reinhardt@amd.comnames = sort_list(generate.sim_objects.keys()) 2968336Ssteve.reinhardt@amd.comenv.Command(params_file, [ Value(v) for v in names ], 2978336Ssteve.reinhardt@amd.com generate.buildParams) 2988336Ssteve.reinhardt@amd.comenv.Depends(params_file, params_hh_files + depends) 2998336Ssteve.reinhardt@amd.comSwigSource('m5.objects', params_file) 30011401Sandreas.sandberg@arm.com 30111401Sandreas.sandberg@arm.com# Build all swig modules 30211401Sandreas.sandberg@arm.comswig_modules = [] 3035871Snate@binkert.orgfor source,package in swig_sources: 3048336Ssteve.reinhardt@amd.com filename = str(source) 3058336Ssteve.reinhardt@amd.com assert filename.endswith('.i') 30611401Sandreas.sandberg@arm.com 30711401Sandreas.sandberg@arm.com base = '.'.join(filename.split('.')[:-1]) 30811401Sandreas.sandberg@arm.com module = basename(base) 30911401Sandreas.sandberg@arm.com cc_file = base + '_wrap.cc' 31011401Sandreas.sandberg@arm.com py_file = base + '.py' 3114678Snate@binkert.org 3125871Snate@binkert.org env.Command([cc_file, py_file], source, 3134678Snate@binkert.org '$SWIG $SWIGFLAGS -outdir ${TARGETS[1].dir} ' 31411401Sandreas.sandberg@arm.com '-o ${TARGETS[0]} $SOURCES') 31511401Sandreas.sandberg@arm.com env.Depends(py_file, source) 31611401Sandreas.sandberg@arm.com env.Depends(cc_file, source) 31711401Sandreas.sandberg@arm.com 31811401Sandreas.sandberg@arm.com swig_modules.append(Value(module)) 31911401Sandreas.sandberg@arm.com Source(cc_file) 32011401Sandreas.sandberg@arm.com PySource(package, py_file) 32111401Sandreas.sandberg@arm.com 32211401Sandreas.sandberg@arm.com# Generate the main swig init file 32311401Sandreas.sandberg@arm.comenv.Command('swig/init.cc', swig_modules, generate.makeSwigInit) 32411401Sandreas.sandberg@arm.comSource('swig/init.cc') 32511401Sandreas.sandberg@arm.com 32611401Sandreas.sandberg@arm.com# Generate traceflags.py 32711401Sandreas.sandberg@arm.comflags = [ Value(f) for f in trace_flags ] 32811401Sandreas.sandberg@arm.comenv.Command('base/traceflags.py', flags, generate.traceFlagsPy) 32911401Sandreas.sandberg@arm.comPySource('m5', 'base/traceflags.py') 33011401Sandreas.sandberg@arm.com 33111401Sandreas.sandberg@arm.comenv.Command('base/traceflags.hh', flags, generate.traceFlagsHH) 33211401Sandreas.sandberg@arm.comenv.Command('base/traceflags.cc', flags, generate.traceFlagsCC) 33311401Sandreas.sandberg@arm.comSource('base/traceflags.cc') 33411401Sandreas.sandberg@arm.com 33511401Sandreas.sandberg@arm.com# Build the zip file 33611401Sandreas.sandberg@arm.compy_compiled = [] 33711401Sandreas.sandberg@arm.compy_zip_depends = [] 33811401Sandreas.sandberg@arm.comfor source in py_sources: 33911401Sandreas.sandberg@arm.com env.Command(source.compiled, source.source, generate.compilePyFile) 34011401Sandreas.sandberg@arm.com py_compiled.append(source.compiled) 34111401Sandreas.sandberg@arm.com 34211401Sandreas.sandberg@arm.com # make the zipfile depend on the archive name so that the archive 34311401Sandreas.sandberg@arm.com # is rebuilt if the name changes 34411401Sandreas.sandberg@arm.com py_zip_depends.append(Value(source.arcname)) 34511401Sandreas.sandberg@arm.com 3468336Ssteve.reinhardt@amd.com# Add the zip file target to the environment. 3478336Ssteve.reinhardt@amd.comm5zip = File('m5py.zip') 3488336Ssteve.reinhardt@amd.comenv.Command(m5zip, py_compiled, generate.buildPyZip) 3498336Ssteve.reinhardt@amd.comenv.Depends(m5zip, py_zip_depends) 3508336Ssteve.reinhardt@amd.com 3518336Ssteve.reinhardt@amd.com######################################################################## 3528336Ssteve.reinhardt@amd.com# 3538336Ssteve.reinhardt@amd.com# Define binaries. Each different build type (debug, opt, etc.) gets 3548336Ssteve.reinhardt@amd.com# a slightly different build environment. 3558336Ssteve.reinhardt@amd.com# 35611401Sandreas.sandberg@arm.com 35711401Sandreas.sandberg@arm.com# List of constructed environments to pass back to SConstruct 3588336Ssteve.reinhardt@amd.comenvList = [] 3598336Ssteve.reinhardt@amd.com 3608336Ssteve.reinhardt@amd.com# This function adds the specified sources to the given build 3615871Snate@binkert.org# environment, and returns a list of all the corresponding SCons 3626121Snate@binkert.org# Object nodes (including an extra one for date.cc). We explicitly 363955SN/A# add the Object nodes so we can set up special dependencies for 364955SN/A# date.cc. 3652632Sstever@eecs.umich.edudef make_objs(sources, env): 3662632Sstever@eecs.umich.edu objs = [env.Object(s) for s in sources] 367955SN/A # make date.cc depend on all other objects so it always gets 368955SN/A # recompiled whenever anything else does 369955SN/A date_obj = env.Object('base/date.cc') 370955SN/A env.Depends(date_obj, objs) 3718878Ssteve.reinhardt@amd.com objs.append(date_obj) 372955SN/A return objs 3732632Sstever@eecs.umich.edu 3742632Sstever@eecs.umich.edu# Function to create a new build environment as clone of current 3752632Sstever@eecs.umich.edu# environment 'env' with modified object suffix and optional stripped 3762632Sstever@eecs.umich.edu# binary. Additional keyword arguments are appended to corresponding 3772632Sstever@eecs.umich.edu# build environment vars. 3782632Sstever@eecs.umich.edudef makeEnv(label, objsfx, strip = False, **kwargs): 3792632Sstever@eecs.umich.edu newEnv = env.Copy(OBJSUFFIX=objsfx) 3808268Ssteve.reinhardt@amd.com newEnv.Label = label 3818268Ssteve.reinhardt@amd.com newEnv.Append(**kwargs) 3828268Ssteve.reinhardt@amd.com exe = 'm5.' + label # final executable 3838268Ssteve.reinhardt@amd.com bin = exe + '.bin' # executable w/o appended Python zip archive 3848268Ssteve.reinhardt@amd.com newEnv.Program(bin, make_objs(cc_sources, newEnv)) 3858268Ssteve.reinhardt@amd.com if strip: 3868268Ssteve.reinhardt@amd.com stripped_bin = bin + '.stripped' 3872632Sstever@eecs.umich.edu if sys.platform == 'sunos5': 3882632Sstever@eecs.umich.edu cmd = 'cp $SOURCE $TARGET; strip $TARGET' 3892632Sstever@eecs.umich.edu else: 3902632Sstever@eecs.umich.edu cmd = 'strip $SOURCE -o $TARGET' 3918268Ssteve.reinhardt@amd.com newEnv.Command(stripped_bin, bin, cmd) 3922632Sstever@eecs.umich.edu bin = stripped_bin 3938268Ssteve.reinhardt@amd.com targets = newEnv.Concat(exe, [bin, 'm5py.zip']) 3948268Ssteve.reinhardt@amd.com newEnv.M5Binary = targets[0] 3958268Ssteve.reinhardt@amd.com envList.append(newEnv) 3968268Ssteve.reinhardt@amd.com 3973718Sstever@eecs.umich.edu# Debug binary 3982634Sstever@eecs.umich.educcflags = {} 3992634Sstever@eecs.umich.eduif env['GCC']: 4005863Snate@binkert.org if sys.platform == 'sunos5': 4012638Sstever@eecs.umich.edu ccflags['debug'] = '-gstabs+' 4028268Ssteve.reinhardt@amd.com else: 4032632Sstever@eecs.umich.edu ccflags['debug'] = '-ggdb3' 4042632Sstever@eecs.umich.edu ccflags['opt'] = '-g -O3' 4052632Sstever@eecs.umich.edu ccflags['fast'] = '-O3' 4062632Sstever@eecs.umich.edu ccflags['prof'] = '-O3 -g -pg' 4072632Sstever@eecs.umich.eduelif env['SUNCC']: 4081858SN/A ccflags['debug'] = '-g0' 4093716Sstever@eecs.umich.edu ccflags['opt'] = '-g -O' 4102638Sstever@eecs.umich.edu ccflags['fast'] = '-fast' 4112638Sstever@eecs.umich.edu ccflags['prof'] = '-fast -g -pg' 4122638Sstever@eecs.umich.eduelif env['ICC']: 4132638Sstever@eecs.umich.edu ccflags['debug'] = '-g -O0' 4142638Sstever@eecs.umich.edu ccflags['opt'] = '-g -O' 4152638Sstever@eecs.umich.edu ccflags['fast'] = '-fast' 4162638Sstever@eecs.umich.edu ccflags['prof'] = '-fast -g -pg' 4175863Snate@binkert.orgelse: 4185863Snate@binkert.org print 'Unknown compiler, please fix compiler options' 4195863Snate@binkert.org Exit(1) 420955SN/A 4215341Sstever@gmail.commakeEnv('debug', '.do', 4225341Sstever@gmail.com CCFLAGS = Split(ccflags['debug']), 4235863Snate@binkert.org CPPDEFINES = ['DEBUG', 'TRACING_ON=1']) 4247756SAli.Saidi@ARM.com 4255341Sstever@gmail.com# Optimized binary 4266121Snate@binkert.orgmakeEnv('opt', '.o', 4274494Ssaidi@eecs.umich.edu CCFLAGS = Split(ccflags['opt']), 4286121Snate@binkert.org CPPDEFINES = ['TRACING_ON=1']) 4291105SN/A 4302667Sstever@eecs.umich.edu# "Fast" binary 4312667Sstever@eecs.umich.edumakeEnv('fast', '.fo', strip = True, 4322667Sstever@eecs.umich.edu CCFLAGS = Split(ccflags['fast']), 4332667Sstever@eecs.umich.edu CPPDEFINES = ['NDEBUG', 'TRACING_ON=0']) 4346121Snate@binkert.org 4352667Sstever@eecs.umich.edu# Profiled binary 4365341Sstever@gmail.commakeEnv('prof', '.po', 4375863Snate@binkert.org CCFLAGS = Split(ccflags['prof']), 4385341Sstever@gmail.com CPPDEFINES = ['NDEBUG', 'TRACING_ON=0'], 4395341Sstever@gmail.com LINKFLAGS = '-pg') 4405341Sstever@gmail.com 4418120Sgblack@eecs.umich.eduReturn('envList') 4425341Sstever@gmail.com