SConstruct revision 8117
12023SN/A# Copyright (c) 2011 Gabe Black
22023SN/A# All rights reserved.
32023SN/A#
42023SN/A# Redistribution and use in source and binary forms, with or without
52023SN/A# modification, are permitted provided that the following conditions are
62023SN/A# met: redistributions of source code must retain the above copyright
72023SN/A# notice, this list of conditions and the following disclaimer;
82023SN/A# redistributions in binary form must reproduce the above copyright
92023SN/A# notice, this list of conditions and the following disclaimer in the
102023SN/A# documentation and/or other materials provided with the distribution;
112023SN/A# neither the name of the copyright holders nor the names of its
122023SN/A# contributors may be used to endorse or promote products derived from
132023SN/A# this software without specific prior written permission.
142023SN/A#
152023SN/A# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
162023SN/A# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
172023SN/A# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
182023SN/A# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
192023SN/A# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
202023SN/A# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
212023SN/A# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
222023SN/A# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
232023SN/A# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
242023SN/A# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
252023SN/A# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
262023SN/A#
272023SN/A# Authors: Gabe Black
282665Ssaidi@eecs.umich.edu
292665Ssaidi@eecs.umich.eduHelp('''
302665Ssaidi@eecs.umich.eduTo build a version of statetrace suitable to run on a particular ISA, use a
312023SN/Atarget of the form build/<arch>/statetrace. For example, to build statetrace
324202Sbinkertn@umich.edufor ARM binaries, run:
332023SN/A
344202Sbinkertn@umich.eduscons build/arm/statetrace
359022Sgblack@eecs.umich.edu
364997Sgblack@eecs.umich.eduYou may need a cross compiler in order to build statetrace successfully. To
374202Sbinkertn@umich.eduspecify an alternative compiler, set the CXX scons argument on the command
388780Sgblack@eecs.umich.eduline. The CXX environment variable is NOT considered when selecting the 
398780Sgblack@eecs.umich.educompiler. To override the compiler for a particular target ISA, set the
408745Sgblack@eecs.umich.edu<arch>CXX scons argument. For example, to build both the AMD64 version and
414997Sgblack@eecs.umich.eduthe ARM version at the same time using the system compiler for the AMD64
426313Sgblack@eecs.umich.eduversion and a cross compiler for arm, your command line would look like the
438777Sgblack@eecs.umich.edufollowing:
448780Sgblack@eecs.umich.edu
458780Sgblack@eecs.umich.eduscons ARMCXX=arm-cross-g++ build/amd64/statetrace build/arm/statetrace
468780Sgblack@eecs.umich.edu
478777Sgblack@eecs.umich.eduAfter a successful build, the statetrace binary(binaries) will be located in
484997Sgblack@eecs.umich.eduthe build/<arch>/ directories you specified on the command line.
498780Sgblack@eecs.umich.edu''')
506327Sgblack@eecs.umich.edu
514202Sbinkertn@umich.edu
528777Sgblack@eecs.umich.eduarches = 'amd64', 'arm', 'i686', 'sparc'
538780Sgblack@eecs.umich.edu
544997Sgblack@eecs.umich.eduimport os
554826Ssaidi@eecs.umich.edu
568755Sgblack@eecs.umich.edumain = Environment()
572023SN/Amain.SetOption('duplicate', 'soft-copy')
588745Sgblack@eecs.umich.edumain['CXXFLAGS'] = "-O3 -ggdb $_CPPINCFLAGS"
599384SAndreas.Sandberg@arm.com
608780Sgblack@eecs.umich.edumain['CXX'] = ARGUMENTS.get('CXX', main['CXX'])
614997Sgblack@eecs.umich.edu
624997Sgblack@eecs.umich.edufor arch in arches:
634202Sbinkertn@umich.edu    env = main.Clone()
6412222Sgabeblack@google.com    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