SConscript revision 2395
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/alpha_o3_exec.cc
49	arch/alpha/fast_cpu_exec.cc
50	arch/alpha/simple_cpu_exec.cc
51	arch/alpha/faults.cc
52	arch/alpha/isa_traits.cc
53
54	base/circlebuf.cc
55	base/copyright.cc
56	base/cprintf.cc
57        base/embedfile.cc
58	base/fast_alloc.cc
59	base/fifo_buffer.cc
60	base/hostinfo.cc
61	base/hybrid_pred.cc
62	base/inifile.cc
63	base/intmath.cc
64	base/match.cc
65	base/misc.cc
66	base/output.cc
67	base/pollevent.cc
68	base/range.cc
69	base/random.cc
70	base/sat_counter.cc
71	base/socket.cc
72	base/statistics.cc
73	base/str.cc
74	base/time.cc
75	base/trace.cc
76	base/traceflags.cc
77	base/userinfo.cc
78	base/compression/lzss_compression.cc
79	base/loader/aout_object.cc
80	base/loader/ecoff_object.cc
81	base/loader/elf_object.cc
82	base/loader/object_file.cc
83	base/loader/symtab.cc
84	base/stats/events.cc
85	base/stats/statdb.cc
86	base/stats/visit.cc
87	base/stats/text.cc
88
89	cpu/base.cc
90        cpu/base_dyn_inst.cc
91	cpu/exec_context.cc
92	cpu/exetrace.cc
93	cpu/pc_event.cc
94	cpu/static_inst.cc
95        cpu/o3/2bit_local_pred.cc
96        cpu/o3/alpha_dyn_inst.cc
97        cpu/o3/alpha_cpu.cc
98        cpu/o3/alpha_cpu_builder.cc
99        cpu/o3/bpred_unit.cc
100        cpu/o3/btb.cc
101        cpu/o3/commit.cc
102        cpu/o3/decode.cc
103        cpu/o3/fetch.cc
104        cpu/o3/free_list.cc
105        cpu/o3/cpu.cc
106        cpu/o3/iew.cc
107        cpu/o3/inst_queue.cc
108        cpu/o3/ldstq.cc
109        cpu/o3/mem_dep_unit.cc
110        cpu/o3/ras.cc
111        cpu/o3/rename.cc
112        cpu/o3/rename_map.cc
113        cpu/o3/rob.cc
114        cpu/o3/sat_counter.cc
115        cpu/o3/store_set.cc
116        cpu/o3/tournament_pred.cc
117	cpu/fast/cpu.cc
118        cpu/sampler/sampler.cc
119        cpu/simple/cpu.cc
120        cpu/trace/reader/mem_trace_reader.cc
121        cpu/trace/reader/ibm_reader.cc
122        cpu/trace/reader/itx_reader.cc
123        cpu/trace/reader/m5_reader.cc
124        cpu/trace/opt_cpu.cc
125        cpu/trace/trace_cpu.cc
126
127	encumbered/mem/functional/main.cc
128
129        mem/memory.cc
130        mem/page_table.cc
131        mem/physical.cc
132        mem/proxy.cc
133
134        python/pyconfig.cc
135        python/embedded_py.cc
136
137	sim/builder.cc
138	sim/configfile.cc
139	sim/debug.cc
140	sim/eventq.cc
141	sim/main.cc
142	sim/param.cc
143	sim/profile.cc
144	sim/root.cc
145	sim/serialize.cc
146	sim/sim_events.cc
147	sim/sim_exit.cc
148	sim/sim_object.cc
149	sim/startup.cc
150	sim/stat_context.cc
151	sim/stat_control.cc
152	sim/system.cc
153	sim/trace_context.cc
154        ''')
155
156full_cpu_sources = Split('''
157	arch/alpha/full_cpu_exec.cc
158	encumbered/cpu/full/bpred.cc
159	encumbered/cpu/full/commit.cc
160	encumbered/cpu/full/cpu.cc
161	encumbered/cpu/full/create_vector.cc
162	encumbered/cpu/full/cv_spec_state.cc
163	encumbered/cpu/full/dd_queue.cc
164	encumbered/cpu/full/dep_link.cc
165	encumbered/cpu/full/dispatch.cc
166	encumbered/cpu/full/dyn_inst.cc
167	encumbered/cpu/full/execute.cc
168	encumbered/cpu/full/fetch.cc
169	encumbered/cpu/full/floss_reasons.cc
170	encumbered/cpu/full/inst_fifo.cc
171	encumbered/cpu/full/instpipe.cc
172	encumbered/cpu/full/issue.cc
173	encumbered/cpu/full/ls_queue.cc
174	encumbered/cpu/full/machine_queue.cc
175        encumbered/cpu/full/pipetrace.cc
176        encumbered/cpu/full/readyq.cc
177        encumbered/cpu/full/reg_info.cc
178        encumbered/cpu/full/rob_station.cc
179        encumbered/cpu/full/spec_memory.cc
180        encumbered/cpu/full/spec_state.cc
181        encumbered/cpu/full/storebuffer.cc
182        encumbered/cpu/full/writeback.cc
183        encumbered/cpu/full/iq/iq_station.cc
184        encumbered/cpu/full/iq/iqueue.cc
185        encumbered/cpu/full/iq/segmented/chain_info.cc
186        encumbered/cpu/full/iq/segmented/chain_wire.cc
187        encumbered/cpu/full/iq/segmented/iq_seg.cc
188        encumbered/cpu/full/iq/segmented/iq_segmented.cc
189        encumbered/cpu/full/iq/segmented/seg_chain.cc
190        encumbered/cpu/full/iq/seznec/iq_seznec.cc
191        encumbered/cpu/full/iq/standard/iq_standard.cc
192        ''')
193
194# MySql sources
195mysql_sources = Split('''
196	base/mysql.cc
197	base/stats/mysql.cc
198        ''')
199
200# Full-system sources
201full_system_sources = Split('''
202	arch/alpha/alpha_memory.cc
203	arch/alpha/arguments.cc
204	arch/alpha/ev5.cc
205	arch/alpha/osfpal.cc
206	arch/alpha/pseudo_inst.cc
207	arch/alpha/stacktrace.cc
208	arch/alpha/vtophys.cc
209
210	base/crc.cc
211	base/inet.cc
212	base/remote_gdb.cc
213
214	cpu/intr_control.cc
215        cpu/profile.cc
216
217	dev/alpha_console.cc
218	dev/baddev.cc
219        dev/simconsole.cc
220	dev/disk_image.cc
221	dev/etherbus.cc
222	dev/etherdump.cc
223	dev/etherint.cc
224	dev/etherlink.cc
225	dev/etherpkt.cc
226	dev/ethertap.cc
227	dev/ide_ctrl.cc
228	dev/ide_disk.cc
229	dev/io_device.cc
230	dev/ns_gige.cc
231	dev/pciconfigall.cc
232	dev/pcidev.cc
233	dev/pcifake.cc
234	dev/pktfifo.cc
235	dev/platform.cc
236	dev/sinic.cc
237	dev/simple_disk.cc
238	dev/tsunami.cc
239	dev/tsunami_cchip.cc
240	dev/isa_fake.cc
241	dev/tsunami_io.cc
242	dev/tsunami_pchip.cc
243	dev/uart.cc
244	dev/uart8250.cc
245
246	kern/kernel_binning.cc
247	kern/kernel_stats.cc
248	kern/system_events.cc
249	kern/freebsd/freebsd_system.cc
250	kern/linux/linux_syscalls.cc
251	kern/linux/linux_system.cc
252	kern/linux/printk.cc
253	kern/tru64/dump_mbuf.cc
254	kern/tru64/printf.cc
255	kern/tru64/tru64_events.cc
256	kern/tru64/tru64_syscalls.cc
257	kern/tru64/tru64_system.cc
258
259	mem/functional/memory_control.cc
260        ''')
261
262# turbolaser encumbered sources
263turbolaser_sources = Split('''
264	encumbered/dev/dma.cc
265	encumbered/dev/etherdev.cc
266	encumbered/dev/scsi.cc
267	encumbered/dev/scsi_ctrl.cc
268	encumbered/dev/scsi_disk.cc
269	encumbered/dev/scsi_none.cc
270	encumbered/dev/tlaser_clock.cc
271	encumbered/dev/tlaser_ipi.cc
272	encumbered/dev/tlaser_mbox.cc
273	encumbered/dev/tlaser_mc146818.cc
274	encumbered/dev/tlaser_node.cc
275	encumbered/dev/tlaser_pcia.cc
276	encumbered/dev/tlaser_pcidev.cc
277	encumbered/dev/tlaser_serial.cc
278	encumbered/dev/turbolaser.cc
279	encumbered/dev/uart8530.cc
280        ''')
281
282# Syscall emulation (non-full-system) sources
283syscall_emulation_sources = Split('''
284	arch/alpha/alpha_common_syscall_emul.cc
285	arch/alpha/alpha_linux_process.cc
286	arch/alpha/alpha_tru64_process.cc
287	cpu/memtest/memtest.cc
288	encumbered/eio/eio.cc
289	encumbered/eio/exolex.cc
290	encumbered/eio/libexo.cc
291	sim/process.cc
292	sim/syscall_emul.cc
293        ''')
294
295targetarch_files = Split('''
296        alpha_common_syscall_emul.hh
297        alpha_linux_process.hh
298        alpha_memory.hh
299        alpha_tru64_process.hh
300        aout_machdep.h
301        arguments.hh
302        byte_swap.hh
303        ecoff_machdep.h
304        ev5.hh
305        faults.hh
306        isa_fullsys_traits.hh
307        isa_traits.hh
308        osfpal.hh
309        pseudo_inst.hh
310        stacktrace.hh
311        vptr.hh
312        vtophys.hh
313        ''')
314
315for f in targetarch_files:
316    env.Command('targetarch/' + f, 'arch/alpha/' + f,
317                '''echo '#include "arch/alpha/%s"' > $TARGET''' % f)
318
319
320# Set up complete list of sources based on configuration.
321sources = base_sources
322
323if env['FULL_SYSTEM']:
324    sources += full_system_sources
325    if env['ALPHA_TLASER']:
326        sources += turbolaser_sources
327else:
328    sources += syscall_emulation_sources
329
330if env['USE_MYSQL']:
331    sources += mysql_sources
332
333for opt in env.ExportOptions:
334    env.ConfigFile(opt)
335
336###################################################
337#
338# Special build rules.
339#
340###################################################
341
342# base/traceflags.{cc,hh} are generated from base/traceflags.py.
343# $TARGET.base will expand to "<build-dir>/base/traceflags".
344env.Command(Split('base/traceflags.hh base/traceflags.cc'),
345            'base/traceflags.py',
346            'python $SOURCE $TARGET.base')
347
348# several files are generated from arch/$TARGET_ISA/isa_desc.
349env.Command(Split('''arch/alpha/decoder.cc
350		     arch/alpha/decoder.hh
351                     arch/alpha/alpha_o3_exec.cc
352		     arch/alpha/fast_cpu_exec.cc
353                     arch/alpha/simple_cpu_exec.cc'''),
354            Split('''arch/alpha/isa_desc
355		     arch/isa_parser.py'''),
356            '$SRCDIR/arch/isa_parser.py $SOURCE $TARGET.dir arch/alpha')
357
358
359# libelf build is described in its own SConscript file.
360# SConscript-local is the per-config build, which just copies some
361# header files into a place where they can be found.
362SConscript('libelf/SConscript-local', exports = 'env', duplicate=0)
363SConscript('python/SConscript', exports = ['env'], duplicate=0)
364
365# This function adds the specified sources to the given build
366# environment, and returns a list of all the corresponding SCons
367# Object nodes (including an extra one for date.cc).  We explicitly
368# add the Object nodes so we can set up special dependencies for
369# date.cc.
370def make_objs(sources, env):
371    objs = [env.Object(s) for s in sources]
372    # make date.cc depend on all other objects so it always gets
373    # recompiled whenever anything else does
374    date_obj = env.Object('base/date.cc')
375    env.Depends(date_obj, objs)
376    objs.append(date_obj)
377    return objs
378
379###################################################
380#
381# Define binaries.  Each different build type (debug, opt, etc.) gets
382# a slightly different build environment.
383#
384###################################################
385
386# Include file paths are rooted in this directory.  SCons will
387# automatically expand '.' to refer to both the source directory and
388# the corresponding build directory to pick up generated include
389# files.
390env.Append(CPPPATH='.')
391
392# Debug binary
393debugEnv = env.Copy(OBJSUFFIX='.do')
394debugEnv.Label = 'debug'
395debugEnv.Append(CCFLAGS=Split('-g -gstabs+ -O0'))
396debugEnv.Append(CPPDEFINES='DEBUG')
397tlist = debugEnv.Program(target = 'm5.debug',
398                         source = make_objs(sources, debugEnv))
399debugEnv.M5Binary = tlist[0]
400
401# Optimized binary
402optEnv = env.Copy()
403optEnv.Label = 'opt'
404optEnv.Append(CCFLAGS=Split('-g -O5'))
405tlist = optEnv.Program(target = 'm5.opt',
406                       source = make_objs(sources, optEnv))
407optEnv.M5Binary = tlist[0]
408
409# "Fast" binary
410fastEnv = env.Copy(OBJSUFFIX='.fo')
411fastEnv.Label = 'fast'
412fastEnv.Append(CCFLAGS=Split('-O5'))
413fastEnv.Append(CPPDEFINES='NDEBUG')
414fastEnv.Program(target = 'm5.fast.unstripped',
415                source = make_objs(sources, fastEnv))
416tlist = fastEnv.Command(target = 'm5.fast',
417                        source = 'm5.fast.unstripped',
418                        action = 'strip $SOURCE -o $TARGET')
419fastEnv.M5Binary = tlist[0]
420
421# Profiled binary
422profEnv = env.Copy(OBJSUFFIX='.po')
423profEnv.Label = 'prof'
424profEnv.Append(CCFLAGS=Split('-O5 -g -pg'), LINKFLAGS='-pg')
425tlist = profEnv.Program(target = 'm5.prof',
426                        source = make_objs(sources, profEnv))
427profEnv.M5Binary = tlist[0]
428
429envList = [debugEnv, optEnv, fastEnv, profEnv]
430
431Return('envList')
432