SConscript revision 8737
13546Sgblack@eecs.umich.edu# -*- mode:python -*- 23546Sgblack@eecs.umich.edu 33546Sgblack@eecs.umich.edu# Copyright (c) 2004-2005 The Regents of The University of Michigan 43546Sgblack@eecs.umich.edu# All rights reserved. 53546Sgblack@eecs.umich.edu# 63546Sgblack@eecs.umich.edu# Redistribution and use in source and binary forms, with or without 73546Sgblack@eecs.umich.edu# modification, are permitted provided that the following conditions are 83546Sgblack@eecs.umich.edu# met: redistributions of source code must retain the above copyright 93546Sgblack@eecs.umich.edu# notice, this list of conditions and the following disclaimer; 103546Sgblack@eecs.umich.edu# redistributions in binary form must reproduce the above copyright 113546Sgblack@eecs.umich.edu# notice, this list of conditions and the following disclaimer in the 123546Sgblack@eecs.umich.edu# documentation and/or other materials provided with the distribution; 133546Sgblack@eecs.umich.edu# neither the name of the copyright holders nor the names of its 143546Sgblack@eecs.umich.edu# contributors may be used to endorse or promote products derived from 153546Sgblack@eecs.umich.edu# this software without specific prior written permission. 163546Sgblack@eecs.umich.edu# 173546Sgblack@eecs.umich.edu# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 183546Sgblack@eecs.umich.edu# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 193546Sgblack@eecs.umich.edu# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 203546Sgblack@eecs.umich.edu# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 213546Sgblack@eecs.umich.edu# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 223546Sgblack@eecs.umich.edu# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 233546Sgblack@eecs.umich.edu# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 243546Sgblack@eecs.umich.edu# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 253546Sgblack@eecs.umich.edu# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 263546Sgblack@eecs.umich.edu# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 273546Sgblack@eecs.umich.edu# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 283546Sgblack@eecs.umich.edu# 293546Sgblack@eecs.umich.edu# Authors: Nathan Binkert 303546Sgblack@eecs.umich.edu 314202Sbinkertn@umich.eduimport os, subprocess 323546Sgblack@eecs.umich.edu 334202Sbinkertn@umich.eduImport('main') 344202Sbinkertn@umich.edu 354202Sbinkertn@umich.eduelf_files = [] 363546Sgblack@eecs.umich.edudef ElfFile(filename): 375192Ssaidi@eecs.umich.edu elf_files.append(File(filename)) 385192Ssaidi@eecs.umich.edu 395192Ssaidi@eecs.umich.eduElfFile('elf_begin.c') 404202Sbinkertn@umich.eduElfFile('elf_cntl.c') 414202Sbinkertn@umich.eduElfFile('elf_data.c') 424202Sbinkertn@umich.eduElfFile('elf_end.c') 433546Sgblack@eecs.umich.eduElfFile('elf_errmsg.c') 444202Sbinkertn@umich.eduElfFile('elf_errno.c') 454202Sbinkertn@umich.eduElfFile('elf_fill.c') 464202Sbinkertn@umich.eduElfFile('elf_flag.c') 474202Sbinkertn@umich.eduElfFile('elf_getarhdr.c') 484202Sbinkertn@umich.eduElfFile('elf_getarsym.c') 495192Ssaidi@eecs.umich.eduElfFile('elf_getbase.c') 505192Ssaidi@eecs.umich.eduElfFile('elf_getident.c') 515401Ssaidi@eecs.umich.eduElfFile('elf_hash.c') 525401Ssaidi@eecs.umich.eduElfFile('elf_kind.c') 535401Ssaidi@eecs.umich.eduElfFile('elf_memory.c') 545401Ssaidi@eecs.umich.eduElfFile('elf_next.c') 555401Ssaidi@eecs.umich.eduElfFile('elf_phnum.c') 565401Ssaidi@eecs.umich.eduElfFile('elf_rand.c') 57ElfFile('elf_rawfile.c') 58ElfFile('elf_scn.c') 59ElfFile('elf_shnum.c') 60ElfFile('elf_shstrndx.c') 61ElfFile('elf_strptr.c') 62ElfFile('elf_update.c') 63ElfFile('elf_version.c') 64ElfFile('gelf_checksum.c') 65ElfFile('gelf_dyn.c') 66ElfFile('gelf_ehdr.c') 67ElfFile('gelf_fsize.c') 68ElfFile('gelf_getclass.c') 69ElfFile('gelf_phdr.c') 70ElfFile('gelf_rel.c') 71ElfFile('gelf_rela.c') 72ElfFile('gelf_shdr.c') 73ElfFile('gelf_sym.c') 74ElfFile('gelf_symshndx.c') 75ElfFile('gelf_xlate.c') 76ElfFile('libelf.c') 77ElfFile('libelf_align.c') 78ElfFile('libelf_allocate.c') 79ElfFile('libelf_ar.c') 80ElfFile('libelf_checksum.c') 81ElfFile('libelf_data.c') 82ElfFile('libelf_ehdr.c') 83ElfFile('libelf_extended.c') 84ElfFile('libelf_phdr.c') 85ElfFile('libelf_shdr.c') 86ElfFile('libelf_xlate.c') 87 88ElfFile('libelf_convert.c') 89ElfFile('libelf_fsize.c') 90ElfFile('libelf_msize.c') 91 92m4env = main.Clone() 93if m4env['GCC']: 94 major,minor,dot = [int(x) for x in m4env['GCC_VERSION'].split('.')] 95 if major >= 4: 96 m4env.Append(CCFLAGS=['-Wno-pointer-sign']) 97if m4env['CLANG']: 98 m4env.Append(CCFLAGS=['-Wno-initializer-overrides', '-Wno-pointer-sign']) 99m4env.Append(CCFLAGS=['-Wno-implicit']) 100del m4env['CPPPATH'] 101 102# If we have gm4 use it 103if m4env.Detect('gm4'): 104 m4env['M4'] = 'gm4' 105 106# Check that m4 is available 107import SCons.Tool.m4 108if not SCons.Tool.m4.exists(m4env): 109 print "Error: Can't find version of M4 macro processor. " + \ 110 "Please install M4 and try again." 111 Exit(1) 112 113m4env.Append(M4FLAGS=['-DSRCDIR=%s' % Dir('.').path]) 114m4env['M4COM'] = '$M4 $M4FLAGS $SOURCES > $TARGET' 115m4env.M4(target=File('libelf_convert.c'), 116 source=[File('elf_types.m4'), File('libelf_convert.m4')]) 117m4env.M4(target=File('libelf_fsize.c'), 118 source=[File('elf_types.m4'), File('libelf_fsize.m4')]) 119m4env.M4(target=File('libelf_msize.c'), 120 source=[File('elf_types.m4'), File('libelf_msize.m4')]) 121 122# Build libelf as a static library with PIC code so it can be linked 123# into either m5 or the library 124m4env.Library('elf', [m4env.SharedObject(f) for f in elf_files]) 125 126main.Prepend(CPPPATH=Dir('.')) 127main.Append(LIBS=['elf']) 128main.Prepend(LIBPATH=[Dir('.')]) 129 130