SConscript revision 3499
12155SN/A# -*- mode:python -*-
22155SN/A
32155SN/A# Copyright (c) 2004-2005 The Regents of The University of Michigan
42155SN/A# All rights reserved.
52155SN/A#
62155SN/A# Redistribution and use in source and binary forms, with or without
72155SN/A# modification, are permitted provided that the following conditions are
82155SN/A# met: redistributions of source code must retain the above copyright
92155SN/A# notice, this list of conditions and the following disclaimer;
102155SN/A# redistributions in binary form must reproduce the above copyright
112155SN/A# notice, this list of conditions and the following disclaimer in the
122155SN/A# documentation and/or other materials provided with the distribution;
132155SN/A# neither the name of the copyright holders nor the names of its
142155SN/A# contributors may be used to endorse or promote products derived from
152155SN/A# this software without specific prior written permission.
162155SN/A#
172155SN/A# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
182155SN/A# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
192155SN/A# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
202155SN/A# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
212155SN/A# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
222155SN/A# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
232155SN/A# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
242155SN/A# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
252155SN/A# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
262155SN/A# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
272155SN/A# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
282155SN/A#
292155SN/A# Authors: Steve Reinhardt
302155SN/A
312155SN/Aimport os
322155SN/Aimport sys
332155SN/Afrom os.path import isdir
342155SN/A
352178SN/A# This file defines how to build a particular configuration of M5
362178SN/A# based on variable settings in the 'env' build environment.
372178SN/A
382178SN/A# Import build environment variable from SConstruct.
392178SN/AImport('env')
402178SN/A
412178SN/A###################################################
422178SN/A#
432178SN/A# Define needed sources.
442178SN/A#
452178SN/A###################################################
462178SN/A
472155SN/A# Base sources used by all configurations.
482178SN/A
492155SN/Abase_sources = Split('''
502155SN/A	base/annotate.cc
512178SN/A	base/circlebuf.cc
522155SN/A	base/cprintf.cc
532155SN/A	base/fast_alloc.cc
542623SN/A	base/fifo_buffer.cc
552623SN/A	base/hostinfo.cc
562623SN/A	base/hybrid_pred.cc
572623SN/A	base/inifile.cc
582623SN/A	base/intmath.cc
592155SN/A	base/match.cc
602155SN/A	base/misc.cc
612292SN/A	base/output.cc
622292SN/A	base/pollevent.cc
632292SN/A	base/range.cc
642292SN/A	base/random.cc
652292SN/A	base/sat_counter.cc
662292SN/A	base/socket.cc
672292SN/A	base/statistics.cc
682292SN/A	base/str.cc
692178SN/A	base/time.cc
702155SN/A	base/trace.cc
712155SN/A	base/traceflags.cc
722155SN/A	base/userinfo.cc
732155SN/A	base/compression/lzss_compression.cc
742155SN/A	base/loader/aout_object.cc
752155SN/A	base/loader/ecoff_object.cc
762155SN/A	base/loader/elf_object.cc
772155SN/A	base/loader/object_file.cc
782623SN/A	base/loader/symtab.cc
792155SN/A	base/stats/events.cc
802155SN/A	base/stats/statdb.cc
812155SN/A	base/stats/visit.cc
822155SN/A	base/stats/text.cc
832178SN/A
842178SN/A        cpu/activity.cc
852178SN/A	cpu/base.cc
862178SN/A	cpu/cpuevent.cc
872178SN/A	cpu/exetrace.cc
882178SN/A        cpu/func_unit.cc
892178SN/A        cpu/op_class.cc
902178SN/A	cpu/pc_event.cc
912178SN/A        cpu/quiesce_event.cc
922178SN/A	cpu/static_inst.cc
932178SN/A        cpu/simple_thread.cc
942178SN/A        cpu/thread_state.cc
952178SN/A
962178SN/A        mem/bridge.cc
972178SN/A        mem/bus.cc
982178SN/A        mem/dram.cc
992155SN/A        mem/mem_object.cc
1002155SN/A        mem/packet.cc
1012155SN/A        mem/physical.cc
1022623SN/A        mem/port.cc
1032623SN/A        mem/tport.cc
1042623SN/A
1052623SN/A        mem/cache/base_cache.cc
1062623SN/A        mem/cache/cache.cc
1072623SN/A        mem/cache/coherence/coherence_protocol.cc
1082623SN/A        mem/cache/coherence/uni_coherence.cc
1092623SN/A        mem/cache/miss/blocking_buffer.cc
1102623SN/A        mem/cache/miss/miss_queue.cc
1112623SN/A        mem/cache/miss/mshr.cc
1122623SN/A        mem/cache/miss/mshr_queue.cc
1132155SN/A        mem/cache/prefetch/base_prefetcher.cc
1142155SN/A        mem/cache/prefetch/ghb_prefetcher.cc
1152155SN/A        mem/cache/prefetch/prefetcher.cc
1162155SN/A        mem/cache/prefetch/stride_prefetcher.cc
1172155SN/A        mem/cache/prefetch/tagged_prefetcher.cc
1182155SN/A        mem/cache/tags/base_tags.cc
1192669Sktlim@umich.edu        mem/cache/tags/cache_tags.cc
1202155SN/A        mem/cache/tags/fa_lru.cc
1212155SN/A        mem/cache/tags/iic.cc
1222155SN/A        mem/cache/tags/lru.cc
1232155SN/A        mem/cache/tags/repl/gen.cc
1242155SN/A        mem/cache/tags/repl/repl.cc
1252155SN/A        mem/cache/tags/split.cc
1262155SN/A        mem/cache/tags/split_lifo.cc
1272155SN/A        mem/cache/tags/split_lru.cc
1282155SN/A
1292155SN/A        mem/cache/cache_builder.cc
1302292SN/A
1312155SN/A	sim/builder.cc
1322155SN/A	sim/debug.cc
1332155SN/A	sim/eventq.cc
1342292SN/A	sim/faults.cc
1352292SN/A	sim/main.cc
1362155SN/A        python/swig/cc_main_wrap.cc
1372155SN/A	sim/param.cc
1382155SN/A	sim/root.cc
1392155SN/A	sim/serialize.cc
1402155SN/A	sim/sim_events.cc
1412292SN/A	sim/sim_object.cc
1422155SN/A	sim/startup.cc
1432155SN/A	sim/stat_context.cc
1442155SN/A	sim/stat_control.cc
1452155SN/A	sim/system.cc
1462292SN/A	sim/trace_context.cc
1472292SN/A        ''')
1482292SN/A
1492292SN/A# Old FullCPU sources
1502292SN/Afull_cpu_sources = Split('''
1512292SN/A	encumbered/cpu/full/bpred.cc
1522292SN/A	encumbered/cpu/full/commit.cc
1532292SN/A	encumbered/cpu/full/cpu.cc
1542292SN/A	encumbered/cpu/full/create_vector.cc
1552292SN/A	encumbered/cpu/full/cv_spec_state.cc
1562292SN/A	encumbered/cpu/full/dd_queue.cc
1572292SN/A	encumbered/cpu/full/dep_link.cc
1582292SN/A	encumbered/cpu/full/dispatch.cc
1592292SN/A	encumbered/cpu/full/dyn_inst.cc
1602297SN/A	encumbered/cpu/full/execute.cc
1612297SN/A	encumbered/cpu/full/fetch.cc
1622292SN/A	encumbered/cpu/full/floss_reasons.cc
1632292SN/A	encumbered/cpu/full/fu_pool.cc
1642315SN/A	encumbered/cpu/full/inst_fifo.cc
1652315SN/A	encumbered/cpu/full/instpipe.cc
1662315SN/A	encumbered/cpu/full/issue.cc
1672315SN/A	encumbered/cpu/full/ls_queue.cc
1682315SN/A	encumbered/cpu/full/machine_queue.cc
1692315SN/A        encumbered/cpu/full/pipetrace.cc
1702155SN/A        encumbered/cpu/full/readyq.cc
1712155SN/A        encumbered/cpu/full/reg_info.cc
1722155SN/A        encumbered/cpu/full/rob_station.cc
1732155SN/A        encumbered/cpu/full/spec_memory.cc
1742155SN/A        encumbered/cpu/full/spec_state.cc
1752155SN/A        encumbered/cpu/full/storebuffer.cc
1762155SN/A        encumbered/cpu/full/writeback.cc
1772155SN/A        encumbered/cpu/full/iq/iq_station.cc
1782155SN/A        encumbered/cpu/full/iq/iqueue.cc
179        encumbered/cpu/full/iq/segmented/chain_info.cc
180        encumbered/cpu/full/iq/segmented/chain_wire.cc
181        encumbered/cpu/full/iq/segmented/iq_seg.cc
182        encumbered/cpu/full/iq/segmented/iq_segmented.cc
183        encumbered/cpu/full/iq/segmented/seg_chain.cc
184        encumbered/cpu/full/iq/seznec/iq_seznec.cc
185        encumbered/cpu/full/iq/standard/iq_standard.cc
186        ''')
187
188trace_reader_sources = Split('''
189        cpu/trace/reader/mem_trace_reader.cc
190        cpu/trace/reader/ibm_reader.cc
191        cpu/trace/reader/itx_reader.cc
192        cpu/trace/reader/m5_reader.cc
193        cpu/trace/opt_cpu.cc
194        cpu/trace/trace_cpu.cc
195        ''')
196
197
198
199# MySql sources
200mysql_sources = Split('''
201	base/mysql.cc
202	base/stats/mysql.cc
203        ''')
204
205# Full-system sources
206full_system_sources = Split('''
207	base/crc.cc
208	base/inet.cc
209	base/remote_gdb.cc
210
211	cpu/intr_control.cc
212        cpu/profile.cc
213
214	dev/alpha_console.cc
215	dev/baddev.cc
216	dev/disk_image.cc
217	dev/etherbus.cc
218	dev/etherdump.cc
219	dev/etherint.cc
220	dev/etherlink.cc
221	dev/etherpkt.cc
222	dev/ethertap.cc	
223        dev/ide_ctrl.cc
224	dev/ide_disk.cc
225	dev/io_device.cc
226	dev/isa_fake.cc
227	dev/ns_gige.cc
228	dev/pciconfigall.cc
229	dev/pcidev.cc
230	dev/pktfifo.cc
231	dev/platform.cc
232        dev/simconsole.cc
233	dev/simple_disk.cc
234	dev/tsunami.cc
235	dev/tsunami_cchip.cc
236	dev/tsunami_io.cc
237	dev/tsunami_pchip.cc
238
239	dev/uart.cc
240	dev/uart8250.cc
241
242	kern/kernel_stats.cc
243	kern/system_events.cc
244	kern/linux/events.cc
245	kern/linux/linux_syscalls.cc
246	kern/linux/printk.cc
247
248        mem/vport.cc
249
250	sim/pseudo_inst.cc
251        ''')
252	#dev/sinic.cc
253        #dev/i8254xGBe.cc
254
255
256if env['TARGET_ISA'] == 'alpha':
257    full_system_sources += Split('''
258	kern/tru64/dump_mbuf.cc
259	kern/tru64/printf.cc
260	kern/tru64/tru64_events.cc
261	kern/tru64/tru64_syscalls.cc
262        ''')
263
264# turbolaser encumbered sources
265turbolaser_sources = Split('''
266	encumbered/dev/dma.cc
267	encumbered/dev/etherdev.cc
268	encumbered/dev/scsi.cc
269	encumbered/dev/scsi_ctrl.cc
270	encumbered/dev/scsi_disk.cc
271	encumbered/dev/scsi_none.cc
272	encumbered/dev/tlaser_clock.cc
273	encumbered/dev/tlaser_ipi.cc
274	encumbered/dev/tlaser_mbox.cc
275	encumbered/dev/tlaser_mc146818.cc
276	encumbered/dev/tlaser_node.cc
277	encumbered/dev/tlaser_pcia.cc
278	encumbered/dev/tlaser_pcidev.cc
279	encumbered/dev/tlaser_serial.cc
280	encumbered/dev/turbolaser.cc
281	encumbered/dev/uart8530.cc
282        ''')
283
284# Syscall emulation (non-full-system) sources
285syscall_emulation_sources = Split('''
286        mem/translating_port.cc
287        mem/page_table.cc
288	sim/process.cc
289	sim/syscall_emul.cc
290        ''')
291
292#if env['TARGET_ISA'] == 'alpha':
293#    syscall_emulation_sources += Split('''
294#        kern/tru64/tru64.cc
295#        ''')
296
297alpha_eio_sources = Split('''
298	encumbered/eio/exolex.cc
299	encumbered/eio/libexo.cc
300	encumbered/eio/eio.cc
301        ''')
302
303if env['TARGET_ISA'] == 'alpha':
304    syscall_emulation_sources += alpha_eio_sources
305    
306memtest_sources = Split('''
307	cpu/memtest/memtest.cc
308        ''')
309
310# Include file paths are rooted in this directory.  SCons will
311# automatically expand '.' to refer to both the source directory and
312# the corresponding build directory to pick up generated include
313# files.
314env.Append(CPPPATH=Dir('.'))
315
316# Add a flag defining what THE_ISA should be for all compilation
317env.Append(CPPDEFINES=[('THE_ISA','%s_ISA' % env['TARGET_ISA'].upper())])
318
319arch_sources = SConscript('arch/SConscript', exports = 'env')
320
321cpu_sources = SConscript('cpu/SConscript', exports = 'env')
322
323# This is outside of cpu/SConscript since the source directory isn't
324# underneath 'cpu'.
325if 'FullCPU' in env['CPU_MODELS']:
326    cpu_sources += full_cpu_sources
327
328# Set up complete list of sources based on configuration.
329sources = base_sources + arch_sources + cpu_sources
330
331if env['FULL_SYSTEM']:
332    sources += full_system_sources
333    if env['ALPHA_TLASER']:
334        sources += turbolaser_sources
335else:
336    sources += syscall_emulation_sources
337
338if env['USE_MYSQL']:
339    sources += mysql_sources
340
341for opt in env.ExportOptions:
342    env.ConfigFile(opt)
343
344###################################################
345#
346# Special build rules.
347#
348###################################################
349
350# base/traceflags.{cc,hh} are generated from base/traceflags.py.
351# $TARGET.base will expand to "<build-dir>/base/traceflags".
352env.Command(Split('base/traceflags.hh base/traceflags.cc'),
353            'base/traceflags.py',
354            'python $SOURCE $TARGET.base')
355
356SConscript('python/SConscript', exports = ['env'])
357
358# This function adds the specified sources to the given build
359# environment, and returns a list of all the corresponding SCons
360# Object nodes (including an extra one for date.cc).  We explicitly
361# add the Object nodes so we can set up special dependencies for
362# date.cc.
363def make_objs(sources, env):
364    objs = [env.Object(s) for s in sources]
365    # make date.cc depend on all other objects so it always gets
366    # recompiled whenever anything else does
367    date_obj = env.Object('base/date.cc')
368    env.Depends(date_obj, objs)
369    objs.append(date_obj)
370    return objs
371
372###################################################
373#
374# Define binaries.  Each different build type (debug, opt, etc.) gets
375# a slightly different build environment.
376#
377###################################################
378
379# List of constructed environments to pass back to SConstruct
380envList = []
381
382# Function to create a new build environment as clone of current
383# environment 'env' with modified object suffix and optional stripped
384# binary.  Additional keyword arguments are appended to corresponding
385# build environment vars.
386def makeEnv(label, objsfx, strip = False, **kwargs):
387    newEnv = env.Copy(OBJSUFFIX=objsfx)
388    newEnv.Label = label
389    newEnv.Append(**kwargs)
390    exe = 'm5.' + label  # final executable
391    bin = exe + '.bin'   # executable w/o appended Python zip archive
392    newEnv.Program(bin, make_objs(sources, newEnv))
393    if strip:
394        stripped_bin = bin + '.stripped'
395        newEnv.Command(stripped_bin, bin, 'strip $SOURCE -o $TARGET')
396        bin = stripped_bin
397    targets = newEnv.Concat(exe, [bin, 'python/m5py.zip'])
398    newEnv.M5Binary = targets[0]
399    envList.append(newEnv)
400
401# Debug binary
402makeEnv('debug', '.do',
403        CCFLAGS = Split('-g3 -gdwarf-2 -O0'),
404        CPPDEFINES = 'DEBUG')
405
406# Optimized binary
407makeEnv('opt', '.o',
408        CCFLAGS = Split('-g -O3'))
409
410# "Fast" binary
411makeEnv('fast', '.fo', strip = True,
412        CCFLAGS = Split('-O3'),
413        CPPDEFINES = 'NDEBUG')
414
415# Profiled binary
416makeEnv('prof', '.po',
417        CCFLAGS = Split('-O3 -g -pg'),
418        LINKFLAGS = '-pg')
419
420Return('envList')
421