SConstruct revision 8117
11897Sstever@eecs.umich.edu# Copyright (c) 2011 Gabe Black 24130Ssaidi@eecs.umich.edu# All rights reserved. 31897Sstever@eecs.umich.edu# 41897Sstever@eecs.umich.edu# Redistribution and use in source and binary forms, with or without 51897Sstever@eecs.umich.edu# modification, are permitted provided that the following conditions are 61897Sstever@eecs.umich.edu# met: redistributions of source code must retain the above copyright 71897Sstever@eecs.umich.edu# notice, this list of conditions and the following disclaimer; 81897Sstever@eecs.umich.edu# redistributions in binary form must reproduce the above copyright 91897Sstever@eecs.umich.edu# notice, this list of conditions and the following disclaimer in the 101897Sstever@eecs.umich.edu# documentation and/or other materials provided with the distribution; 111897Sstever@eecs.umich.edu# neither the name of the copyright holders nor the names of its 121897Sstever@eecs.umich.edu# contributors may be used to endorse or promote products derived from 131897Sstever@eecs.umich.edu# this software without specific prior written permission. 141897Sstever@eecs.umich.edu# 151897Sstever@eecs.umich.edu# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 161897Sstever@eecs.umich.edu# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 171897Sstever@eecs.umich.edu# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 181897Sstever@eecs.umich.edu# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 191897Sstever@eecs.umich.edu# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 201897Sstever@eecs.umich.edu# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 211897Sstever@eecs.umich.edu# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 221897Sstever@eecs.umich.edu# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 231897Sstever@eecs.umich.edu# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 241897Sstever@eecs.umich.edu# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 251897Sstever@eecs.umich.edu# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 261897Sstever@eecs.umich.edu# 271897Sstever@eecs.umich.edu# Authors: Gabe Black 281897Sstever@eecs.umich.edu 291897Sstever@eecs.umich.eduHelp(''' 301897Sstever@eecs.umich.eduTo build a version of statetrace suitable to run on a particular ISA, use a 311897Sstever@eecs.umich.edutarget of the form build/<arch>/statetrace. For example, to build statetrace 321897Sstever@eecs.umich.edufor ARM binaries, run: 331897Sstever@eecs.umich.edu 344961Ssaidi@eecs.umich.eduscons build/arm/statetrace 351897Sstever@eecs.umich.edu 361897Sstever@eecs.umich.eduYou may need a cross compiler in order to build statetrace successfully. To 371897Sstever@eecs.umich.eduspecify an alternative compiler, set the CXX scons argument on the command 381897Sstever@eecs.umich.eduline. The CXX environment variable is NOT considered when selecting the 391897Sstever@eecs.umich.educompiler. To override the compiler for a particular target ISA, set the 401897Sstever@eecs.umich.edu<arch>CXX scons argument. For example, to build both the AMD64 version and 411897Sstever@eecs.umich.eduthe ARM version at the same time using the system compiler for the AMD64 421897Sstever@eecs.umich.eduversion and a cross compiler for arm, your command line would look like the 434130Ssaidi@eecs.umich.edufollowing: 443099Sstever@eecs.umich.edu 453099Sstever@eecs.umich.eduscons ARMCXX=arm-cross-g++ build/amd64/statetrace build/arm/statetrace 461897Sstever@eecs.umich.edu 473709Sstever@eecs.umich.eduAfter a successful build, the statetrace binary(binaries) will be located in 483099Sstever@eecs.umich.eduthe build/<arch>/ directories you specified on the command line. 493099Sstever@eecs.umich.edu''') 501897Sstever@eecs.umich.edu 513099Sstever@eecs.umich.edu 523725Sstever@eecs.umich.eduarches = 'amd64', 'arm', 'i686', 'sparc' 533725Sstever@eecs.umich.edu 541897Sstever@eecs.umich.eduimport os 551897Sstever@eecs.umich.edu 561897Sstever@eecs.umich.edumain = Environment() 571897Sstever@eecs.umich.edumain.SetOption('duplicate', 'soft-copy') 581897Sstever@eecs.umich.edumain['CXXFLAGS'] = "-O3 -ggdb $_CPPINCFLAGS" 591897Sstever@eecs.umich.edu 601897Sstever@eecs.umich.edumain['CXX'] = ARGUMENTS.get('CXX', main['CXX']) 611897Sstever@eecs.umich.edu 621897Sstever@eecs.umich.edufor arch in arches: 631897Sstever@eecs.umich.edu env = main.Clone() 644961Ssaidi@eecs.umich.edu env['CXX'] = ARGUMENTS.get(arch.upper() + 'CXX', env['CXX']) 654961Ssaidi@eecs.umich.edu env.Append(CPPFLAGS = '-D__STATETRACE_%s__' % arch.upper()) 664961Ssaidi@eecs.umich.edu Export('env', 'arch') 674961Ssaidi@eecs.umich.edu env.SConscript('SConscript', variant_dir = os.path.join('build', arch)) 684961Ssaidi@eecs.umich.edu