3 # Copyright (c) 2004-2005 The Regents of The University of Michigan
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.
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.
29 # Authors: Steve Reinhardt
33 from os.path import isfile, join as joinpath
35 # This file defines how to build a particular configuration of M5
36 # based on variable settings in the 'env' build environment.
38 # Import build environment variable from SConstruct.
41 ###################################################
43 # Define needed sources.
45 ###################################################
47 # Base sources used by all configurations.
49 base_sources = Split('''
74 base/compression/lzss_compression.cc
75 base/loader/aout_object.cc
76 base/loader/ecoff_object.cc
77 base/loader/elf_object.cc
78 base/loader/raw_object.cc
79 base/loader/object_file.cc
108 mem/cache/base_cache.cc
110 mem/cache/coherence/coherence_protocol.cc
111 mem/cache/coherence/uni_coherence.cc
112 mem/cache/miss/blocking_buffer.cc
113 mem/cache/miss/miss_buffer.cc
114 mem/cache/miss/miss_queue.cc
115 mem/cache/miss/mshr.cc
116 mem/cache/miss/mshr_queue.cc
117 mem/cache/prefetch/base_prefetcher.cc
118 mem/cache/prefetch/ghb_prefetcher.cc
119 mem/cache/prefetch/stride_prefetcher.cc
120 mem/cache/prefetch/tagged_prefetcher.cc
121 mem/cache/tags/base_tags.cc
122 mem/cache/tags/fa_lru.cc
123 mem/cache/tags/iic.cc
124 mem/cache/tags/lru.cc
125 mem/cache/tags/repl/gen.cc
126 mem/cache/tags/repl/repl.cc
127 mem/cache/tags/split.cc
128 mem/cache/tags/split_lifo.cc
129 mem/cache/tags/split_lru.cc
131 mem/cache/cache_builder.cc
134 python/swig/core_wrap.cc
135 python/swig/debug_wrap.cc
136 python/swig/event_wrap.cc
137 python/swig/random_wrap.cc
138 python/swig/sim_object_wrap.cc
139 python/swig/stats_wrap.cc
140 python/swig/trace_wrap.cc
141 python/swig/pyevent.cc
142 python/swig/pyobject.cc
162 trace_reader_sources = Split('''
163 cpu/trace/reader/mem_trace_reader.cc
164 cpu/trace/reader/ibm_reader.cc
165 cpu/trace/reader/itx_reader.cc
166 cpu/trace/reader/m5_reader.cc
168 cpu/trace/trace_cpu.cc
174 mysql_sources = Split('''
179 # Full-system sources
180 full_system_sources = Split('''
197 if env['TARGET_ISA'] == 'alpha':
198 full_system_sources += Split('''
199 kern/tru64/dump_mbuf.cc
201 kern/tru64/tru64_events.cc
202 kern/tru64/tru64_syscalls.cc
205 # Syscall emulation (non-full-system) sources
206 syscall_emulation_sources = Split('''
207 mem/translating_port.cc
213 #if env['TARGET_ISA'] == 'alpha':
214 # syscall_emulation_sources += Split('''
215 # kern/tru64/tru64.cc
218 memtest_sources = Split('''
219 cpu/memtest/memtest.cc
222 # Include file paths are rooted in this directory. SCons will
223 # automatically expand '.' to refer to both the source directory and
224 # the corresponding build directory to pick up generated include
226 env.Append(CPPPATH=Dir('.'))
228 # Add a flag defining what THE_ISA should be for all compilation
229 env.Append(CPPDEFINES=[('THE_ISA','%s_ISA' % env['TARGET_ISA'].upper())])
231 arch_sources = SConscript(os.path.join('arch', 'SConscript'), exports = 'env')
233 cpu_sources = SConscript(os.path.join('cpu', 'SConscript'), exports = 'env')
235 if env['FULL_SYSTEM']:
236 dev_sources = SConscript(os.path.join('dev', 'SConscript'),
238 full_system_sources += dev_sources
240 kern_sources = SConscript(os.path.join('kern', 'SConscript'),
242 full_system_sources += kern_sources
244 # Set up complete list of sources based on configuration.
245 sources = base_sources + arch_sources + cpu_sources
247 # encumbered should be last because we're adding to some of the other groups
248 if isfile(joinpath(env['SRCDIR'], 'encumbered/SConscript')):
249 sources += SConscript('encumbered/SConscript', exports = 'env')
252 if env['FULL_SYSTEM']:
253 sources += full_system_sources
255 sources += syscall_emulation_sources
258 sources += mysql_sources
260 for opt in env.ExportOptions:
263 ###################################################
265 # Special build rules.
267 ###################################################
269 # base/traceflags.{cc,hh} are generated from base/traceflags.py.
270 # $TARGET.base will expand to "<build-dir>/base/traceflags".
271 env.Command(Split('base/traceflags.hh base/traceflags.cc'),
272 'base/traceflags.py',
273 'python $SOURCE $TARGET.base')
275 SConscript('python/SConscript', exports = ['env'])
277 # This function adds the specified sources to the given build
278 # environment, and returns a list of all the corresponding SCons
279 # Object nodes (including an extra one for date.cc). We explicitly
280 # add the Object nodes so we can set up special dependencies for
282 def make_objs(sources, env):
283 objs = [env.Object(s) for s in sources]
284 # make date.cc depend on all other objects so it always gets
285 # recompiled whenever anything else does
286 date_obj = env.Object('base/date.cc')
287 env.Depends(date_obj, objs)
288 objs.append(date_obj)
291 ###################################################
293 # Define binaries. Each different build type (debug, opt, etc.) gets
294 # a slightly different build environment.
296 ###################################################
298 # List of constructed environments to pass back to SConstruct
301 # Function to create a new build environment as clone of current
302 # environment 'env' with modified object suffix and optional stripped
303 # binary. Additional keyword arguments are appended to corresponding
304 # build environment vars.
305 def makeEnv(label, objsfx, strip = False, **kwargs):
306 newEnv = env.Copy(OBJSUFFIX=objsfx)
308 newEnv.Append(**kwargs)
309 exe = 'm5.' + label # final executable
310 bin = exe + '.bin' # executable w/o appended Python zip archive
311 newEnv.Program(bin, make_objs(sources, newEnv))
313 stripped_bin = bin + '.stripped'
314 if sys.platform == 'sunos5':
315 newEnv.Command(stripped_bin, bin, 'cp $SOURCE $TARGET; strip $TARGET')
317 newEnv.Command(stripped_bin, bin, 'strip $SOURCE -o $TARGET')
319 targets = newEnv.Concat(exe, [bin, 'python/m5py.zip'])
320 newEnv.M5Binary = targets[0]
321 envList.append(newEnv)
326 if sys.platform == 'sunos5':
327 ccflags['debug'] = '-gstabs+'
329 ccflags['debug'] = '-ggdb3'
330 ccflags['opt'] = '-g -O3'
331 ccflags['fast'] = '-O3'
332 ccflags['prof'] = '-O3 -g -pg'
334 ccflags['debug'] = '-g0'
335 ccflags['opt'] = '-g -O'
336 ccflags['fast'] = '-fast'
337 ccflags['prof'] = '-fast -g -pg'
339 ccflags['debug'] = '-g -O0'
340 ccflags['opt'] = '-g -O'
341 ccflags['fast'] = '-fast'
342 ccflags['prof'] = '-fast -g -pg'
344 print 'Unknown compiler, please fix compiler options'
347 makeEnv('debug', '.do',
348 CCFLAGS = Split(ccflags['debug']),
349 CPPDEFINES = ['DEBUG', 'TRACING_ON=1'])
353 CCFLAGS = Split(ccflags['opt']),
354 CPPDEFINES = ['TRACING_ON=1'])
357 makeEnv('fast', '.fo', strip = True,
358 CCFLAGS = Split(ccflags['fast']),
359 CPPDEFINES = ['NDEBUG', 'TRACING_ON=0'])
362 makeEnv('prof', '.po',
363 CCFLAGS = Split(ccflags['prof']),
364 CPPDEFINES = ['NDEBUG', 'TRACING_ON=0'],