SConscript revision 10664
12155SN/A# -*- mode:python -*- 22155SN/A 32155SN/A# Copyright (c) 2004-2005 The Regents of The University of Michigan 42155SN/A# All rights reserved. 52155SN/A# 62155SN/A# Redistribution and use in source and binary forms, with or without 72155SN/A# modification, are permitted provided that the following conditions are 82155SN/A# met: redistributions of source code must retain the above copyright 92155SN/A# notice, this list of conditions and the following disclaimer; 102155SN/A# redistributions in binary form must reproduce the above copyright 112155SN/A# notice, this list of conditions and the following disclaimer in the 122155SN/A# documentation and/or other materials provided with the distribution; 132155SN/A# neither the name of the copyright holders nor the names of its 142155SN/A# contributors may be used to endorse or promote products derived from 152155SN/A# this software without specific prior written permission. 162155SN/A# 172155SN/A# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 182155SN/A# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 192155SN/A# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 202155SN/A# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 212155SN/A# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 222155SN/A# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 232155SN/A# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 242155SN/A# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 252155SN/A# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 262155SN/A# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 272155SN/A# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 282665Ssaidi@eecs.umich.edu# 292665Ssaidi@eecs.umich.edu# Authors: Nathan Binkert 302155SN/A 314202Sbinkertn@umich.eduimport os, subprocess 322155SN/A 337768SAli.Saidi@ARM.comImport('main') 347768SAli.Saidi@ARM.com 357768SAli.Saidi@ARM.comfrom m5.util import compareVersions 362178SN/A 372178SN/Aelf_files = [] 382178SN/Adef ElfFile(filename): 392178SN/A elf_files.append(File(filename)) 402178SN/A 412178SN/AElfFile('elf_begin.c') 422178SN/AElfFile('elf_cntl.c') 432178SN/AElfFile('elf_data.c') 442178SN/AElfFile('elf_end.c') 452178SN/AElfFile('elf_errmsg.c') 462178SN/AElfFile('elf_errno.c') 472155SN/AElfFile('elf_fill.c') 485865Sksewell@umich.eduElfFile('elf_flag.c') 496181Sksewell@umich.eduElfFile('elf_getarhdr.c') 506181Sksewell@umich.eduElfFile('elf_getarsym.c') 515865Sksewell@umich.eduElfFile('elf_getbase.c') 523918Ssaidi@eecs.umich.eduElfFile('elf_getident.c') 535865Sksewell@umich.eduElfFile('elf_hash.c') 542623SN/AElfFile('elf_kind.c') 553918Ssaidi@eecs.umich.eduElfFile('elf_memory.c') 562155SN/AElfFile('elf_next.c') 572155SN/AElfFile('elf_phnum.c') 582292SN/AElfFile('elf_rand.c') 596181Sksewell@umich.eduElfFile('elf_rawfile.c') 606181Sksewell@umich.eduElfFile('elf_scn.c') 613918Ssaidi@eecs.umich.eduElfFile('elf_shnum.c') 622292SN/AElfFile('elf_shstrndx.c') 632292SN/AElfFile('elf_strptr.c') 642292SN/AElfFile('elf_update.c') 653918Ssaidi@eecs.umich.eduElfFile('elf_version.c') 662292SN/AElfFile('gelf_checksum.c') 672292SN/AElfFile('gelf_dyn.c') 682766Sktlim@umich.eduElfFile('gelf_ehdr.c') 692766Sktlim@umich.eduElfFile('gelf_fsize.c') 702766Sktlim@umich.eduElfFile('gelf_getclass.c') 712921Sktlim@umich.eduElfFile('gelf_phdr.c') 722921Sktlim@umich.eduElfFile('gelf_rel.c') 732766Sktlim@umich.eduElfFile('gelf_rela.c') 742766Sktlim@umich.eduElfFile('gelf_shdr.c') 755529Snate@binkert.orgElfFile('gelf_sym.c') 762766Sktlim@umich.eduElfFile('gelf_symshndx.c') 774762Snate@binkert.orgElfFile('gelf_xlate.c') 782155SN/AElfFile('libelf.c') 792155SN/AElfFile('libelf_align.c') 802155SN/AElfFile('libelf_allocate.c') 812155SN/AElfFile('libelf_ar.c') 822155SN/AElfFile('libelf_checksum.c') 832155SN/AElfFile('libelf_data.c') 842766Sktlim@umich.eduElfFile('libelf_ehdr.c') 852155SN/AElfFile('libelf_extended.c') 865865Sksewell@umich.eduElfFile('libelf_phdr.c') 872155SN/AElfFile('libelf_shdr.c') 882155SN/AElfFile('libelf_xlate.c') 892155SN/A 902155SN/AElfFile('libelf_convert.c') 912178SN/AElfFile('libelf_fsize.c') 922178SN/AElfFile('libelf_msize.c') 937756SAli.Saidi@ARM.com 942766Sktlim@umich.edum4env = main.Clone() 952178SN/Aif m4env['GCC']: 962178SN/A m4env.Append(CCFLAGS=['-Wno-pointer-sign']) 976994Snate@binkert.org if compareVersions(m4env['GCC_VERSION'], '4.6') >= 0: 982178SN/A m4env.Append(CCFLAGS=['-Wno-unused-but-set-variable', 992766Sktlim@umich.edu '-Wno-implicit-function-declaration']) 1002766Sktlim@umich.eduif m4env['CLANG']: 1012766Sktlim@umich.edu m4env.Append(CCFLAGS=['-Wno-initializer-overrides', '-Wno-pointer-sign']) 1022788Sktlim@umich.edu # clang defaults to c99 (while gcc defaults to gnu89) and there is a 1032178SN/A # difference in the handling of inlining functions which causes 1042733Sktlim@umich.edu # linking problems with multiple definitions of the symbols in 1052733Sktlim@umich.edu # sysmacros.h for older versions of glibc 1062817Sksewell@umich.edu m4env.Append(CCFLAGS=['-std=gnu89']) 1072733Sktlim@umich.edum4env.Append(CCFLAGS=['-Wno-implicit']) 1084486Sbinkertn@umich.edudel m4env['CPPPATH'] 1094486Sbinkertn@umich.edu 1104776Sgblack@eecs.umich.edu# If we have gm4 use it 1114776Sgblack@eecs.umich.eduif m4env.Detect('gm4'): 1128739Sgblack@eecs.umich.edu m4env['M4'] = 'gm4' 1136365Sgblack@eecs.umich.edu 1144486Sbinkertn@umich.edu# Check that m4 is available 1154202Sbinkertn@umich.eduimport SCons.Tool.m4 1164202Sbinkertn@umich.eduif not SCons.Tool.m4.exists(m4env): 1174202Sbinkertn@umich.edu print "Error: Can't find version of M4 macro processor. " + \ 1188541Sgblack@eecs.umich.edu "Please install M4 and try again." 1194202Sbinkertn@umich.edu Exit(1) 1204202Sbinkertn@umich.edu 1214776Sgblack@eecs.umich.edum4env.Append(M4FLAGS=['-DSRCDIR=%s' % Dir('.').path]) 1228739Sgblack@eecs.umich.edum4env['M4COM'] = '$M4 $M4FLAGS $SOURCES > $TARGET' 1236365Sgblack@eecs.umich.edum4env.M4(target=File('libelf_convert.c'), 1244202Sbinkertn@umich.edu source=[File('elf_types.m4'), File('libelf_convert.m4')]) 1258777Sgblack@eecs.umich.edum4env.M4(target=File('libelf_fsize.c'), 1264202Sbinkertn@umich.edu source=[File('elf_types.m4'), File('libelf_fsize.m4')]) 1274202Sbinkertn@umich.edum4env.M4(target=File('libelf_msize.c'), 1284202Sbinkertn@umich.edu source=[File('elf_types.m4'), File('libelf_msize.m4')]) 1295217Ssaidi@eecs.umich.edu 1304202Sbinkertn@umich.edu# Build libelf as a static library with PIC code so it can be linked 1312155SN/A# into either m5 or the library 1328793Sgblack@eecs.umich.edum4env.Library('elf', [m4env.SharedObject(f) for f in elf_files]) 1338793Sgblack@eecs.umich.edu 1348793Sgblack@eecs.umich.edumain.Prepend(CPPPATH=Dir('.')) 1354776Sgblack@eecs.umich.edumain.Append(LIBS=['elf']) 1362766Sktlim@umich.edumain.Prepend(LIBPATH=[Dir('.')]) 1374202Sbinkertn@umich.edu 1388335Snate@binkert.org