SConscript revision 12222
14202Sbinkertn@umich.edu# -*- mode:python -*- 24202Sbinkertn@umich.edu 34202Sbinkertn@umich.edu# Copyright (c) 2004-2005 The Regents of The University of Michigan 44202Sbinkertn@umich.edu# All rights reserved. 54202Sbinkertn@umich.edu# 64202Sbinkertn@umich.edu# Redistribution and use in source and binary forms, with or without 74202Sbinkertn@umich.edu# modification, are permitted provided that the following conditions are 84202Sbinkertn@umich.edu# met: redistributions of source code must retain the above copyright 94202Sbinkertn@umich.edu# notice, this list of conditions and the following disclaimer; 104202Sbinkertn@umich.edu# redistributions in binary form must reproduce the above copyright 114202Sbinkertn@umich.edu# notice, this list of conditions and the following disclaimer in the 124202Sbinkertn@umich.edu# documentation and/or other materials provided with the distribution; 134202Sbinkertn@umich.edu# neither the name of the copyright holders nor the names of its 144202Sbinkertn@umich.edu# contributors may be used to endorse or promote products derived from 154202Sbinkertn@umich.edu# this software without specific prior written permission. 164202Sbinkertn@umich.edu# 174202Sbinkertn@umich.edu# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 184202Sbinkertn@umich.edu# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 194202Sbinkertn@umich.edu# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 204202Sbinkertn@umich.edu# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 214202Sbinkertn@umich.edu# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 224202Sbinkertn@umich.edu# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 234202Sbinkertn@umich.edu# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 244202Sbinkertn@umich.edu# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 254202Sbinkertn@umich.edu# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 264202Sbinkertn@umich.edu# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 274202Sbinkertn@umich.edu# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 284202Sbinkertn@umich.edu# 294202Sbinkertn@umich.edu# Authors: Nathan Binkert 304202Sbinkertn@umich.edu 314202Sbinkertn@umich.eduimport os, subprocess 324202Sbinkertn@umich.edu 335952Ssaidi@eecs.umich.eduImport('main') 345952Ssaidi@eecs.umich.edu 355952Ssaidi@eecs.umich.edufrom m5.util import compareVersions 365548Snate@binkert.org 374202Sbinkertn@umich.eduelf_files = [] 387949SAli.Saidi@ARM.comdef ElfFile(filename): 397067Snate@binkert.org elf_files.append(File(filename)) 404202Sbinkertn@umich.edu 414202Sbinkertn@umich.eduElfFile('elf_begin.c') 425882Snate@binkert.orgElfFile('elf_cntl.c') 434550Sbinkertn@umich.eduElfFile('elf_data.c') 444550Sbinkertn@umich.eduElfFile('elf_end.c') 454202Sbinkertn@umich.eduElfFile('elf_errmsg.c') 464202Sbinkertn@umich.eduElfFile('elf_errno.c') 474202Sbinkertn@umich.eduElfFile('elf_fill.c') 484202Sbinkertn@umich.eduElfFile('elf_flag.c') 494202Sbinkertn@umich.eduElfFile('elf_getarhdr.c') 504202Sbinkertn@umich.eduElfFile('elf_getarsym.c') 514202Sbinkertn@umich.eduElfFile('elf_getbase.c') 524202Sbinkertn@umich.eduElfFile('elf_getident.c') 534202Sbinkertn@umich.eduElfFile('elf_hash.c') 545190Ssaidi@eecs.umich.eduElfFile('elf_kind.c') 559850Sandreas.hansson@arm.comElfFile('elf_memory.c') 567768SAli.Saidi@ARM.comElfFile('elf_next.c') 574202Sbinkertn@umich.eduElfFile('elf_phnum.c') 584202Sbinkertn@umich.eduElfFile('elf_rand.c') 594202Sbinkertn@umich.eduElfFile('elf_rawfile.c') 604202Sbinkertn@umich.eduElfFile('elf_scn.c') 614202Sbinkertn@umich.eduElfFile('elf_shnum.c') 629500Snilay@cs.wisc.eduElfFile('elf_shstrndx.c') 634202Sbinkertn@umich.eduElfFile('elf_strptr.c') 644202Sbinkertn@umich.eduElfFile('elf_update.c') 654202Sbinkertn@umich.eduElfFile('elf_version.c') 669538Satgutier@umich.eduElfFile('gelf_checksum.c') 674202Sbinkertn@umich.eduElfFile('gelf_dyn.c') 684202Sbinkertn@umich.eduElfFile('gelf_ehdr.c') 695222Sksewell@umich.eduElfFile('gelf_fsize.c') 704202Sbinkertn@umich.eduElfFile('gelf_getclass.c') 714202Sbinkertn@umich.eduElfFile('gelf_phdr.c') 724202Sbinkertn@umich.eduElfFile('gelf_rel.c') 734202Sbinkertn@umich.eduElfFile('gelf_rela.c') 744202Sbinkertn@umich.eduElfFile('gelf_shdr.c') 754202Sbinkertn@umich.eduElfFile('gelf_sym.c') 768335Snate@binkert.orgElfFile('gelf_symshndx.c') 778335Snate@binkert.orgElfFile('gelf_xlate.c') 788335Snate@binkert.orgElfFile('libelf.c') 798335Snate@binkert.orgElfFile('libelf_align.c') 808335Snate@binkert.orgElfFile('libelf_allocate.c') 818335Snate@binkert.orgElfFile('libelf_ar.c') 828335Snate@binkert.orgElfFile('libelf_checksum.c') 838335Snate@binkert.orgElfFile('libelf_data.c') 848335Snate@binkert.orgElfFile('libelf_ehdr.c') 858335Snate@binkert.orgElfFile('libelf_extended.c') 868335Snate@binkert.orgElfFile('libelf_phdr.c') 878335Snate@binkert.orgElfFile('libelf_shdr.c') 885192Ssaidi@eecs.umich.eduElfFile('libelf_xlate.c') 895800Snate@binkert.org 905800Snate@binkert.orgElfFile('libelf_convert.c') 915800Snate@binkert.orgElfFile('libelf_fsize.c') 925800Snate@binkert.orgElfFile('libelf_msize.c') 935952Ssaidi@eecs.umich.edu 945952Ssaidi@eecs.umich.edum4env = main.Clone() 955952Ssaidi@eecs.umich.eduif m4env['GCC']: 96 m4env.Append(CCFLAGS=['-Wno-pointer-sign', 97 '-Wno-unused-but-set-variable', 98 '-Wno-implicit-function-declaration', 99 '-Wno-override-init']) 100if m4env['CLANG']: 101 m4env.Append(CCFLAGS=['-Wno-initializer-overrides', '-Wno-pointer-sign']) 102 # clang defaults to c99 (while gcc defaults to gnu89) and there is a 103 # difference in the handling of inlining functions which causes 104 # linking problems with multiple definitions of the symbols in 105 # sysmacros.h for older versions of glibc 106 m4env.Append(CCFLAGS=['-std=gnu89']) 107m4env.Append(CCFLAGS=['-Wno-implicit']) 108del m4env['CPPPATH'] 109 110# If we have gm4 use it 111if m4env.Detect('gm4'): 112 m4env['M4'] = 'gm4' 113 114# Check that m4 is available 115import SCons.Tool.m4 116if not SCons.Tool.m4.exists(m4env): 117 print "Error: Can't find version of M4 macro processor. " + \ 118 "Please install M4 and try again." 119 Exit(1) 120 121m4env.Append(M4FLAGS=['-DSRCDIR=%s' % Dir('.').path]) 122m4env['M4COM'] = '$M4 $M4FLAGS $SOURCES > $TARGET' 123m4env.M4(target=File('libelf_convert.c'), 124 source=[File('elf_types.m4'), File('libelf_convert.m4')]) 125m4env.M4(target=File('libelf_fsize.c'), 126 source=[File('elf_types.m4'), File('libelf_fsize.m4')]) 127m4env.M4(target=File('libelf_msize.c'), 128 source=[File('elf_types.m4'), File('libelf_msize.m4')]) 129 130# Build libelf as a static library with PIC code so it can be linked 131# into either m5 or the library 132m4env.Library('elf', [m4env.SharedObject(f) for f in elf_files]) 133 134main.Prepend(CPPPATH=Dir('.')) 135main.Append(LIBS=['elf']) 136main.Prepend(LIBPATH=[Dir('.')]) 137 138