Hand merge
[gem5.git] / SConscript
1 # -*- mode:python -*-
2
3 # Copyright (c) 2004 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
29 import os
30 import sys
31
32 # This file defines how to build a particular configuration of M5
33 # based on variable settings in the 'env' build environment.
34
35 # Import build environment variable from SConstruct.
36 Import('env')
37
38 ###################################################
39 #
40 # Define needed sources.
41 #
42 ###################################################
43
44 # Base sources used by all configurations.
45 base_sources = Split('''
46 arch/alpha/decoder.cc
47 arch/alpha/alpha_full_cpu_exec.cc
48 arch/alpha/fast_cpu_exec.cc
49 arch/alpha/simple_cpu_exec.cc
50 arch/alpha/inorder_cpu_exec.cc
51 arch/alpha/full_cpu_exec.cc
52 arch/alpha/faults.cc
53 arch/alpha/isa_traits.cc
54
55 base/circlebuf.cc
56 base/copyright.cc
57 base/cprintf.cc
58 base/embedfile.cc
59 base/fast_alloc.cc
60 base/fifo_buffer.cc
61 base/hostinfo.cc
62 base/hybrid_pred.cc
63 base/inifile.cc
64 base/intmath.cc
65 base/match.cc
66 base/misc.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/base_dyn_inst.cc
93 cpu/exec_context.cc
94 cpu/exetrace.cc
95 cpu/pc_event.cc
96 cpu/static_inst.cc
97 cpu/beta_cpu/2bit_local_pred.cc
98 cpu/beta_cpu/alpha_dyn_inst.cc
99 cpu/beta_cpu/alpha_full_cpu.cc
100 cpu/beta_cpu/alpha_full_cpu_builder.cc
101 cpu/beta_cpu/bpred_unit.cc
102 cpu/beta_cpu/btb.cc
103 cpu/beta_cpu/commit.cc
104 cpu/beta_cpu/decode.cc
105 cpu/beta_cpu/fetch.cc
106 cpu/beta_cpu/free_list.cc
107 cpu/beta_cpu/full_cpu.cc
108 cpu/beta_cpu/iew.cc
109 cpu/beta_cpu/inst_queue.cc
110 cpu/beta_cpu/ldstq.cc
111 cpu/beta_cpu/mem_dep_unit.cc
112 cpu/beta_cpu/ras.cc
113 cpu/beta_cpu/rename.cc
114 cpu/beta_cpu/rename_map.cc
115 cpu/beta_cpu/rob.cc
116 cpu/beta_cpu/store_set.cc
117 cpu/beta_cpu/tournament_pred.cc
118 cpu/fast_cpu/fast_cpu.cc
119 cpu/full_cpu/bpred.cc
120 cpu/full_cpu/commit.cc
121 cpu/full_cpu/create_vector.cc
122 cpu/full_cpu/cv_spec_state.cc
123 cpu/full_cpu/dd_queue.cc
124 cpu/full_cpu/dep_link.cc
125 cpu/full_cpu/dispatch.cc
126 cpu/full_cpu/dyn_inst.cc
127 cpu/full_cpu/execute.cc
128 cpu/full_cpu/fetch.cc
129 cpu/full_cpu/floss_reasons.cc
130 cpu/full_cpu/fu_pool.cc
131 cpu/full_cpu/full_cpu.cc
132 cpu/full_cpu/inst_fifo.cc
133 cpu/full_cpu/instpipe.cc
134 cpu/full_cpu/issue.cc
135 cpu/full_cpu/ls_queue.cc
136 cpu/full_cpu/machine_queue.cc
137 cpu/full_cpu/pc_sample_profile.cc
138 cpu/full_cpu/pipetrace.cc
139 cpu/full_cpu/readyq.cc
140 cpu/full_cpu/reg_info.cc
141 cpu/full_cpu/rob_station.cc
142 cpu/full_cpu/spec_memory.cc
143 cpu/full_cpu/spec_state.cc
144 cpu/full_cpu/storebuffer.cc
145 cpu/full_cpu/writeback.cc
146 cpu/full_cpu/iq/iq_station.cc
147 cpu/full_cpu/iq/iqueue.cc
148 cpu/full_cpu/iq/segmented/chain_info.cc
149 cpu/full_cpu/iq/segmented/chain_wire.cc
150 cpu/full_cpu/iq/segmented/iq_seg.cc
151 cpu/full_cpu/iq/segmented/iq_segmented.cc
152 cpu/full_cpu/iq/segmented/seg_chain.cc
153 cpu/full_cpu/iq/seznec/iq_seznec.cc
154 cpu/full_cpu/iq/standard/iq_standard.cc
155 cpu/sampling_cpu/sampling_cpu.cc
156 cpu/simple_cpu/simple_cpu.cc
157 cpu/inorder_cpu/inorder_cpu.cc
158 cpu/trace/reader/mem_trace_reader.cc
159 cpu/trace/reader/ibm_reader.cc
160 cpu/trace/reader/itx_reader.cc
161 cpu/trace/reader/m5_reader.cc
162
163 mem/base_hier.cc
164 mem/base_mem.cc
165 mem/hier_params.cc
166 mem/mem_cmd.cc
167 mem/mem_debug.cc
168 mem/mem_req.cc
169 mem/memory_interface.cc
170 mem/bus/base_interface.cc
171 mem/bus/bus.cc
172 mem/bus/bus_bridge.cc
173 mem/bus/bus_bridge_master.cc
174 mem/bus/bus_bridge_slave.cc
175 mem/bus/bus_interface.cc
176 mem/bus/dma_bus_interface.cc
177 mem/bus/dma_interface.cc
178 mem/bus/master_interface.cc
179 mem/bus/slave_interface.cc
180 mem/cache/base_cache.cc
181 mem/cache/cache.cc
182 mem/cache/cache_builder.cc
183 mem/cache/coherence/coherence_protocol.cc
184 mem/cache/coherence/uni_coherence.cc
185 mem/cache/miss/blocking_buffer.cc
186 mem/cache/miss/miss_queue.cc
187 mem/cache/miss/mshr.cc
188 mem/cache/miss/mshr_queue.cc
189 mem/cache/tags/base_tags.cc
190 mem/cache/tags/cache_tags.cc
191 mem/cache/tags/fa_lru.cc
192 mem/cache/tags/iic.cc
193 mem/cache/tags/lru.cc
194 mem/cache/tags/split.cc
195 mem/cache/tags/split_lifo.cc
196 mem/cache/tags/split_lru.cc
197 mem/cache/tags/repl/gen.cc
198 mem/cache/tags/repl/repl.cc
199 mem/functional_mem/functional_memory.cc
200 mem/functional_mem/main_memory.cc
201 mem/timing_mem/base_memory.cc
202 mem/timing_mem/memory_builder.cc
203 mem/timing_mem/simple_mem_bank.cc
204 mem/trace/itx_writer.cc
205 mem/trace/mem_trace_writer.cc
206 mem/trace/m5_writer.cc
207
208 sim/builder.cc
209 sim/configfile.cc
210 sim/debug.cc
211 sim/eventq.cc
212 sim/main.cc
213 sim/param.cc
214 sim/profile.cc
215 sim/serialize.cc
216 sim/sim_events.cc
217 sim/sim_exit.cc
218 sim/sim_object.cc
219 sim/startup.cc
220 sim/stat_context.cc
221 sim/stat_control.cc
222 sim/trace_context.cc
223 sim/universe.cc
224 sim/pyconfig/pyconfig.cc
225 sim/pyconfig/embedded_py.cc
226 ''')
227
228 # MySql sources
229 mysql_sources = Split('''
230 base/mysql.cc
231 base/stats/mysql.cc
232 ''')
233
234 # Full-system sources
235 full_system_sources = Split('''
236 arch/alpha/alpha_memory.cc
237 arch/alpha/arguments.cc
238 arch/alpha/ev5.cc
239 arch/alpha/osfpal.cc
240 arch/alpha/pseudo_inst.cc
241 arch/alpha/vtophys.cc
242
243 base/crc.cc
244 base/inet.cc
245 base/remote_gdb.cc
246
247 cpu/intr_control.cc
248
249 dev/alpha_console.cc
250 dev/baddev.cc
251 dev/simconsole.cc
252 dev/disk_image.cc
253 dev/dma.cc
254 dev/etherbus.cc
255 dev/etherdump.cc
256 dev/etherint.cc
257 dev/etherlink.cc
258 dev/etherpkt.cc
259 dev/ethertap.cc
260 dev/ide_ctrl.cc
261 dev/ide_disk.cc
262 dev/io_device.cc
263 dev/ns_gige.cc
264 dev/etherdev.cc
265 dev/pciconfigall.cc
266 dev/pcidev.cc
267 dev/pktfifo.cc
268 dev/scsi.cc
269 dev/scsi_ctrl.cc
270 dev/scsi_disk.cc
271 dev/scsi_none.cc
272 dev/sinic.cc
273 dev/simple_disk.cc
274 dev/tlaser_clock.cc
275 dev/tlaser_ipi.cc
276 dev/tlaser_mbox.cc
277 dev/tlaser_mc146818.cc
278 dev/tlaser_node.cc
279 dev/tlaser_pcia.cc
280 dev/tlaser_pcidev.cc
281 dev/tlaser_serial.cc
282 dev/turbolaser.cc
283 dev/tsunami.cc
284 dev/tsunami_cchip.cc
285 dev/tsunami_fake.cc
286 dev/tsunami_io.cc
287 dev/tsunami_pchip.cc
288 dev/uart.cc
289
290 kern/kernel_binning.cc
291 kern/kernel_stats.cc
292 kern/system_events.cc
293 kern/linux/linux_events.cc
294 kern/linux/linux_syscalls.cc
295 kern/linux/linux_system.cc
296 kern/linux/printk.cc
297 kern/tru64/dump_mbuf.cc
298 kern/tru64/printf.cc
299 kern/tru64/tru64_events.cc
300 kern/tru64/tru64_syscalls.cc
301 kern/tru64/tru64_system.cc
302
303 mem/functional_mem/memory_control.cc
304 mem/functional_mem/physical_memory.cc
305 dev/platform.cc
306
307 sim/system.cc
308 ''')
309
310 # Syscall emulation (non-full-system) sources
311 syscall_emulation_sources = Split('''
312 arch/alpha/alpha_common_syscall_emul.cc
313 arch/alpha/alpha_linux_process.cc
314 arch/alpha/alpha_tru64_process.cc
315 cpu/memtest/memtest.cc
316 cpu/trace/opt_cpu.cc
317 cpu/trace/trace_cpu.cc
318 eio/eio.cc
319 eio/exolex.cc
320 eio/libexo.cc
321 sim/process.cc
322 sim/syscall_emul.cc
323 ''')
324
325 targetarch_files = Split('''
326 alpha_common_syscall_emul.hh
327 alpha_linux_process.hh
328 alpha_memory.hh
329 alpha_tru64_process.hh
330 aout_machdep.h
331 arguments.hh
332 byte_swap.hh
333 ecoff_machdep.h
334 elf_machdep.h
335 ev5.hh
336 faults.hh
337 isa_fullsys_traits.hh
338 isa_traits.hh
339 machine_exo.h
340 osfpal.hh
341 pseudo_inst.hh
342 vptr.hh
343 vtophys.hh
344 ''')
345
346 for f in targetarch_files:
347 env.Command('targetarch/' + f, 'arch/alpha/' + f,
348 '''echo '#include "arch/alpha/%s"' > $TARGET''' % f)
349
350
351 # Set up complete list of sources based on configuration.
352 sources = base_sources
353
354 if env['FULL_SYSTEM']:
355 sources += full_system_sources
356 else:
357 sources += syscall_emulation_sources
358
359 extra_libraries = []
360 env.Append(LIBS=['z'])
361 if env['USE_MYSQL']:
362 sources += mysql_sources
363 env.Append(CPPDEFINES = 'USE_MYSQL')
364 env.Append(CPPDEFINES = 'STATS_BINNING')
365 env.Append(CPPPATH=['/usr/local/include/mysql', '/usr/include/mysql'])
366 if os.path.isdir('/usr/lib64'):
367 env.Append(LIBPATH=['/usr/lib64/mysql'])
368 else:
369 env.Append(LIBPATH=['/usr/lib/mysql/'])
370 env.Append(LIBS=['mysqlclient'])
371
372
373 ###################################################
374 #
375 # Special build rules.
376 #
377 ###################################################
378
379 # base/traceflags.{cc,hh} are generated from base/traceflags.py.
380 # $TARGET.base will expand to "<build-dir>/base/traceflags".
381 env.Command(Split('base/traceflags.hh base/traceflags.cc'),
382 'base/traceflags.py',
383 'python $SOURCE $TARGET.base')
384
385 # several files are generated from arch/$TARGET_ISA/isa_desc.
386 env.Command(Split('''arch/alpha/decoder.cc
387 arch/alpha/decoder.hh
388 arch/alpha/alpha_full_cpu_exec.cc
389 arch/alpha/fast_cpu_exec.cc
390 arch/alpha/simple_cpu_exec.cc
391 arch/alpha/inorder_cpu_exec.cc
392 arch/alpha/full_cpu_exec.cc'''),
393 Split('''arch/alpha/isa_desc
394 arch/isa_parser.py'''),
395 '$SRCDIR/arch/isa_parser.py $SOURCE $TARGET.dir arch/alpha')
396
397
398 # libelf build is described in its own SConscript file.
399 # SConscript-local is the per-config build, which just copies some
400 # header files into a place where they can be found.
401 SConscript('libelf/SConscript-local', exports = 'env', duplicate=0)
402 SConscript('sim/pyconfig/SConscript', exports = ['env'], duplicate=0)
403
404
405 # This function adds the specified sources to the given build
406 # environment, and returns a list of all the corresponding SCons
407 # Object nodes (including an extra one for date.cc). We explicitly
408 # add the Object nodes so we can set up special dependencies for
409 # date.cc.
410 def make_objs(sources, env):
411 objs = [env.Object(s) for s in sources]
412 # make date.cc depend on all other objects so it always gets
413 # recompiled whenever anything else does
414 date_obj = env.Object('base/date.cc')
415 env.Depends(date_obj, objs)
416 objs.append(date_obj)
417 objs.extend(extra_libraries)
418 return objs
419
420 ###################################################
421 #
422 # Define binaries. Each different build type (debug, opt, etc.) gets
423 # a slightly different build environment.
424 #
425 ###################################################
426
427 # Include file paths are rooted in this directory. SCons will
428 # automatically expand '.' to refer to both the source directory and
429 # the corresponding build directory to pick up generated include
430 # files.
431 env.Append(CPPPATH='.')
432
433 # Debug binary
434 debug = env.Copy(OBJSUFFIX='.do')
435 debug.Append(CCFLAGS=Split('-g -gstabs+ -O0 -lefence'))
436 debug.Append(CPPDEFINES='DEBUG')
437 debug.Program(target = 'm5.debug', source = make_objs(sources, debug))
438
439 # Optimized binary
440 opt = env.Copy()
441 opt.Append(CCFLAGS=Split('-g -O5'))
442 opt.Program(target = 'm5.opt', source = make_objs(sources, opt))
443
444 # "Fast" binary
445 fast = env.Copy(OBJSUFFIX='.fo')
446 fast.Append(CCFLAGS=Split('-O5'))
447 fast.Append(CPPDEFINES='NDEBUG')
448 fast.Program(target = 'm5.fast.unstripped', source = make_objs(sources, fast))
449 fast.Command(target = 'm5.fast', source = 'm5.fast.unstripped',
450 action = 'strip $SOURCE -o $TARGET')
451
452 # Profiled binary
453 prof = env.Copy(OBJSUFFIX='.po')
454 prof.Append(CCFLAGS=Split('-O5 -g -pg'), LINKFLAGS='-pg')
455 prof.Program(target = 'm5.prof', source = make_objs(sources, prof))