SConscript revision 5342:c19e3a1a607c
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 7412363Sgabeblack@google.com self.package = package 7512302Sgabeblack@google.com self.modpath = modpath 7612302Sgabeblack@google.com self.arcname = arcname 7712302Sgabeblack@google.com self.filename = filename 7812363Sgabeblack@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''' 8612363Sgabeblack@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''' 10512362Sgabeblack@google.com 10612362Sgabeblack@google.com if sim_objects_fixed: 10712362Sgabeblack@google.com raise AttributeError, "Too late to call SimObject now." 10812362Sgabeblack@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)) 11412363Sgabeblack@google.com assert modfile.endswith('.py') 11512363Sgabeblack@google.com modname = modfile[:-3] 11612363Sgabeblack@google.com sim_object_modfiles.add(modname) 11712363Sgabeblack@google.com 11812302Sgabeblack@google.comswig_sources = [] 11912363Sgabeblack@google.comdef SwigSource(package, source): 12012363Sgabeblack@google.com '''Add a swig file to build''' 12112363Sgabeblack@google.com if not isinstance(source, SCons.Node.FS.File): 12212363Sgabeblack@google.com source = File(source) 12312363Sgabeblack@google.com val = source,package 1248233Snate@binkert.org swig_sources.append(val) 1256143Snate@binkert.org 1266143Snate@binkert.org# Children should have access 1276143Snate@binkert.orgExport('Source') 1286143Snate@binkert.orgExport('PySource') 1296143Snate@binkert.orgExport('SimObject') 1306143Snate@binkert.orgExport('SwigSource') 1316143Snate@binkert.org 1326143Snate@binkert.org######################################################################## 1336143Snate@binkert.org# 1347065Snate@binkert.org# Trace Flags 1356143Snate@binkert.org# 13612362Sgabeblack@google.comall_flags = {} 13712362Sgabeblack@google.comtrace_flags = [] 13812362Sgabeblack@google.comdef TraceFlag(name, desc=''): 13912362Sgabeblack@google.com if name in all_flags: 14012362Sgabeblack@google.com raise AttributeError, "Flag %s already specified" % name 14112362Sgabeblack@google.com flag = (name, (), desc) 14212362Sgabeblack@google.com trace_flags.append(flag) 14312362Sgabeblack@google.com all_flags[name] = () 14412362Sgabeblack@google.com 14512362Sgabeblack@google.comdef CompoundFlag(name, flags, desc=''): 14612362Sgabeblack@google.com if name in all_flags: 14712362Sgabeblack@google.com raise AttributeError, "Flag %s already specified" % name 1488233Snate@binkert.org 1498233Snate@binkert.org compound = tuple(flags) 1508233Snate@binkert.org for flag in compound: 1518233Snate@binkert.org if flag not in all_flags: 1528233Snate@binkert.org raise AttributeError, "Trace flag %s not found" % flag 1538233Snate@binkert.org if all_flags[flag]: 1548233Snate@binkert.org raise AttributeError, \ 1558233Snate@binkert.org "Compound flag can't point to another compound flag" 1568233Snate@binkert.org 1578233Snate@binkert.org flag = (name, compound, desc) 1588233Snate@binkert.org trace_flags.append(flag) 1598233Snate@binkert.org all_flags[name] = compound 1608233Snate@binkert.org 1618233Snate@binkert.orgExport('TraceFlag') 1628233Snate@binkert.orgExport('CompoundFlag') 1638233Snate@binkert.org 1648233Snate@binkert.org######################################################################## 1658233Snate@binkert.org# 1668233Snate@binkert.org# Set some compiler variables 1678233Snate@binkert.org# 1688233Snate@binkert.org 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. 1736143Snate@binkert.orgenv.Append(CPPPATH=Dir('.')) 1746143Snate@binkert.org 1759982Satgutier@umich.edu# 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())]) 17712302Sgabeblack@google.com 17812302Sgabeblack@google.com######################################################################## 17912302Sgabeblack@google.com# 18012302Sgabeblack@google.com# Walk the tree and execute all SConscripts in 'src' subdirectories 18112302Sgabeblack@google.com# 18212302Sgabeblack@google.com 18312302Sgabeblack@google.comfor base_dir in base_dir_list: 18412302Sgabeblack@google.com src_dir = joinpath(base_dir, 'src') 18511983Sgabeblack@google.com if not isdir(src_dir): 18611983Sgabeblack@google.com continue 18711983Sgabeblack@google.com here = Dir('.').srcnode().abspath 18812302Sgabeblack@google.com for root, dirs, files in os.walk(src_dir, topdown=True): 18912302Sgabeblack@google.com if root == here: 19012302Sgabeblack@google.com # we don't want to recurse back into this SConscript 19112302Sgabeblack@google.com continue 19212302Sgabeblack@google.com 19312302Sgabeblack@google.com if 'SConscript' in files: 19411983Sgabeblack@google.com build_dir = joinpath(env['BUILDDIR'], root[len(src_dir) + 1:]) 1956143Snate@binkert.org SConscript(joinpath(root, 'SConscript'), build_dir=build_dir) 19612305Sgabeblack@google.com 19712302Sgabeblack@google.comfor opt in env.ExportOptions: 19812302Sgabeblack@google.com env.ConfigFile(opt) 19912302Sgabeblack@google.com 2006143Snate@binkert.org######################################################################## 2016143Snate@binkert.org# 2026143Snate@binkert.org# Prevent any SimObjects from being added after this point, they 2035522Snate@binkert.org# should all have been added in the SConscripts above 2046143Snate@binkert.org# 2056143Snate@binkert.orgsim_objects_fixed = True 2066143Snate@binkert.org 2079982Satgutier@umich.edu######################################################################## 20812302Sgabeblack@google.com# 20912302Sgabeblack@google.com# Manually turn python/generate.py into a python module and import it 21012302Sgabeblack@google.com# 2116143Snate@binkert.orggenerate_file = File('python/generate.py') 2126143Snate@binkert.orggenerate_module = imp.new_module('generate') 2136143Snate@binkert.orgsys.modules['generate'] = generate_module 2146143Snate@binkert.orgexec file(generate_file.srcnode().abspath, 'r') in generate_module.__dict__ 2155522Snate@binkert.org 2165522Snate@binkert.org######################################################################## 2175522Snate@binkert.org# 2185522Snate@binkert.org# build a generate 2195604Snate@binkert.org# 2205604Snate@binkert.orgfrom generate import Generate 2216143Snate@binkert.orgoptionDict = dict([(opt, env[opt]) for opt in env.ExportOptions]) 2226143Snate@binkert.orggenerate = Generate(py_sources, sim_object_modfiles, optionDict) 2234762Snate@binkert.orgm5 = generate.m5 2244762Snate@binkert.org 2256143Snate@binkert.org######################################################################## 2266727Ssteve.reinhardt@amd.com# 2276727Ssteve.reinhardt@amd.com# calculate extra dependencies 2286727Ssteve.reinhardt@amd.com# 2294762Snate@binkert.orgmodule_depends = ["m5", "m5.SimObject", "m5.params"] 2306143Snate@binkert.orgmodule_depends = [ File(generate.py_modules[dep]) for dep in module_depends ] 2316143Snate@binkert.orgfile_depends = [ generate_file ] 2326143Snate@binkert.orgdepends = module_depends + file_depends 2336143Snate@binkert.org 2346727Ssteve.reinhardt@amd.com######################################################################## 2356143Snate@binkert.org# 2367674Snate@binkert.org# Commands for the basic automatically generated python files 2377674Snate@binkert.org# 2385604Snate@binkert.org 2396143Snate@binkert.org# Generate a file with all of the compile options in it 2406143Snate@binkert.orgenv.Command('python/m5/defines.py', Value(optionDict), 2416143Snate@binkert.org generate.makeDefinesPyFile) 2424762Snate@binkert.orgPySource('m5', 'python/m5/defines.py') 2436143Snate@binkert.org 2444762Snate@binkert.org# Generate a file that wraps the basic top level files 2454762Snate@binkert.orgenv.Command('python/m5/info.py', 2464762Snate@binkert.org [ '#/AUTHORS', '#/LICENSE', '#/README', '#/RELEASE_NOTES' ], 2476143Snate@binkert.org generate.makeInfoPyFile) 2486143Snate@binkert.orgPySource('m5', 'python/m5/info.py') 2494762Snate@binkert.org 25012302Sgabeblack@google.com# Generate an __init__.py file for the objects package 25112302Sgabeblack@google.comenv.Command('python/m5/objects/__init__.py', 2528233Snate@binkert.org [ Value(o) for o in sort_list(sim_object_modfiles) ], 25312302Sgabeblack@google.com generate.makeObjectsInitFile) 2546143Snate@binkert.orgPySource('m5.objects', 'python/m5/objects/__init__.py') 2556143Snate@binkert.org 2564762Snate@binkert.org######################################################################## 2576143Snate@binkert.org# 2584762Snate@binkert.org# Create all of the SimObject param headers and enum headers 2599396Sandreas.hansson@arm.com# 2609396Sandreas.hansson@arm.com 2619396Sandreas.hansson@arm.com# Generate all of the SimObject param struct header files 26212302Sgabeblack@google.comparams_hh_files = [] 26312302Sgabeblack@google.comfor name,simobj in generate.sim_objects.iteritems(): 26412302Sgabeblack@google.com extra_deps = [ File(generate.py_modules[simobj.__module__]) ] 2659396Sandreas.hansson@arm.com 2669396Sandreas.hansson@arm.com hh_file = File('params/%s.hh' % name) 2679396Sandreas.hansson@arm.com params_hh_files.append(hh_file) 2689396Sandreas.hansson@arm.com env.Command(hh_file, Value(name), generate.createSimObjectParam) 2699396Sandreas.hansson@arm.com env.Depends(hh_file, depends + extra_deps) 2709396Sandreas.hansson@arm.com 2719396Sandreas.hansson@arm.com# Generate any parameter header files needed 2729930Sandreas.hansson@arm.comfor name,param in generate.params.iteritems(): 2739930Sandreas.hansson@arm.com if isinstance(param, m5.params.VectorParamDesc): 2749396Sandreas.hansson@arm.com ext = 'vptype' 2758235Snate@binkert.org else: 2768235Snate@binkert.org ext = 'ptype' 2776143Snate@binkert.org 2788235Snate@binkert.org i_file = File('params/%s_%s.i' % (name, ext)) 2799003SAli.Saidi@ARM.com env.Command(i_file, Value(name), generate.createSwigParam) 2808235Snate@binkert.org env.Depends(i_file, depends) 2818235Snate@binkert.org 28212302Sgabeblack@google.com# Generate all enum header files 2838235Snate@binkert.orgfor name,enum in generate.enums.iteritems(): 28412302Sgabeblack@google.com extra_deps = [ File(generate.py_modules[enum.__module__]) ] 2858235Snate@binkert.org 2868235Snate@binkert.org cc_file = File('enums/%s.cc' % name) 28712302Sgabeblack@google.com env.Command(cc_file, Value(name), generate.createEnumStrings) 2888235Snate@binkert.org env.Depends(cc_file, depends + extra_deps) 2898235Snate@binkert.org Source(cc_file) 2908235Snate@binkert.org 2918235Snate@binkert.org hh_file = File('enums/%s.hh' % name) 2929003SAli.Saidi@ARM.com env.Command(hh_file, Value(name), generate.createEnumParam) 29312313Sgabeblack@google.com env.Depends(hh_file, depends + extra_deps) 29412313Sgabeblack@google.com 29512313Sgabeblack@google.com# Build the big monolithic swigged params module (wraps all SimObject 29612313Sgabeblack@google.com# param structs and enum structs) 29712313Sgabeblack@google.comparams_file = File('params/params.i') 29812313Sgabeblack@google.comnames = sort_list(generate.sim_objects.keys()) 29912315Sgabeblack@google.comenv.Command(params_file, [ Value(v) for v in names ], 30012315Sgabeblack@google.com generate.buildParams) 30112315Sgabeblack@google.comenv.Depends(params_file, params_hh_files + depends) 3025584Snate@binkert.orgSwigSource('m5.objects', params_file) 3034382Sbinkertn@umich.edu 3044202Sbinkertn@umich.edu# Build all swig modules 3054382Sbinkertn@umich.eduswig_modules = [] 3064382Sbinkertn@umich.edufor source,package in swig_sources: 3079396Sandreas.hansson@arm.com filename = str(source) 3085584Snate@binkert.org assert filename.endswith('.i') 30912313Sgabeblack@google.com 3104382Sbinkertn@umich.edu base = '.'.join(filename.split('.')[:-1]) 3114382Sbinkertn@umich.edu module = basename(base) 3124382Sbinkertn@umich.edu cc_file = base + '_wrap.cc' 3138232Snate@binkert.org py_file = base + '.py' 3145192Ssaidi@eecs.umich.edu 3158232Snate@binkert.org env.Command([cc_file, py_file], source, 3168232Snate@binkert.org '$SWIG $SWIGFLAGS -outdir ${TARGETS[1].dir} ' 3178232Snate@binkert.org '-o ${TARGETS[0]} $SOURCES') 3185192Ssaidi@eecs.umich.edu env.Depends(py_file, source) 3198232Snate@binkert.org env.Depends(cc_file, source) 3205192Ssaidi@eecs.umich.edu 3215799Snate@binkert.org swig_modules.append(Value(module)) 3228232Snate@binkert.org Source(cc_file) 3235192Ssaidi@eecs.umich.edu PySource(package, py_file) 3245192Ssaidi@eecs.umich.edu 3255192Ssaidi@eecs.umich.edu# Generate the main swig init file 3268232Snate@binkert.orgenv.Command('swig/init.cc', swig_modules, generate.makeSwigInit) 3275192Ssaidi@eecs.umich.eduSource('swig/init.cc') 3288232Snate@binkert.org 3295192Ssaidi@eecs.umich.edu# Generate traceflags.py 3305192Ssaidi@eecs.umich.eduflags = [ Value(f) for f in trace_flags ] 3315192Ssaidi@eecs.umich.eduenv.Command('base/traceflags.py', flags, generate.traceFlagsPy) 3325192Ssaidi@eecs.umich.eduPySource('m5', 'base/traceflags.py') 3334382Sbinkertn@umich.edu 3344382Sbinkertn@umich.eduenv.Command('base/traceflags.hh', flags, generate.traceFlagsHH) 3354382Sbinkertn@umich.eduenv.Command('base/traceflags.cc', flags, generate.traceFlagsCC) 3362667Sstever@eecs.umich.eduSource('base/traceflags.cc') 3372667Sstever@eecs.umich.edu 3382667Sstever@eecs.umich.edu# Build the zip file 3392667Sstever@eecs.umich.edupy_compiled = [] 3402667Sstever@eecs.umich.edupy_zip_depends = [] 3412667Sstever@eecs.umich.edufor source in py_sources: 3425742Snate@binkert.org env.Command(source.compiled, source.source, generate.compilePyFile) 3435742Snate@binkert.org py_compiled.append(source.compiled) 3445742Snate@binkert.org 3455793Snate@binkert.org # make the zipfile depend on the archive name so that the archive 3468334Snate@binkert.org # is rebuilt if the name changes 3475793Snate@binkert.org py_zip_depends.append(Value(source.arcname)) 3485793Snate@binkert.org 3495793Snate@binkert.org# Add the zip file target to the environment. 3504382Sbinkertn@umich.edum5zip = File('m5py.zip') 3514762Snate@binkert.orgenv.Command(m5zip, py_compiled, generate.buildPyZip) 3525344Sstever@gmail.comenv.Depends(m5zip, py_zip_depends) 3534382Sbinkertn@umich.edu 3545341Sstever@gmail.com######################################################################## 3555742Snate@binkert.org# 3565742Snate@binkert.org# Define binaries. Each different build type (debug, opt, etc.) gets 3575742Snate@binkert.org# a slightly different build environment. 3585742Snate@binkert.org# 3595742Snate@binkert.org 3604762Snate@binkert.org# List of constructed environments to pass back to SConstruct 3615742Snate@binkert.orgenvList = [] 3625742Snate@binkert.org 36311984Sgabeblack@google.com# This function adds the specified sources to the given build 3647722Sgblack@eecs.umich.edu# environment, and returns a list of all the corresponding SCons 3655742Snate@binkert.org# Object nodes (including an extra one for date.cc). We explicitly 3665742Snate@binkert.org# add the Object nodes so we can set up special dependencies for 3675742Snate@binkert.org# date.cc. 3689930Sandreas.hansson@arm.comdef make_objs(sources, env): 3699930Sandreas.hansson@arm.com objs = [env.Object(s) for s in sources] 3709930Sandreas.hansson@arm.com # make date.cc depend on all other objects so it always gets 3719930Sandreas.hansson@arm.com # recompiled whenever anything else does 3729930Sandreas.hansson@arm.com date_obj = env.Object('base/date.cc') 3735742Snate@binkert.org env.Depends(date_obj, objs) 3748242Sbradley.danofsky@amd.com objs.append(date_obj) 3758242Sbradley.danofsky@amd.com return objs 3768242Sbradley.danofsky@amd.com 3778242Sbradley.danofsky@amd.com# Function to create a new build environment as clone of current 3785341Sstever@gmail.com# environment 'env' with modified object suffix and optional stripped 3795742Snate@binkert.org# binary. Additional keyword arguments are appended to corresponding 3807722Sgblack@eecs.umich.edu# build environment vars. 3814773Snate@binkert.orgdef makeEnv(label, objsfx, strip = False, **kwargs): 3826108Snate@binkert.org newEnv = env.Copy(OBJSUFFIX=objsfx) 3831858SN/A newEnv.Label = label 3841085SN/A newEnv.Append(**kwargs) 3856658Snate@binkert.org exe = 'm5.' + label # final executable 3866658Snate@binkert.org bin = exe + '.bin' # executable w/o appended Python zip archive 3877673Snate@binkert.org newEnv.Program(bin, make_objs(cc_sources, newEnv)) 3886658Snate@binkert.org if strip: 3896658Snate@binkert.org stripped_bin = bin + '.stripped' 39011308Santhony.gutierrez@amd.com if sys.platform == 'sunos5': 3916658Snate@binkert.org cmd = 'cp $SOURCE $TARGET; strip $TARGET' 39211308Santhony.gutierrez@amd.com else: 3936658Snate@binkert.org cmd = 'strip $SOURCE -o $TARGET' 3946658Snate@binkert.org newEnv.Command(stripped_bin, bin, cmd) 3957673Snate@binkert.org bin = stripped_bin 3967673Snate@binkert.org targets = newEnv.Concat(exe, [bin, 'm5py.zip']) 3977673Snate@binkert.org newEnv.M5Binary = targets[0] 3987673Snate@binkert.org envList.append(newEnv) 3997673Snate@binkert.org 4007673Snate@binkert.org# Debug binary 4017673Snate@binkert.orgccflags = {} 40210467Sandreas.hansson@arm.comif env['GCC']: 4036658Snate@binkert.org if sys.platform == 'sunos5': 4047673Snate@binkert.org ccflags['debug'] = '-gstabs+' 40510467Sandreas.hansson@arm.com else: 40610467Sandreas.hansson@arm.com ccflags['debug'] = '-ggdb3' 40710467Sandreas.hansson@arm.com ccflags['opt'] = '-g -O3' 40810467Sandreas.hansson@arm.com ccflags['fast'] = '-O3' 40910467Sandreas.hansson@arm.com ccflags['prof'] = '-O3 -g -pg' 41010467Sandreas.hansson@arm.comelif env['SUNCC']: 41110467Sandreas.hansson@arm.com ccflags['debug'] = '-g0' 41210467Sandreas.hansson@arm.com ccflags['opt'] = '-g -O' 41310467Sandreas.hansson@arm.com ccflags['fast'] = '-fast' 41410467Sandreas.hansson@arm.com ccflags['prof'] = '-fast -g -pg' 41510467Sandreas.hansson@arm.comelif env['ICC']: 4167673Snate@binkert.org ccflags['debug'] = '-g -O0' 4177673Snate@binkert.org ccflags['opt'] = '-g -O' 4187673Snate@binkert.org ccflags['fast'] = '-fast' 4197673Snate@binkert.org ccflags['prof'] = '-fast -g -pg' 4207673Snate@binkert.orgelse: 4219048SAli.Saidi@ARM.com print 'Unknown compiler, please fix compiler options' 4227673Snate@binkert.org Exit(1) 4237673Snate@binkert.org 4247673Snate@binkert.orgmakeEnv('debug', '.do', 4257673Snate@binkert.org CCFLAGS = Split(ccflags['debug']), 4266658Snate@binkert.org CPPDEFINES = ['DEBUG', 'TRACING_ON=1']) 4277756SAli.Saidi@ARM.com 4287816Ssteve.reinhardt@amd.com# Optimized binary 4296658Snate@binkert.orgmakeEnv('opt', '.o', 43011308Santhony.gutierrez@amd.com CCFLAGS = Split(ccflags['opt']), 43111308Santhony.gutierrez@amd.com CPPDEFINES = ['TRACING_ON=1']) 43211308Santhony.gutierrez@amd.com 43311308Santhony.gutierrez@amd.com# "Fast" binary 43411308Santhony.gutierrez@amd.commakeEnv('fast', '.fo', strip = True, 43511308Santhony.gutierrez@amd.com CCFLAGS = Split(ccflags['fast']), 43611308Santhony.gutierrez@amd.com CPPDEFINES = ['NDEBUG', 'TRACING_ON=0']) 43711308Santhony.gutierrez@amd.com 43811308Santhony.gutierrez@amd.com# Profiled binary 43911308Santhony.gutierrez@amd.commakeEnv('prof', '.po', 44011308Santhony.gutierrez@amd.com CCFLAGS = Split(ccflags['prof']), 44111308Santhony.gutierrez@amd.com CPPDEFINES = ['NDEBUG', 'TRACING_ON=0'], 44211308Santhony.gutierrez@amd.com LINKFLAGS = '-pg') 44311308Santhony.gutierrez@amd.com 44411308Santhony.gutierrez@amd.comReturn('envList') 44511308Santhony.gutierrez@amd.com