SConscript revision 8655
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') 438349Sgblack@eecs.umich.eduElfFile('elf_errmsg.c') 448349Sgblack@eecs.umich.eduElfFile('elf_errno.c') 454484Sbinkertn@umich.eduElfFile('elf_fill.c') 464484Sbinkertn@umich.eduElfFile('elf_flag.c') 474484Sbinkertn@umich.eduElfFile('elf_getarhdr.c') 484484Sbinkertn@umich.eduElfFile('elf_getarsym.c') 494484Sbinkertn@umich.eduElfFile('elf_getbase.c') 504484Sbinkertn@umich.eduElfFile('elf_getident.c') 514484Sbinkertn@umich.eduElfFile('elf_hash.c') 524484Sbinkertn@umich.eduElfFile('elf_kind.c') 534484Sbinkertn@umich.eduElfFile('elf_memory.c') 544484Sbinkertn@umich.eduElfFile('elf_next.c') 554484Sbinkertn@umich.eduElfFile('elf_phnum.c') 564484Sbinkertn@umich.eduElfFile('elf_rand.c') 574484Sbinkertn@umich.eduElfFile('elf_rawfile.c') 584484Sbinkertn@umich.eduElfFile('elf_scn.c') 594484Sbinkertn@umich.eduElfFile('elf_shnum.c') 604484Sbinkertn@umich.eduElfFile('elf_shstrndx.c') 614484Sbinkertn@umich.eduElfFile('elf_strptr.c') 624484Sbinkertn@umich.eduElfFile('elf_update.c') 634484Sbinkertn@umich.eduElfFile('elf_version.c') 644484Sbinkertn@umich.eduElfFile('gelf_checksum.c') 654484Sbinkertn@umich.eduElfFile('gelf_dyn.c') 664484Sbinkertn@umich.eduElfFile('gelf_ehdr.c') 674484Sbinkertn@umich.eduElfFile('gelf_fsize.c') 684484Sbinkertn@umich.eduElfFile('gelf_getclass.c') 694484Sbinkertn@umich.eduElfFile('gelf_phdr.c') 704484Sbinkertn@umich.eduElfFile('gelf_rel.c') 714484Sbinkertn@umich.eduElfFile('gelf_rela.c') 724484Sbinkertn@umich.eduElfFile('gelf_shdr.c') 734484Sbinkertn@umich.eduElfFile('gelf_sym.c') 744484Sbinkertn@umich.eduElfFile('gelf_symshndx.c') 754484Sbinkertn@umich.eduElfFile('gelf_xlate.c') 764484Sbinkertn@umich.eduElfFile('libelf.c') 774484Sbinkertn@umich.eduElfFile('libelf_align.c') 784484Sbinkertn@umich.eduElfFile('libelf_allocate.c') 794484Sbinkertn@umich.eduElfFile('libelf_ar.c') 804484Sbinkertn@umich.eduElfFile('libelf_checksum.c') 814484Sbinkertn@umich.eduElfFile('libelf_data.c') 824484Sbinkertn@umich.eduElfFile('libelf_ehdr.c') 834484Sbinkertn@umich.eduElfFile('libelf_extended.c') 844484Sbinkertn@umich.eduElfFile('libelf_phdr.c') 854484Sbinkertn@umich.eduElfFile('libelf_shdr.c') 864484Sbinkertn@umich.eduElfFile('libelf_xlate.c') 874484Sbinkertn@umich.edu 884484Sbinkertn@umich.eduElfFile('libelf_convert.c') 894484Sbinkertn@umich.eduElfFile('libelf_fsize.c') 904484Sbinkertn@umich.eduElfFile('libelf_msize.c') 914484Sbinkertn@umich.edu 926121Snate@binkert.orgm4env = main.Clone() 936121Snate@binkert.orgif m4env['GCC']: 948655Sandreas.hansson@arm.com major,minor,dot = [int(x) for x in m4env['GCC_VERSION'].split('.')] 955765Snate@binkert.org if major >= 4: 965765Snate@binkert.org m4env.Append(CCFLAGS=['-Wno-pointer-sign']) 975765Snate@binkert.orgm4env.Append(CCFLAGS=['-Wno-implicit']) 985397Ssaidi@eecs.umich.edudel m4env['CPPPATH'] 995274Ssaidi@eecs.umich.edu 1004494Ssaidi@eecs.umich.edu# If we have gm4 use it 1014504Ssaidi@eecs.umich.eduif m4env.Detect('gm4'): 1024494Ssaidi@eecs.umich.edu m4env['M4'] = 'gm4' 1034494Ssaidi@eecs.umich.edu 1044496Ssaidi@eecs.umich.edu# Check that m4 is available 1054504Ssaidi@eecs.umich.eduimport SCons.Tool.m4 1064504Ssaidi@eecs.umich.eduif not SCons.Tool.m4.exists(m4env): 1074500Sbinkertn@umich.edu print "Error: Can't find version of M4 macro processor. " + \ 1084500Sbinkertn@umich.edu "Please install M4 and try again." 1094496Ssaidi@eecs.umich.edu Exit(1) 1104496Ssaidi@eecs.umich.edu 1117739Sgblack@eecs.umich.edum4env.Append(M4FLAGS=['-DSRCDIR=%s' % Dir('.').path]) 1124487Sstever@eecs.umich.edum4env['M4COM'] = '$M4 $M4FLAGS $SOURCES > $TARGET' 1134484Sbinkertn@umich.edum4env.M4(target=File('libelf_convert.c'), 1144484Sbinkertn@umich.edu source=[File('elf_types.m4'), File('libelf_convert.m4')]) 1154484Sbinkertn@umich.edum4env.M4(target=File('libelf_fsize.c'), 1164484Sbinkertn@umich.edu source=[File('elf_types.m4'), File('libelf_fsize.m4')]) 1174484Sbinkertn@umich.edum4env.M4(target=File('libelf_msize.c'), 1184484Sbinkertn@umich.edu source=[File('elf_types.m4'), File('libelf_msize.m4')]) 1195601Snate@binkert.org 1205601Snate@binkert.org# Build libelf as a static library with PIC code so it can be linked 1215601Snate@binkert.org# into either m5 or the library 1225601Snate@binkert.orgm4env.Library('elf', [m4env.SharedObject(f) for f in elf_files]) 1234484Sbinkertn@umich.edu 1246121Snate@binkert.orgmain.Prepend(CPPPATH=Dir('.')) 1256121Snate@binkert.orgmain.Append(LIBS=['elf']) 1266121Snate@binkert.orgmain.Prepend(LIBPATH=[Dir('.')]) 1274494Ssaidi@eecs.umich.edu 128