SConscript revision 6313
17019SBrad.Beckmann@amd.com# -*- mode:python -*- 27019SBrad.Beckmann@amd.com 37019SBrad.Beckmann@amd.com# Copyright (c) 2004-2005 The Regents of The University of Michigan 47019SBrad.Beckmann@amd.com# All rights reserved. 57019SBrad.Beckmann@amd.com# 67019SBrad.Beckmann@amd.com# Redistribution and use in source and binary forms, with or without 77019SBrad.Beckmann@amd.com# modification, are permitted provided that the following conditions are 87019SBrad.Beckmann@amd.com# met: redistributions of source code must retain the above copyright 97019SBrad.Beckmann@amd.com# notice, this list of conditions and the following disclaimer; 107019SBrad.Beckmann@amd.com# redistributions in binary form must reproduce the above copyright 117019SBrad.Beckmann@amd.com# notice, this list of conditions and the following disclaimer in the 127019SBrad.Beckmann@amd.com# documentation and/or other materials provided with the distribution; 137019SBrad.Beckmann@amd.com# neither the name of the copyright holders nor the names of its 147019SBrad.Beckmann@amd.com# contributors may be used to endorse or promote products derived from 157019SBrad.Beckmann@amd.com# this software without specific prior written permission. 167019SBrad.Beckmann@amd.com# 177019SBrad.Beckmann@amd.com# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 187019SBrad.Beckmann@amd.com# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 197019SBrad.Beckmann@amd.com# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 207019SBrad.Beckmann@amd.com# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 217019SBrad.Beckmann@amd.com# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 227019SBrad.Beckmann@amd.com# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 237019SBrad.Beckmann@amd.com# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 247019SBrad.Beckmann@amd.com# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 257019SBrad.Beckmann@amd.com# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 267019SBrad.Beckmann@amd.com# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 277019SBrad.Beckmann@amd.com# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 287019SBrad.Beckmann@amd.com# 297019SBrad.Beckmann@amd.com# Authors: Nathan Binkert 306876Ssteve.reinhardt@amd.com 319274Snilay@cs.wisc.eduimport os, subprocess 326876Ssteve.reinhardt@amd.com 339274Snilay@cs.wisc.eduImport('main') 3411021Sjthestness@gmail.com 356876Ssteve.reinhardt@amd.comelf_files = [] 366876Ssteve.reinhardt@amd.comdef ElfFile(filename): 376876Ssteve.reinhardt@amd.com elf_files.append(File(filename)) 389338SAndreas.Sandberg@arm.com 398259SBrad.Beckmann@amd.comElfFile('elf_begin.c') 408259SBrad.Beckmann@amd.comElfFile('elf_cntl.c') 418261SBrad.Beckmann@amd.comElfFile('elf_data.c') 428259SBrad.Beckmann@amd.comElfFile('elf_end.c') 4311021Sjthestness@gmail.comElfFile('elf_fill.c') 4411021Sjthestness@gmail.comElfFile('elf_flag.c') 4511021Sjthestness@gmail.comElfFile('elf_getarhdr.c') 4611021Sjthestness@gmail.comElfFile('elf_getarsym.c') 4711021Sjthestness@gmail.comElfFile('elf_getbase.c') 4811021Sjthestness@gmail.comElfFile('elf_getident.c') 4911021Sjthestness@gmail.comElfFile('elf_hash.c') 5011021Sjthestness@gmail.comElfFile('elf_kind.c') 5111021Sjthestness@gmail.comElfFile('elf_memory.c') 5211021Sjthestness@gmail.comElfFile('elf_next.c') 5311021Sjthestness@gmail.comElfFile('elf_phnum.c') 5411021Sjthestness@gmail.comElfFile('elf_rand.c') 5511021Sjthestness@gmail.comElfFile('elf_rawfile.c') 5611021Sjthestness@gmail.comElfFile('elf_scn.c') 5711021Sjthestness@gmail.comElfFile('elf_shnum.c') 5811021Sjthestness@gmail.comElfFile('elf_shstrndx.c') 5911021Sjthestness@gmail.comElfFile('elf_strptr.c') 6011021Sjthestness@gmail.comElfFile('elf_update.c') 6111021Sjthestness@gmail.comElfFile('elf_version.c') 6211021Sjthestness@gmail.comElfFile('gelf_checksum.c') 6311021Sjthestness@gmail.comElfFile('gelf_dyn.c') 6411021Sjthestness@gmail.comElfFile('gelf_ehdr.c') 6511021Sjthestness@gmail.comElfFile('gelf_fsize.c') 6611021Sjthestness@gmail.comElfFile('gelf_getclass.c') 6711021Sjthestness@gmail.comElfFile('gelf_phdr.c') 6811021Sjthestness@gmail.comElfFile('gelf_rel.c') 6911021Sjthestness@gmail.comElfFile('gelf_rela.c') 7011021Sjthestness@gmail.comElfFile('gelf_shdr.c') 7111021Sjthestness@gmail.comElfFile('gelf_sym.c') 7211021Sjthestness@gmail.comElfFile('gelf_symshndx.c') 7311021Sjthestness@gmail.comElfFile('gelf_xlate.c') 7411021Sjthestness@gmail.comElfFile('libelf.c') 7511021Sjthestness@gmail.comElfFile('libelf_align.c') 7611021Sjthestness@gmail.comElfFile('libelf_allocate.c') 7711021Sjthestness@gmail.comElfFile('libelf_ar.c') 789274Snilay@cs.wisc.eduElfFile('libelf_checksum.c') 799274Snilay@cs.wisc.eduElfFile('libelf_data.c') 809274Snilay@cs.wisc.eduElfFile('libelf_ehdr.c') 819389Sandreas.hansson@arm.comElfFile('libelf_extended.c') 829274Snilay@cs.wisc.eduElfFile('libelf_phdr.c') 839274Snilay@cs.wisc.eduElfFile('libelf_shdr.c') 8411021Sjthestness@gmail.comElfFile('libelf_xlate.c') 8511021Sjthestness@gmail.com 8611021Sjthestness@gmail.comElfFile('libelf_convert.c') 8711021Sjthestness@gmail.comElfFile('libelf_fsize.c') 88ElfFile('libelf_msize.c') 89 90m4env = main.Clone() 91if m4env['GCC']: 92 major,minor,dot = [ int(x) for x in m4env['CXXVERSION'].split('.')] 93 if major >= 4: 94 m4env.Append(CCFLAGS=['-Wno-pointer-sign']) 95m4env.Append(CCFLAGS=['-Wno-implicit']) 96del m4env['CPPPATH'] 97 98# If we have gm4 use it 99if m4env.Detect('gm4'): 100 m4env['M4'] = 'gm4' 101 102# Check that m4 is available 103import SCons.Tool.m4 104if not SCons.Tool.m4.exists(m4env): 105 print "Error: Can't find version of M4 macro processor. " + \ 106 "Please install M4 and try again." 107 Exit(1) 108 109m4env.Append(M4FLAGS='-DSRCDIR=%s' % Dir('.').path) 110m4env['M4COM'] = '$M4 $M4FLAGS $SOURCES > $TARGET' 111m4env.M4(target=File('libelf_convert.c'), 112 source=[File('elf_types.m4'), File('libelf_convert.m4')]) 113m4env.M4(target=File('libelf_fsize.c'), 114 source=[File('elf_types.m4'), File('libelf_fsize.m4')]) 115m4env.M4(target=File('libelf_msize.c'), 116 source=[File('elf_types.m4'), File('libelf_msize.m4')]) 117 118# Build libelf as a static library with PIC code so it can be linked 119# into either m5 or the library 120m4env.Library('elf', [m4env.SharedObject(f) for f in elf_files]) 121 122main.Prepend(CPPPATH=Dir('.')) 123main.Append(LIBS=['elf']) 124main.Prepend(LIBPATH=[Dir('.')]) 125 126