SConscript revision 2410
1# -*- mode:python -*-
2
3# Copyright (c) 2004-2005 The Regents of The University of Michigan
4# All rights reserved.
5#
6# Redistribution and use in source and binary forms, with or without
7# modification, are permitted provided that the following conditions are
8# met: redistributions of source code must retain the above copyright
9# notice, this list of conditions and the following disclaimer;
10# redistributions in binary form must reproduce the above copyright
11# notice, this list of conditions and the following disclaimer in the
12# documentation and/or other materials provided with the distribution;
13# neither the name of the copyright holders nor the names of its
14# contributors may be used to endorse or promote products derived from
15# this software without specific prior written permission.
16#
17# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
29import os
30import sys
31from os.path import isdir
32
33# This file defines how to build a particular configuration of M5
34# based on variable settings in the 'env' build environment.
35
36# Import build environment variable from SConstruct.
37Import('env')
38
39###################################################
40#
41# Define needed sources.
42#
43###################################################
44
45# Base sources used by all configurations.
46base_sources = Split('''
47	arch/alpha/decoder.cc
48	arch/alpha/faults.cc
49	arch/alpha/isa_traits.cc
50
51	base/circlebuf.cc
52	base/copyright.cc
53	base/cprintf.cc
54        base/embedfile.cc
55	base/fast_alloc.cc
56	base/fifo_buffer.cc
57	base/hostinfo.cc
58	base/hybrid_pred.cc
59	base/inifile.cc
60	base/intmath.cc
61	base/match.cc
62	base/misc.cc
63	base/output.cc
64	base/pollevent.cc
65	base/range.cc
66	base/random.cc
67	base/sat_counter.cc
68	base/socket.cc
69	base/statistics.cc
70	base/str.cc
71	base/time.cc
72	base/trace.cc
73	base/traceflags.cc
74	base/userinfo.cc
75	base/compression/lzss_compression.cc
76	base/loader/aout_object.cc
77	base/loader/ecoff_object.cc
78	base/loader/elf_object.cc
79	base/loader/object_file.cc
80	base/loader/symtab.cc
81	base/stats/events.cc
82	base/stats/statdb.cc
83	base/stats/visit.cc
84	base/stats/text.cc
85
86	cpu/base.cc
87	cpu/exec_context.cc
88	cpu/exetrace.cc
89        cpu/op_class.cc
90	cpu/pc_event.cc
91	cpu/static_inst.cc
92        cpu/sampler/sampler.cc
93
94        mem/memory.cc
95        mem/page_table.cc
96        mem/physical.cc
97        mem/port.cc
98        mem/translating_port.cc
99
100        python/pyconfig.cc
101        python/embedded_py.cc
102
103	sim/builder.cc
104	sim/configfile.cc
105	sim/debug.cc
106	sim/eventq.cc
107	sim/main.cc
108	sim/param.cc
109	sim/profile.cc
110	sim/root.cc
111	sim/serialize.cc
112	sim/sim_events.cc
113	sim/sim_exit.cc
114	sim/sim_object.cc
115	sim/startup.cc
116	sim/stat_context.cc
117	sim/stat_control.cc
118	sim/system.cc
119	sim/trace_context.cc
120        ''')
121
122fast_cpu_sources = Split('''
123	arch/alpha/fast_cpu_exec.cc
124	cpu/fast/cpu.cc
125        ''')
126
127simple_cpu_sources = Split('''
128	arch/alpha/simple_cpu_exec.cc
129        cpu/simple/cpu.cc
130        ''')
131
132trace_reader_sources = Split('''
133        cpu/trace/reader/mem_trace_reader.cc
134        cpu/trace/reader/ibm_reader.cc
135        cpu/trace/reader/itx_reader.cc
136        cpu/trace/reader/m5_reader.cc
137        cpu/trace/opt_cpu.cc
138        cpu/trace/trace_cpu.cc
139        ''')
140
141full_cpu_sources = Split('''
142	arch/alpha/full_cpu_exec.cc
143        cpu/base_dyn_inst.cc
144	encumbered/cpu/full/bpred.cc
145	encumbered/cpu/full/commit.cc
146	encumbered/cpu/full/cpu.cc
147	encumbered/cpu/full/create_vector.cc
148	encumbered/cpu/full/cv_spec_state.cc
149	encumbered/cpu/full/dd_queue.cc
150	encumbered/cpu/full/dep_link.cc
151	encumbered/cpu/full/dispatch.cc
152	encumbered/cpu/full/dyn_inst.cc
153	encumbered/cpu/full/execute.cc
154	encumbered/cpu/full/fetch.cc
155	encumbered/cpu/full/floss_reasons.cc
156	encumbered/cpu/full/inst_fifo.cc
157	encumbered/cpu/full/instpipe.cc
158	encumbered/cpu/full/issue.cc
159	encumbered/cpu/full/ls_queue.cc
160	encumbered/cpu/full/machine_queue.cc
161        encumbered/cpu/full/pipetrace.cc
162        encumbered/cpu/full/readyq.cc
163        encumbered/cpu/full/reg_info.cc
164        encumbered/cpu/full/rob_station.cc
165        encumbered/cpu/full/spec_memory.cc
166        encumbered/cpu/full/spec_state.cc
167        encumbered/cpu/full/storebuffer.cc
168        encumbered/cpu/full/writeback.cc
169        encumbered/cpu/full/iq/iq_station.cc
170        encumbered/cpu/full/iq/iqueue.cc
171        encumbered/cpu/full/iq/segmented/chain_info.cc
172        encumbered/cpu/full/iq/segmented/chain_wire.cc
173        encumbered/cpu/full/iq/segmented/iq_seg.cc
174        encumbered/cpu/full/iq/segmented/iq_segmented.cc
175        encumbered/cpu/full/iq/segmented/seg_chain.cc
176        encumbered/cpu/full/iq/seznec/iq_seznec.cc
177        encumbered/cpu/full/iq/standard/iq_standard.cc
178        ''')
179
180o3_cpu_sources = Split('''
181        arch/alpha/alpha_o3_exec.cc
182        cpu/o3/2bit_local_pred.cc
183        cpu/o3/alpha_dyn_inst.cc
184        cpu/o3/alpha_cpu.cc
185        cpu/o3/alpha_cpu_builder.cc
186        cpu/o3/bpred_unit.cc
187        cpu/o3/btb.cc
188        cpu/o3/commit.cc
189        cpu/o3/decode.cc
190        cpu/o3/fetch.cc
191        cpu/o3/free_list.cc
192        cpu/o3/cpu.cc
193        cpu/o3/iew.cc
194        cpu/o3/inst_queue.cc
195        cpu/o3/ldstq.cc
196        cpu/o3/mem_dep_unit.cc
197        cpu/o3/ras.cc
198        cpu/o3/rename.cc
199        cpu/o3/rename_map.cc
200        cpu/o3/rob.cc
201        cpu/o3/sat_counter.cc
202        cpu/o3/store_set.cc
203        cpu/o3/tournament_pred.cc
204        ''')
205
206# MySql sources
207mysql_sources = Split('''
208	base/mysql.cc
209	base/stats/mysql.cc
210        ''')
211
212# Full-system sources
213full_system_sources = Split('''
214	arch/alpha/alpha_memory.cc
215	arch/alpha/arguments.cc
216	arch/alpha/ev5.cc
217	arch/alpha/osfpal.cc
218	arch/alpha/pseudo_inst.cc
219	arch/alpha/stacktrace.cc
220	arch/alpha/vtophys.cc
221
222	base/crc.cc
223	base/inet.cc
224	base/remote_gdb.cc
225
226	cpu/intr_control.cc
227        cpu/profile.cc
228
229	dev/alpha_console.cc
230	dev/baddev.cc
231        dev/simconsole.cc
232	dev/disk_image.cc
233	dev/etherbus.cc
234	dev/etherdump.cc
235	dev/etherint.cc
236	dev/etherlink.cc
237	dev/etherpkt.cc
238	dev/ethertap.cc
239	dev/ide_ctrl.cc
240	dev/ide_disk.cc
241	dev/io_device.cc
242	dev/ns_gige.cc
243	dev/pciconfigall.cc
244	dev/pcidev.cc
245	dev/pcifake.cc
246	dev/pktfifo.cc
247	dev/platform.cc
248	dev/sinic.cc
249	dev/simple_disk.cc
250	dev/tsunami.cc
251	dev/tsunami_cchip.cc
252	dev/isa_fake.cc
253	dev/tsunami_io.cc
254	dev/tsunami_pchip.cc
255	dev/uart.cc
256	dev/uart8250.cc
257
258	kern/kernel_binning.cc
259	kern/kernel_stats.cc
260	kern/system_events.cc
261	kern/freebsd/freebsd_system.cc
262	kern/linux/linux_syscalls.cc
263	kern/linux/linux_system.cc
264	kern/linux/printk.cc
265	kern/tru64/dump_mbuf.cc
266	kern/tru64/printf.cc
267	kern/tru64/tru64_events.cc
268	kern/tru64/tru64_syscalls.cc
269	kern/tru64/tru64_system.cc
270
271	mem/functional/memory_control.cc
272        ''')
273
274# turbolaser encumbered sources
275turbolaser_sources = Split('''
276	encumbered/dev/dma.cc
277	encumbered/dev/etherdev.cc
278	encumbered/dev/scsi.cc
279	encumbered/dev/scsi_ctrl.cc
280	encumbered/dev/scsi_disk.cc
281	encumbered/dev/scsi_none.cc
282	encumbered/dev/tlaser_clock.cc
283	encumbered/dev/tlaser_ipi.cc
284	encumbered/dev/tlaser_mbox.cc
285	encumbered/dev/tlaser_mc146818.cc
286	encumbered/dev/tlaser_node.cc
287	encumbered/dev/tlaser_pcia.cc
288	encumbered/dev/tlaser_pcidev.cc
289	encumbered/dev/tlaser_serial.cc
290	encumbered/dev/turbolaser.cc
291	encumbered/dev/uart8530.cc
292        ''')
293
294# Syscall emulation (non-full-system) sources
295syscall_emulation_sources = Split('''
296	arch/alpha/alpha_common_syscall_emul.cc
297	arch/alpha/alpha_linux_process.cc
298	arch/alpha/alpha_tru64_process.cc
299
300	encumbered/eio/exolex.cc
301	encumbered/eio/libexo.cc
302	sim/process.cc
303	sim/syscall_emul.cc
304        ''')
305
306eio_sources = Split('''
307	encumbered/eio/eio.cc
308        ''')
309
310memtest_sources = Split('''
311	cpu/memtest/memtest.cc
312        ''')
313
314targetarch_files = Split('''
315        alpha_common_syscall_emul.hh
316        alpha_linux_process.hh
317        alpha_memory.hh
318        alpha_tru64_process.hh
319        aout_machdep.h
320        arguments.hh
321        byte_swap.hh
322        ecoff_machdep.h
323        ev5.hh
324        faults.hh
325        isa_fullsys_traits.hh
326        isa_traits.hh
327        osfpal.hh
328        pseudo_inst.hh
329        stacktrace.hh
330        vptr.hh
331        vtophys.hh
332        ''')
333
334for f in targetarch_files:
335    env.Command('targetarch/' + f, 'arch/alpha/' + f,
336                '''echo '#include "arch/alpha/%s"' > $TARGET''' % f)
337
338
339# Set up complete list of sources based on configuration.
340sources = base_sources + simple_cpu_sources
341
342if env['FULL_SYSTEM']:
343    sources += full_system_sources
344    if env['ALPHA_TLASER']:
345        sources += turbolaser_sources
346else:
347    sources += syscall_emulation_sources
348
349if env['USE_MYSQL']:
350    sources += mysql_sources
351
352for opt in env.ExportOptions:
353    env.ConfigFile(opt)
354
355###################################################
356#
357# Special build rules.
358#
359###################################################
360
361# base/traceflags.{cc,hh} are generated from base/traceflags.py.
362# $TARGET.base will expand to "<build-dir>/base/traceflags".
363env.Command(Split('base/traceflags.hh base/traceflags.cc'),
364            'base/traceflags.py',
365            'python $SOURCE $TARGET.base')
366
367# several files are generated from arch/$TARGET_ISA/isa_desc.
368env.Command(Split('''arch/alpha/decoder.cc
369		     arch/alpha/decoder.hh
370                     arch/alpha/alpha_o3_exec.cc
371		     arch/alpha/fast_cpu_exec.cc
372                     arch/alpha/simple_cpu_exec.cc'''),
373            Split('''arch/alpha/isa_desc
374		     arch/isa_parser.py'''),
375            '$SRCDIR/arch/isa_parser.py $SOURCE $TARGET.dir arch/alpha')
376
377
378# libelf build is described in its own SConscript file.
379# SConscript-local is the per-config build, which just copies some
380# header files into a place where they can be found.
381SConscript('libelf/SConscript-local', exports = 'env', duplicate=0)
382SConscript('python/SConscript', exports = ['env'], duplicate=0)
383
384# This function adds the specified sources to the given build
385# environment, and returns a list of all the corresponding SCons
386# Object nodes (including an extra one for date.cc).  We explicitly
387# add the Object nodes so we can set up special dependencies for
388# date.cc.
389def make_objs(sources, env):
390    objs = [env.Object(s) for s in sources]
391    # make date.cc depend on all other objects so it always gets
392    # recompiled whenever anything else does
393    date_obj = env.Object('base/date.cc')
394    env.Depends(date_obj, objs)
395    objs.append(date_obj)
396    return objs
397
398###################################################
399#
400# Define binaries.  Each different build type (debug, opt, etc.) gets
401# a slightly different build environment.
402#
403###################################################
404
405# Include file paths are rooted in this directory.  SCons will
406# automatically expand '.' to refer to both the source directory and
407# the corresponding build directory to pick up generated include
408# files.
409env.Append(CPPPATH='.')
410
411# Debug binary
412debugEnv = env.Copy(OBJSUFFIX='.do')
413debugEnv.Label = 'debug'
414debugEnv.Append(CCFLAGS=Split('-g -gstabs+ -O0'))
415debugEnv.Append(CPPDEFINES='DEBUG')
416tlist = debugEnv.Program(target = 'm5.debug',
417                         source = make_objs(sources, debugEnv))
418debugEnv.M5Binary = tlist[0]
419
420# Optimized binary
421optEnv = env.Copy()
422optEnv.Label = 'opt'
423optEnv.Append(CCFLAGS=Split('-g -O5'))
424tlist = optEnv.Program(target = 'm5.opt',
425                       source = make_objs(sources, optEnv))
426optEnv.M5Binary = tlist[0]
427
428# "Fast" binary
429fastEnv = env.Copy(OBJSUFFIX='.fo')
430fastEnv.Label = 'fast'
431fastEnv.Append(CCFLAGS=Split('-O5'))
432fastEnv.Append(CPPDEFINES='NDEBUG')
433fastEnv.Program(target = 'm5.fast.unstripped',
434                source = make_objs(sources, fastEnv))
435tlist = fastEnv.Command(target = 'm5.fast',
436                        source = 'm5.fast.unstripped',
437                        action = 'strip $SOURCE -o $TARGET')
438fastEnv.M5Binary = tlist[0]
439
440# Profiled binary
441profEnv = env.Copy(OBJSUFFIX='.po')
442profEnv.Label = 'prof'
443profEnv.Append(CCFLAGS=Split('-O5 -g -pg'), LINKFLAGS='-pg')
444tlist = profEnv.Program(target = 'm5.prof',
445                        source = make_objs(sources, profEnv))
446profEnv.M5Binary = tlist[0]
447
448envList = [debugEnv, optEnv, fastEnv, profEnv]
449
450Return('envList')
451