SConscript revision 2400
1# -*- mode:python -*- 2 3# Copyright (c) 2004-2005 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 29import os 30import sys 31from os.path import isdir 32 33# This file defines how to build a particular configuration of M5 34# based on variable settings in the 'env' build environment. 35 36# Import build environment variable from SConstruct. 37Import('env') 38 39################################################### 40# 41# Define needed sources. 42# 43################################################### 44 45# Base sources used by all configurations. 46base_sources = Split(''' 47 arch/alpha/decoder.cc 48 arch/alpha/faults.cc 49 arch/alpha/isa_traits.cc 50 51 base/circlebuf.cc 52 base/copyright.cc 53 base/cprintf.cc 54 base/embedfile.cc 55 base/fast_alloc.cc 56 base/fifo_buffer.cc 57 base/hostinfo.cc 58 base/hybrid_pred.cc 59 base/inifile.cc 60 base/intmath.cc 61 base/match.cc 62 base/misc.cc 63 base/output.cc 64 base/pollevent.cc 65 base/range.cc 66 base/random.cc 67 base/sat_counter.cc 68 base/socket.cc 69 base/statistics.cc 70 base/str.cc 71 base/time.cc 72 base/trace.cc 73 base/traceflags.cc 74 base/userinfo.cc 75 base/compression/lzss_compression.cc 76 base/loader/aout_object.cc 77 base/loader/ecoff_object.cc 78 base/loader/elf_object.cc 79 base/loader/object_file.cc 80 base/loader/symtab.cc 81 base/stats/events.cc 82 base/stats/statdb.cc 83 base/stats/visit.cc 84 base/stats/text.cc 85 86 cpu/base.cc 87 cpu/exec_context.cc 88 cpu/exetrace.cc 89 cpu/pc_event.cc 90 cpu/static_inst.cc 91 cpu/sampler/sampler.cc 92 93 mem/memory.cc 94 mem/page_table.cc 95 mem/physical.cc 96 mem/translating_port.cc 97 98 python/pyconfig.cc 99 python/embedded_py.cc 100 101 sim/builder.cc 102 sim/configfile.cc 103 sim/debug.cc 104 sim/eventq.cc 105 sim/main.cc 106 sim/param.cc 107 sim/profile.cc 108 sim/root.cc 109 sim/serialize.cc 110 sim/sim_events.cc 111 sim/sim_exit.cc 112 sim/sim_object.cc 113 sim/startup.cc 114 sim/stat_context.cc 115 sim/stat_control.cc 116 sim/system.cc 117 sim/trace_context.cc 118 ''') 119 120fast_cpu_sources = Split(''' 121 arch/alpha/fast_cpu_exec.cc 122 cpu/fast/cpu.cc 123 ''') 124 125simple_cpu_sources = Split(''' 126 arch/alpha/simple_cpu_exec.cc 127 cpu/simple/cpu.cc 128 ''') 129 130trace_reader_sources = Split(''' 131 cpu/trace/reader/mem_trace_reader.cc 132 cpu/trace/reader/ibm_reader.cc 133 cpu/trace/reader/itx_reader.cc 134 cpu/trace/reader/m5_reader.cc 135 cpu/trace/opt_cpu.cc 136 cpu/trace/trace_cpu.cc 137 ''') 138 139full_cpu_sources = Split(''' 140 arch/alpha/full_cpu_exec.cc 141 cpu/base_dyn_inst.cc 142 encumbered/cpu/full/bpred.cc 143 encumbered/cpu/full/commit.cc 144 encumbered/cpu/full/cpu.cc 145 encumbered/cpu/full/create_vector.cc 146 encumbered/cpu/full/cv_spec_state.cc 147 encumbered/cpu/full/dd_queue.cc 148 encumbered/cpu/full/dep_link.cc 149 encumbered/cpu/full/dispatch.cc 150 encumbered/cpu/full/dyn_inst.cc 151 encumbered/cpu/full/execute.cc 152 encumbered/cpu/full/fetch.cc 153 encumbered/cpu/full/floss_reasons.cc 154 encumbered/cpu/full/inst_fifo.cc 155 encumbered/cpu/full/instpipe.cc 156 encumbered/cpu/full/issue.cc 157 encumbered/cpu/full/ls_queue.cc 158 encumbered/cpu/full/machine_queue.cc 159 encumbered/cpu/full/pipetrace.cc 160 encumbered/cpu/full/readyq.cc 161 encumbered/cpu/full/reg_info.cc 162 encumbered/cpu/full/rob_station.cc 163 encumbered/cpu/full/spec_memory.cc 164 encumbered/cpu/full/spec_state.cc 165 encumbered/cpu/full/storebuffer.cc 166 encumbered/cpu/full/writeback.cc 167 encumbered/cpu/full/iq/iq_station.cc 168 encumbered/cpu/full/iq/iqueue.cc 169 encumbered/cpu/full/iq/segmented/chain_info.cc 170 encumbered/cpu/full/iq/segmented/chain_wire.cc 171 encumbered/cpu/full/iq/segmented/iq_seg.cc 172 encumbered/cpu/full/iq/segmented/iq_segmented.cc 173 encumbered/cpu/full/iq/segmented/seg_chain.cc 174 encumbered/cpu/full/iq/seznec/iq_seznec.cc 175 encumbered/cpu/full/iq/standard/iq_standard.cc 176 ''') 177 178o3_cpu_sources = Split(''' 179 arch/alpha/alpha_o3_exec.cc 180 cpu/o3/2bit_local_pred.cc 181 cpu/o3/alpha_dyn_inst.cc 182 cpu/o3/alpha_cpu.cc 183 cpu/o3/alpha_cpu_builder.cc 184 cpu/o3/bpred_unit.cc 185 cpu/o3/btb.cc 186 cpu/o3/commit.cc 187 cpu/o3/decode.cc 188 cpu/o3/fetch.cc 189 cpu/o3/free_list.cc 190 cpu/o3/cpu.cc 191 cpu/o3/iew.cc 192 cpu/o3/inst_queue.cc 193 cpu/o3/ldstq.cc 194 cpu/o3/mem_dep_unit.cc 195 cpu/o3/ras.cc 196 cpu/o3/rename.cc 197 cpu/o3/rename_map.cc 198 cpu/o3/rob.cc 199 cpu/o3/sat_counter.cc 200 cpu/o3/store_set.cc 201 cpu/o3/tournament_pred.cc 202 ''') 203 204# MySql sources 205mysql_sources = Split(''' 206 base/mysql.cc 207 base/stats/mysql.cc 208 ''') 209 210# Full-system sources 211full_system_sources = Split(''' 212 arch/alpha/alpha_memory.cc 213 arch/alpha/arguments.cc 214 arch/alpha/ev5.cc 215 arch/alpha/osfpal.cc 216 arch/alpha/pseudo_inst.cc 217 arch/alpha/stacktrace.cc 218 arch/alpha/vtophys.cc 219 220 base/crc.cc 221 base/inet.cc 222 base/remote_gdb.cc 223 224 cpu/intr_control.cc 225 cpu/profile.cc 226 227 dev/alpha_console.cc 228 dev/baddev.cc 229 dev/simconsole.cc 230 dev/disk_image.cc 231 dev/etherbus.cc 232 dev/etherdump.cc 233 dev/etherint.cc 234 dev/etherlink.cc 235 dev/etherpkt.cc 236 dev/ethertap.cc 237 dev/ide_ctrl.cc 238 dev/ide_disk.cc 239 dev/io_device.cc 240 dev/ns_gige.cc 241 dev/pciconfigall.cc 242 dev/pcidev.cc 243 dev/pcifake.cc 244 dev/pktfifo.cc 245 dev/platform.cc 246 dev/sinic.cc 247 dev/simple_disk.cc 248 dev/tsunami.cc 249 dev/tsunami_cchip.cc 250 dev/isa_fake.cc 251 dev/tsunami_io.cc 252 dev/tsunami_pchip.cc 253 dev/uart.cc 254 dev/uart8250.cc 255 256 kern/kernel_binning.cc 257 kern/kernel_stats.cc 258 kern/system_events.cc 259 kern/freebsd/freebsd_system.cc 260 kern/linux/linux_syscalls.cc 261 kern/linux/linux_system.cc 262 kern/linux/printk.cc 263 kern/tru64/dump_mbuf.cc 264 kern/tru64/printf.cc 265 kern/tru64/tru64_events.cc 266 kern/tru64/tru64_syscalls.cc 267 kern/tru64/tru64_system.cc 268 269 mem/functional/memory_control.cc 270 ''') 271 272# turbolaser encumbered sources 273turbolaser_sources = Split(''' 274 encumbered/dev/dma.cc 275 encumbered/dev/etherdev.cc 276 encumbered/dev/scsi.cc 277 encumbered/dev/scsi_ctrl.cc 278 encumbered/dev/scsi_disk.cc 279 encumbered/dev/scsi_none.cc 280 encumbered/dev/tlaser_clock.cc 281 encumbered/dev/tlaser_ipi.cc 282 encumbered/dev/tlaser_mbox.cc 283 encumbered/dev/tlaser_mc146818.cc 284 encumbered/dev/tlaser_node.cc 285 encumbered/dev/tlaser_pcia.cc 286 encumbered/dev/tlaser_pcidev.cc 287 encumbered/dev/tlaser_serial.cc 288 encumbered/dev/turbolaser.cc 289 encumbered/dev/uart8530.cc 290 ''') 291 292# Syscall emulation (non-full-system) sources 293syscall_emulation_sources = Split(''' 294 arch/alpha/alpha_common_syscall_emul.cc 295 arch/alpha/alpha_linux_process.cc 296 arch/alpha/alpha_tru64_process.cc 297 298 encumbered/eio/exolex.cc 299 encumbered/eio/libexo.cc 300 sim/process.cc 301 sim/syscall_emul.cc 302 ''') 303 304eio_sources = Split(''' 305 encumbered/eio/eio.cc 306 ''') 307 308memtest_sources = Split(''' 309 cpu/memtest/memtest.cc 310 ''') 311 312targetarch_files = Split(''' 313 alpha_common_syscall_emul.hh 314 alpha_linux_process.hh 315 alpha_memory.hh 316 alpha_tru64_process.hh 317 aout_machdep.h 318 arguments.hh 319 byte_swap.hh 320 ecoff_machdep.h 321 ev5.hh 322 faults.hh 323 isa_fullsys_traits.hh 324 isa_traits.hh 325 osfpal.hh 326 pseudo_inst.hh 327 stacktrace.hh 328 vptr.hh 329 vtophys.hh 330 ''') 331 332for f in targetarch_files: 333 env.Command('targetarch/' + f, 'arch/alpha/' + f, 334 '''echo '#include "arch/alpha/%s"' > $TARGET''' % f) 335 336 337# Set up complete list of sources based on configuration. 338sources = base_sources 339 340if env['FULL_SYSTEM']: 341 sources += full_system_sources 342 if env['ALPHA_TLASER']: 343 sources += turbolaser_sources 344else: 345 sources += syscall_emulation_sources 346 347if env['USE_MYSQL']: 348 sources += mysql_sources 349 350for opt in env.ExportOptions: 351 env.ConfigFile(opt) 352 353################################################### 354# 355# Special build rules. 356# 357################################################### 358 359# base/traceflags.{cc,hh} are generated from base/traceflags.py. 360# $TARGET.base will expand to "<build-dir>/base/traceflags". 361env.Command(Split('base/traceflags.hh base/traceflags.cc'), 362 'base/traceflags.py', 363 'python $SOURCE $TARGET.base') 364 365# several files are generated from arch/$TARGET_ISA/isa_desc. 366env.Command(Split('''arch/alpha/decoder.cc 367 arch/alpha/decoder.hh 368 arch/alpha/alpha_o3_exec.cc 369 arch/alpha/fast_cpu_exec.cc 370 arch/alpha/simple_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) 381 382# This function adds the specified sources to the given build 383# environment, and returns a list of all the corresponding SCons 384# Object nodes (including an extra one for date.cc). We explicitly 385# add the Object nodes so we can set up special dependencies for 386# date.cc. 387def make_objs(sources, env): 388 objs = [env.Object(s) for s in sources] 389 # make date.cc depend on all other objects so it always gets 390 # recompiled whenever anything else does 391 date_obj = env.Object('base/date.cc') 392 env.Depends(date_obj, objs) 393 objs.append(date_obj) 394 return objs 395 396################################################### 397# 398# Define binaries. Each different build type (debug, opt, etc.) gets 399# a slightly different build environment. 400# 401################################################### 402 403# Include file paths are rooted in this directory. SCons will 404# automatically expand '.' to refer to both the source directory and 405# the corresponding build directory to pick up generated include 406# files. 407env.Append(CPPPATH='.') 408 409# Debug binary 410debugEnv = env.Copy(OBJSUFFIX='.do') 411debugEnv.Label = 'debug' 412debugEnv.Append(CCFLAGS=Split('-g -gstabs+ -O0')) 413debugEnv.Append(CPPDEFINES='DEBUG') 414tlist = debugEnv.Program(target = 'm5.debug', 415 source = make_objs(sources, debugEnv)) 416debugEnv.M5Binary = tlist[0] 417 418# Optimized binary 419optEnv = env.Copy() 420optEnv.Label = 'opt' 421optEnv.Append(CCFLAGS=Split('-g -O5')) 422tlist = optEnv.Program(target = 'm5.opt', 423 source = make_objs(sources, optEnv)) 424optEnv.M5Binary = tlist[0] 425 426# "Fast" binary 427fastEnv = env.Copy(OBJSUFFIX='.fo') 428fastEnv.Label = 'fast' 429fastEnv.Append(CCFLAGS=Split('-O5')) 430fastEnv.Append(CPPDEFINES='NDEBUG') 431fastEnv.Program(target = 'm5.fast.unstripped', 432 source = make_objs(sources, fastEnv)) 433tlist = fastEnv.Command(target = 'm5.fast', 434 source = 'm5.fast.unstripped', 435 action = 'strip $SOURCE -o $TARGET') 436fastEnv.M5Binary = tlist[0] 437 438# Profiled binary 439profEnv = env.Copy(OBJSUFFIX='.po') 440profEnv.Label = 'prof' 441profEnv.Append(CCFLAGS=Split('-O5 -g -pg'), LINKFLAGS='-pg') 442tlist = profEnv.Program(target = 'm5.prof', 443 source = make_objs(sources, profEnv)) 444profEnv.M5Binary = tlist[0] 445 446envList = [debugEnv, optEnv, fastEnv, profEnv] 447 448Return('envList') 449