SConscript revision 3645
11736SN/A# -*- mode:python -*-
21736SN/A
31736SN/A# Copyright (c) 2004-2005 The Regents of The University of Michigan
41736SN/A# All rights reserved.
51736SN/A#
61736SN/A# Redistribution and use in source and binary forms, with or without
71736SN/A# modification, are permitted provided that the following conditions are
81736SN/A# met: redistributions of source code must retain the above copyright
91736SN/A# notice, this list of conditions and the following disclaimer;
101736SN/A# redistributions in binary form must reproduce the above copyright
111736SN/A# notice, this list of conditions and the following disclaimer in the
121736SN/A# documentation and/or other materials provided with the distribution;
131736SN/A# neither the name of the copyright holders nor the names of its
141736SN/A# contributors may be used to endorse or promote products derived from
151736SN/A# this software without specific prior written permission.
161736SN/A#
171736SN/A# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
181736SN/A# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
191736SN/A# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
201736SN/A# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
211736SN/A# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
221736SN/A# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
231736SN/A# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
241736SN/A# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
251736SN/A# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
262665Ssaidi@eecs.umich.edu# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
272665Ssaidi@eecs.umich.edu# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
282665Ssaidi@eecs.umich.edu#
291736SN/A# Authors: Steve Reinhardt
302667Sstever@eecs.umich.edu
312655Sstever@eecs.umich.eduimport os
322667Sstever@eecs.umich.eduimport sys
332667Sstever@eecs.umich.edufrom os.path import isfile, join as joinpath
342667Sstever@eecs.umich.edu
352667Sstever@eecs.umich.edu# This file defines how to build a particular configuration of M5
362667Sstever@eecs.umich.edu# based on variable settings in the 'env' build environment.
372667Sstever@eecs.umich.edu
382655Sstever@eecs.umich.edu# Import build environment variable from SConstruct.
392667Sstever@eecs.umich.eduImport('env')
402667Sstever@eecs.umich.edu
411530SN/A###################################################
421530SN/A#
431530SN/A# Define needed sources.
441530SN/A#
451530SN/A###################################################
461530SN/A
472667Sstever@eecs.umich.edu# Base sources used by all configurations.
482667Sstever@eecs.umich.edu
492667Sstever@eecs.umich.edubase_sources = Split('''
501692SN/A	base/annotate.cc
511869SN/A	base/circlebuf.cc
521869SN/A	base/cprintf.cc
531869SN/A	base/fast_alloc.cc
541869SN/A	base/fifo_buffer.cc
551692SN/A	base/hostinfo.cc
561869SN/A	base/hybrid_pred.cc
571869SN/A	base/inifile.cc
581869SN/A	base/intmath.cc
591581SN/A	base/match.cc
602667Sstever@eecs.umich.edu	base/misc.cc
612667Sstever@eecs.umich.edu	base/output.cc
622667Sstever@eecs.umich.edu	base/pollevent.cc
632667Sstever@eecs.umich.edu	base/range.cc
642667Sstever@eecs.umich.edu	base/random.cc
652667Sstever@eecs.umich.edu	base/sat_counter.cc
662667Sstever@eecs.umich.edu	base/socket.cc
672728Sktlim@umich.edu	base/statistics.cc
682728Sktlim@umich.edu	base/str.cc
692728Sktlim@umich.edu	base/time.cc
702728Sktlim@umich.edu	base/trace.cc
712728Sktlim@umich.edu	base/traceflags.cc
722728Sktlim@umich.edu	base/userinfo.cc
732728Sktlim@umich.edu	base/compression/lzss_compression.cc
742728Sktlim@umich.edu	base/loader/aout_object.cc
752728Sktlim@umich.edu	base/loader/ecoff_object.cc
762728Sktlim@umich.edu	base/loader/elf_object.cc
772728Sktlim@umich.edu	base/loader/raw_object.cc
782728Sktlim@umich.edu	base/loader/object_file.cc
792667Sstever@eecs.umich.edu	base/loader/symtab.cc
802667Sstever@eecs.umich.edu	base/stats/events.cc
812667Sstever@eecs.umich.edu	base/stats/statdb.cc
822667Sstever@eecs.umich.edu	base/stats/visit.cc
832728Sktlim@umich.edu	base/stats/text.cc
842728Sktlim@umich.edu
852728Sktlim@umich.edu        cpu/activity.cc
862728Sktlim@umich.edu	cpu/base.cc
872728Sktlim@umich.edu	cpu/cpuevent.cc
882728Sktlim@umich.edu	cpu/exetrace.cc
892728Sktlim@umich.edu        cpu/func_unit.cc
902728Sktlim@umich.edu        cpu/op_class.cc
912728Sktlim@umich.edu	cpu/pc_event.cc
922728Sktlim@umich.edu        cpu/quiesce_event.cc
932728Sktlim@umich.edu	cpu/static_inst.cc
942728Sktlim@umich.edu        cpu/simple_thread.cc
952667Sstever@eecs.umich.edu        cpu/thread_state.cc
961530SN/A
971530SN/A        mem/bridge.cc
981530SN/A        mem/bus.cc
991530SN/A        mem/dram.cc
1002667Sstever@eecs.umich.edu        mem/mem_object.cc
1011530SN/A        mem/packet.cc
1021530SN/A        mem/physical.cc
1031530SN/A        mem/port.cc
1041530SN/A        mem/tport.cc
1051530SN/A
1062667Sstever@eecs.umich.edu        mem/cache/base_cache.cc
1072667Sstever@eecs.umich.edu        mem/cache/cache.cc
1082667Sstever@eecs.umich.edu        mem/cache/coherence/coherence_protocol.cc
1092667Sstever@eecs.umich.edu        mem/cache/coherence/uni_coherence.cc
1102667Sstever@eecs.umich.edu        mem/cache/miss/blocking_buffer.cc
1112667Sstever@eecs.umich.edu        mem/cache/miss/miss_queue.cc
1122667Sstever@eecs.umich.edu        mem/cache/miss/mshr.cc
1132667Sstever@eecs.umich.edu        mem/cache/miss/mshr_queue.cc
1142667Sstever@eecs.umich.edu        mem/cache/prefetch/base_prefetcher.cc
1152667Sstever@eecs.umich.edu        mem/cache/prefetch/ghb_prefetcher.cc
1162667Sstever@eecs.umich.edu        mem/cache/prefetch/prefetcher.cc
1172667Sstever@eecs.umich.edu        mem/cache/prefetch/stride_prefetcher.cc
1182667Sstever@eecs.umich.edu        mem/cache/prefetch/tagged_prefetcher.cc
1192667Sstever@eecs.umich.edu        mem/cache/tags/base_tags.cc
1202667Sstever@eecs.umich.edu        mem/cache/tags/cache_tags.cc
1212667Sstever@eecs.umich.edu        mem/cache/tags/fa_lru.cc
1222667Sstever@eecs.umich.edu        mem/cache/tags/iic.cc
1232667Sstever@eecs.umich.edu        mem/cache/tags/lru.cc
1242667Sstever@eecs.umich.edu        mem/cache/tags/repl/gen.cc
1252667Sstever@eecs.umich.edu        mem/cache/tags/repl/repl.cc
1261527SN/A        mem/cache/tags/split.cc
1272667Sstever@eecs.umich.edu        mem/cache/tags/split_lifo.cc
1282667Sstever@eecs.umich.edu        mem/cache/tags/split_lru.cc
1292667Sstever@eecs.umich.edu
1301511SN/A        mem/cache/cache_builder.cc
1312667Sstever@eecs.umich.edu
1322667Sstever@eecs.umich.edu        python/swig/debug_wrap.cc
1332655Sstever@eecs.umich.edu        python/swig/main_wrap.cc
1342667Sstever@eecs.umich.edu
1352667Sstever@eecs.umich.edu	sim/builder.cc
1362667Sstever@eecs.umich.edu	sim/debug.cc
1372667Sstever@eecs.umich.edu	sim/eventq.cc
138	sim/faults.cc
139	sim/main.cc
140	sim/param.cc
141	sim/root.cc
142	sim/serialize.cc
143	sim/sim_events.cc
144	sim/sim_object.cc
145	sim/startup.cc
146	sim/stat_context.cc
147	sim/stat_control.cc
148	sim/system.cc
149	sim/trace_context.cc
150        ''')
151
152trace_reader_sources = Split('''
153        cpu/trace/reader/mem_trace_reader.cc
154        cpu/trace/reader/ibm_reader.cc
155        cpu/trace/reader/itx_reader.cc
156        cpu/trace/reader/m5_reader.cc
157        cpu/trace/opt_cpu.cc
158        cpu/trace/trace_cpu.cc
159        ''')
160
161
162
163# MySql sources
164mysql_sources = Split('''
165	base/mysql.cc
166	base/stats/mysql.cc
167        ''')
168
169# Full-system sources
170full_system_sources = Split('''
171	base/crc.cc
172	base/inet.cc
173	base/remote_gdb.cc
174
175	cpu/intr_control.cc
176        cpu/profile.cc
177
178	dev/uart.cc
179	dev/uart8250.cc
180
181        mem/vport.cc
182
183	sim/pseudo_inst.cc
184        ''')
185	#dev/sinic.cc
186        #dev/i8254xGBe.cc
187
188if env['TARGET_ISA'] == 'alpha':
189    full_system_sources += Split('''
190	kern/tru64/dump_mbuf.cc
191	kern/tru64/printf.cc
192	kern/tru64/tru64_events.cc
193	kern/tru64/tru64_syscalls.cc
194        ''')
195
196# Syscall emulation (non-full-system) sources
197syscall_emulation_sources = Split('''
198        mem/translating_port.cc
199        mem/page_table.cc
200	sim/process.cc
201	sim/syscall_emul.cc
202        ''')
203
204#if env['TARGET_ISA'] == 'alpha':
205#    syscall_emulation_sources += Split('''
206#        kern/tru64/tru64.cc
207#        ''')
208
209memtest_sources = Split('''
210	cpu/memtest/memtest.cc
211        ''')
212
213# Include file paths are rooted in this directory.  SCons will
214# automatically expand '.' to refer to both the source directory and
215# the corresponding build directory to pick up generated include
216# files.
217env.Append(CPPPATH=Dir('.'))
218
219# Add a flag defining what THE_ISA should be for all compilation
220env.Append(CPPDEFINES=[('THE_ISA','%s_ISA' % env['TARGET_ISA'].upper())])
221
222arch_sources = SConscript(os.path.join('arch', 'SConscript'), exports = 'env')
223
224cpu_sources = SConscript(os.path.join('cpu', 'SConscript'), exports = 'env')
225
226if env['FULL_SYSTEM']:
227    dev_sources = SConscript(os.path.join('dev', 'SConscript'),
228                             exports = 'env')
229    full_system_sources += dev_sources
230
231    kern_sources = SConscript(os.path.join('kern', 'SConscript'),
232                              exports = 'env')
233    full_system_sources += kern_sources
234
235# Set up complete list of sources based on configuration.
236sources = base_sources + arch_sources + cpu_sources
237
238# encumbered should be last because we're adding to some of the other groups
239if isfile(joinpath(env['SRCDIR'], 'encumbered/SConscript')):
240    sources += SConscript('encumbered/SConscript', exports = 'env')
241
242
243if env['FULL_SYSTEM']:
244    sources += full_system_sources
245else:
246    sources += syscall_emulation_sources
247
248if env['USE_MYSQL']:
249    sources += mysql_sources
250
251for opt in env.ExportOptions:
252    env.ConfigFile(opt)
253
254###################################################
255#
256# Special build rules.
257#
258###################################################
259
260# base/traceflags.{cc,hh} are generated from base/traceflags.py.
261# $TARGET.base will expand to "<build-dir>/base/traceflags".
262env.Command(Split('base/traceflags.hh base/traceflags.cc'),
263            'base/traceflags.py',
264            'python $SOURCE $TARGET.base')
265
266SConscript('python/SConscript', exports = ['env'])
267
268# This function adds the specified sources to the given build
269# environment, and returns a list of all the corresponding SCons
270# Object nodes (including an extra one for date.cc).  We explicitly
271# add the Object nodes so we can set up special dependencies for
272# date.cc.
273def make_objs(sources, env):
274    objs = [env.Object(s) for s in sources]
275    # make date.cc depend on all other objects so it always gets
276    # recompiled whenever anything else does
277    date_obj = env.Object('base/date.cc')
278    env.Depends(date_obj, objs)
279    objs.append(date_obj)
280    return objs
281
282###################################################
283#
284# Define binaries.  Each different build type (debug, opt, etc.) gets
285# a slightly different build environment.
286#
287###################################################
288
289# List of constructed environments to pass back to SConstruct
290envList = []
291
292# Function to create a new build environment as clone of current
293# environment 'env' with modified object suffix and optional stripped
294# binary.  Additional keyword arguments are appended to corresponding
295# build environment vars.
296def makeEnv(label, objsfx, strip = False, **kwargs):
297    newEnv = env.Copy(OBJSUFFIX=objsfx)
298    newEnv.Label = label
299    newEnv.Append(**kwargs)
300    exe = 'm5.' + label  # final executable
301    bin = exe + '.bin'   # executable w/o appended Python zip archive
302    newEnv.Program(bin, make_objs(sources, newEnv))
303    if strip:
304        stripped_bin = bin + '.stripped'
305        newEnv.Command(stripped_bin, bin, 'strip $SOURCE -o $TARGET')
306        bin = stripped_bin
307    targets = newEnv.Concat(exe, [bin, 'python/m5py.zip'])
308    newEnv.M5Binary = targets[0]
309    envList.append(newEnv)
310
311# Debug binary
312# Solaris seems to have some issue with DWARF2 debugging information, it's ok
313# with stabs though
314if sys.platform == 'sunos5':
315   debug_flag = '-gstabs+'
316else:
317   debug_flag = '-ggdb3'
318
319makeEnv('debug', '.do',
320        CCFLAGS = Split('%s -O0' % debug_flag),
321        CPPDEFINES = ['DEBUG', 'TRACING_ON=1'])
322
323# Optimized binary
324makeEnv('opt', '.o',
325        CCFLAGS = Split('-g -O3'),
326        CPPDEFINES = ['TRACING_ON=1'])
327
328# "Fast" binary
329makeEnv('fast', '.fo', strip = True,
330        CCFLAGS = Split('-O3'),
331        CPPDEFINES = ['NDEBUG', 'TRACING_ON=0'])
332
333# Profiled binary
334makeEnv('prof', '.po',
335        CCFLAGS = Split('-O3 -g -pg'),
336        LINKFLAGS = '-pg')
337
338Return('envList')
339