SConstruct revision 11320
18112Sgblack@eecs.umich.edu# Copyright (c) 2011 Gabe Black
28112Sgblack@eecs.umich.edu# All rights reserved.
38112Sgblack@eecs.umich.edu#
48112Sgblack@eecs.umich.edu# Redistribution and use in source and binary forms, with or without
58112Sgblack@eecs.umich.edu# modification, are permitted provided that the following conditions are
68112Sgblack@eecs.umich.edu# met: redistributions of source code must retain the above copyright
78112Sgblack@eecs.umich.edu# notice, this list of conditions and the following disclaimer;
88112Sgblack@eecs.umich.edu# redistributions in binary form must reproduce the above copyright
98112Sgblack@eecs.umich.edu# notice, this list of conditions and the following disclaimer in the
108112Sgblack@eecs.umich.edu# documentation and/or other materials provided with the distribution;
118112Sgblack@eecs.umich.edu# neither the name of the copyright holders nor the names of its
128112Sgblack@eecs.umich.edu# contributors may be used to endorse or promote products derived from
138112Sgblack@eecs.umich.edu# this software without specific prior written permission.
148112Sgblack@eecs.umich.edu#
158112Sgblack@eecs.umich.edu# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
168112Sgblack@eecs.umich.edu# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
178112Sgblack@eecs.umich.edu# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
188112Sgblack@eecs.umich.edu# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
198112Sgblack@eecs.umich.edu# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
208112Sgblack@eecs.umich.edu# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
218112Sgblack@eecs.umich.edu# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
228112Sgblack@eecs.umich.edu# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
238112Sgblack@eecs.umich.edu# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
248112Sgblack@eecs.umich.edu# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
258112Sgblack@eecs.umich.edu# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
268112Sgblack@eecs.umich.edu#
278112Sgblack@eecs.umich.edu# Authors: Gabe Black
288112Sgblack@eecs.umich.edu
298112Sgblack@eecs.umich.eduHelp('''
308112Sgblack@eecs.umich.eduTo build a version of statetrace suitable to run on a particular ISA, use a
318112Sgblack@eecs.umich.edutarget of the form build/<arch>/statetrace. For example, to build statetrace
328112Sgblack@eecs.umich.edufor ARM binaries, run:
33
34scons build/arm/statetrace
35
36You may need a cross compiler in order to build statetrace successfully. To
37specify an alternative compiler, set the CXX scons argument on the command
38line. The CXX environment variable is NOT considered when selecting the
39compiler. To override the compiler for a particular target ISA, set the
40<arch>CXX scons argument. For example, to build both the AMD64 version and
41the ARM version at the same time using the system compiler for the AMD64
42version and a cross compiler for arm, your command line would look like the
43following:
44
45scons ARMCXX=arm-cross-g++ build/amd64/statetrace build/arm/statetrace
46
47After a successful build, the statetrace binary(binaries) will be located in
48the build/<arch>/ directories you specified on the command line.
49''')
50
51
52arches = 'amd64', 'arm', 'i686', 'sparc'
53
54import os
55
56main = Environment()
57main.SetOption('duplicate', 'soft-copy')
58main['CXXFLAGS'] = "-O3 -ggdb $_CPPINCFLAGS"
59
60main['CXX'] = ARGUMENTS.get('CXX', main['CXX'])
61
62for arch in arches:
63    env = main.Clone()
64    env['CXX'] = ARGUMENTS.get(arch.upper() + 'CXX', env['CXX'])
65    env.Append(CPPFLAGS = '-D__STATETRACE_%s__' % arch.upper())
66    Export('env', 'arch')
67    env.SConscript('SConscript', variant_dir = os.path.join('build', arch))
68