SConscript revision 6007
1955SN/A# -*- mode:python -*- 2955SN/A 31762SN/A# Copyright (c) 2004-2005 The Regents of The University of Michigan 4955SN/A# All rights reserved. 5955SN/A# 6955SN/A# Redistribution and use in source and binary forms, with or without 7955SN/A# modification, are permitted provided that the following conditions are 8955SN/A# met: redistributions of source code must retain the above copyright 9955SN/A# notice, this list of conditions and the following disclaimer; 10955SN/A# redistributions in binary form must reproduce the above copyright 11955SN/A# notice, this list of conditions and the following disclaimer in the 12955SN/A# documentation and/or other materials provided with the distribution; 13955SN/A# neither the name of the copyright holders nor the names of its 14955SN/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. 282665Ssaidi@eecs.umich.edu# 294762Snate@binkert.org# Authors: Nathan Binkert 30955SN/A 315522Snate@binkert.orgimport os, subprocess 326143Snate@binkert.org 334762Snate@binkert.orgImport('env') 345522Snate@binkert.org 35955SN/Aelf_files = [] 365522Snate@binkert.orgdef ElfFile(filename): 37955SN/A elf_files.append(File(filename)) 385522Snate@binkert.org 394202Sbinkertn@umich.eduElfFile('elf_begin.c') 405742Snate@binkert.orgElfFile('elf_cntl.c') 41955SN/AElfFile('elf_data.c') 424381Sbinkertn@umich.eduElfFile('elf_end.c') 434381Sbinkertn@umich.eduElfFile('elf_fill.c') 448334Snate@binkert.orgElfFile('elf_flag.c') 45955SN/AElfFile('elf_getarhdr.c') 46955SN/AElfFile('elf_getarsym.c') 474202Sbinkertn@umich.eduElfFile('elf_getbase.c') 48955SN/AElfFile('elf_getident.c') 494382Sbinkertn@umich.eduElfFile('elf_hash.c') 504382Sbinkertn@umich.eduElfFile('elf_kind.c') 514382Sbinkertn@umich.eduElfFile('elf_memory.c') 526654Snate@binkert.orgElfFile('elf_next.c') 535517Snate@binkert.orgElfFile('elf_phnum.c') 548614Sgblack@eecs.umich.eduElfFile('elf_rand.c') 557674Snate@binkert.orgElfFile('elf_rawfile.c') 566143Snate@binkert.orgElfFile('elf_scn.c') 576143Snate@binkert.orgElfFile('elf_shnum.c') 586143Snate@binkert.orgElfFile('elf_shstrndx.c') 598233Snate@binkert.orgElfFile('elf_strptr.c') 608233Snate@binkert.orgElfFile('elf_update.c') 618233Snate@binkert.orgElfFile('elf_version.c') 628233Snate@binkert.orgElfFile('gelf_checksum.c') 638233Snate@binkert.orgElfFile('gelf_dyn.c') 648334Snate@binkert.orgElfFile('gelf_ehdr.c') 658334Snate@binkert.orgElfFile('gelf_fsize.c') 6610453SAndrew.Bardsley@arm.comElfFile('gelf_getclass.c') 6710453SAndrew.Bardsley@arm.comElfFile('gelf_phdr.c') 688233Snate@binkert.orgElfFile('gelf_rel.c') 698233Snate@binkert.orgElfFile('gelf_rela.c') 708233Snate@binkert.orgElfFile('gelf_shdr.c') 718233Snate@binkert.orgElfFile('gelf_sym.c') 728233Snate@binkert.orgElfFile('gelf_symshndx.c') 738233Snate@binkert.orgElfFile('gelf_xlate.c') 746143Snate@binkert.orgElfFile('libelf.c') 758233Snate@binkert.orgElfFile('libelf_align.c') 768233Snate@binkert.orgElfFile('libelf_allocate.c') 778233Snate@binkert.orgElfFile('libelf_ar.c') 786143Snate@binkert.orgElfFile('libelf_checksum.c') 796143Snate@binkert.orgElfFile('libelf_data.c') 806143Snate@binkert.orgElfFile('libelf_ehdr.c') 816143Snate@binkert.orgElfFile('libelf_extended.c') 828233Snate@binkert.orgElfFile('libelf_phdr.c') 838233Snate@binkert.orgElfFile('libelf_shdr.c') 848233Snate@binkert.orgElfFile('libelf_xlate.c') 856143Snate@binkert.org 868233Snate@binkert.orgElfFile('libelf_convert.c') 878233Snate@binkert.orgElfFile('libelf_fsize.c') 888233Snate@binkert.orgElfFile('libelf_msize.c') 898233Snate@binkert.org 906143Snate@binkert.orgm4env = env.Clone() 916143Snate@binkert.orgif env['GCC']: 926143Snate@binkert.org major,minor,dot = [ int(x) for x in env['CXXVERSION'].split('.')] 934762Snate@binkert.org if major >= 4: 946143Snate@binkert.org m4env.Append(CCFLAGS=['-Wno-pointer-sign']) 958233Snate@binkert.orgm4env.Append(CCFLAGS=['-Wno-implicit']) 968233Snate@binkert.orgdel m4env['CPPPATH'] 978233Snate@binkert.org 988233Snate@binkert.org# If we have gm4 use it 998233Snate@binkert.orgif m4env.Detect('gm4'): 1006143Snate@binkert.org m4env['M4'] = 'gm4' 1018233Snate@binkert.org 1028233Snate@binkert.org# Check that m4 is available 1038233Snate@binkert.orgimport SCons.Tool.m4 1048233Snate@binkert.orgif not SCons.Tool.m4.exists(m4env): 1056143Snate@binkert.org print "Error: Can't find version of M4 macro processor. " + \ 1066143Snate@binkert.org "Please install M4 and try again." 1076143Snate@binkert.org Exit(1) 1086143Snate@binkert.org 1096143Snate@binkert.orgm4env.Append(M4FLAGS='-DSRCDIR=%s' % Dir('.').path) 1106143Snate@binkert.orgm4env['M4COM'] = '$M4 $M4FLAGS $SOURCES > $TARGET' 1116143Snate@binkert.orgm4env.M4(target=File('libelf_convert.c'), 1126143Snate@binkert.org source=[File('elf_types.m4'), File('libelf_convert.m4')]) 1136143Snate@binkert.orgm4env.M4(target=File('libelf_fsize.c'), 1147065Snate@binkert.org source=[File('elf_types.m4'), File('libelf_fsize.m4')]) 1156143Snate@binkert.orgm4env.M4(target=File('libelf_msize.c'), 1168233Snate@binkert.org source=[File('elf_types.m4'), File('libelf_msize.m4')]) 1178233Snate@binkert.org 1188233Snate@binkert.org# Build libelf as a static library with PIC code so it can be linked 1198233Snate@binkert.org# into either m5 or the library 1208233Snate@binkert.orgm4env.Library('elf', [m4env.SharedObject(f) for f in elf_files]) 1218233Snate@binkert.org 1228233Snate@binkert.orgenv.Append(CPPPATH=Dir('.')) 1238233Snate@binkert.orgenv.Append(LIBS=['elf']) 1248233Snate@binkert.orgenv.Append(LIBPATH=[Dir('.')]) 1258233Snate@binkert.org 1268233Snate@binkert.org