SConscript revision 7739
12929Sktlim@umich.edu# -*- mode:python -*- 22929Sktlim@umich.edu 32932Sktlim@umich.edu# Copyright (c) 2004-2005 The Regents of The University of Michigan 42929Sktlim@umich.edu# All rights reserved. 52929Sktlim@umich.edu# 62929Sktlim@umich.edu# Redistribution and use in source and binary forms, with or without 72929Sktlim@umich.edu# modification, are permitted provided that the following conditions are 82929Sktlim@umich.edu# met: redistributions of source code must retain the above copyright 92929Sktlim@umich.edu# notice, this list of conditions and the following disclaimer; 102929Sktlim@umich.edu# redistributions in binary form must reproduce the above copyright 112929Sktlim@umich.edu# notice, this list of conditions and the following disclaimer in the 122929Sktlim@umich.edu# documentation and/or other materials provided with the distribution; 132929Sktlim@umich.edu# neither the name of the copyright holders nor the names of its 142929Sktlim@umich.edu# contributors may be used to endorse or promote products derived from 152929Sktlim@umich.edu# this software without specific prior written permission. 162929Sktlim@umich.edu# 172929Sktlim@umich.edu# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 182929Sktlim@umich.edu# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 192929Sktlim@umich.edu# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 202929Sktlim@umich.edu# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 212929Sktlim@umich.edu# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 222929Sktlim@umich.edu# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 232929Sktlim@umich.edu# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 242929Sktlim@umich.edu# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 252929Sktlim@umich.edu# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 262929Sktlim@umich.edu# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 272929Sktlim@umich.edu# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 282932Sktlim@umich.edu# 292932Sktlim@umich.edu# Authors: Nathan Binkert 302932Sktlim@umich.edu 312929Sktlim@umich.eduimport os, subprocess 326007Ssteve.reinhardt@amd.com 337735SAli.Saidi@ARM.comImport('main') 342929Sktlim@umich.edu 352929Sktlim@umich.eduelf_files = [] 362929Sktlim@umich.edudef ElfFile(filename): 372929Sktlim@umich.edu elf_files.append(File(filename)) 382929Sktlim@umich.edu 392929Sktlim@umich.eduElfFile('elf_begin.c') 402929Sktlim@umich.eduElfFile('elf_cntl.c') 418947Sandreas.hansson@arm.comElfFile('elf_data.c') 428947Sandreas.hansson@arm.comElfFile('elf_end.c') 438947Sandreas.hansson@arm.comElfFile('elf_fill.c') 442929Sktlim@umich.eduElfFile('elf_flag.c') 452929Sktlim@umich.eduElfFile('elf_getarhdr.c') 462929Sktlim@umich.eduElfFile('elf_getarsym.c') 472929Sktlim@umich.eduElfFile('elf_getbase.c') 482929Sktlim@umich.eduElfFile('elf_getident.c') 492929Sktlim@umich.eduElfFile('elf_hash.c') 506007Ssteve.reinhardt@amd.comElfFile('elf_kind.c') 516007Ssteve.reinhardt@amd.comElfFile('elf_memory.c') 526007Ssteve.reinhardt@amd.comElfFile('elf_next.c') 536007Ssteve.reinhardt@amd.comElfFile('elf_phnum.c') 546007Ssteve.reinhardt@amd.comElfFile('elf_rand.c') 556007Ssteve.reinhardt@amd.comElfFile('elf_rawfile.c') 566007Ssteve.reinhardt@amd.comElfFile('elf_scn.c') 576007Ssteve.reinhardt@amd.comElfFile('elf_shnum.c') 586007Ssteve.reinhardt@amd.comElfFile('elf_shstrndx.c') 596007Ssteve.reinhardt@amd.comElfFile('elf_strptr.c') 606007Ssteve.reinhardt@amd.comElfFile('elf_update.c') 616007Ssteve.reinhardt@amd.comElfFile('elf_version.c') 626007Ssteve.reinhardt@amd.comElfFile('gelf_checksum.c') 636007Ssteve.reinhardt@amd.comElfFile('gelf_dyn.c') 646007Ssteve.reinhardt@amd.comElfFile('gelf_ehdr.c') 656007Ssteve.reinhardt@amd.comElfFile('gelf_fsize.c') 669435SAndreas.Sandberg@ARM.comElfFile('gelf_getclass.c') 679435SAndreas.Sandberg@ARM.comElfFile('gelf_phdr.c') 689435SAndreas.Sandberg@ARM.comElfFile('gelf_rel.c') 696007Ssteve.reinhardt@amd.comElfFile('gelf_rela.c') 706007Ssteve.reinhardt@amd.comElfFile('gelf_shdr.c') 716007Ssteve.reinhardt@amd.comElfFile('gelf_sym.c') 726007Ssteve.reinhardt@amd.comElfFile('gelf_symshndx.c') 736007Ssteve.reinhardt@amd.comElfFile('gelf_xlate.c') 746007Ssteve.reinhardt@amd.comElfFile('libelf.c') 756007Ssteve.reinhardt@amd.comElfFile('libelf_align.c') 766007Ssteve.reinhardt@amd.comElfFile('libelf_allocate.c') 776007Ssteve.reinhardt@amd.comElfFile('libelf_ar.c') 786007Ssteve.reinhardt@amd.comElfFile('libelf_checksum.c') 792929Sktlim@umich.eduElfFile('libelf_data.c') 802929Sktlim@umich.eduElfFile('libelf_ehdr.c') 812929Sktlim@umich.eduElfFile('libelf_extended.c') 826007Ssteve.reinhardt@amd.comElfFile('libelf_phdr.c') 836007Ssteve.reinhardt@amd.comElfFile('libelf_shdr.c') 846007Ssteve.reinhardt@amd.comElfFile('libelf_xlate.c') 859781Sandreas.hansson@arm.com 866007Ssteve.reinhardt@amd.comElfFile('libelf_convert.c') 876007Ssteve.reinhardt@amd.comElfFile('libelf_fsize.c') 882929Sktlim@umich.eduElfFile('libelf_msize.c') 892929Sktlim@umich.edu 902929Sktlim@umich.edum4env = main.Clone() 912929Sktlim@umich.eduif m4env['GCC']: 922929Sktlim@umich.edu major,minor,dot = [ int(x) for x in m4env['CXXVERSION'].split('.')] 936011Ssteve.reinhardt@amd.com if major >= 4: 946007Ssteve.reinhardt@amd.com m4env.Append(CCFLAGS=['-Wno-pointer-sign']) 956007Ssteve.reinhardt@amd.comm4env.Append(CCFLAGS=['-Wno-implicit']) 966007Ssteve.reinhardt@amd.comdel m4env['CPPPATH'] 976007Ssteve.reinhardt@amd.com 986007Ssteve.reinhardt@amd.com# If we have gm4 use it 996007Ssteve.reinhardt@amd.comif m4env.Detect('gm4'): 1006007Ssteve.reinhardt@amd.com m4env['M4'] = 'gm4' 1016007Ssteve.reinhardt@amd.com 1026007Ssteve.reinhardt@amd.com# Check that m4 is available 1036007Ssteve.reinhardt@amd.comimport SCons.Tool.m4 1046007Ssteve.reinhardt@amd.comif not SCons.Tool.m4.exists(m4env): 1056007Ssteve.reinhardt@amd.com print "Error: Can't find version of M4 macro processor. " + \ 1066007Ssteve.reinhardt@amd.com "Please install M4 and try again." 1076007Ssteve.reinhardt@amd.com Exit(1) 1089781Sandreas.hansson@arm.com 1099781Sandreas.hansson@arm.comm4env.Append(M4FLAGS=['-DSRCDIR=%s' % Dir('.').path]) 1109781Sandreas.hansson@arm.comm4env['M4COM'] = '$M4 $M4FLAGS $SOURCES > $TARGET' 1119781Sandreas.hansson@arm.comm4env.M4(target=File('libelf_convert.c'), 1127735SAli.Saidi@ARM.com source=[File('elf_types.m4'), File('libelf_convert.m4')]) 1136011Ssteve.reinhardt@amd.comm4env.M4(target=File('libelf_fsize.c'), 1146007Ssteve.reinhardt@amd.com source=[File('elf_types.m4'), File('libelf_fsize.m4')]) 1159781Sandreas.hansson@arm.comm4env.M4(target=File('libelf_msize.c'), 1166007Ssteve.reinhardt@amd.com source=[File('elf_types.m4'), File('libelf_msize.m4')]) 1176007Ssteve.reinhardt@amd.com 1187735SAli.Saidi@ARM.com# Build libelf as a static library with PIC code so it can be linked 1197735SAli.Saidi@ARM.com# into either m5 or the library 1207735SAli.Saidi@ARM.comm4env.Library('elf', [m4env.SharedObject(f) for f in elf_files]) 1217735SAli.Saidi@ARM.com 1227735SAli.Saidi@ARM.commain.Prepend(CPPPATH=Dir('.')) 1237735SAli.Saidi@ARM.commain.Append(LIBS=['elf']) 1247735SAli.Saidi@ARM.commain.Prepend(LIBPATH=[Dir('.')]) 1257735SAli.Saidi@ARM.com 1267735SAli.Saidi@ARM.com