Statetrace: Accomodate cross compiling statetrace with scons.
[gem5.git] / util / statetrace / SConstruct
index de0eade6a8c94ae446aeda0770124aa7f5bd0177..2e93162d8770a2b82e0061a6a5fc78bf0359f17d 100644 (file)
 #
 # Authors: Gabe Black
 
-sources = ['statetrace.cc', 'tracechild.cc', 'tracechild_arch.cc']
-cxx_flags = "-O3 -ggdb -I ./ -I ./arch"
-objects = [Object(source, CXXFLAGS=cxx_flags) for source in sources]
-Program('statetrace', objects)
+Help('''
+To build a version of statetrace suitable to run on a particular ISA, use a
+target of the form build/<arch>/statetrace. For example, to build statetrace
+for ARM binaries, run:
+
+scons build/arm/statetrace
+
+You may need a cross compiler in order to build statetrace successfully. To
+specify an alternative compiler, set the CXX scons argument on the command
+line. The CXX environment variable is NOT considered when selecting the 
+compiler. To override the compiler for a particular target ISA, set the
+<arch>CXX scons argument. For example, to build both the AMD64 version and
+the ARM version at the same time using the system compiler for the AMD64
+version and a cross compiler for arm, your command line would look like the
+following:
+
+scons ARMCXX=arm-cross-g++ build/amd64/statetrace build/arm/statetrace
+
+After a successful build, the statetrace binary(binaries) will be located in
+the build/<arch>/ directories you specified on the command line.
+''')
+
+
+arches = 'amd64', 'arm', 'i386', 'sparc'
+
+import os
+
+main = Environment()
+main.SetOption('duplicate', 'soft-copy')
+main['CXXFLAGS'] = "-O3 -ggdb $_CPPINCFLAGS"
+
+main['CXX'] = ARGUMENTS.get('CXX', main['CXX'])
+
+for arch in arches:
+    env = main.Clone()
+    env['CXX'] = ARGUMENTS.get(arch.upper() + 'CXX', env['CXX'])
+    env.Append(CPPFLAGS = '-D__STATETRACE_%s__' % arch.upper())
+    Export('env', 'arch')
+    env.SConscript('SConscript', variant_dir = os.path.join('build', arch))