SConscript revision 5086
1955SN/A# -*- mode:python -*- 2955SN/A 313576Sciro.santilli@arm.com# Copyright (c) 2004-2005 The Regents of The University of Michigan 413576Sciro.santilli@arm.com# All rights reserved. 513576Sciro.santilli@arm.com# 613576Sciro.santilli@arm.com# Redistribution and use in source and binary forms, with or without 713576Sciro.santilli@arm.com# modification, are permitted provided that the following conditions are 813576Sciro.santilli@arm.com# met: redistributions of source code must retain the above copyright 913576Sciro.santilli@arm.com# notice, this list of conditions and the following disclaimer; 1013576Sciro.santilli@arm.com# redistributions in binary form must reproduce the above copyright 1113576Sciro.santilli@arm.com# notice, this list of conditions and the following disclaimer in the 1213576Sciro.santilli@arm.com# documentation and/or other materials provided with the distribution; 1313576Sciro.santilli@arm.com# neither the name of the copyright holders nor the names of its 141762SN/A# contributors may be used to endorse or promote products derived from 15955SN/A# this software without specific prior written permission. 16955SN/A# 17955SN/A# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18955SN/A# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19955SN/A# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20955SN/A# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21955SN/A# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22955SN/A# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23955SN/A# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24955SN/A# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25955SN/A# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26955SN/A# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27955SN/A# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28955SN/A# 29955SN/A# Authors: Nathan Binkert 30955SN/A 31955SN/Aimport os, subprocess 32955SN/A 33955SN/AImport('env') 34955SN/A 35955SN/Aelf_files = [] 36955SN/Adef ElfFile(filename): 37955SN/A elf_files.append(File(filename)) 38955SN/A 392665Ssaidi@eecs.umich.eduElfFile('elf_begin.c') 404762Snate@binkert.orgElfFile('elf_cntl.c') 41955SN/AElfFile('elf_data.c') 4212563Sgabeblack@google.comElfFile('elf_end.c') 4312563Sgabeblack@google.comElfFile('elf_fill.c') 445522Snate@binkert.orgElfFile('elf_flag.c') 456143Snate@binkert.orgElfFile('elf_getarhdr.c') 4612371Sgabeblack@google.comElfFile('elf_getarsym.c') 474762Snate@binkert.orgElfFile('elf_getbase.c') 485522Snate@binkert.orgElfFile('elf_getident.c') 49955SN/AElfFile('elf_hash.c') 505522Snate@binkert.orgElfFile('elf_kind.c') 5111974Sgabeblack@google.comElfFile('elf_memory.c') 52955SN/AElfFile('elf_next.c') 535522Snate@binkert.orgElfFile('elf_phnum.c') 544202Sbinkertn@umich.eduElfFile('elf_rand.c') 555742Snate@binkert.orgElfFile('elf_rawfile.c') 56955SN/AElfFile('elf_scn.c') 574381Sbinkertn@umich.eduElfFile('elf_shnum.c') 584381Sbinkertn@umich.eduElfFile('elf_shstrndx.c') 5912246Sgabeblack@google.comElfFile('elf_strptr.c') 6012246Sgabeblack@google.comElfFile('elf_update.c') 618334Snate@binkert.orgElfFile('elf_version.c') 62955SN/AElfFile('gelf_checksum.c') 63955SN/AElfFile('gelf_dyn.c') 644202Sbinkertn@umich.eduElfFile('gelf_ehdr.c') 65955SN/AElfFile('gelf_fsize.c') 664382Sbinkertn@umich.eduElfFile('gelf_getclass.c') 674382Sbinkertn@umich.eduElfFile('gelf_phdr.c') 684382Sbinkertn@umich.eduElfFile('gelf_rel.c') 696654Snate@binkert.orgElfFile('gelf_rela.c') 705517Snate@binkert.orgElfFile('gelf_shdr.c') 718614Sgblack@eecs.umich.eduElfFile('gelf_sym.c') 727674Snate@binkert.orgElfFile('gelf_symshndx.c') 736143Snate@binkert.orgElfFile('gelf_xlate.c') 746143Snate@binkert.orgElfFile('libelf.c') 756143Snate@binkert.orgElfFile('libelf_align.c') 7612302Sgabeblack@google.comElfFile('libelf_allocate.c') 7712302Sgabeblack@google.comElfFile('libelf_ar.c') 7812302Sgabeblack@google.comElfFile('libelf_checksum.c') 7912371Sgabeblack@google.comElfFile('libelf_data.c') 8012371Sgabeblack@google.comElfFile('libelf_ehdr.c') 8112371Sgabeblack@google.comElfFile('libelf_extended.c') 8212371Sgabeblack@google.comElfFile('libelf_phdr.c') 8312371Sgabeblack@google.comElfFile('libelf_shdr.c') 8412371Sgabeblack@google.comElfFile('libelf_xlate.c') 8512371Sgabeblack@google.com 8612371Sgabeblack@google.comElfFile('libelf_convert.c') 8712371Sgabeblack@google.comElfFile('libelf_fsize.c') 8812371Sgabeblack@google.comElfFile('libelf_msize.c') 8912371Sgabeblack@google.com 9012371Sgabeblack@google.comm4env = Environment(ENV=os.environ) 9112371Sgabeblack@google.comif env.get('CC'): 9212371Sgabeblack@google.com m4env['CC'] = env['CC'] 9312371Sgabeblack@google.comif env.get('CXX'): 9412371Sgabeblack@google.com m4env['CXX'] = env['CXX'] 9512371Sgabeblack@google.com 9612371Sgabeblack@google.com# If we have gm4 use it 9712371Sgabeblack@google.comif m4env.Detect('gm4'): 9812371Sgabeblack@google.com m4env['M4'] = 'gm4' 9912371Sgabeblack@google.com 10012371Sgabeblack@google.com# Check that m4 is available 10112371Sgabeblack@google.comimport SCons.Tool.m4 10212371Sgabeblack@google.comif not SCons.Tool.m4.exists(m4env): 10312371Sgabeblack@google.com print "Error: Can't find version of M4 macro processor. " + \ 10412371Sgabeblack@google.com "Please install M4 and try again." 10512371Sgabeblack@google.com Exit(1) 10612371Sgabeblack@google.com 10712371Sgabeblack@google.comm4env.Append(M4FLAGS='-DSRCDIR=%s' % Dir('.').path) 10812371Sgabeblack@google.comm4env['M4COM'] = '$M4 $M4FLAGS $SOURCES > $TARGET' 10912371Sgabeblack@google.comm4env.M4(target=File('libelf_convert.c'), 11012371Sgabeblack@google.com source=[File('elf_types.m4'), File('libelf_convert.m4')]) 11112371Sgabeblack@google.comm4env.M4(target=File('libelf_fsize.c'), 11212371Sgabeblack@google.com source=[File('elf_types.m4'), File('libelf_fsize.m4')]) 11312371Sgabeblack@google.comm4env.M4(target=File('libelf_msize.c'), 11412371Sgabeblack@google.com source=[File('elf_types.m4'), File('libelf_msize.m4')]) 11512371Sgabeblack@google.comm4env.Library('elf', elf_files) 11612371Sgabeblack@google.com 11712371Sgabeblack@google.comenv.Append(CPPPATH=Dir('.')) 11812371Sgabeblack@google.comenv.Append(LIBS=['elf']) 11912371Sgabeblack@google.comenv.Append(LIBPATH=[Dir('.')]) 12012371Sgabeblack@google.com 12112371Sgabeblack@google.com