misc: Reorder sources in util/tlm and rewrite build scripts
[gem5.git] / util / tlm / SConstruct
1 #!python
2
3 # Copyright (c) 2016, Dresden University of Technology (TU Dresden)
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:
9 #
10 # 1. Redistributions of source code must retain the above copyright notice,
11 # this list of conditions and the following disclaimer.
12 #
13 # 2. Redistributions in binary form must reproduce the above copyright
14 # notice, this list of conditions and the following disclaimer in the
15 # documentation and/or other materials provided with the distribution.
16 #
17 # 3. Neither the name of the copyright holder nor the names of its
18 # contributors may be used to endorse or promote products derived from
19 # this software without specific prior written permission.
20 #
21 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
23 # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24 # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER
25 # OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
26 # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27 # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
28 # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
29 # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
30 # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31 # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 #
33 # Authors: Christian Menard
34
35 import os
36 import sys
37
38
39 gem5_arch = 'ARM'
40 gem5_variant = 'opt'
41 #gem5_variant = 'debug'
42
43 gem5_root = Dir('#../..').srcnode().abspath
44
45 env = Environment()
46
47 #Make the gem5 root available in SConscripts
48 env['GEM5_ROOT'] = gem5_root
49
50 shlibsuffix = env['SHLIBSUFFIX']
51
52 # add include dirs
53 env.Append(CPPPATH=[gem5_root + '/build/' + gem5_arch,
54 gem5_root + '/util/systemc',
55 gem5_root + '/ext/systemc/src',
56 '#src',
57 '#examples/common',
58 ])
59
60 env.Append(CXXFLAGS=['-std=c++11',
61 '-DSC_INCLUDE_DYNAMIC_PROCESSES',
62 '-DTRACING_ON',
63 ])
64
65 if gem5_variant == 'debug':
66 env.Append(CXXFLAGS=['-g', '-DDEBUG'])
67
68 deps = [] # keep track of all dependencies required for building the binaries
69
70 deps += SConscript('src/SConscript', variant_dir='build/tlm', exports='env')
71
72 deps += SConscript('examples/common/SConscript',
73 variant_dir='build/examples/common',
74 exports=['env'])
75
76 # the SystemC SConscript makes certain assumptions, we need to fulfill these
77 # assumptions before calling the SConscript.
78 main = env
79 sys.path.append(gem5_root + '/src/python')
80 AddOption('--no-colors', dest='use_colors', action='store_false',
81 help="Don't add color to abbreviated scons output")
82
83 SConscript(gem5_root + '/ext/systemc/SConscript',
84 variant_dir='build/systemc',
85 exports='main')
86
87 # By adding libraries as dependencies instead of using LIBS, we avoid that
88 # the user needs to set the LD_LIBRARY_PATH
89 deps.append(File('build/systemc/libsystemc' + shlibsuffix))
90 deps.append(File(os.path.join(gem5_root, 'build', gem5_arch,
91 'libgem5_' + gem5_variant + shlibsuffix)))
92
93 ex_master = SConscript('examples/master_port/SConscript',
94 variant_dir='build/examples/master_port',
95 exports=['env', 'deps'])
96
97 ex_slave = SConscript('examples/slave_port/SConscript',
98 variant_dir='build/examples/slave_port',
99 exports=['env', 'deps'])
100
101 Default(ex_master + ex_slave)