SConscript revision 4120
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: Steve Reinhardt 30955SN/A 315522Snate@binkert.orgimport os 324762Snate@binkert.orgimport sys 335522Snate@binkert.orgfrom os.path import isfile, join as joinpath 34955SN/A 355522Snate@binkert.org# This file defines how to build a particular configuration of M5 36955SN/A# based on variable settings in the 'env' build environment. 375522Snate@binkert.org 384202Sbinkertn@umich.edu# Import build environment variable from SConstruct. 395742Snate@binkert.orgImport('env') 40955SN/A 414381Sbinkertn@umich.edu################################################### 424381Sbinkertn@umich.edu# 43955SN/A# Define needed sources. 44955SN/A# 45955SN/A################################################### 464202Sbinkertn@umich.edu 47955SN/A# Base sources used by all configurations. 484382Sbinkertn@umich.edu 494382Sbinkertn@umich.edubase_sources = Split(''' 504382Sbinkertn@umich.edu base/annotate.cc 515863Snate@binkert.org base/circlebuf.cc 525517Snate@binkert.org base/cprintf.cc 534762Snate@binkert.org base/fast_alloc.cc 544762Snate@binkert.org base/fifo_buffer.cc 554762Snate@binkert.org base/hostinfo.cc 564762Snate@binkert.org base/hybrid_pred.cc 574762Snate@binkert.org base/inifile.cc 584762Snate@binkert.org base/intmath.cc 594762Snate@binkert.org base/match.cc 604762Snate@binkert.org base/misc.cc 614762Snate@binkert.org base/output.cc 624762Snate@binkert.org base/pollevent.cc 635522Snate@binkert.org base/range.cc 645604Snate@binkert.org base/random.cc 655604Snate@binkert.org base/remote_gdb.cc 665604Snate@binkert.org base/sat_counter.cc 674762Snate@binkert.org base/socket.cc 684762Snate@binkert.org base/statistics.cc 694762Snate@binkert.org base/str.cc 705522Snate@binkert.org base/time.cc 715522Snate@binkert.org base/trace.cc 725522Snate@binkert.org base/traceflags.cc 735522Snate@binkert.org base/userinfo.cc 745604Snate@binkert.org base/compression/lzss_compression.cc 755604Snate@binkert.org base/loader/aout_object.cc 764762Snate@binkert.org base/loader/ecoff_object.cc 774762Snate@binkert.org base/loader/elf_object.cc 784762Snate@binkert.org base/loader/raw_object.cc 794762Snate@binkert.org base/loader/object_file.cc 805522Snate@binkert.org base/loader/symtab.cc 814762Snate@binkert.org base/stats/events.cc 824762Snate@binkert.org base/stats/output.cc 835604Snate@binkert.org base/stats/statdb.cc 845604Snate@binkert.org base/stats/visit.cc 855604Snate@binkert.org base/stats/text.cc 865604Snate@binkert.org 875604Snate@binkert.org cpu/activity.cc 885604Snate@binkert.org cpu/base.cc 894762Snate@binkert.org cpu/cpuevent.cc 904762Snate@binkert.org cpu/exetrace.cc 914762Snate@binkert.org cpu/func_unit.cc 924762Snate@binkert.org cpu/op_class.cc 935604Snate@binkert.org cpu/pc_event.cc 944762Snate@binkert.org cpu/quiesce_event.cc 955522Snate@binkert.org cpu/static_inst.cc 965522Snate@binkert.org cpu/simple_thread.cc 975522Snate@binkert.org cpu/thread_state.cc 984762Snate@binkert.org 994382Sbinkertn@umich.edu mem/bridge.cc 1004762Snate@binkert.org mem/bus.cc 1014382Sbinkertn@umich.edu mem/dram.cc 1025522Snate@binkert.org mem/mem_object.cc 1034381Sbinkertn@umich.edu mem/packet.cc 1045522Snate@binkert.org mem/physical.cc 1054762Snate@binkert.org mem/port.cc 1064762Snate@binkert.org mem/tport.cc 1074762Snate@binkert.org 1085522Snate@binkert.org mem/cache/base_cache.cc 1095522Snate@binkert.org mem/cache/cache.cc 1105522Snate@binkert.org mem/cache/coherence/coherence_protocol.cc 1115522Snate@binkert.org mem/cache/coherence/uni_coherence.cc 1125522Snate@binkert.org mem/cache/miss/blocking_buffer.cc 1135522Snate@binkert.org mem/cache/miss/miss_buffer.cc 1145522Snate@binkert.org mem/cache/miss/miss_queue.cc 1155522Snate@binkert.org mem/cache/miss/mshr.cc 1165522Snate@binkert.org mem/cache/miss/mshr_queue.cc 1174762Snate@binkert.org mem/cache/prefetch/base_prefetcher.cc 1184762Snate@binkert.org mem/cache/prefetch/ghb_prefetcher.cc 1194762Snate@binkert.org mem/cache/prefetch/stride_prefetcher.cc 1204762Snate@binkert.org mem/cache/prefetch/tagged_prefetcher.cc 1214762Snate@binkert.org mem/cache/tags/base_tags.cc 1224762Snate@binkert.org mem/cache/tags/fa_lru.cc 1234762Snate@binkert.org mem/cache/tags/iic.cc 1244762Snate@binkert.org mem/cache/tags/lru.cc 1254762Snate@binkert.org mem/cache/tags/repl/gen.cc 1264762Snate@binkert.org mem/cache/tags/repl/repl.cc 1274762Snate@binkert.org mem/cache/tags/split.cc 1284762Snate@binkert.org mem/cache/tags/split_lifo.cc 1294762Snate@binkert.org mem/cache/tags/split_lru.cc 1304762Snate@binkert.org 1314762Snate@binkert.org mem/cache/cache_builder.cc 1324762Snate@binkert.org 1334762Snate@binkert.org python/swig/init.cc 1344762Snate@binkert.org python/swig/debug_wrap.cc 1354762Snate@binkert.org python/swig/main_wrap.cc 1364762Snate@binkert.org python/swig/event_wrap.cc 1374762Snate@binkert.org python/swig/random_wrap.cc 1384762Snate@binkert.org python/swig/stats_wrap.cc 1394762Snate@binkert.org python/swig/trace_wrap.cc 1404762Snate@binkert.org python/swig/pyevent.cc 1414762Snate@binkert.org 1424762Snate@binkert.org sim/builder.cc 1434762Snate@binkert.org sim/debug.cc 1444762Snate@binkert.org sim/eventq.cc 1454762Snate@binkert.org sim/faults.cc 1464762Snate@binkert.org sim/main.cc 1474762Snate@binkert.org sim/param.cc 1484762Snate@binkert.org sim/root.cc 1494762Snate@binkert.org sim/serialize.cc 1504762Snate@binkert.org sim/sim_events.cc 1514762Snate@binkert.org sim/sim_object.cc 152955SN/A sim/startup.cc 1535584Snate@binkert.org sim/stat_control.cc 1545584Snate@binkert.org sim/system.cc 1555584Snate@binkert.org ''') 1565584Snate@binkert.org 1575584Snate@binkert.orgtrace_reader_sources = Split(''' 1585584Snate@binkert.org cpu/trace/reader/mem_trace_reader.cc 1595584Snate@binkert.org cpu/trace/reader/ibm_reader.cc 1605584Snate@binkert.org cpu/trace/reader/itx_reader.cc 1615584Snate@binkert.org cpu/trace/reader/m5_reader.cc 1625584Snate@binkert.org cpu/trace/opt_cpu.cc 1635584Snate@binkert.org cpu/trace/trace_cpu.cc 1645584Snate@binkert.org ''') 1655584Snate@binkert.org 1664382Sbinkertn@umich.edu 1674202Sbinkertn@umich.edu 1685522Snate@binkert.org# MySql sources 1694382Sbinkertn@umich.edumysql_sources = Split(''' 1704382Sbinkertn@umich.edu base/mysql.cc 1714382Sbinkertn@umich.edu base/stats/mysql.cc 1725584Snate@binkert.org ''') 1734382Sbinkertn@umich.edu 1744382Sbinkertn@umich.edu# Full-system sources 1754382Sbinkertn@umich.edufull_system_sources = Split(''' 1765192Ssaidi@eecs.umich.edu base/crc.cc 1775192Ssaidi@eecs.umich.edu base/inet.cc 1785799Snate@binkert.org 1795799Snate@binkert.org cpu/intr_control.cc 1805799Snate@binkert.org cpu/profile.cc 1815192Ssaidi@eecs.umich.edu 1825799Snate@binkert.org dev/uart.cc 1835192Ssaidi@eecs.umich.edu dev/uart8250.cc 1845799Snate@binkert.org 1855799Snate@binkert.org mem/vport.cc 1865192Ssaidi@eecs.umich.edu 1875192Ssaidi@eecs.umich.edu sim/pseudo_inst.cc 1885192Ssaidi@eecs.umich.edu ''') 1895192Ssaidi@eecs.umich.edu #dev/sinic.cc 1905799Snate@binkert.org #dev/i8254xGBe.cc 1915192Ssaidi@eecs.umich.edu 1925799Snate@binkert.orgif env['TARGET_ISA'] == 'alpha': 1935192Ssaidi@eecs.umich.edu full_system_sources += Split(''' 1945192Ssaidi@eecs.umich.edu kern/tru64/dump_mbuf.cc 1955192Ssaidi@eecs.umich.edu kern/tru64/printf.cc 1965799Snate@binkert.org kern/tru64/tru64_events.cc 1975192Ssaidi@eecs.umich.edu kern/tru64/tru64_syscalls.cc 1985192Ssaidi@eecs.umich.edu ''') 1995192Ssaidi@eecs.umich.edu 2005192Ssaidi@eecs.umich.edu# Syscall emulation (non-full-system) sources 2015192Ssaidi@eecs.umich.edusyscall_emulation_sources = Split(''' 2025192Ssaidi@eecs.umich.edu mem/translating_port.cc 2034382Sbinkertn@umich.edu mem/page_table.cc 2044382Sbinkertn@umich.edu sim/process.cc 2054382Sbinkertn@umich.edu sim/syscall_emul.cc 2062667Sstever@eecs.umich.edu ''') 2072667Sstever@eecs.umich.edu 2082667Sstever@eecs.umich.edu#if env['TARGET_ISA'] == 'alpha': 2092667Sstever@eecs.umich.edu# syscall_emulation_sources += Split(''' 2102667Sstever@eecs.umich.edu# kern/tru64/tru64.cc 2112667Sstever@eecs.umich.edu# ''') 2125742Snate@binkert.org 2135742Snate@binkert.orgmemtest_sources = Split(''' 2145742Snate@binkert.org cpu/memtest/memtest.cc 2152037SN/A ''') 2162037SN/A 2172037SN/A# Include file paths are rooted in this directory. SCons will 2185793Snate@binkert.org# automatically expand '.' to refer to both the source directory and 2195793Snate@binkert.org# the corresponding build directory to pick up generated include 2205793Snate@binkert.org# files. 2215793Snate@binkert.orgenv.Append(CPPPATH=Dir('.')) 2225793Snate@binkert.org 2234382Sbinkertn@umich.edu# Add a flag defining what THE_ISA should be for all compilation 2244762Snate@binkert.orgenv.Append(CPPDEFINES=[('THE_ISA','%s_ISA' % env['TARGET_ISA'].upper())]) 2255344Sstever@gmail.com 2264382Sbinkertn@umich.eduarch_sources = SConscript(os.path.join('arch', 'SConscript'), exports = 'env') 2275341Sstever@gmail.com 2285742Snate@binkert.orgcpu_sources = SConscript(os.path.join('cpu', 'SConscript'), exports = 'env') 2295742Snate@binkert.org 2305742Snate@binkert.orgif env['FULL_SYSTEM']: 2315742Snate@binkert.org dev_sources = SConscript(os.path.join('dev', 'SConscript'), 2325742Snate@binkert.org exports = 'env') 2334762Snate@binkert.org full_system_sources += dev_sources 2345742Snate@binkert.org 2355742Snate@binkert.org kern_sources = SConscript(os.path.join('kern', 'SConscript'), 2365742Snate@binkert.org exports = 'env') 2375742Snate@binkert.org full_system_sources += kern_sources 2385742Snate@binkert.org 2395742Snate@binkert.org# Set up complete list of sources based on configuration. 2405742Snate@binkert.orgsources = base_sources + arch_sources + cpu_sources 2415341Sstever@gmail.com 2425742Snate@binkert.org# encumbered should be last because we're adding to some of the other groups 2435341Sstever@gmail.comif isfile(joinpath(env['SRCDIR'], 'encumbered/SConscript')): 2444773Snate@binkert.org sources += SConscript('encumbered/SConscript', exports = 'env') 2455863Snate@binkert.org 2461858SN/A 2471085SN/Aif env['FULL_SYSTEM']: 2484382Sbinkertn@umich.edu sources += full_system_sources 2494382Sbinkertn@umich.eduelse: 2504762Snate@binkert.org sources += syscall_emulation_sources 2514762Snate@binkert.org 2524762Snate@binkert.orgif env['USE_MYSQL']: 2535517Snate@binkert.org sources += mysql_sources 2545517Snate@binkert.org 2555517Snate@binkert.orgfor opt in env.ExportOptions: 2565517Snate@binkert.org env.ConfigFile(opt) 2575517Snate@binkert.org 2585517Snate@binkert.org################################################### 2595517Snate@binkert.org# 2605517Snate@binkert.org# Special build rules. 2615517Snate@binkert.org# 2625517Snate@binkert.org################################################### 2635517Snate@binkert.org 2645517Snate@binkert.org# base/traceflags.{cc,hh} are generated from base/traceflags.py. 2655517Snate@binkert.org# $TARGET.base will expand to "<build-dir>/base/traceflags". 2665517Snate@binkert.orgenv.Command(Split('base/traceflags.hh base/traceflags.cc'), 2675517Snate@binkert.org 'base/traceflags.py', 2685517Snate@binkert.org 'python $SOURCE $TARGET.base') 2695517Snate@binkert.org 2705798Snate@binkert.orgSConscript('python/SConscript', exports = ['env']) 2715517Snate@binkert.org 2725517Snate@binkert.org# This function adds the specified sources to the given build 2735517Snate@binkert.org# environment, and returns a list of all the corresponding SCons 2745517Snate@binkert.org# Object nodes (including an extra one for date.cc). We explicitly 2755517Snate@binkert.org# add the Object nodes so we can set up special dependencies for 2765517Snate@binkert.org# date.cc. 2775517Snate@binkert.orgdef make_objs(sources, env): 2785517Snate@binkert.org objs = [env.Object(s) for s in sources] 2795517Snate@binkert.org # make date.cc depend on all other objects so it always gets 2805517Snate@binkert.org # recompiled whenever anything else does 2815517Snate@binkert.org date_obj = env.Object('base/date.cc') 2825517Snate@binkert.org env.Depends(date_obj, objs) 2835517Snate@binkert.org objs.append(date_obj) 2845517Snate@binkert.org return objs 2855517Snate@binkert.org 2865517Snate@binkert.org################################################### 2875517Snate@binkert.org# 2885517Snate@binkert.org# Define binaries. Each different build type (debug, opt, etc.) gets 2895517Snate@binkert.org# a slightly different build environment. 2905517Snate@binkert.org# 2915517Snate@binkert.org################################################### 2925517Snate@binkert.org 2935517Snate@binkert.org# List of constructed environments to pass back to SConstruct 2945798Snate@binkert.orgenvList = [] 2955798Snate@binkert.org 2965517Snate@binkert.org# Function to create a new build environment as clone of current 2975517Snate@binkert.org# environment 'env' with modified object suffix and optional stripped 2985517Snate@binkert.org# binary. Additional keyword arguments are appended to corresponding 2995517Snate@binkert.org# build environment vars. 3005517Snate@binkert.orgdef makeEnv(label, objsfx, strip = False, **kwargs): 3015517Snate@binkert.org newEnv = env.Copy(OBJSUFFIX=objsfx) 3025517Snate@binkert.org newEnv.Label = label 3035517Snate@binkert.org newEnv.Append(**kwargs) 3045517Snate@binkert.org exe = 'm5.' + label # final executable 3055517Snate@binkert.org bin = exe + '.bin' # executable w/o appended Python zip archive 3065517Snate@binkert.org newEnv.Program(bin, make_objs(sources, newEnv)) 3075517Snate@binkert.org if strip: 3085517Snate@binkert.org stripped_bin = bin + '.stripped' 3095522Snate@binkert.org if sys.platform == 'sunos5': 3105517Snate@binkert.org newEnv.Command(stripped_bin, bin, 'cp $SOURCE $TARGET; strip $TARGET') 3115517Snate@binkert.org else: 3125517Snate@binkert.org newEnv.Command(stripped_bin, bin, 'strip $SOURCE -o $TARGET') 3135517Snate@binkert.org bin = stripped_bin 3144762Snate@binkert.org targets = newEnv.Concat(exe, [bin, 'python/m5py.zip']) 3155517Snate@binkert.org newEnv.M5Binary = targets[0] 3165517Snate@binkert.org envList.append(newEnv) 3174762Snate@binkert.org 3185517Snate@binkert.org# Debug binary 3194762Snate@binkert.orgccflags = {} 3205517Snate@binkert.orgif env['GCC']: 3215517Snate@binkert.org if sys.platform == 'sunos5': 3225517Snate@binkert.org ccflags['debug'] = '-gstabs+' 3235517Snate@binkert.org else: 3245517Snate@binkert.org ccflags['debug'] = '-ggdb3' 3255517Snate@binkert.org ccflags['opt'] = '-g -O3' 3265517Snate@binkert.org ccflags['fast'] = '-O3' 3275517Snate@binkert.org ccflags['prof'] = '-O3 -g -pg' 3285517Snate@binkert.orgelif env['SUNCC']: 3295517Snate@binkert.org ccflags['debug'] = '-g0' 3305517Snate@binkert.org ccflags['opt'] = '-g -O' 3315517Snate@binkert.org ccflags['fast'] = '-fast' 3325517Snate@binkert.org ccflags['prof'] = '-fast -g -pg' 3335517Snate@binkert.orgelif env['ICC']: 3345517Snate@binkert.org ccflags['debug'] = '-g -O0' 3355517Snate@binkert.org ccflags['opt'] = '-g -O' 3365517Snate@binkert.org ccflags['fast'] = '-fast' 3375517Snate@binkert.org ccflags['prof'] = '-fast -g -pg' 3385517Snate@binkert.orgelse: 3395517Snate@binkert.org print 'Unknown compiler, please fix compiler options' 3405517Snate@binkert.org Exit(1) 3415517Snate@binkert.org 3425517Snate@binkert.orgmakeEnv('debug', '.do', 3434762Snate@binkert.org CCFLAGS = Split(ccflags['debug']), 3444762Snate@binkert.org CPPDEFINES = ['DEBUG', 'TRACING_ON=1']) 3454762Snate@binkert.org 3464762Snate@binkert.org# Optimized binary 3474762Snate@binkert.orgmakeEnv('opt', '.o', 3484762Snate@binkert.org CCFLAGS = Split(ccflags['opt']), 3495517Snate@binkert.org CPPDEFINES = ['TRACING_ON=1']) 3504762Snate@binkert.org 3514762Snate@binkert.org# "Fast" binary 3524762Snate@binkert.orgmakeEnv('fast', '.fo', strip = True, 3534762Snate@binkert.org CCFLAGS = Split(ccflags['fast']), 3544382Sbinkertn@umich.edu CPPDEFINES = ['NDEBUG', 'TRACING_ON=0']) 3554382Sbinkertn@umich.edu 3565517Snate@binkert.org# Profiled binary 3575517Snate@binkert.orgmakeEnv('prof', '.po', 3585517Snate@binkert.org CCFLAGS = Split(ccflags['prof']), 3595517Snate@binkert.org CPPDEFINES = ['NDEBUG', 'TRACING_ON=0'], 3605798Snate@binkert.org LINKFLAGS = '-pg') 3615798Snate@binkert.org 3625824Ssaidi@eecs.umich.eduReturn('envList') 3635517Snate@binkert.org