SConscript revision 1530
12086SN/A# -*- mode:python -*-
22086SN/A
32086SN/A# Copyright (c) 2004 The Regents of The University of Michigan
42086SN/A# All rights reserved.
52086SN/A#
62086SN/A# Redistribution and use in source and binary forms, with or without
72086SN/A# modification, are permitted provided that the following conditions are
82086SN/A# met: redistributions of source code must retain the above copyright
92086SN/A# notice, this list of conditions and the following disclaimer;
102086SN/A# redistributions in binary form must reproduce the above copyright
112086SN/A# notice, this list of conditions and the following disclaimer in the
122086SN/A# documentation and/or other materials provided with the distribution;
132086SN/A# neither the name of the copyright holders nor the names of its
142086SN/A# contributors may be used to endorse or promote products derived from
152086SN/A# this software without specific prior written permission.
162086SN/A#
172086SN/A# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
182086SN/A# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
192086SN/A# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
202086SN/A# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
212086SN/A# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
222086SN/A# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
232086SN/A# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
242086SN/A# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
252086SN/A# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
262086SN/A# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
272086SN/A# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
282665Ssaidi@eecs.umich.edu
292665Ssaidi@eecs.umich.eduimport os
302665Ssaidi@eecs.umich.eduimport sys
312686Sksewell@umich.edu
322086SN/A# This file defines how to build a particular configuration of M5
334202Sbinkertn@umich.edu# based on variable settings in the 'env' build environment.
342086SN/A
354202Sbinkertn@umich.edu# Import build environment variable from SConstruct.
364202Sbinkertn@umich.eduImport('env')
374202Sbinkertn@umich.edu
384661Sksewell@umich.edu###################################################
394202Sbinkertn@umich.edu#
404661Sksewell@umich.edu# Define needed sources.
412086SN/A#
424202Sbinkertn@umich.edu###################################################
434202Sbinkertn@umich.edu
444202Sbinkertn@umich.edu# Base sources used by all configurations.
454202Sbinkertn@umich.edubase_sources = Split('''
464202Sbinkertn@umich.edu	arch/alpha/decoder.cc
472086SN/A	arch/alpha/fast_cpu_exec.cc
484202Sbinkertn@umich.edu	arch/alpha/simple_cpu_exec.cc
494202Sbinkertn@umich.edu	arch/alpha/inorder_cpu_exec.cc
502086SN/A	arch/alpha/full_cpu_exec.cc
514202Sbinkertn@umich.edu	arch/alpha/faults.cc
524202Sbinkertn@umich.edu	arch/alpha/isa_traits.cc
534202Sbinkertn@umich.edu
544202Sbinkertn@umich.edu	base/circlebuf.cc
554202Sbinkertn@umich.edu	base/copyright.cc
564202Sbinkertn@umich.edu	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/python.cc
69	base/range.cc
70	base/random.cc
71	base/sat_counter.cc
72	base/socket.cc
73	base/statistics.cc
74	base/str.cc
75	base/time.cc
76	base/trace.cc
77	base/traceflags.cc
78	base/userinfo.cc
79	base/compression/lzss_compression.cc
80	base/loader/aout_object.cc
81	base/loader/ecoff_object.cc
82	base/loader/elf_object.cc
83	base/loader/object_file.cc
84	base/loader/symtab.cc
85	base/stats/events.cc
86	base/stats/python.cc
87	base/stats/statdb.cc
88	base/stats/visit.cc
89	base/stats/text.cc
90
91	cpu/base_cpu.cc
92	cpu/exec_context.cc
93	cpu/exetrace.cc
94	cpu/pc_event.cc
95	cpu/static_inst.cc
96	cpu/fast_cpu/fast_cpu.cc
97	cpu/full_cpu/bpred.cc
98	cpu/full_cpu/commit.cc
99	cpu/full_cpu/create_vector.cc
100	cpu/full_cpu/cv_spec_state.cc
101	cpu/full_cpu/dd_queue.cc
102	cpu/full_cpu/dep_link.cc
103	cpu/full_cpu/dispatch.cc
104	cpu/full_cpu/dyn_inst.cc
105	cpu/full_cpu/execute.cc
106	cpu/full_cpu/fetch.cc
107	cpu/full_cpu/floss_reasons.cc
108	cpu/full_cpu/fu_pool.cc
109	cpu/full_cpu/full_cpu.cc
110	cpu/full_cpu/inst_fifo.cc
111	cpu/full_cpu/instpipe.cc
112	cpu/full_cpu/issue.cc
113	cpu/full_cpu/ls_queue.cc
114	cpu/full_cpu/machine_queue.cc
115        cpu/full_cpu/pc_sample_profile.cc
116	cpu/full_cpu/pipetrace.cc
117	cpu/full_cpu/readyq.cc
118	cpu/full_cpu/reg_info.cc
119	cpu/full_cpu/rob_station.cc
120	cpu/full_cpu/spec_memory.cc
121	cpu/full_cpu/spec_state.cc
122	cpu/full_cpu/storebuffer.cc
123	cpu/full_cpu/writeback.cc
124	cpu/full_cpu/iq/iq_station.cc
125	cpu/full_cpu/iq/iqueue.cc
126	cpu/full_cpu/iq/segmented/chain_info.cc
127	cpu/full_cpu/iq/segmented/chain_wire.cc
128	cpu/full_cpu/iq/segmented/iq_seg.cc
129	cpu/full_cpu/iq/segmented/iq_segmented.cc
130	cpu/full_cpu/iq/segmented/seg_chain.cc
131	cpu/full_cpu/iq/seznec/iq_seznec.cc
132	cpu/full_cpu/iq/standard/iq_standard.cc
133	cpu/sampling_cpu/sampling_cpu.cc
134	cpu/simple_cpu/simple_cpu.cc
135	cpu/inorder_cpu/inorder_cpu.cc
136	cpu/trace/reader/mem_trace_reader.cc
137	cpu/trace/reader/ibm_reader.cc
138	cpu/trace/reader/itx_reader.cc
139	cpu/trace/reader/m5_reader.cc
140
141	mem/base_hier.cc
142	mem/base_mem.cc
143	mem/hier_params.cc
144	mem/mem_cmd.cc
145	mem/mem_debug.cc
146	mem/mem_req.cc
147	mem/memory_interface.cc
148	mem/bus/base_interface.cc
149	mem/bus/bus.cc
150	mem/bus/bus_bridge.cc
151	mem/bus/bus_bridge_master.cc
152	mem/bus/bus_bridge_slave.cc
153	mem/bus/bus_interface.cc
154	mem/bus/dma_bus_interface.cc
155	mem/bus/dma_interface.cc
156	mem/bus/master_interface.cc
157	mem/bus/slave_interface.cc
158	mem/cache/base_cache.cc
159	mem/cache/cache.cc
160	mem/cache/cache_builder.cc
161	mem/cache/coherence/coherence_protocol.cc
162	mem/cache/coherence/uni_coherence.cc
163	mem/cache/miss/blocking_buffer.cc
164	mem/cache/miss/miss_queue.cc
165	mem/cache/miss/mshr.cc
166	mem/cache/miss/mshr_queue.cc
167	mem/cache/tags/base_tags.cc
168	mem/cache/tags/cache_tags.cc
169	mem/cache/tags/fa_lru.cc
170	mem/cache/tags/iic.cc
171	mem/cache/tags/lru.cc
172	mem/cache/tags/split.cc
173	mem/cache/tags/split_lifo.cc
174	mem/cache/tags/split_lru.cc
175	mem/cache/tags/repl/gen.cc
176	mem/cache/tags/repl/repl.cc
177	mem/functional_mem/functional_memory.cc
178	mem/functional_mem/main_memory.cc
179	mem/timing_mem/base_memory.cc
180	mem/timing_mem/memory_builder.cc
181	mem/timing_mem/simple_mem_bank.cc
182        mem/trace/itx_writer.cc
183	mem/trace/mem_trace_writer.cc
184	mem/trace/m5_writer.cc
185
186        python/pyconfig.cc
187        python/embedded_py.cc
188
189	sim/builder.cc
190	sim/configfile.cc
191	sim/debug.cc
192	sim/eventq.cc
193	sim/main.cc
194	sim/param.cc
195	sim/profile.cc
196	sim/serialize.cc
197	sim/sim_events.cc
198	sim/sim_exit.cc
199	sim/sim_object.cc
200	sim/startup.cc
201	sim/stat_context.cc
202	sim/stat_control.cc
203	sim/trace_context.cc
204	sim/universe.cc
205        ''')
206
207# MySql sources
208mysql_sources = Split('''
209	base/mysql.cc
210	base/stats/mysql.cc
211        ''')
212
213# Full-system sources
214full_system_sources = Split('''
215	arch/alpha/alpha_memory.cc
216	arch/alpha/arguments.cc
217	arch/alpha/ev5.cc
218	arch/alpha/osfpal.cc
219	arch/alpha/pseudo_inst.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
228	dev/alpha_console.cc
229	dev/baddev.cc
230        dev/simconsole.cc
231	dev/disk_image.cc
232	dev/dma.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/etherdev.cc
244	dev/pciconfigall.cc
245	dev/pcidev.cc
246	dev/pktfifo.cc
247	dev/scsi.cc
248	dev/scsi_ctrl.cc
249	dev/scsi_disk.cc
250	dev/scsi_none.cc
251	dev/sinic.cc
252	dev/simple_disk.cc
253	dev/tlaser_clock.cc
254	dev/tlaser_ipi.cc
255	dev/tlaser_mbox.cc
256	dev/tlaser_mc146818.cc
257	dev/tlaser_node.cc
258	dev/tlaser_pcia.cc
259	dev/tlaser_pcidev.cc
260	dev/tlaser_serial.cc
261	dev/turbolaser.cc
262	dev/tsunami.cc
263	dev/tsunami_cchip.cc
264	dev/tsunami_fake.cc
265	dev/tsunami_io.cc
266	dev/tsunami_pchip.cc
267	dev/uart.cc
268
269	kern/kernel_binning.cc
270	kern/kernel_stats.cc
271	kern/system_events.cc
272	kern/linux/linux_events.cc
273	kern/linux/linux_syscalls.cc
274	kern/linux/linux_system.cc
275	kern/linux/printk.cc
276	kern/tru64/dump_mbuf.cc
277	kern/tru64/printf.cc
278	kern/tru64/tru64_events.cc
279	kern/tru64/tru64_syscalls.cc
280	kern/tru64/tru64_system.cc
281
282	mem/functional_mem/memory_control.cc
283	mem/functional_mem/physical_memory.cc
284        dev/platform.cc
285
286	sim/system.cc
287        ''')
288
289# Syscall emulation (non-full-system) sources
290syscall_emulation_sources = Split('''
291	arch/alpha/alpha_common_syscall_emul.cc
292	arch/alpha/alpha_linux_process.cc
293	arch/alpha/alpha_tru64_process.cc
294	cpu/memtest/memtest.cc
295        cpu/trace/opt_cpu.cc
296	cpu/trace/trace_cpu.cc
297	eio/eio.cc
298	eio/exolex.cc
299	eio/libexo.cc
300	sim/process.cc
301	sim/syscall_emul.cc
302        ''')
303
304targetarch_files = Split('''
305        alpha_common_syscall_emul.hh
306        alpha_linux_process.hh
307        alpha_memory.hh
308        alpha_tru64_process.hh
309        aout_machdep.h
310        arguments.hh
311        byte_swap.hh
312        ecoff_machdep.h
313        elf_machdep.h
314        ev5.hh
315        faults.hh
316        isa_fullsys_traits.hh
317        isa_traits.hh
318        machine_exo.h
319        osfpal.hh
320        pseudo_inst.hh
321        vptr.hh
322        vtophys.hh
323        ''')
324
325for f in targetarch_files:
326    env.Command('targetarch/' + f, 'arch/alpha/' + f,
327                '''echo '#include "arch/alpha/%s"' > $TARGET''' % f)
328
329
330# Set up complete list of sources based on configuration.
331sources = base_sources
332
333if env['FULL_SYSTEM']:
334    sources += full_system_sources
335else:
336    sources += syscall_emulation_sources
337
338extra_libraries = []
339env.Append(LIBS=['z'])
340if env['USE_MYSQL']:
341    sources += mysql_sources
342    env.Append(CPPDEFINES = 'USE_MYSQL')
343    env.Append(CPPDEFINES = 'STATS_BINNING')
344    env.Append(CPPPATH=['/usr/local/include/mysql', '/usr/include/mysql'])
345    if os.path.isdir('/usr/lib64'):
346        env.Append(LIBPATH=['/usr/lib64/mysql'])
347    else:
348        env.Append(LIBPATH=['/usr/lib/mysql/'])
349    env.Append(LIBS=['mysqlclient'])
350
351
352###################################################
353#
354# Special build rules.
355#
356###################################################
357
358# base/traceflags.{cc,hh} are generated from base/traceflags.py.
359# $TARGET.base will expand to "<build-dir>/base/traceflags".
360env.Command(Split('base/traceflags.hh base/traceflags.cc'),
361            'base/traceflags.py',
362            'python $SOURCE $TARGET.base')
363
364# several files are generated from arch/$TARGET_ISA/isa_desc.
365env.Command(Split('''arch/alpha/decoder.cc
366		     arch/alpha/decoder.hh
367		     arch/alpha/fast_cpu_exec.cc
368                     arch/alpha/simple_cpu_exec.cc
369                     arch/alpha/inorder_cpu_exec.cc
370                     arch/alpha/full_cpu_exec.cc'''),
371            Split('''arch/alpha/isa_desc
372		     arch/isa_parser.py'''),
373            '$SRCDIR/arch/isa_parser.py $SOURCE $TARGET.dir arch/alpha')
374
375
376# libelf build is described in its own SConscript file.
377# SConscript-local is the per-config build, which just copies some
378# header files into a place where they can be found.
379SConscript('libelf/SConscript-local', exports = 'env', duplicate=0)
380SConscript('python/SConscript', exports = ['env'], duplicate=0)
381SConscript('simobj/SConscript', exports = 'env', duplicate=0)
382
383# This function adds the specified sources to the given build
384# environment, and returns a list of all the corresponding SCons
385# Object nodes (including an extra one for date.cc).  We explicitly
386# add the Object nodes so we can set up special dependencies for
387# date.cc.
388def make_objs(sources, env):
389    objs = [env.Object(s) for s in sources]
390    # make date.cc depend on all other objects so it always gets
391    # recompiled whenever anything else does
392    date_obj = env.Object('base/date.cc')
393    env.Depends(date_obj, objs)
394    objs.append(date_obj)
395    objs.extend(extra_libraries)
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
412debug = env.Copy(OBJSUFFIX='.do')
413debug.Append(CCFLAGS=Split('-g -gstabs+ -O0'))
414debug.Append(CPPDEFINES='DEBUG')
415debug.Program(target = 'm5.debug', source = make_objs(sources, debug))
416
417# Optimized binary
418opt = env.Copy()
419opt.Append(CCFLAGS=Split('-g -O5'))
420opt.Program(target = 'm5.opt', source = make_objs(sources, opt))
421
422# "Fast" binary
423fast = env.Copy(OBJSUFFIX='.fo')
424fast.Append(CCFLAGS=Split('-O5'))
425fast.Append(CPPDEFINES='NDEBUG')
426fast.Program(target = 'm5.fast.unstripped', source = make_objs(sources, fast))
427fast.Command(target = 'm5.fast', source = 'm5.fast.unstripped',
428             action = 'strip $SOURCE -o $TARGET')
429
430# Profiled binary
431prof = env.Copy(OBJSUFFIX='.po')
432prof.Append(CCFLAGS=Split('-O5 -g -pg'), LINKFLAGS='-pg')
433prof.Program(target = 'm5.prof', source = make_objs(sources, prof))
434