SConstruct revision 8117
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
298113Sgblack@eecs.umich.eduHelp('''
308113Sgblack@eecs.umich.eduTo build a version of statetrace suitable to run on a particular ISA, use a
318113Sgblack@eecs.umich.edutarget of the form build/<arch>/statetrace. For example, to build statetrace
328113Sgblack@eecs.umich.edufor ARM binaries, run:
338113Sgblack@eecs.umich.edu
348113Sgblack@eecs.umich.eduscons build/arm/statetrace
358113Sgblack@eecs.umich.edu
368113Sgblack@eecs.umich.eduYou may need a cross compiler in order to build statetrace successfully. To
378113Sgblack@eecs.umich.eduspecify an alternative compiler, set the CXX scons argument on the command
388113Sgblack@eecs.umich.eduline. The CXX environment variable is NOT considered when selecting the 
398113Sgblack@eecs.umich.educompiler. To override the compiler for a particular target ISA, set the
408113Sgblack@eecs.umich.edu<arch>CXX scons argument. For example, to build both the AMD64 version and
418113Sgblack@eecs.umich.eduthe ARM version at the same time using the system compiler for the AMD64
428113Sgblack@eecs.umich.eduversion and a cross compiler for arm, your command line would look like the
438113Sgblack@eecs.umich.edufollowing:
448113Sgblack@eecs.umich.edu
458113Sgblack@eecs.umich.eduscons ARMCXX=arm-cross-g++ build/amd64/statetrace build/arm/statetrace
468113Sgblack@eecs.umich.edu
478113Sgblack@eecs.umich.eduAfter a successful build, the statetrace binary(binaries) will be located in
488113Sgblack@eecs.umich.eduthe build/<arch>/ directories you specified on the command line.
498113Sgblack@eecs.umich.edu''')
508113Sgblack@eecs.umich.edu
518113Sgblack@eecs.umich.edu
528117Sgblack@eecs.umich.eduarches = 'amd64', 'arm', 'i686', 'sparc'
538113Sgblack@eecs.umich.edu
548113Sgblack@eecs.umich.eduimport os
558113Sgblack@eecs.umich.edu
568113Sgblack@eecs.umich.edumain = Environment()
578113Sgblack@eecs.umich.edumain.SetOption('duplicate', 'soft-copy')
588113Sgblack@eecs.umich.edumain['CXXFLAGS'] = "-O3 -ggdb $_CPPINCFLAGS"
598113Sgblack@eecs.umich.edu
608113Sgblack@eecs.umich.edumain['CXX'] = ARGUMENTS.get('CXX', main['CXX'])
618113Sgblack@eecs.umich.edu
628113Sgblack@eecs.umich.edufor arch in arches:
638113Sgblack@eecs.umich.edu    env = main.Clone()
648113Sgblack@eecs.umich.edu    env['CXX'] = ARGUMENTS.get(arch.upper() + 'CXX', env['CXX'])
658113Sgblack@eecs.umich.edu    env.Append(CPPFLAGS = '-D__STATETRACE_%s__' % arch.upper())
668113Sgblack@eecs.umich.edu    Export('env', 'arch')
678113Sgblack@eecs.umich.edu    env.SConscript('SConscript', variant_dir = os.path.join('build', arch))
68