SConscript revision 8655:e4001326a5ba
1955SN/A# -*- mode:python -*- 2955SN/A 312230Sgiacomo.travaglini@arm.com# Copyright (c) 2004-2005 The Regents of The University of Michigan 49812Sandreas.hansson@arm.com# All rights reserved. 59812Sandreas.hansson@arm.com# 69812Sandreas.hansson@arm.com# Redistribution and use in source and binary forms, with or without 79812Sandreas.hansson@arm.com# modification, are permitted provided that the following conditions are 89812Sandreas.hansson@arm.com# met: redistributions of source code must retain the above copyright 99812Sandreas.hansson@arm.com# notice, this list of conditions and the following disclaimer; 109812Sandreas.hansson@arm.com# redistributions in binary form must reproduce the above copyright 119812Sandreas.hansson@arm.com# notice, this list of conditions and the following disclaimer in the 129812Sandreas.hansson@arm.com# documentation and/or other materials provided with the distribution; 139812Sandreas.hansson@arm.com# neither the name of the copyright holders nor the names of its 149812Sandreas.hansson@arm.com# contributors may be used to endorse or promote products derived from 157816Ssteve.reinhardt@amd.com# this software without specific prior written permission. 165871Snate@binkert.org# 171762SN/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('main') 34955SN/A 35955SN/Aelf_files = [] 36955SN/Adef ElfFile(filename): 37955SN/A elf_files.append(File(filename)) 38955SN/A 39955SN/AElfFile('elf_begin.c') 40955SN/AElfFile('elf_cntl.c') 41955SN/AElfFile('elf_data.c') 422665Ssaidi@eecs.umich.eduElfFile('elf_end.c') 432665Ssaidi@eecs.umich.eduElfFile('elf_errmsg.c') 445863Snate@binkert.orgElfFile('elf_errno.c') 45955SN/AElfFile('elf_fill.c') 46955SN/AElfFile('elf_flag.c') 47955SN/AElfFile('elf_getarhdr.c') 48955SN/AElfFile('elf_getarsym.c') 49955SN/AElfFile('elf_getbase.c') 508878Ssteve.reinhardt@amd.comElfFile('elf_getident.c') 512632Sstever@eecs.umich.eduElfFile('elf_hash.c') 528878Ssteve.reinhardt@amd.comElfFile('elf_kind.c') 532632Sstever@eecs.umich.eduElfFile('elf_memory.c') 54955SN/AElfFile('elf_next.c') 558878Ssteve.reinhardt@amd.comElfFile('elf_phnum.c') 562632Sstever@eecs.umich.eduElfFile('elf_rand.c') 572761Sstever@eecs.umich.eduElfFile('elf_rawfile.c') 582632Sstever@eecs.umich.eduElfFile('elf_scn.c') 592632Sstever@eecs.umich.eduElfFile('elf_shnum.c') 602632Sstever@eecs.umich.eduElfFile('elf_shstrndx.c') 612761Sstever@eecs.umich.eduElfFile('elf_strptr.c') 622761Sstever@eecs.umich.eduElfFile('elf_update.c') 632761Sstever@eecs.umich.eduElfFile('elf_version.c') 648878Ssteve.reinhardt@amd.comElfFile('gelf_checksum.c') 658878Ssteve.reinhardt@amd.comElfFile('gelf_dyn.c') 662761Sstever@eecs.umich.eduElfFile('gelf_ehdr.c') 672761Sstever@eecs.umich.eduElfFile('gelf_fsize.c') 682761Sstever@eecs.umich.eduElfFile('gelf_getclass.c') 692761Sstever@eecs.umich.eduElfFile('gelf_phdr.c') 702761Sstever@eecs.umich.eduElfFile('gelf_rel.c') 718878Ssteve.reinhardt@amd.comElfFile('gelf_rela.c') 728878Ssteve.reinhardt@amd.comElfFile('gelf_shdr.c') 732632Sstever@eecs.umich.eduElfFile('gelf_sym.c') 742632Sstever@eecs.umich.eduElfFile('gelf_symshndx.c') 758878Ssteve.reinhardt@amd.comElfFile('gelf_xlate.c') 768878Ssteve.reinhardt@amd.comElfFile('libelf.c') 772632Sstever@eecs.umich.eduElfFile('libelf_align.c') 78955SN/AElfFile('libelf_allocate.c') 79955SN/AElfFile('libelf_ar.c') 80955SN/AElfFile('libelf_checksum.c') 8112563Sgabeblack@google.comElfFile('libelf_data.c') 8212563Sgabeblack@google.comElfFile('libelf_ehdr.c') 836654Snate@binkert.orgElfFile('libelf_extended.c') 8410196SCurtis.Dunham@arm.comElfFile('libelf_phdr.c') 85955SN/AElfFile('libelf_shdr.c') 865396Ssaidi@eecs.umich.eduElfFile('libelf_xlate.c') 8711401Sandreas.sandberg@arm.com 885863Snate@binkert.orgElfFile('libelf_convert.c') 895863Snate@binkert.orgElfFile('libelf_fsize.c') 904202Sbinkertn@umich.eduElfFile('libelf_msize.c') 915863Snate@binkert.org 925863Snate@binkert.orgm4env = main.Clone() 935863Snate@binkert.orgif m4env['GCC']: 945863Snate@binkert.org major,minor,dot = [int(x) for x in m4env['GCC_VERSION'].split('.')] 9513541Sandrea.mondelli@ucf.edu if major >= 4: 96955SN/A m4env.Append(CCFLAGS=['-Wno-pointer-sign']) 976654Snate@binkert.orgm4env.Append(CCFLAGS=['-Wno-implicit']) 985273Sstever@gmail.comdel m4env['CPPPATH'] 995871Snate@binkert.org 10013758Sgabeblack@google.com# If we have gm4 use it 1015273Sstever@gmail.comif m4env.Detect('gm4'): 1026654Snate@binkert.org m4env['M4'] = 'gm4' 1035396Ssaidi@eecs.umich.edu 1048120Sgblack@eecs.umich.edu# Check that m4 is available 1058120Sgblack@eecs.umich.eduimport SCons.Tool.m4 1068120Sgblack@eecs.umich.eduif not SCons.Tool.m4.exists(m4env): 1078120Sgblack@eecs.umich.edu print "Error: Can't find version of M4 macro processor. " + \ 1088120Sgblack@eecs.umich.edu "Please install M4 and try again." 1098120Sgblack@eecs.umich.edu Exit(1) 1108120Sgblack@eecs.umich.edu 1118120Sgblack@eecs.umich.edum4env.Append(M4FLAGS=['-DSRCDIR=%s' % Dir('.').path]) 1128879Ssteve.reinhardt@amd.comm4env['M4COM'] = '$M4 $M4FLAGS $SOURCES > $TARGET' 1138879Ssteve.reinhardt@amd.comm4env.M4(target=File('libelf_convert.c'), 1148879Ssteve.reinhardt@amd.com source=[File('elf_types.m4'), File('libelf_convert.m4')]) 1158879Ssteve.reinhardt@amd.comm4env.M4(target=File('libelf_fsize.c'), 1168879Ssteve.reinhardt@amd.com source=[File('elf_types.m4'), File('libelf_fsize.m4')]) 1178879Ssteve.reinhardt@amd.comm4env.M4(target=File('libelf_msize.c'), 1188879Ssteve.reinhardt@amd.com source=[File('elf_types.m4'), File('libelf_msize.m4')]) 1198879Ssteve.reinhardt@amd.com 1208879Ssteve.reinhardt@amd.com# Build libelf as a static library with PIC code so it can be linked 1218879Ssteve.reinhardt@amd.com# into either m5 or the library 1228879Ssteve.reinhardt@amd.comm4env.Library('elf', [m4env.SharedObject(f) for f in elf_files]) 1238879Ssteve.reinhardt@amd.com 1248879Ssteve.reinhardt@amd.commain.Prepend(CPPPATH=Dir('.')) 1258120Sgblack@eecs.umich.edumain.Append(LIBS=['elf']) 1268120Sgblack@eecs.umich.edumain.Prepend(LIBPATH=[Dir('.')]) 1278120Sgblack@eecs.umich.edu 1288120Sgblack@eecs.umich.edu