SConscript revision 6329
14484Sbinkertn@umich.edu# -*- mode:python -*- 24484Sbinkertn@umich.edu 34484Sbinkertn@umich.edu# Copyright (c) 2004-2005 The Regents of The University of Michigan 44484Sbinkertn@umich.edu# All rights reserved. 54484Sbinkertn@umich.edu# 64484Sbinkertn@umich.edu# Redistribution and use in source and binary forms, with or without 74484Sbinkertn@umich.edu# modification, are permitted provided that the following conditions are 84484Sbinkertn@umich.edu# met: redistributions of source code must retain the above copyright 94484Sbinkertn@umich.edu# notice, this list of conditions and the following disclaimer; 104484Sbinkertn@umich.edu# redistributions in binary form must reproduce the above copyright 114484Sbinkertn@umich.edu# notice, this list of conditions and the following disclaimer in the 124484Sbinkertn@umich.edu# documentation and/or other materials provided with the distribution; 134484Sbinkertn@umich.edu# neither the name of the copyright holders nor the names of its 144484Sbinkertn@umich.edu# contributors may be used to endorse or promote products derived from 154484Sbinkertn@umich.edu# this software without specific prior written permission. 164484Sbinkertn@umich.edu# 174484Sbinkertn@umich.edu# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 184484Sbinkertn@umich.edu# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 194484Sbinkertn@umich.edu# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 204484Sbinkertn@umich.edu# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 214484Sbinkertn@umich.edu# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 224484Sbinkertn@umich.edu# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 234484Sbinkertn@umich.edu# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 244484Sbinkertn@umich.edu# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 254484Sbinkertn@umich.edu# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 264484Sbinkertn@umich.edu# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 274484Sbinkertn@umich.edu# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 284484Sbinkertn@umich.edu# 294484Sbinkertn@umich.edu# Authors: Nathan Binkert 304484Sbinkertn@umich.edu 314494Ssaidi@eecs.umich.eduimport os, subprocess 324484Sbinkertn@umich.edu 336121Snate@binkert.orgImport('main') 344484Sbinkertn@umich.edu 354484Sbinkertn@umich.eduelf_files = [] 364484Sbinkertn@umich.edudef ElfFile(filename): 374484Sbinkertn@umich.edu elf_files.append(File(filename)) 384781Snate@binkert.org 394484Sbinkertn@umich.eduElfFile('elf_begin.c') 404484Sbinkertn@umich.eduElfFile('elf_cntl.c') 414484Sbinkertn@umich.eduElfFile('elf_data.c') 424484Sbinkertn@umich.eduElfFile('elf_end.c') 434484Sbinkertn@umich.eduElfFile('elf_fill.c') 444484Sbinkertn@umich.eduElfFile('elf_flag.c') 454484Sbinkertn@umich.eduElfFile('elf_getarhdr.c') 464484Sbinkertn@umich.eduElfFile('elf_getarsym.c') 474484Sbinkertn@umich.eduElfFile('elf_getbase.c') 484484Sbinkertn@umich.eduElfFile('elf_getident.c') 494484Sbinkertn@umich.eduElfFile('elf_hash.c') 504484Sbinkertn@umich.eduElfFile('elf_kind.c') 514484Sbinkertn@umich.eduElfFile('elf_memory.c') 524484Sbinkertn@umich.eduElfFile('elf_next.c') 534484Sbinkertn@umich.eduElfFile('elf_phnum.c') 544484Sbinkertn@umich.eduElfFile('elf_rand.c') 554484Sbinkertn@umich.eduElfFile('elf_rawfile.c') 564484Sbinkertn@umich.eduElfFile('elf_scn.c') 574484Sbinkertn@umich.eduElfFile('elf_shnum.c') 584484Sbinkertn@umich.eduElfFile('elf_shstrndx.c') 594484Sbinkertn@umich.eduElfFile('elf_strptr.c') 604484Sbinkertn@umich.eduElfFile('elf_update.c') 614484Sbinkertn@umich.eduElfFile('elf_version.c') 624484Sbinkertn@umich.eduElfFile('gelf_checksum.c') 634484Sbinkertn@umich.eduElfFile('gelf_dyn.c') 644484Sbinkertn@umich.eduElfFile('gelf_ehdr.c') 654484Sbinkertn@umich.eduElfFile('gelf_fsize.c') 664484Sbinkertn@umich.eduElfFile('gelf_getclass.c') 674484Sbinkertn@umich.eduElfFile('gelf_phdr.c') 684484Sbinkertn@umich.eduElfFile('gelf_rel.c') 694484Sbinkertn@umich.eduElfFile('gelf_rela.c') 704484Sbinkertn@umich.eduElfFile('gelf_shdr.c') 714484Sbinkertn@umich.eduElfFile('gelf_sym.c') 724484Sbinkertn@umich.eduElfFile('gelf_symshndx.c') 734484Sbinkertn@umich.eduElfFile('gelf_xlate.c') 744484Sbinkertn@umich.eduElfFile('libelf.c') 754484Sbinkertn@umich.eduElfFile('libelf_align.c') 764484Sbinkertn@umich.eduElfFile('libelf_allocate.c') 774484Sbinkertn@umich.eduElfFile('libelf_ar.c') 784484Sbinkertn@umich.eduElfFile('libelf_checksum.c') 794484Sbinkertn@umich.eduElfFile('libelf_data.c') 804484Sbinkertn@umich.eduElfFile('libelf_ehdr.c') 814484Sbinkertn@umich.eduElfFile('libelf_extended.c') 824484Sbinkertn@umich.eduElfFile('libelf_phdr.c') 834484Sbinkertn@umich.eduElfFile('libelf_shdr.c') 844484Sbinkertn@umich.eduElfFile('libelf_xlate.c') 854484Sbinkertn@umich.edu 864484Sbinkertn@umich.eduElfFile('libelf_convert.c') 874484Sbinkertn@umich.eduElfFile('libelf_fsize.c') 884484Sbinkertn@umich.eduElfFile('libelf_msize.c') 894484Sbinkertn@umich.edu 906121Snate@binkert.orgm4env = main.Clone() 916121Snate@binkert.orgif m4env['GCC']: 926121Snate@binkert.org major,minor,dot = [ int(x) for x in m4env['CXXVERSION'].split('.')] 935765Snate@binkert.org if major >= 4: 945765Snate@binkert.org m4env.Append(CCFLAGS=['-Wno-pointer-sign']) 955765Snate@binkert.orgm4env.Append(CCFLAGS=['-Wno-implicit']) 965397Ssaidi@eecs.umich.edudel m4env['CPPPATH'] 975274Ssaidi@eecs.umich.edu 984494Ssaidi@eecs.umich.edu# If we have gm4 use it 994504Ssaidi@eecs.umich.eduif m4env.Detect('gm4'): 1004494Ssaidi@eecs.umich.edu m4env['M4'] = 'gm4' 1014494Ssaidi@eecs.umich.edu 1024496Ssaidi@eecs.umich.edu# Check that m4 is available 1034504Ssaidi@eecs.umich.eduimport SCons.Tool.m4 1044504Ssaidi@eecs.umich.eduif not SCons.Tool.m4.exists(m4env): 1054500Sbinkertn@umich.edu print "Error: Can't find version of M4 macro processor. " + \ 1064500Sbinkertn@umich.edu "Please install M4 and try again." 1074496Ssaidi@eecs.umich.edu Exit(1) 1084496Ssaidi@eecs.umich.edu 1094487Sstever@eecs.umich.edum4env.Append(M4FLAGS='-DSRCDIR=%s' % Dir('.').path) 1104487Sstever@eecs.umich.edum4env['M4COM'] = '$M4 $M4FLAGS $SOURCES > $TARGET' 1114484Sbinkertn@umich.edum4env.M4(target=File('libelf_convert.c'), 1124484Sbinkertn@umich.edu source=[File('elf_types.m4'), File('libelf_convert.m4')]) 1134484Sbinkertn@umich.edum4env.M4(target=File('libelf_fsize.c'), 1144484Sbinkertn@umich.edu source=[File('elf_types.m4'), File('libelf_fsize.m4')]) 1154484Sbinkertn@umich.edum4env.M4(target=File('libelf_msize.c'), 1164484Sbinkertn@umich.edu source=[File('elf_types.m4'), File('libelf_msize.m4')]) 1175601Snate@binkert.org 1185601Snate@binkert.org# Build libelf as a static library with PIC code so it can be linked 1195601Snate@binkert.org# into either m5 or the library 1205601Snate@binkert.orgm4env.Library('elf', [m4env.SharedObject(f) for f in elf_files]) 1214484Sbinkertn@umich.edu 1226121Snate@binkert.orgmain.Prepend(CPPPATH=Dir('.')) 1236121Snate@binkert.orgmain.Append(LIBS=['elf']) 1246121Snate@binkert.orgmain.Prepend(LIBPATH=[Dir('.')]) 1254494Ssaidi@eecs.umich.edu 126