SConstruct revision 8117
12221SN/A# Copyright (c) 2011 Gabe Black
22221SN/A# All rights reserved.
32221SN/A#
42221SN/A# Redistribution and use in source and binary forms, with or without
52221SN/A# modification, are permitted provided that the following conditions are
62221SN/A# met: redistributions of source code must retain the above copyright
72221SN/A# notice, this list of conditions and the following disclaimer;
82221SN/A# redistributions in binary form must reproduce the above copyright
92221SN/A# notice, this list of conditions and the following disclaimer in the
102221SN/A# documentation and/or other materials provided with the distribution;
112221SN/A# neither the name of the copyright holders nor the names of its
122221SN/A# contributors may be used to endorse or promote products derived from
132221SN/A# this software without specific prior written permission.
142221SN/A#
152221SN/A# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
162221SN/A# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
172221SN/A# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
182221SN/A# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
192221SN/A# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
202221SN/A# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
212221SN/A# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
222221SN/A# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
232221SN/A# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
242221SN/A# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
252221SN/A# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
262221SN/A#
272665Ssaidi@eecs.umich.edu# Authors: Gabe Black
282665Ssaidi@eecs.umich.edu
292665Ssaidi@eecs.umich.eduHelp('''
302221SN/ATo build a version of statetrace suitable to run on a particular ISA, use a
312221SN/Atarget of the form build/<arch>/statetrace. For example, to build statetrace
323890Ssaidi@eecs.umich.edufor ARM binaries, run:
333890Ssaidi@eecs.umich.edu
342221SN/Ascons build/arm/statetrace
357678Sgblack@eecs.umich.edu
362221SN/AYou may need a cross compiler in order to build statetrace successfully. To
372221SN/Aspecify an alternative compiler, set the CXX scons argument on the command
382221SN/Aline. The CXX environment variable is NOT considered when selecting the 
392221SN/Acompiler. To override the compiler for a particular target ISA, set the
402223SN/A<arch>CXX scons argument. For example, to build both the AMD64 version and
412221SN/Athe ARM version at the same time using the system compiler for the AMD64
422221SN/Aversion and a cross compiler for arm, your command line would look like the
433415Sgblack@eecs.umich.edufollowing:
443415Sgblack@eecs.umich.edu
452221SN/Ascons ARMCXX=arm-cross-g++ build/amd64/statetrace build/arm/statetrace
464997Sgblack@eecs.umich.edu
474997Sgblack@eecs.umich.eduAfter a successful build, the statetrace binary(binaries) will be located in
483573Sgblack@eecs.umich.eduthe build/<arch>/ directories you specified on the command line.
492221SN/A''')
502221SN/A
513576Sgblack@eecs.umich.edu
523576Sgblack@eecs.umich.eduarches = 'amd64', 'arm', 'i686', 'sparc'
533576Sgblack@eecs.umich.edu
543576Sgblack@eecs.umich.eduimport os
553576Sgblack@eecs.umich.edu
563576Sgblack@eecs.umich.edumain = Environment()
573576Sgblack@eecs.umich.edumain.SetOption('duplicate', 'soft-copy')
583576Sgblack@eecs.umich.edumain['CXXFLAGS'] = "-O3 -ggdb $_CPPINCFLAGS"
593576Sgblack@eecs.umich.edu
6012517Srekai.gonzalezalberquilla@arm.commain['CXX'] = ARGUMENTS.get('CXX', main['CXX'])
613573Sgblack@eecs.umich.edu
623573Sgblack@eecs.umich.edufor arch in arches:
633573Sgblack@eecs.umich.edu    env = main.Clone()
643573Sgblack@eecs.umich.edu    env['CXX'] = ARGUMENTS.get(arch.upper() + 'CXX', env['CXX'])
653573Sgblack@eecs.umich.edu    env.Append(CPPFLAGS = '-D__STATETRACE_%s__' % arch.upper())
6612517Srekai.gonzalezalberquilla@arm.com    Export('env', 'arch')
673573Sgblack@eecs.umich.edu    env.SConscript('SConscript', variant_dir = os.path.join('build', arch))
6812517Srekai.gonzalezalberquilla@arm.com