SConscript revision 2405
114184Sgabeblack@google.com# -*- mode:python -*-
214184Sgabeblack@google.com
314184Sgabeblack@google.com# Copyright (c) 2004-2005 The Regents of The University of Michigan
414184Sgabeblack@google.com# All rights reserved.
514184Sgabeblack@google.com#
614184Sgabeblack@google.com# Redistribution and use in source and binary forms, with or without
714184Sgabeblack@google.com# modification, are permitted provided that the following conditions are
814184Sgabeblack@google.com# met: redistributions of source code must retain the above copyright
914184Sgabeblack@google.com# notice, this list of conditions and the following disclaimer;
1014184Sgabeblack@google.com# redistributions in binary form must reproduce the above copyright
1114184Sgabeblack@google.com# notice, this list of conditions and the following disclaimer in the
1214184Sgabeblack@google.com# documentation and/or other materials provided with the distribution;
1314184Sgabeblack@google.com# neither the name of the copyright holders nor the names of its
1414184Sgabeblack@google.com# contributors may be used to endorse or promote products derived from
1514184Sgabeblack@google.com# this software without specific prior written permission.
1614184Sgabeblack@google.com#
1714184Sgabeblack@google.com# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1814184Sgabeblack@google.com# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1914184Sgabeblack@google.com# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
2014184Sgabeblack@google.com# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2114184Sgabeblack@google.com# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2214184Sgabeblack@google.com# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2314184Sgabeblack@google.com# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2414184Sgabeblack@google.com# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2514184Sgabeblack@google.com# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2614184Sgabeblack@google.com# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2714184Sgabeblack@google.com# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2814184Sgabeblack@google.com
2914184Sgabeblack@google.comimport os
3014184Sgabeblack@google.comimport sys
3114184Sgabeblack@google.comfrom os.path import isdir
3214184Sgabeblack@google.com
3314184Sgabeblack@google.com# This file defines how to build a particular configuration of M5
3414184Sgabeblack@google.com# based on variable settings in the 'env' build environment.
3514184Sgabeblack@google.com
3614184Sgabeblack@google.com# Import build environment variable from SConstruct.
3714184Sgabeblack@google.comImport('env')
3814184Sgabeblack@google.com
3914184Sgabeblack@google.com###################################################
4014184Sgabeblack@google.com#
4114184Sgabeblack@google.com# Define needed sources.
4214184Sgabeblack@google.com#
4314184Sgabeblack@google.com###################################################
4414184Sgabeblack@google.com
4514184Sgabeblack@google.com# Base sources used by all configurations.
4614184Sgabeblack@google.combase_sources = Split('''
4714184Sgabeblack@google.com	arch/alpha/decoder.cc
4814184Sgabeblack@google.com	arch/alpha/faults.cc
4914184Sgabeblack@google.com	arch/alpha/isa_traits.cc
5014184Sgabeblack@google.com
5114184Sgabeblack@google.com	base/circlebuf.cc
5214184Sgabeblack@google.com	base/copyright.cc
5314184Sgabeblack@google.com	base/cprintf.cc
5414184Sgabeblack@google.com        base/embedfile.cc
5514184Sgabeblack@google.com	base/fast_alloc.cc
5614184Sgabeblack@google.com	base/fifo_buffer.cc
5714184Sgabeblack@google.com	base/hostinfo.cc
5814184Sgabeblack@google.com	base/hybrid_pred.cc
5914184Sgabeblack@google.com	base/inifile.cc
6014184Sgabeblack@google.com	base/intmath.cc
6114184Sgabeblack@google.com	base/match.cc
6214184Sgabeblack@google.com	base/misc.cc
6314184Sgabeblack@google.com	base/output.cc
6414184Sgabeblack@google.com	base/pollevent.cc
6514184Sgabeblack@google.com	base/range.cc
6614184Sgabeblack@google.com	base/random.cc
6714184Sgabeblack@google.com	base/sat_counter.cc
6814184Sgabeblack@google.com	base/socket.cc
6914184Sgabeblack@google.com	base/statistics.cc
7014184Sgabeblack@google.com	base/str.cc
7114184Sgabeblack@google.com	base/time.cc
7214184Sgabeblack@google.com	base/trace.cc
7314184Sgabeblack@google.com	base/traceflags.cc
7414184Sgabeblack@google.com	base/userinfo.cc
7514184Sgabeblack@google.com	base/compression/lzss_compression.cc
7614184Sgabeblack@google.com	base/loader/aout_object.cc
7714184Sgabeblack@google.com	base/loader/ecoff_object.cc
7814184Sgabeblack@google.com	base/loader/elf_object.cc
7914184Sgabeblack@google.com	base/loader/object_file.cc
8014184Sgabeblack@google.com	base/loader/symtab.cc
8114184Sgabeblack@google.com	base/stats/events.cc
8214184Sgabeblack@google.com	base/stats/statdb.cc
8314184Sgabeblack@google.com	base/stats/visit.cc
8414184Sgabeblack@google.com	base/stats/text.cc
8514184Sgabeblack@google.com
8614184Sgabeblack@google.com	cpu/base.cc
8714184Sgabeblack@google.com	cpu/exec_context.cc
8814184Sgabeblack@google.com	cpu/exetrace.cc
8914184Sgabeblack@google.com	cpu/pc_event.cc
9014184Sgabeblack@google.com	cpu/static_inst.cc
9114184Sgabeblack@google.com        cpu/sampler/sampler.cc
9214184Sgabeblack@google.com
9314184Sgabeblack@google.com        mem/memory.cc
9414184Sgabeblack@google.com        mem/page_table.cc
9514184Sgabeblack@google.com        mem/physical.cc
9614184Sgabeblack@google.com        mem/port.cc
9714184Sgabeblack@google.com        mem/translating_port.cc
9814184Sgabeblack@google.com
9914184Sgabeblack@google.com        python/pyconfig.cc
10014184Sgabeblack@google.com        python/embedded_py.cc
10114184Sgabeblack@google.com
10214184Sgabeblack@google.com	sim/builder.cc
10314184Sgabeblack@google.com	sim/configfile.cc
10414184Sgabeblack@google.com	sim/debug.cc
10514184Sgabeblack@google.com	sim/eventq.cc
10614184Sgabeblack@google.com	sim/main.cc
10714184Sgabeblack@google.com	sim/param.cc
10814184Sgabeblack@google.com	sim/profile.cc
10914184Sgabeblack@google.com	sim/root.cc
11014184Sgabeblack@google.com	sim/serialize.cc
11114184Sgabeblack@google.com	sim/sim_events.cc
11214184Sgabeblack@google.com	sim/sim_exit.cc
11314184Sgabeblack@google.com	sim/sim_object.cc
11414184Sgabeblack@google.com	sim/startup.cc
11514184Sgabeblack@google.com	sim/stat_context.cc
11614184Sgabeblack@google.com	sim/stat_control.cc
11714184Sgabeblack@google.com	sim/system.cc
11814184Sgabeblack@google.com	sim/trace_context.cc
11914184Sgabeblack@google.com        ''')
12014184Sgabeblack@google.com
12114184Sgabeblack@google.comfast_cpu_sources = Split('''
12214184Sgabeblack@google.com	arch/alpha/fast_cpu_exec.cc
12314184Sgabeblack@google.com	cpu/fast/cpu.cc
12414184Sgabeblack@google.com        ''')
12514184Sgabeblack@google.com
12614184Sgabeblack@google.comsimple_cpu_sources = Split('''
12714184Sgabeblack@google.com	arch/alpha/simple_cpu_exec.cc
12814184Sgabeblack@google.com        cpu/simple/cpu.cc
12914184Sgabeblack@google.com        ''')
13014184Sgabeblack@google.com
13114184Sgabeblack@google.comtrace_reader_sources = Split('''
13214184Sgabeblack@google.com        cpu/trace/reader/mem_trace_reader.cc
13314184Sgabeblack@google.com        cpu/trace/reader/ibm_reader.cc
13414184Sgabeblack@google.com        cpu/trace/reader/itx_reader.cc
13514184Sgabeblack@google.com        cpu/trace/reader/m5_reader.cc
13614184Sgabeblack@google.com        cpu/trace/opt_cpu.cc
13714184Sgabeblack@google.com        cpu/trace/trace_cpu.cc
13814184Sgabeblack@google.com        ''')
13914184Sgabeblack@google.com
14014184Sgabeblack@google.comfull_cpu_sources = Split('''
14114184Sgabeblack@google.com	arch/alpha/full_cpu_exec.cc
14214184Sgabeblack@google.com        cpu/base_dyn_inst.cc
14314184Sgabeblack@google.com	encumbered/cpu/full/bpred.cc
14414184Sgabeblack@google.com	encumbered/cpu/full/commit.cc
14514184Sgabeblack@google.com	encumbered/cpu/full/cpu.cc
14614184Sgabeblack@google.com	encumbered/cpu/full/create_vector.cc
14714184Sgabeblack@google.com	encumbered/cpu/full/cv_spec_state.cc
14814184Sgabeblack@google.com	encumbered/cpu/full/dd_queue.cc
14914184Sgabeblack@google.com	encumbered/cpu/full/dep_link.cc
15014184Sgabeblack@google.com	encumbered/cpu/full/dispatch.cc
15114184Sgabeblack@google.com	encumbered/cpu/full/dyn_inst.cc
15214184Sgabeblack@google.com	encumbered/cpu/full/execute.cc
15314184Sgabeblack@google.com	encumbered/cpu/full/fetch.cc
15414184Sgabeblack@google.com	encumbered/cpu/full/floss_reasons.cc
15514184Sgabeblack@google.com	encumbered/cpu/full/inst_fifo.cc
15614184Sgabeblack@google.com	encumbered/cpu/full/instpipe.cc
15714184Sgabeblack@google.com	encumbered/cpu/full/issue.cc
15814184Sgabeblack@google.com	encumbered/cpu/full/ls_queue.cc
15914184Sgabeblack@google.com	encumbered/cpu/full/machine_queue.cc
16014184Sgabeblack@google.com        encumbered/cpu/full/pipetrace.cc
16114184Sgabeblack@google.com        encumbered/cpu/full/readyq.cc
16214184Sgabeblack@google.com        encumbered/cpu/full/reg_info.cc
16314184Sgabeblack@google.com        encumbered/cpu/full/rob_station.cc
16414184Sgabeblack@google.com        encumbered/cpu/full/spec_memory.cc
16514184Sgabeblack@google.com        encumbered/cpu/full/spec_state.cc
16614184Sgabeblack@google.com        encumbered/cpu/full/storebuffer.cc
16714184Sgabeblack@google.com        encumbered/cpu/full/writeback.cc
16814184Sgabeblack@google.com        encumbered/cpu/full/iq/iq_station.cc
16914184Sgabeblack@google.com        encumbered/cpu/full/iq/iqueue.cc
17014184Sgabeblack@google.com        encumbered/cpu/full/iq/segmented/chain_info.cc
17114184Sgabeblack@google.com        encumbered/cpu/full/iq/segmented/chain_wire.cc
17214184Sgabeblack@google.com        encumbered/cpu/full/iq/segmented/iq_seg.cc
17314184Sgabeblack@google.com        encumbered/cpu/full/iq/segmented/iq_segmented.cc
17414184Sgabeblack@google.com        encumbered/cpu/full/iq/segmented/seg_chain.cc
17514184Sgabeblack@google.com        encumbered/cpu/full/iq/seznec/iq_seznec.cc
17614184Sgabeblack@google.com        encumbered/cpu/full/iq/standard/iq_standard.cc
17714184Sgabeblack@google.com        ''')
17814184Sgabeblack@google.com
17914184Sgabeblack@google.como3_cpu_sources = Split('''
18014184Sgabeblack@google.com        arch/alpha/alpha_o3_exec.cc
18114184Sgabeblack@google.com        cpu/o3/2bit_local_pred.cc
18214184Sgabeblack@google.com        cpu/o3/alpha_dyn_inst.cc
18314184Sgabeblack@google.com        cpu/o3/alpha_cpu.cc
18414184Sgabeblack@google.com        cpu/o3/alpha_cpu_builder.cc
18514184Sgabeblack@google.com        cpu/o3/bpred_unit.cc
18614184Sgabeblack@google.com        cpu/o3/btb.cc
18714184Sgabeblack@google.com        cpu/o3/commit.cc
18814184Sgabeblack@google.com        cpu/o3/decode.cc
18914184Sgabeblack@google.com        cpu/o3/fetch.cc
19014184Sgabeblack@google.com        cpu/o3/free_list.cc
19114184Sgabeblack@google.com        cpu/o3/cpu.cc
19214184Sgabeblack@google.com        cpu/o3/iew.cc
19314184Sgabeblack@google.com        cpu/o3/inst_queue.cc
19414184Sgabeblack@google.com        cpu/o3/ldstq.cc
19514184Sgabeblack@google.com        cpu/o3/mem_dep_unit.cc
19614184Sgabeblack@google.com        cpu/o3/ras.cc
19714184Sgabeblack@google.com        cpu/o3/rename.cc
19814184Sgabeblack@google.com        cpu/o3/rename_map.cc
19914184Sgabeblack@google.com        cpu/o3/rob.cc
20014184Sgabeblack@google.com        cpu/o3/sat_counter.cc
20114184Sgabeblack@google.com        cpu/o3/store_set.cc
202        cpu/o3/tournament_pred.cc
203        ''')
204
205# MySql sources
206mysql_sources = Split('''
207	base/mysql.cc
208	base/stats/mysql.cc
209        ''')
210
211# Full-system sources
212full_system_sources = Split('''
213	arch/alpha/alpha_memory.cc
214	arch/alpha/arguments.cc
215	arch/alpha/ev5.cc
216	arch/alpha/osfpal.cc
217	arch/alpha/pseudo_inst.cc
218	arch/alpha/stacktrace.cc
219	arch/alpha/vtophys.cc
220
221	base/crc.cc
222	base/inet.cc
223	base/remote_gdb.cc
224
225	cpu/intr_control.cc
226        cpu/profile.cc
227
228	dev/alpha_console.cc
229	dev/baddev.cc
230        dev/simconsole.cc
231	dev/disk_image.cc
232	dev/etherbus.cc
233	dev/etherdump.cc
234	dev/etherint.cc
235	dev/etherlink.cc
236	dev/etherpkt.cc
237	dev/ethertap.cc
238	dev/ide_ctrl.cc
239	dev/ide_disk.cc
240	dev/io_device.cc
241	dev/ns_gige.cc
242	dev/pciconfigall.cc
243	dev/pcidev.cc
244	dev/pcifake.cc
245	dev/pktfifo.cc
246	dev/platform.cc
247	dev/sinic.cc
248	dev/simple_disk.cc
249	dev/tsunami.cc
250	dev/tsunami_cchip.cc
251	dev/isa_fake.cc
252	dev/tsunami_io.cc
253	dev/tsunami_pchip.cc
254	dev/uart.cc
255	dev/uart8250.cc
256
257	kern/kernel_binning.cc
258	kern/kernel_stats.cc
259	kern/system_events.cc
260	kern/freebsd/freebsd_system.cc
261	kern/linux/linux_syscalls.cc
262	kern/linux/linux_system.cc
263	kern/linux/printk.cc
264	kern/tru64/dump_mbuf.cc
265	kern/tru64/printf.cc
266	kern/tru64/tru64_events.cc
267	kern/tru64/tru64_syscalls.cc
268	kern/tru64/tru64_system.cc
269
270	mem/functional/memory_control.cc
271        ''')
272
273# turbolaser encumbered sources
274turbolaser_sources = Split('''
275	encumbered/dev/dma.cc
276	encumbered/dev/etherdev.cc
277	encumbered/dev/scsi.cc
278	encumbered/dev/scsi_ctrl.cc
279	encumbered/dev/scsi_disk.cc
280	encumbered/dev/scsi_none.cc
281	encumbered/dev/tlaser_clock.cc
282	encumbered/dev/tlaser_ipi.cc
283	encumbered/dev/tlaser_mbox.cc
284	encumbered/dev/tlaser_mc146818.cc
285	encumbered/dev/tlaser_node.cc
286	encumbered/dev/tlaser_pcia.cc
287	encumbered/dev/tlaser_pcidev.cc
288	encumbered/dev/tlaser_serial.cc
289	encumbered/dev/turbolaser.cc
290	encumbered/dev/uart8530.cc
291        ''')
292
293# Syscall emulation (non-full-system) sources
294syscall_emulation_sources = Split('''
295	arch/alpha/alpha_common_syscall_emul.cc
296	arch/alpha/alpha_linux_process.cc
297	arch/alpha/alpha_tru64_process.cc
298
299	encumbered/eio/exolex.cc
300	encumbered/eio/libexo.cc
301	sim/process.cc
302	sim/syscall_emul.cc
303        ''')
304
305eio_sources = Split('''
306	encumbered/eio/eio.cc
307        ''')
308
309memtest_sources = Split('''
310	cpu/memtest/memtest.cc
311        ''')
312
313targetarch_files = Split('''
314        alpha_common_syscall_emul.hh
315        alpha_linux_process.hh
316        alpha_memory.hh
317        alpha_tru64_process.hh
318        aout_machdep.h
319        arguments.hh
320        byte_swap.hh
321        ecoff_machdep.h
322        ev5.hh
323        faults.hh
324        isa_fullsys_traits.hh
325        isa_traits.hh
326        osfpal.hh
327        pseudo_inst.hh
328        stacktrace.hh
329        vptr.hh
330        vtophys.hh
331        ''')
332
333for f in targetarch_files:
334    env.Command('targetarch/' + f, 'arch/alpha/' + f,
335                '''echo '#include "arch/alpha/%s"' > $TARGET''' % f)
336
337
338# Set up complete list of sources based on configuration.
339sources = base_sources + simple_cpu_sources
340
341if env['FULL_SYSTEM']:
342    sources += full_system_sources
343    if env['ALPHA_TLASER']:
344        sources += turbolaser_sources
345else:
346    sources += syscall_emulation_sources
347
348if env['USE_MYSQL']:
349    sources += mysql_sources
350
351for opt in env.ExportOptions:
352    env.ConfigFile(opt)
353
354###################################################
355#
356# Special build rules.
357#
358###################################################
359
360# base/traceflags.{cc,hh} are generated from base/traceflags.py.
361# $TARGET.base will expand to "<build-dir>/base/traceflags".
362env.Command(Split('base/traceflags.hh base/traceflags.cc'),
363            'base/traceflags.py',
364            'python $SOURCE $TARGET.base')
365
366# several files are generated from arch/$TARGET_ISA/isa_desc.
367env.Command(Split('''arch/alpha/decoder.cc
368		     arch/alpha/decoder.hh
369                     arch/alpha/alpha_o3_exec.cc
370		     arch/alpha/fast_cpu_exec.cc
371                     arch/alpha/simple_cpu_exec.cc'''),
372            Split('''arch/alpha/isa_desc
373		     arch/isa_parser.py'''),
374            '$SRCDIR/arch/isa_parser.py $SOURCE $TARGET.dir arch/alpha')
375
376
377# libelf build is described in its own SConscript file.
378# SConscript-local is the per-config build, which just copies some
379# header files into a place where they can be found.
380SConscript('libelf/SConscript-local', exports = 'env', duplicate=0)
381SConscript('python/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    return objs
396
397###################################################
398#
399# Define binaries.  Each different build type (debug, opt, etc.) gets
400# a slightly different build environment.
401#
402###################################################
403
404# Include file paths are rooted in this directory.  SCons will
405# automatically expand '.' to refer to both the source directory and
406# the corresponding build directory to pick up generated include
407# files.
408env.Append(CPPPATH='.')
409
410# Debug binary
411debugEnv = env.Copy(OBJSUFFIX='.do')
412debugEnv.Label = 'debug'
413debugEnv.Append(CCFLAGS=Split('-g -gstabs+ -O0'))
414debugEnv.Append(CPPDEFINES='DEBUG')
415tlist = debugEnv.Program(target = 'm5.debug',
416                         source = make_objs(sources, debugEnv))
417debugEnv.M5Binary = tlist[0]
418
419# Optimized binary
420optEnv = env.Copy()
421optEnv.Label = 'opt'
422optEnv.Append(CCFLAGS=Split('-g -O5'))
423tlist = optEnv.Program(target = 'm5.opt',
424                       source = make_objs(sources, optEnv))
425optEnv.M5Binary = tlist[0]
426
427# "Fast" binary
428fastEnv = env.Copy(OBJSUFFIX='.fo')
429fastEnv.Label = 'fast'
430fastEnv.Append(CCFLAGS=Split('-O5'))
431fastEnv.Append(CPPDEFINES='NDEBUG')
432fastEnv.Program(target = 'm5.fast.unstripped',
433                source = make_objs(sources, fastEnv))
434tlist = fastEnv.Command(target = 'm5.fast',
435                        source = 'm5.fast.unstripped',
436                        action = 'strip $SOURCE -o $TARGET')
437fastEnv.M5Binary = tlist[0]
438
439# Profiled binary
440profEnv = env.Copy(OBJSUFFIX='.po')
441profEnv.Label = 'prof'
442profEnv.Append(CCFLAGS=Split('-O5 -g -pg'), LINKFLAGS='-pg')
443tlist = profEnv.Program(target = 'm5.prof',
444                        source = make_objs(sources, profEnv))
445profEnv.M5Binary = tlist[0]
446
447envList = [debugEnv, optEnv, fastEnv, profEnv]
448
449Return('envList')
450