SConscript revision 4123
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#
292665Ssaidi@eecs.umich.edu# Authors: Steve Reinhardt
30955SN/A
31955SN/Aimport os
32955SN/Aimport sys
333583Sbinkertn@umich.edufrom os.path import isfile, join as joinpath
34955SN/A
35955SN/A# This file defines how to build a particular configuration of M5
36955SN/A# based on variable settings in the 'env' build environment.
37955SN/A
38955SN/A# Import build environment variable from SConstruct.
39955SN/AImport('env')
40955SN/A
41955SN/A###################################################
42955SN/A#
43955SN/A# Define needed sources.
44955SN/A#
45955SN/A###################################################
46955SN/A
47955SN/A# Base sources used by all configurations.
482023SN/A
49955SN/Abase_sources = Split('''
503089Ssaidi@eecs.umich.edu	base/annotate.cc
51955SN/A	base/circlebuf.cc
52955SN/A	base/cprintf.cc
53955SN/A	base/fast_alloc.cc
54955SN/A	base/fifo_buffer.cc
55955SN/A	base/hostinfo.cc
56955SN/A	base/hybrid_pred.cc
57955SN/A	base/inifile.cc
58955SN/A	base/intmath.cc
591031SN/A	base/match.cc
60955SN/A	base/misc.cc
611388SN/A	base/output.cc
62955SN/A	base/pollevent.cc
63955SN/A	base/range.cc
641296SN/A	base/random.cc
653960Sgblack@eecs.umich.edu	base/remote_gdb.cc
66955SN/A	base/sat_counter.cc
67955SN/A	base/socket.cc
68955SN/A	base/statistics.cc
69955SN/A	base/str.cc
70955SN/A	base/time.cc
71955SN/A	base/trace.cc
72955SN/A	base/traceflags.cc
73955SN/A	base/userinfo.cc
74955SN/A	base/compression/lzss_compression.cc
75955SN/A	base/loader/aout_object.cc
76955SN/A	base/loader/ecoff_object.cc
77955SN/A	base/loader/elf_object.cc
783584Ssaidi@eecs.umich.edu	base/loader/raw_object.cc
79955SN/A	base/loader/object_file.cc
80955SN/A	base/loader/symtab.cc
81955SN/A	base/stats/events.cc
824078Sbinkertn@umich.edu        base/stats/output.cc
83955SN/A	base/stats/statdb.cc
84955SN/A	base/stats/visit.cc
85955SN/A	base/stats/text.cc
86955SN/A
872325SN/A        cpu/activity.cc
881717SN/A	cpu/base.cc
892652Ssaidi@eecs.umich.edu	cpu/cpuevent.cc
90955SN/A	cpu/exetrace.cc
912736Sktlim@umich.edu        cpu/func_unit.cc
922410SN/A        cpu/op_class.cc
93955SN/A	cpu/pc_event.cc
942290SN/A        cpu/quiesce_event.cc
95955SN/A	cpu/static_inst.cc
962683Sktlim@umich.edu        cpu/simple_thread.cc
972683Sktlim@umich.edu        cpu/thread_state.cc
982669Sktlim@umich.edu
992568SN/A        mem/bridge.cc
1002568SN/A        mem/bus.cc
1013012Ssaidi@eecs.umich.edu        mem/dram.cc
1022462SN/A        mem/mem_object.cc
1032568SN/A        mem/packet.cc
1042395SN/A        mem/physical.cc
1052405SN/A        mem/port.cc
1062914Ssaidi@eecs.umich.edu        mem/tport.cc
107955SN/A
1082811Srdreslin@umich.edu        mem/cache/base_cache.cc
1092811Srdreslin@umich.edu        mem/cache/cache.cc
1102811Srdreslin@umich.edu        mem/cache/coherence/coherence_protocol.cc
1112811Srdreslin@umich.edu        mem/cache/coherence/uni_coherence.cc
1122811Srdreslin@umich.edu        mem/cache/miss/blocking_buffer.cc
1133719Sstever@eecs.umich.edu        mem/cache/miss/miss_buffer.cc
1142811Srdreslin@umich.edu        mem/cache/miss/miss_queue.cc
1152811Srdreslin@umich.edu        mem/cache/miss/mshr.cc
1162811Srdreslin@umich.edu        mem/cache/miss/mshr_queue.cc
1172811Srdreslin@umich.edu        mem/cache/prefetch/base_prefetcher.cc
1182811Srdreslin@umich.edu        mem/cache/prefetch/ghb_prefetcher.cc
1192811Srdreslin@umich.edu        mem/cache/prefetch/stride_prefetcher.cc
1202811Srdreslin@umich.edu        mem/cache/prefetch/tagged_prefetcher.cc
1212811Srdreslin@umich.edu        mem/cache/tags/base_tags.cc
1222811Srdreslin@umich.edu        mem/cache/tags/fa_lru.cc
1232814Srdreslin@umich.edu        mem/cache/tags/iic.cc
1242811Srdreslin@umich.edu        mem/cache/tags/lru.cc
1252811Srdreslin@umich.edu        mem/cache/tags/repl/gen.cc
1262811Srdreslin@umich.edu        mem/cache/tags/repl/repl.cc
1272811Srdreslin@umich.edu        mem/cache/tags/split.cc
1282811Srdreslin@umich.edu        mem/cache/tags/split_lifo.cc
1292811Srdreslin@umich.edu        mem/cache/tags/split_lru.cc
1302811Srdreslin@umich.edu
1312813Srdreslin@umich.edu        mem/cache/cache_builder.cc
1322813Srdreslin@umich.edu
1333868Sbinkertn@umich.edu        python/swig/init.cc
1344123Sbinkertn@umich.edu        python/swig/core_wrap.cc
1353645Sbinkertn@umich.edu        python/swig/debug_wrap.cc
1363871Sbinkertn@umich.edu        python/swig/event_wrap.cc
1374045Sbinkertn@umich.edu        python/swig/random_wrap.cc
1384123Sbinkertn@umich.edu        python/swig/sim_object_wrap.cc
1394078Sbinkertn@umich.edu        python/swig/stats_wrap.cc
1404042Sbinkertn@umich.edu        python/swig/trace_wrap.cc
1413871Sbinkertn@umich.edu        python/swig/pyevent.cc
1424123Sbinkertn@umich.edu        python/swig/pyobject.cc
1433624Sbinkertn@umich.edu
1444123Sbinkertn@umich.edu        sim/async.cc
145955SN/A	sim/builder.cc
1464123Sbinkertn@umich.edu        sim/core.cc
147955SN/A	sim/debug.cc
148955SN/A	sim/eventq.cc
1492090SN/A	sim/faults.cc
150955SN/A	sim/main.cc
151955SN/A	sim/param.cc
1521696SN/A	sim/root.cc
153955SN/A	sim/serialize.cc
154955SN/A	sim/sim_events.cc
155955SN/A	sim/sim_object.cc
1564123Sbinkertn@umich.edu        sim/simulate.cc
1571127SN/A	sim/startup.cc
158955SN/A	sim/stat_control.cc
1592379SN/A	sim/system.cc
160955SN/A        ''')
161955SN/A
1622422SN/Atrace_reader_sources = Split('''
1632422SN/A        cpu/trace/reader/mem_trace_reader.cc
1642422SN/A        cpu/trace/reader/ibm_reader.cc
1652422SN/A        cpu/trace/reader/itx_reader.cc
1662422SN/A        cpu/trace/reader/m5_reader.cc
1672422SN/A        cpu/trace/opt_cpu.cc
1682422SN/A        cpu/trace/trace_cpu.cc
1692397SN/A        ''')
1702397SN/A
1712422SN/A
1722422SN/A
173955SN/A# MySql sources
174955SN/Amysql_sources = Split('''
175955SN/A	base/mysql.cc
176955SN/A	base/stats/mysql.cc
177955SN/A        ''')
178955SN/A
179955SN/A# Full-system sources
180955SN/Afull_system_sources = Split('''
1811078SN/A	base/crc.cc
182955SN/A	base/inet.cc
183955SN/A
184955SN/A	cpu/intr_control.cc
1851917SN/A        cpu/profile.cc
186955SN/A
187955SN/A	dev/uart.cc
1881730SN/A	dev/uart8250.cc
189955SN/A
1902521SN/A        mem/vport.cc
1912521SN/A
1922507SN/A	sim/pseudo_inst.cc
1932507SN/A        ''')
1942989Ssaidi@eecs.umich.edu	#dev/sinic.cc
1953408Ssaidi@eecs.umich.edu        #dev/i8254xGBe.cc
1962507SN/A
1972507SN/Aif env['TARGET_ISA'] == 'alpha':
1982507SN/A    full_system_sources += Split('''
199955SN/A	kern/tru64/dump_mbuf.cc
200955SN/A	kern/tru64/printf.cc
201955SN/A	kern/tru64/tru64_events.cc
202955SN/A	kern/tru64/tru64_syscalls.cc
203955SN/A        ''')
204955SN/A
205955SN/A# Syscall emulation (non-full-system) sources
206955SN/Asyscall_emulation_sources = Split('''
2072520SN/A        mem/translating_port.cc
2082517SN/A        mem/page_table.cc
2092253SN/A	sim/process.cc
2102253SN/A	sim/syscall_emul.cc
2112253SN/A        ''')
2122253SN/A
2132553SN/A#if env['TARGET_ISA'] == 'alpha':
2142553SN/A#    syscall_emulation_sources += Split('''
2152553SN/A#        kern/tru64/tru64.cc
2162553SN/A#        ''')
2172507SN/A
2182400SN/Amemtest_sources = Split('''
2192400SN/A	cpu/memtest/memtest.cc
220955SN/A        ''')
221955SN/A
2222667Sstever@eecs.umich.edu# Include file paths are rooted in this directory.  SCons will
2232667Sstever@eecs.umich.edu# automatically expand '.' to refer to both the source directory and
2242667Sstever@eecs.umich.edu# the corresponding build directory to pick up generated include
2252667Sstever@eecs.umich.edu# files.
2262667Sstever@eecs.umich.eduenv.Append(CPPPATH=Dir('.'))
2272667Sstever@eecs.umich.edu
2282037SN/A# Add a flag defining what THE_ISA should be for all compilation
2292037SN/Aenv.Append(CPPDEFINES=[('THE_ISA','%s_ISA' % env['TARGET_ISA'].upper())])
2302037SN/A
2313534Sgblack@eecs.umich.eduarch_sources = SConscript(os.path.join('arch', 'SConscript'), exports = 'env')
2322139SN/A
2333534Sgblack@eecs.umich.educpu_sources = SConscript(os.path.join('cpu', 'SConscript'), exports = 'env')
2343534Sgblack@eecs.umich.edu
2353542Sgblack@eecs.umich.eduif env['FULL_SYSTEM']:
2363583Sbinkertn@umich.edu    dev_sources = SConscript(os.path.join('dev', 'SConscript'),
2373583Sbinkertn@umich.edu                             exports = 'env')
2383542Sgblack@eecs.umich.edu    full_system_sources += dev_sources
2393499Ssaidi@eecs.umich.edu
2403583Sbinkertn@umich.edu    kern_sources = SConscript(os.path.join('kern', 'SConscript'),
2413583Sbinkertn@umich.edu                              exports = 'env')
2423547Sgblack@eecs.umich.edu    full_system_sources += kern_sources
2432155SN/A
244955SN/A# Set up complete list of sources based on configuration.
2452155SN/Asources = base_sources + arch_sources + cpu_sources
246955SN/A
2473583Sbinkertn@umich.edu# encumbered should be last because we're adding to some of the other groups
2483583Sbinkertn@umich.eduif isfile(joinpath(env['SRCDIR'], 'encumbered/SConscript')):
2493583Sbinkertn@umich.edu    sources += SConscript('encumbered/SConscript', exports = 'env')
2503583Sbinkertn@umich.edu
2513583Sbinkertn@umich.edu
252955SN/Aif env['FULL_SYSTEM']:
253955SN/A    sources += full_system_sources
254955SN/Aelse:
255955SN/A    sources += syscall_emulation_sources
256955SN/A
2571858SN/Aif env['USE_MYSQL']:
258955SN/A    sources += mysql_sources
2591858SN/A
2601858SN/Afor opt in env.ExportOptions:
2611858SN/A    env.ConfigFile(opt)
2621085SN/A
263955SN/A###################################################
264955SN/A#
265955SN/A# Special build rules.
266955SN/A#
267955SN/A###################################################
268955SN/A
269955SN/A# base/traceflags.{cc,hh} are generated from base/traceflags.py.
270955SN/A# $TARGET.base will expand to "<build-dir>/base/traceflags".
271955SN/Aenv.Command(Split('base/traceflags.hh base/traceflags.cc'),
272955SN/A            'base/traceflags.py',
273955SN/A            'python $SOURCE $TARGET.base')
274955SN/A
2752667Sstever@eecs.umich.eduSConscript('python/SConscript', exports = ['env'])
2761045SN/A
277955SN/A# This function adds the specified sources to the given build
278955SN/A# environment, and returns a list of all the corresponding SCons
279955SN/A# Object nodes (including an extra one for date.cc).  We explicitly
280955SN/A# add the Object nodes so we can set up special dependencies for
2811108SN/A# date.cc.
282955SN/Adef make_objs(sources, env):
283955SN/A    objs = [env.Object(s) for s in sources]
284955SN/A    # make date.cc depend on all other objects so it always gets
285955SN/A    # recompiled whenever anything else does
286955SN/A    date_obj = env.Object('base/date.cc')
287955SN/A    env.Depends(date_obj, objs)
288955SN/A    objs.append(date_obj)
289955SN/A    return objs
290955SN/A
291955SN/A###################################################
292955SN/A#
293955SN/A# Define binaries.  Each different build type (debug, opt, etc.) gets
294955SN/A# a slightly different build environment.
295955SN/A#
296955SN/A###################################################
297955SN/A
2982655Sstever@eecs.umich.edu# List of constructed environments to pass back to SConstruct
2992655Sstever@eecs.umich.eduenvList = []
3002655Sstever@eecs.umich.edu
3012655Sstever@eecs.umich.edu# Function to create a new build environment as clone of current
3022655Sstever@eecs.umich.edu# environment 'env' with modified object suffix and optional stripped
3032655Sstever@eecs.umich.edu# binary.  Additional keyword arguments are appended to corresponding
3042655Sstever@eecs.umich.edu# build environment vars.
3052655Sstever@eecs.umich.edudef makeEnv(label, objsfx, strip = False, **kwargs):
3062655Sstever@eecs.umich.edu    newEnv = env.Copy(OBJSUFFIX=objsfx)
3072655Sstever@eecs.umich.edu    newEnv.Label = label
3082655Sstever@eecs.umich.edu    newEnv.Append(**kwargs)
3092655Sstever@eecs.umich.edu    exe = 'm5.' + label  # final executable
3102655Sstever@eecs.umich.edu    bin = exe + '.bin'   # executable w/o appended Python zip archive
3112655Sstever@eecs.umich.edu    newEnv.Program(bin, make_objs(sources, newEnv))
3122655Sstever@eecs.umich.edu    if strip:
3132655Sstever@eecs.umich.edu        stripped_bin = bin + '.stripped'
3144007Ssaidi@eecs.umich.edu        if sys.platform == 'sunos5':
3154007Ssaidi@eecs.umich.edu            newEnv.Command(stripped_bin, bin, 'cp $SOURCE $TARGET; strip $TARGET')
3164007Ssaidi@eecs.umich.edu        else:
3174007Ssaidi@eecs.umich.edu            newEnv.Command(stripped_bin, bin, 'strip $SOURCE -o $TARGET')
3182655Sstever@eecs.umich.edu        bin = stripped_bin
3192655Sstever@eecs.umich.edu    targets = newEnv.Concat(exe, [bin, 'python/m5py.zip'])
3202655Sstever@eecs.umich.edu    newEnv.M5Binary = targets[0]
3212655Sstever@eecs.umich.edu    envList.append(newEnv)
3222655Sstever@eecs.umich.edu
323955SN/A# Debug binary
3243918Ssaidi@eecs.umich.educcflags = {}
3253918Ssaidi@eecs.umich.eduif env['GCC']:
3263918Ssaidi@eecs.umich.edu    if sys.platform == 'sunos5':
3273918Ssaidi@eecs.umich.edu        ccflags['debug'] = '-gstabs+'
3283918Ssaidi@eecs.umich.edu    else:
3293918Ssaidi@eecs.umich.edu        ccflags['debug'] = '-ggdb3'
3303918Ssaidi@eecs.umich.edu    ccflags['opt'] = '-g -O3'
3313918Ssaidi@eecs.umich.edu    ccflags['fast'] = '-O3'
3323918Ssaidi@eecs.umich.edu    ccflags['prof'] = '-O3 -g -pg'
3333918Ssaidi@eecs.umich.eduelif env['SUNCC']:
3343918Ssaidi@eecs.umich.edu    ccflags['debug'] = '-g0'
3353918Ssaidi@eecs.umich.edu    ccflags['opt'] = '-g -O'
3363918Ssaidi@eecs.umich.edu    ccflags['fast'] = '-fast'
3373918Ssaidi@eecs.umich.edu    ccflags['prof'] = '-fast -g -pg'
3383940Ssaidi@eecs.umich.eduelif env['ICC']:
3393940Ssaidi@eecs.umich.edu    ccflags['debug'] = '-g -O0'
3403940Ssaidi@eecs.umich.edu    ccflags['opt'] = '-g -O'
3413942Ssaidi@eecs.umich.edu    ccflags['fast'] = '-fast'
3423940Ssaidi@eecs.umich.edu    ccflags['prof'] = '-fast -g -pg'
3433515Ssaidi@eecs.umich.eduelse:
3443918Ssaidi@eecs.umich.edu    print 'Unknown compiler, please fix compiler options'
3453918Ssaidi@eecs.umich.edu    Exit(1)    
3463515Ssaidi@eecs.umich.edu
3472655Sstever@eecs.umich.edumakeEnv('debug', '.do',
3483918Ssaidi@eecs.umich.edu        CCFLAGS = Split(ccflags['debug']),
3493619Sbinkertn@umich.edu        CPPDEFINES = ['DEBUG', 'TRACING_ON=1'])
350955SN/A
351955SN/A# Optimized binary
3522655Sstever@eecs.umich.edumakeEnv('opt', '.o',
3533918Ssaidi@eecs.umich.edu        CCFLAGS = Split(ccflags['opt']),
3543619Sbinkertn@umich.edu        CPPDEFINES = ['TRACING_ON=1'])
355955SN/A
356955SN/A# "Fast" binary
3572655Sstever@eecs.umich.edumakeEnv('fast', '.fo', strip = True,
3583918Ssaidi@eecs.umich.edu        CCFLAGS = Split(ccflags['fast']),
3593619Sbinkertn@umich.edu        CPPDEFINES = ['NDEBUG', 'TRACING_ON=0'])
360955SN/A
361955SN/A# Profiled binary
3622655Sstever@eecs.umich.edumakeEnv('prof', '.po',
3633918Ssaidi@eecs.umich.edu        CCFLAGS = Split(ccflags['prof']),
3643683Sstever@eecs.umich.edu        CPPDEFINES = ['NDEBUG', 'TRACING_ON=0'],
3652655Sstever@eecs.umich.edu        LINKFLAGS = '-pg')
3661869SN/A
3671869SN/AReturn('envList')
368