SConscript revision 4046:ef34b290091e
1955SN/A# -*- mode:python -*-
2955SN/A
31762SN/A# Copyright (c) 2004-2005 The Regents of The University of Michigan
4955SN/A# All rights reserved.
5955SN/A#
6955SN/A# Redistribution and use in source and binary forms, with or without
7955SN/A# modification, are permitted provided that the following conditions are
8955SN/A# met: redistributions of source code must retain the above copyright
9955SN/A# notice, this list of conditions and the following disclaimer;
10955SN/A# redistributions in binary form must reproduce the above copyright
11955SN/A# notice, this list of conditions and the following disclaimer in the
12955SN/A# documentation and/or other materials provided with the distribution;
13955SN/A# neither the name of the copyright holders nor the names of its
14955SN/A# contributors may be used to endorse or promote products derived from
15955SN/A# this software without specific prior written permission.
16955SN/A#
17955SN/A# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18955SN/A# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19955SN/A# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20955SN/A# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21955SN/A# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22955SN/A# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23955SN/A# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24955SN/A# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25955SN/A# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26955SN/A# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27955SN/A# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
282665Ssaidi@eecs.umich.edu#
292665Ssaidi@eecs.umich.edu# Authors: Steve Reinhardt
30955SN/A
31955SN/Aimport os
32955SN/Aimport sys
331608SN/Afrom os.path import isfile, join as joinpath
34955SN/A
35955SN/A# This file defines how to build a particular configuration of M5
36955SN/A# based on variable settings in the 'env' build environment.
37955SN/A
38955SN/A# Import build environment variable from SConstruct.
39955SN/AImport('env')
40955SN/A
41955SN/A###################################################
42955SN/A#
43955SN/A# Define needed sources.
44955SN/A#
45955SN/A###################################################
46955SN/A
47955SN/A# Base sources used by all configurations.
482023SN/A
49955SN/Abase_sources = Split('''
50955SN/A	base/annotate.cc
51955SN/A	base/circlebuf.cc
52955SN/A	base/cprintf.cc
53955SN/A	base/fast_alloc.cc
54955SN/A	base/fifo_buffer.cc
55955SN/A	base/hostinfo.cc
56955SN/A	base/hybrid_pred.cc
57955SN/A	base/inifile.cc
581031SN/A	base/intmath.cc
59955SN/A	base/match.cc
601388SN/A	base/misc.cc
61955SN/A	base/output.cc
62955SN/A	base/pollevent.cc
631296SN/A	base/range.cc
64955SN/A	base/random.cc
652609SN/A	base/remote_gdb.cc
66955SN/A	base/sat_counter.cc
67955SN/A	base/socket.cc
68955SN/A	base/statistics.cc
69955SN/A	base/str.cc
70955SN/A	base/time.cc
71955SN/A	base/trace.cc
72955SN/A	base/traceflags.cc
73955SN/A	base/userinfo.cc
74955SN/A	base/compression/lzss_compression.cc
75955SN/A	base/loader/aout_object.cc
76955SN/A	base/loader/ecoff_object.cc
77955SN/A	base/loader/elf_object.cc
78955SN/A	base/loader/raw_object.cc
79955SN/A	base/loader/object_file.cc
80955SN/A	base/loader/symtab.cc
81955SN/A	base/stats/events.cc
82955SN/A	base/stats/statdb.cc
83955SN/A	base/stats/visit.cc
841717SN/A	base/stats/text.cc
852190SN/A
862652Ssaidi@eecs.umich.edu        cpu/activity.cc
87955SN/A	cpu/base.cc
882410SN/A	cpu/cpuevent.cc
89955SN/A	cpu/exetrace.cc
90955SN/A        cpu/func_unit.cc
911717SN/A        cpu/op_class.cc
922568SN/A	cpu/pc_event.cc
932568SN/A        cpu/quiesce_event.cc
942568SN/A	cpu/static_inst.cc
952499SN/A        cpu/simple_thread.cc
962462SN/A        cpu/thread_state.cc
972568SN/A
982395SN/A        mem/bridge.cc
992405SN/A        mem/bus.cc
100955SN/A        mem/dram.cc
101955SN/A        mem/mem_object.cc
102955SN/A        mem/packet.cc
103955SN/A        mem/physical.cc
104955SN/A        mem/port.cc
1052090SN/A        mem/tport.cc
106955SN/A
1072667Sstever@eecs.umich.edu        mem/cache/base_cache.cc
108955SN/A        mem/cache/cache.cc
109955SN/A        mem/cache/coherence/coherence_protocol.cc
1101696SN/A        mem/cache/coherence/uni_coherence.cc
111955SN/A        mem/cache/miss/blocking_buffer.cc
112955SN/A        mem/cache/miss/miss_buffer.cc
113955SN/A        mem/cache/miss/miss_queue.cc
1141127SN/A        mem/cache/miss/mshr.cc
115955SN/A        mem/cache/miss/mshr_queue.cc
116955SN/A        mem/cache/prefetch/base_prefetcher.cc
1172379SN/A        mem/cache/prefetch/ghb_prefetcher.cc
118955SN/A        mem/cache/prefetch/stride_prefetcher.cc
119955SN/A        mem/cache/prefetch/tagged_prefetcher.cc
120955SN/A        mem/cache/tags/base_tags.cc
1212155SN/A        mem/cache/tags/fa_lru.cc
1222155SN/A        mem/cache/tags/iic.cc
1232155SN/A        mem/cache/tags/lru.cc
1242155SN/A        mem/cache/tags/repl/gen.cc
1252155SN/A        mem/cache/tags/repl/repl.cc
1262155SN/A        mem/cache/tags/split.cc
1272155SN/A        mem/cache/tags/split_lifo.cc
1282155SN/A        mem/cache/tags/split_lru.cc
1292155SN/A
1302155SN/A        mem/cache/cache_builder.cc
1312155SN/A
1322155SN/A        python/swig/init.cc
1332155SN/A        python/swig/debug_wrap.cc
1342155SN/A        python/swig/main_wrap.cc
1352155SN/A        python/swig/event_wrap.cc
1362155SN/A        python/swig/random_wrap.cc
1372155SN/A        python/swig/trace_wrap.cc
1382155SN/A        python/swig/pyevent.cc
1392155SN/A
1402155SN/A	sim/builder.cc
1412155SN/A	sim/debug.cc
1422155SN/A	sim/eventq.cc
1432155SN/A	sim/faults.cc
1442155SN/A	sim/main.cc
1452155SN/A	sim/param.cc
1462155SN/A	sim/root.cc
1472155SN/A	sim/serialize.cc
1482155SN/A	sim/sim_events.cc
1492155SN/A	sim/sim_object.cc
1502155SN/A	sim/startup.cc
1512155SN/A	sim/stat_context.cc
1522155SN/A	sim/stat_control.cc
1532155SN/A	sim/system.cc
1542155SN/A        ''')
1552155SN/A
1562155SN/Atrace_reader_sources = Split('''
1572155SN/A        cpu/trace/reader/mem_trace_reader.cc
1582155SN/A        cpu/trace/reader/ibm_reader.cc
1592155SN/A        cpu/trace/reader/itx_reader.cc
1602422SN/A        cpu/trace/reader/m5_reader.cc
1612422SN/A        cpu/trace/opt_cpu.cc
1622422SN/A        cpu/trace/trace_cpu.cc
1632422SN/A        ''')
1642422SN/A
1652422SN/A
1662422SN/A
1672397SN/A# MySql sources
1682397SN/Amysql_sources = Split('''
1692422SN/A	base/mysql.cc
1702422SN/A	base/stats/mysql.cc
171955SN/A        ''')
172955SN/A
173955SN/A# Full-system sources
174955SN/Afull_system_sources = Split('''
175955SN/A	base/crc.cc
176955SN/A	base/inet.cc
177955SN/A
178955SN/A	cpu/intr_control.cc
1791078SN/A        cpu/profile.cc
180955SN/A
181955SN/A	dev/uart.cc
182955SN/A	dev/uart8250.cc
183955SN/A
1841917SN/A        mem/vport.cc
185955SN/A
186955SN/A	sim/pseudo_inst.cc
187955SN/A        ''')
188955SN/A	#dev/sinic.cc
189974SN/A        #dev/i8254xGBe.cc
190955SN/A
191955SN/Aif env['TARGET_ISA'] == 'alpha':
192955SN/A    full_system_sources += Split('''
193955SN/A	kern/tru64/dump_mbuf.cc
1942566SN/A	kern/tru64/printf.cc
1952566SN/A	kern/tru64/tru64_events.cc
196955SN/A	kern/tru64/tru64_syscalls.cc
197955SN/A        ''')
1982539SN/A
199955SN/A# Syscall emulation (non-full-system) sources
200955SN/Asyscall_emulation_sources = Split('''
201955SN/A        mem/translating_port.cc
2021817SN/A        mem/page_table.cc
2031154SN/A	sim/process.cc
2041840SN/A	sim/syscall_emul.cc
2052522SN/A        ''')
2062522SN/A
2072629SN/A#if env['TARGET_ISA'] == 'alpha':
208955SN/A#    syscall_emulation_sources += Split('''
209955SN/A#        kern/tru64/tru64.cc
210955SN/A#        ''')
2112539SN/A
212955SN/Amemtest_sources = Split('''
2132539SN/A	cpu/memtest/memtest.cc
214955SN/A        ''')
2151730SN/A
216955SN/A# Include file paths are rooted in this directory.  SCons will
2171070SN/A# automatically expand '.' to refer to both the source directory and
218955SN/A# the corresponding build directory to pick up generated include
219955SN/A# files.
2202212SN/Aenv.Append(CPPPATH=Dir('.'))
221955SN/A
2221040SN/A# Add a flag defining what THE_ISA should be for all compilation
2232507SN/Aenv.Append(CPPDEFINES=[('THE_ISA','%s_ISA' % env['TARGET_ISA'].upper())])
2242521SN/A
2252521SN/Aarch_sources = SConscript(os.path.join('arch', 'SConscript'), exports = 'env')
2262507SN/A
2272507SN/Acpu_sources = SConscript(os.path.join('cpu', 'SConscript'), exports = 'env')
2282507SN/A
2292521SN/Aif env['FULL_SYSTEM']:
2302507SN/A    dev_sources = SConscript(os.path.join('dev', 'SConscript'),
2312507SN/A                             exports = 'env')
232955SN/A    full_system_sources += dev_sources
233955SN/A
234955SN/A    kern_sources = SConscript(os.path.join('kern', 'SConscript'),
235955SN/A                              exports = 'env')
236955SN/A    full_system_sources += kern_sources
237955SN/A
2381742SN/A# Set up complete list of sources based on configuration.
2391742SN/Asources = base_sources + arch_sources + cpu_sources
2401742SN/A
2411742SN/A# encumbered should be last because we're adding to some of the other groups
2421742SN/Aif isfile(joinpath(env['SRCDIR'], 'encumbered/SConscript')):
2431742SN/A    sources += SConscript('encumbered/SConscript', exports = 'env')
2441742SN/A
2451742SN/A
2461742SN/Aif env['FULL_SYSTEM']:
2471742SN/A    sources += full_system_sources
2481742SN/Aelse:
2491742SN/A    sources += syscall_emulation_sources
2501742SN/A
2511742SN/Aif env['USE_MYSQL']:
2521742SN/A    sources += mysql_sources
2531742SN/A
2541742SN/Afor opt in env.ExportOptions:
2551742SN/A    env.ConfigFile(opt)
2561742SN/A
2571742SN/A###################################################
258955SN/A#
259955SN/A# Special build rules.
2602520SN/A#
2612517SN/A###################################################
2622253SN/A
2632253SN/A# base/traceflags.{cc,hh} are generated from base/traceflags.py.
2642253SN/A# $TARGET.base will expand to "<build-dir>/base/traceflags".
2652253SN/Aenv.Command(Split('base/traceflags.hh base/traceflags.cc'),
2662553SN/A            'base/traceflags.py',
2672553SN/A            'python $SOURCE $TARGET.base')
2682553SN/A
2692553SN/ASConscript('python/SConscript', exports = ['env'])
2702507SN/A
2712470SN/A# This function adds the specified sources to the given build
2721744SN/A# environment, and returns a list of all the corresponding SCons
2731744SN/A# Object nodes (including an extra one for date.cc).  We explicitly
2742470SN/A# add the Object nodes so we can set up special dependencies for
2752470SN/A# date.cc.
2762470SN/Adef make_objs(sources, env):
2772470SN/A    objs = [env.Object(s) for s in sources]
2782470SN/A    # make date.cc depend on all other objects so it always gets
2792470SN/A    # recompiled whenever anything else does
2802400SN/A    date_obj = env.Object('base/date.cc')
2812400SN/A    env.Depends(date_obj, objs)
282955SN/A    objs.append(date_obj)
283955SN/A    return objs
2842667Sstever@eecs.umich.edu
2852667Sstever@eecs.umich.edu###################################################
2862667Sstever@eecs.umich.edu#
2872667Sstever@eecs.umich.edu# Define binaries.  Each different build type (debug, opt, etc.) gets
2882667Sstever@eecs.umich.edu# a slightly different build environment.
2892667Sstever@eecs.umich.edu#
2902037SN/A###################################################
2912037SN/A
2922037SN/A# List of constructed environments to pass back to SConstruct
2932667Sstever@eecs.umich.eduenvList = []
2942139SN/A
2952667Sstever@eecs.umich.edu# Function to create a new build environment as clone of current
2962155SN/A# environment 'env' with modified object suffix and optional stripped
2972155SN/A# binary.  Additional keyword arguments are appended to corresponding
2982155SN/A# build environment vars.
2992155SN/Adef makeEnv(label, objsfx, strip = False, **kwargs):
3002155SN/A    newEnv = env.Copy(OBJSUFFIX=objsfx)
3012155SN/A    newEnv.Label = label
302955SN/A    newEnv.Append(**kwargs)
3032155SN/A    exe = 'm5.' + label  # final executable
304955SN/A    bin = exe + '.bin'   # executable w/o appended Python zip archive
305955SN/A    newEnv.Program(bin, make_objs(sources, newEnv))
306955SN/A    if strip:
3071742SN/A        stripped_bin = bin + '.stripped'
3081742SN/A        if sys.platform == 'sunos5':
309955SN/A            newEnv.Command(stripped_bin, bin, 'cp $SOURCE $TARGET; strip $TARGET')
310955SN/A        else:
311955SN/A            newEnv.Command(stripped_bin, bin, 'strip $SOURCE -o $TARGET')
3121858SN/A        bin = stripped_bin
313955SN/A    targets = newEnv.Concat(exe, [bin, 'python/m5py.zip'])
3141858SN/A    newEnv.M5Binary = targets[0]
3151858SN/A    envList.append(newEnv)
3161858SN/A
3171085SN/A# Debug binary
318955SN/Accflags = {}
319955SN/Aif env['GCC']:
320955SN/A    if sys.platform == 'sunos5':
321955SN/A        ccflags['debug'] = '-gstabs+'
322955SN/A    else:
323955SN/A        ccflags['debug'] = '-ggdb3'
324955SN/A    ccflags['opt'] = '-g -O3'
325955SN/A    ccflags['fast'] = '-O3'
326955SN/A    ccflags['prof'] = '-O3 -g -pg'
327955SN/Aelif env['SUNCC']:
328955SN/A    ccflags['debug'] = '-g0'
329955SN/A    ccflags['opt'] = '-g -O'
3302667Sstever@eecs.umich.edu    ccflags['fast'] = '-fast'
3311045SN/A    ccflags['prof'] = '-fast -g -pg'
332955SN/Aelif env['ICC']:
333955SN/A    ccflags['debug'] = '-g -O0'
334955SN/A    ccflags['opt'] = '-g -O'
335955SN/A    ccflags['fast'] = '-fast'
3361108SN/A    ccflags['prof'] = '-fast -g -pg'
337955SN/Aelse:
338955SN/A    print 'Unknown compiler, please fix compiler options'
339955SN/A    Exit(1)    
340955SN/A
341955SN/AmakeEnv('debug', '.do',
342955SN/A        CCFLAGS = Split(ccflags['debug']),
343955SN/A        CPPDEFINES = ['DEBUG', 'TRACING_ON=1'])
344955SN/A
345955SN/A# Optimized binary
346955SN/AmakeEnv('opt', '.o',
347955SN/A        CCFLAGS = Split(ccflags['opt']),
348955SN/A        CPPDEFINES = ['TRACING_ON=1'])
349955SN/A
350955SN/A# "Fast" binary
351955SN/AmakeEnv('fast', '.fo', strip = True,
352955SN/A        CCFLAGS = Split(ccflags['fast']),
3532655Sstever@eecs.umich.edu        CPPDEFINES = ['NDEBUG', 'TRACING_ON=0'])
3542655Sstever@eecs.umich.edu
3552655Sstever@eecs.umich.edu# Profiled binary
3562655Sstever@eecs.umich.edumakeEnv('prof', '.po',
3572655Sstever@eecs.umich.edu        CCFLAGS = Split(ccflags['prof']),
3582655Sstever@eecs.umich.edu        CPPDEFINES = ['NDEBUG', 'TRACING_ON=0'],
3592655Sstever@eecs.umich.edu        LINKFLAGS = '-pg')
3602655Sstever@eecs.umich.edu
3612655Sstever@eecs.umich.eduReturn('envList')
3622655Sstever@eecs.umich.edu