SConscript revision 4679
16654Snate@binkert.org# -*- mode:python -*- 26654Snate@binkert.org 35467Snate@binkert.org# Copyright (c) 2004-2005 The Regents of The University of Michigan 45467Snate@binkert.org# All rights reserved. 55467Snate@binkert.org# 65467Snate@binkert.org# Redistribution and use in source and binary forms, with or without 75467Snate@binkert.org# modification, are permitted provided that the following conditions are 85467Snate@binkert.org# met: redistributions of source code must retain the above copyright 95467Snate@binkert.org# notice, this list of conditions and the following disclaimer; 105467Snate@binkert.org# redistributions in binary form must reproduce the above copyright 115467Snate@binkert.org# notice, this list of conditions and the following disclaimer in the 125467Snate@binkert.org# documentation and/or other materials provided with the distribution; 135467Snate@binkert.org# neither the name of the copyright holders nor the names of its 145467Snate@binkert.org# contributors may be used to endorse or promote products derived from 155467Snate@binkert.org# this software without specific prior written permission. 165467Snate@binkert.org# 175467Snate@binkert.org# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 185467Snate@binkert.org# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 195467Snate@binkert.org# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 205467Snate@binkert.org# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 215467Snate@binkert.org# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 225467Snate@binkert.org# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 235467Snate@binkert.org# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 245467Snate@binkert.org# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 255467Snate@binkert.org# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 265467Snate@binkert.org# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 275467Snate@binkert.org# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 285467Snate@binkert.org# 295467Snate@binkert.org# Authors: Nathan Binkert 306654Snate@binkert.org 316654Snate@binkert.orgimport os, subprocess 326654Snate@binkert.org 336654Snate@binkert.orgImport('env') 346654Snate@binkert.org 356654Snate@binkert.orgelf_files = [] 366654Snate@binkert.orgdef ElfFile(filename): 377459Snate@binkert.org elf_files.append(File(filename)) 386502Snate@binkert.org 395467Snate@binkert.orgElfFile('elf_begin.c') 406500Snate@binkert.orgElfFile('elf_cntl.c') 416654Snate@binkert.orgElfFile('elf_data.c') 427503Snate@binkert.orgElfFile('elf_end.c') 435873Snate@binkert.orgElfFile('elf_fill.c') 446654Snate@binkert.orgElfFile('elf_flag.c') 456654Snate@binkert.orgElfFile('elf_getarhdr.c') 466654Snate@binkert.orgElfFile('elf_getarsym.c') 476654Snate@binkert.orgElfFile('elf_getbase.c') 486654Snate@binkert.orgElfFile('elf_getident.c') 496654Snate@binkert.orgElfFile('elf_hash.c') 506654Snate@binkert.orgElfFile('elf_kind.c') 516654Snate@binkert.orgElfFile('elf_memory.c') 526654Snate@binkert.orgElfFile('elf_next.c') 536654Snate@binkert.orgElfFile('elf_phnum.c') 546654Snate@binkert.orgElfFile('elf_rand.c') 556654Snate@binkert.orgElfFile('elf_rawfile.c') 566654Snate@binkert.orgElfFile('elf_scn.c') 576654Snate@binkert.orgElfFile('elf_shnum.c') 586654Snate@binkert.orgElfFile('elf_shstrndx.c') 596654Snate@binkert.orgElfFile('elf_strptr.c') 606654Snate@binkert.orgElfFile('elf_update.c') 616654Snate@binkert.orgElfFile('elf_version.c') 626654Snate@binkert.orgElfFile('gelf_checksum.c') 636654Snate@binkert.orgElfFile('gelf_dyn.c') 646654Snate@binkert.orgElfFile('gelf_ehdr.c') 656654Snate@binkert.orgElfFile('gelf_fsize.c') 666654Snate@binkert.orgElfFile('gelf_getclass.c') 676654Snate@binkert.orgElfFile('gelf_phdr.c') 686654Snate@binkert.orgElfFile('gelf_rel.c') 696654Snate@binkert.orgElfFile('gelf_rela.c') 706654Snate@binkert.orgElfFile('gelf_shdr.c') 716654Snate@binkert.orgElfFile('gelf_sym.c') 726654Snate@binkert.orgElfFile('gelf_symshndx.c') 736654Snate@binkert.orgElfFile('gelf_xlate.c') 746654Snate@binkert.orgElfFile('libelf.c') 756654Snate@binkert.orgElfFile('libelf_align.c') 766654Snate@binkert.orgElfFile('libelf_allocate.c') 776654Snate@binkert.orgElfFile('libelf_ar.c') 786654Snate@binkert.orgElfFile('libelf_checksum.c') 796654Snate@binkert.orgElfFile('libelf_data.c') 806654Snate@binkert.orgElfFile('libelf_ehdr.c') 816654Snate@binkert.orgElfFile('libelf_extended.c') 826654Snate@binkert.orgElfFile('libelf_phdr.c') 836654Snate@binkert.orgElfFile('libelf_shdr.c') 846654Snate@binkert.orgElfFile('libelf_xlate.c') 856654Snate@binkert.org 866654Snate@binkert.orgElfFile('libelf_convert.c') 876654Snate@binkert.orgElfFile('libelf_fsize.c') 886654Snate@binkert.orgElfFile('libelf_msize.c') 896654Snate@binkert.org 906654Snate@binkert.orgm4env = Environment(ENV=os.environ) 916654Snate@binkert.orgif env.get('CC'): 926654Snate@binkert.org m4env['CC'] = env['CC'] 936654Snate@binkert.orgif env.get('CXX'): 946654Snate@binkert.org m4env['CXX'] = env['CXX'] 956654Snate@binkert.org 966654Snate@binkert.org# If we have gm4 use it 976654Snate@binkert.orgif m4env.Detect('gm4'): 986654Snate@binkert.org m4env['M4'] = 'gm4' 996654Snate@binkert.org 1006654Snate@binkert.org# Check that m4 is available 1016654Snate@binkert.orgimport SCons.Tool.m4 1026654Snate@binkert.orgif not SCons.Tool.m4.exists(m4env): 1036654Snate@binkert.org print "Error: Can't find version of M4 macro processor. " + \ 1046654Snate@binkert.org "Please install M4 and try again." 1056654Snate@binkert.org Exit(1) 1066654Snate@binkert.org 1076654Snate@binkert.orgm4env.Append(M4FLAGS='-DSRCDIR=%s' % Dir('.').path) 1086654Snate@binkert.orgm4env['M4COM'] = '$M4 $M4FLAGS $SOURCES > $TARGET' 1096654Snate@binkert.orgm4env.M4(target=File('libelf_convert.c'), 1106654Snate@binkert.org source=[File('elf_types.m4'), File('libelf_convert.m4')]) 1116654Snate@binkert.orgm4env.M4(target=File('libelf_fsize.c'), 1126654Snate@binkert.org source=[File('elf_types.m4'), File('libelf_fsize.m4')]) 1136654Snate@binkert.orgm4env.M4(target=File('libelf_msize.c'), 1146654Snate@binkert.org source=[File('elf_types.m4'), File('libelf_msize.m4')]) 1156654Snate@binkert.orgm4env.Library('elf', elf_files) 1166654Snate@binkert.org 1176654Snate@binkert.orgenv.Append(CPPPATH=Dir('.')) 1186654Snate@binkert.orgenv.Append(LIBS=['elf']) 1196654Snate@binkert.orgenv.Append(LIBPATH=[Dir('.')]) 1206654Snate@binkert.org 1216654Snate@binkert.org