SConscript revision 3624
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
65955SN/A	base/sat_counter.cc
66955SN/A	base/socket.cc
67955SN/A	base/statistics.cc
68955SN/A	base/str.cc
69955SN/A	base/time.cc
70955SN/A	base/trace.cc
71955SN/A	base/traceflags.cc
72955SN/A	base/userinfo.cc
73955SN/A	base/compression/lzss_compression.cc
74955SN/A	base/loader/aout_object.cc
75955SN/A	base/loader/ecoff_object.cc
76955SN/A	base/loader/elf_object.cc
773584Ssaidi@eecs.umich.edu	base/loader/raw_object.cc
78955SN/A	base/loader/object_file.cc
79955SN/A	base/loader/symtab.cc
80955SN/A	base/stats/events.cc
81955SN/A	base/stats/statdb.cc
82955SN/A	base/stats/visit.cc
83955SN/A	base/stats/text.cc
84955SN/A
852325SN/A        cpu/activity.cc
861717SN/A	cpu/base.cc
872652Ssaidi@eecs.umich.edu	cpu/cpuevent.cc
88955SN/A	cpu/exetrace.cc
892736Sktlim@umich.edu        cpu/func_unit.cc
902410SN/A        cpu/op_class.cc
91955SN/A	cpu/pc_event.cc
922290SN/A        cpu/quiesce_event.cc
93955SN/A	cpu/static_inst.cc
942683Sktlim@umich.edu        cpu/simple_thread.cc
952683Sktlim@umich.edu        cpu/thread_state.cc
962669Sktlim@umich.edu
972568SN/A        mem/bridge.cc
982568SN/A        mem/bus.cc
993012Ssaidi@eecs.umich.edu        mem/dram.cc
1002462SN/A        mem/mem_object.cc
1012568SN/A        mem/packet.cc
1022395SN/A        mem/physical.cc
1032405SN/A        mem/port.cc
1042914Ssaidi@eecs.umich.edu        mem/tport.cc
105955SN/A
1062811Srdreslin@umich.edu        mem/cache/base_cache.cc
1072811Srdreslin@umich.edu        mem/cache/cache.cc
1082811Srdreslin@umich.edu        mem/cache/coherence/coherence_protocol.cc
1092811Srdreslin@umich.edu        mem/cache/coherence/uni_coherence.cc
1102811Srdreslin@umich.edu        mem/cache/miss/blocking_buffer.cc
1112811Srdreslin@umich.edu        mem/cache/miss/miss_queue.cc
1122811Srdreslin@umich.edu        mem/cache/miss/mshr.cc
1132811Srdreslin@umich.edu        mem/cache/miss/mshr_queue.cc
1142811Srdreslin@umich.edu        mem/cache/prefetch/base_prefetcher.cc
1152811Srdreslin@umich.edu        mem/cache/prefetch/ghb_prefetcher.cc
1162811Srdreslin@umich.edu        mem/cache/prefetch/prefetcher.cc
1172811Srdreslin@umich.edu        mem/cache/prefetch/stride_prefetcher.cc
1182811Srdreslin@umich.edu        mem/cache/prefetch/tagged_prefetcher.cc
1192811Srdreslin@umich.edu        mem/cache/tags/base_tags.cc
1202811Srdreslin@umich.edu        mem/cache/tags/cache_tags.cc
1212811Srdreslin@umich.edu        mem/cache/tags/fa_lru.cc
1222814Srdreslin@umich.edu        mem/cache/tags/iic.cc
1232811Srdreslin@umich.edu        mem/cache/tags/lru.cc
1242811Srdreslin@umich.edu        mem/cache/tags/repl/gen.cc
1252811Srdreslin@umich.edu        mem/cache/tags/repl/repl.cc
1262811Srdreslin@umich.edu        mem/cache/tags/split.cc
1272811Srdreslin@umich.edu        mem/cache/tags/split_lifo.cc
1282811Srdreslin@umich.edu        mem/cache/tags/split_lru.cc
1292811Srdreslin@umich.edu
1302813Srdreslin@umich.edu        mem/cache/cache_builder.cc
1312813Srdreslin@umich.edu
1323624Sbinkertn@umich.edu        python/swig/main_wrap.cc
1333624Sbinkertn@umich.edu
134955SN/A	sim/builder.cc
135955SN/A	sim/debug.cc
136955SN/A	sim/eventq.cc
1372090SN/A	sim/faults.cc
138955SN/A	sim/main.cc
139955SN/A	sim/param.cc
1401696SN/A	sim/root.cc
141955SN/A	sim/serialize.cc
142955SN/A	sim/sim_events.cc
143955SN/A	sim/sim_object.cc
1441127SN/A	sim/startup.cc
145955SN/A	sim/stat_context.cc
146955SN/A	sim/stat_control.cc
1472379SN/A	sim/system.cc
148955SN/A	sim/trace_context.cc
149955SN/A        ''')
150955SN/A
1512422SN/Atrace_reader_sources = Split('''
1522422SN/A        cpu/trace/reader/mem_trace_reader.cc
1532422SN/A        cpu/trace/reader/ibm_reader.cc
1542422SN/A        cpu/trace/reader/itx_reader.cc
1552422SN/A        cpu/trace/reader/m5_reader.cc
1562422SN/A        cpu/trace/opt_cpu.cc
1572422SN/A        cpu/trace/trace_cpu.cc
1582397SN/A        ''')
1592397SN/A
1602422SN/A
1612422SN/A
162955SN/A# MySql sources
163955SN/Amysql_sources = Split('''
164955SN/A	base/mysql.cc
165955SN/A	base/stats/mysql.cc
166955SN/A        ''')
167955SN/A
168955SN/A# Full-system sources
169955SN/Afull_system_sources = Split('''
1701078SN/A	base/crc.cc
171955SN/A	base/inet.cc
172955SN/A	base/remote_gdb.cc
173955SN/A
174955SN/A	cpu/intr_control.cc
1751917SN/A        cpu/profile.cc
176955SN/A
177955SN/A	dev/uart.cc
1781730SN/A	dev/uart8250.cc
179955SN/A
1802521SN/A        mem/vport.cc
1812521SN/A
1822507SN/A	sim/pseudo_inst.cc
1832507SN/A        ''')
1842989Ssaidi@eecs.umich.edu	#dev/sinic.cc
1853408Ssaidi@eecs.umich.edu        #dev/i8254xGBe.cc
1862507SN/A
1872507SN/Aif env['TARGET_ISA'] == 'alpha':
1882507SN/A    full_system_sources += Split('''
189955SN/A	kern/tru64/dump_mbuf.cc
190955SN/A	kern/tru64/printf.cc
191955SN/A	kern/tru64/tru64_events.cc
192955SN/A	kern/tru64/tru64_syscalls.cc
193955SN/A        ''')
194955SN/A
195955SN/A# Syscall emulation (non-full-system) sources
196955SN/Asyscall_emulation_sources = Split('''
1972520SN/A        mem/translating_port.cc
1982517SN/A        mem/page_table.cc
1992253SN/A	sim/process.cc
2002253SN/A	sim/syscall_emul.cc
2012253SN/A        ''')
2022253SN/A
2032553SN/A#if env['TARGET_ISA'] == 'alpha':
2042553SN/A#    syscall_emulation_sources += Split('''
2052553SN/A#        kern/tru64/tru64.cc
2062553SN/A#        ''')
2072507SN/A
2082400SN/Amemtest_sources = Split('''
2092400SN/A	cpu/memtest/memtest.cc
210955SN/A        ''')
211955SN/A
2122667Sstever@eecs.umich.edu# Include file paths are rooted in this directory.  SCons will
2132667Sstever@eecs.umich.edu# automatically expand '.' to refer to both the source directory and
2142667Sstever@eecs.umich.edu# the corresponding build directory to pick up generated include
2152667Sstever@eecs.umich.edu# files.
2162667Sstever@eecs.umich.eduenv.Append(CPPPATH=Dir('.'))
2172667Sstever@eecs.umich.edu
2182037SN/A# Add a flag defining what THE_ISA should be for all compilation
2192037SN/Aenv.Append(CPPDEFINES=[('THE_ISA','%s_ISA' % env['TARGET_ISA'].upper())])
2202037SN/A
2213534Sgblack@eecs.umich.eduarch_sources = SConscript(os.path.join('arch', 'SConscript'), exports = 'env')
2222139SN/A
2233534Sgblack@eecs.umich.educpu_sources = SConscript(os.path.join('cpu', 'SConscript'), exports = 'env')
2243534Sgblack@eecs.umich.edu
2253542Sgblack@eecs.umich.eduif env['FULL_SYSTEM']:
2263583Sbinkertn@umich.edu    dev_sources = SConscript(os.path.join('dev', 'SConscript'),
2273583Sbinkertn@umich.edu                             exports = 'env')
2283542Sgblack@eecs.umich.edu    full_system_sources += dev_sources
2293499Ssaidi@eecs.umich.edu
2303583Sbinkertn@umich.edu    kern_sources = SConscript(os.path.join('kern', 'SConscript'),
2313583Sbinkertn@umich.edu                              exports = 'env')
2323547Sgblack@eecs.umich.edu    full_system_sources += kern_sources
2332155SN/A
234955SN/A# Set up complete list of sources based on configuration.
2352155SN/Asources = base_sources + arch_sources + cpu_sources
236955SN/A
2373583Sbinkertn@umich.edu# encumbered should be last because we're adding to some of the other groups
2383583Sbinkertn@umich.eduif isfile(joinpath(env['SRCDIR'], 'encumbered/SConscript')):
2393583Sbinkertn@umich.edu    sources += SConscript('encumbered/SConscript', exports = 'env')
2403583Sbinkertn@umich.edu
2413583Sbinkertn@umich.edu
242955SN/Aif env['FULL_SYSTEM']:
243955SN/A    sources += full_system_sources
244955SN/Aelse:
245955SN/A    sources += syscall_emulation_sources
246955SN/A
2471858SN/Aif env['USE_MYSQL']:
248955SN/A    sources += mysql_sources
2491858SN/A
2501858SN/Afor opt in env.ExportOptions:
2511858SN/A    env.ConfigFile(opt)
2521085SN/A
253955SN/A###################################################
254955SN/A#
255955SN/A# Special build rules.
256955SN/A#
257955SN/A###################################################
258955SN/A
259955SN/A# base/traceflags.{cc,hh} are generated from base/traceflags.py.
260955SN/A# $TARGET.base will expand to "<build-dir>/base/traceflags".
261955SN/Aenv.Command(Split('base/traceflags.hh base/traceflags.cc'),
262955SN/A            'base/traceflags.py',
263955SN/A            'python $SOURCE $TARGET.base')
264955SN/A
2652667Sstever@eecs.umich.eduSConscript('python/SConscript', exports = ['env'])
2661045SN/A
267955SN/A# This function adds the specified sources to the given build
268955SN/A# environment, and returns a list of all the corresponding SCons
269955SN/A# Object nodes (including an extra one for date.cc).  We explicitly
270955SN/A# add the Object nodes so we can set up special dependencies for
2711108SN/A# date.cc.
272955SN/Adef make_objs(sources, env):
273955SN/A    objs = [env.Object(s) for s in sources]
274955SN/A    # make date.cc depend on all other objects so it always gets
275955SN/A    # recompiled whenever anything else does
276955SN/A    date_obj = env.Object('base/date.cc')
277955SN/A    env.Depends(date_obj, objs)
278955SN/A    objs.append(date_obj)
279955SN/A    return objs
280955SN/A
281955SN/A###################################################
282955SN/A#
283955SN/A# Define binaries.  Each different build type (debug, opt, etc.) gets
284955SN/A# a slightly different build environment.
285955SN/A#
286955SN/A###################################################
287955SN/A
2882655Sstever@eecs.umich.edu# List of constructed environments to pass back to SConstruct
2892655Sstever@eecs.umich.eduenvList = []
2902655Sstever@eecs.umich.edu
2912655Sstever@eecs.umich.edu# Function to create a new build environment as clone of current
2922655Sstever@eecs.umich.edu# environment 'env' with modified object suffix and optional stripped
2932655Sstever@eecs.umich.edu# binary.  Additional keyword arguments are appended to corresponding
2942655Sstever@eecs.umich.edu# build environment vars.
2952655Sstever@eecs.umich.edudef makeEnv(label, objsfx, strip = False, **kwargs):
2962655Sstever@eecs.umich.edu    newEnv = env.Copy(OBJSUFFIX=objsfx)
2972655Sstever@eecs.umich.edu    newEnv.Label = label
2982655Sstever@eecs.umich.edu    newEnv.Append(**kwargs)
2992655Sstever@eecs.umich.edu    exe = 'm5.' + label  # final executable
3002655Sstever@eecs.umich.edu    bin = exe + '.bin'   # executable w/o appended Python zip archive
3012655Sstever@eecs.umich.edu    newEnv.Program(bin, make_objs(sources, newEnv))
3022655Sstever@eecs.umich.edu    if strip:
3032655Sstever@eecs.umich.edu        stripped_bin = bin + '.stripped'
3042655Sstever@eecs.umich.edu        newEnv.Command(stripped_bin, bin, 'strip $SOURCE -o $TARGET')
3052655Sstever@eecs.umich.edu        bin = stripped_bin
3062655Sstever@eecs.umich.edu    targets = newEnv.Concat(exe, [bin, 'python/m5py.zip'])
3072655Sstever@eecs.umich.edu    newEnv.M5Binary = targets[0]
3082655Sstever@eecs.umich.edu    envList.append(newEnv)
3092655Sstever@eecs.umich.edu
310955SN/A# Debug binary
3113515Ssaidi@eecs.umich.edu# Solaris seems to have some issue with DWARF2 debugging information, it's ok
3123515Ssaidi@eecs.umich.edu# with stabs though
3133515Ssaidi@eecs.umich.eduif sys.platform == 'sunos5':
3143515Ssaidi@eecs.umich.edu   debug_flag = '-gstabs+'
3153515Ssaidi@eecs.umich.eduelse:
3163515Ssaidi@eecs.umich.edu   debug_flag = '-ggdb3'
3173515Ssaidi@eecs.umich.edu
3182655Sstever@eecs.umich.edumakeEnv('debug', '.do',
3193515Ssaidi@eecs.umich.edu        CCFLAGS = Split('%s -O0' % debug_flag),
3203619Sbinkertn@umich.edu        CPPDEFINES = ['DEBUG', 'TRACING_ON=1'])
321955SN/A
322955SN/A# Optimized binary
3232655Sstever@eecs.umich.edumakeEnv('opt', '.o',
3243619Sbinkertn@umich.edu        CCFLAGS = Split('-g -O3'),
3253619Sbinkertn@umich.edu        CPPDEFINES = ['TRACING_ON=1'])
326955SN/A
327955SN/A# "Fast" binary
3282655Sstever@eecs.umich.edumakeEnv('fast', '.fo', strip = True,
3292655Sstever@eecs.umich.edu        CCFLAGS = Split('-O3'),
3303619Sbinkertn@umich.edu        CPPDEFINES = ['NDEBUG', 'TRACING_ON=0'])
331955SN/A
332955SN/A# Profiled binary
3332655Sstever@eecs.umich.edumakeEnv('prof', '.po',
3342655Sstever@eecs.umich.edu        CCFLAGS = Split('-O3 -g -pg'),
3352655Sstever@eecs.umich.edu        LINKFLAGS = '-pg')
3361869SN/A
3371869SN/AReturn('envList')
338