SConscript revision 8946:fb6c89334b86
111527Sdavid.guillen@arm.com# -*- mode:python -*- 211527Sdavid.guillen@arm.com 311527Sdavid.guillen@arm.com# Copyright (c) 2004-2005 The Regents of The University of Michigan 411527Sdavid.guillen@arm.com# All rights reserved. 511527Sdavid.guillen@arm.com# 611527Sdavid.guillen@arm.com# Redistribution and use in source and binary forms, with or without 711527Sdavid.guillen@arm.com# modification, are permitted provided that the following conditions are 811527Sdavid.guillen@arm.com# met: redistributions of source code must retain the above copyright 911527Sdavid.guillen@arm.com# notice, this list of conditions and the following disclaimer; 1011527Sdavid.guillen@arm.com# redistributions in binary form must reproduce the above copyright 1111527Sdavid.guillen@arm.com# notice, this list of conditions and the following disclaimer in the 1211527Sdavid.guillen@arm.com# documentation and/or other materials provided with the distribution; 1311527Sdavid.guillen@arm.com# neither the name of the copyright holders nor the names of its 1411527Sdavid.guillen@arm.com# contributors may be used to endorse or promote products derived from 1511527Sdavid.guillen@arm.com# this software without specific prior written permission. 1611527Sdavid.guillen@arm.com# 1711527Sdavid.guillen@arm.com# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1811527Sdavid.guillen@arm.com# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1911527Sdavid.guillen@arm.com# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 2011527Sdavid.guillen@arm.com# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 2111527Sdavid.guillen@arm.com# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 2211527Sdavid.guillen@arm.com# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 2311527Sdavid.guillen@arm.com# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2411527Sdavid.guillen@arm.com# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2511527Sdavid.guillen@arm.com# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2611527Sdavid.guillen@arm.com# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 2711527Sdavid.guillen@arm.com# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2811527Sdavid.guillen@arm.com# 2911527Sdavid.guillen@arm.com# Authors: Nathan Binkert 3011527Sdavid.guillen@arm.com 3111527Sdavid.guillen@arm.comimport os, subprocess 3211527Sdavid.guillen@arm.com 3311527Sdavid.guillen@arm.comImport('main') 3411527Sdavid.guillen@arm.com 3511527Sdavid.guillen@arm.comfrom m5.util import compareVersions 3611527Sdavid.guillen@arm.com 3711527Sdavid.guillen@arm.comelf_files = [] 3811527Sdavid.guillen@arm.comdef ElfFile(filename): 3911527Sdavid.guillen@arm.com elf_files.append(File(filename)) 4011527Sdavid.guillen@arm.com 4111527Sdavid.guillen@arm.comElfFile('elf_begin.c') 4211527Sdavid.guillen@arm.comElfFile('elf_cntl.c') 4311527Sdavid.guillen@arm.comElfFile('elf_data.c') 4411527Sdavid.guillen@arm.comElfFile('elf_end.c') 4511800Sbrandon.potter@amd.comElfFile('elf_errmsg.c') 4611527Sdavid.guillen@arm.comElfFile('elf_errno.c') 4711527Sdavid.guillen@arm.comElfFile('elf_fill.c') 4811527Sdavid.guillen@arm.comElfFile('elf_flag.c') 4911527Sdavid.guillen@arm.comElfFile('elf_getarhdr.c') 5011527Sdavid.guillen@arm.comElfFile('elf_getarsym.c') 5111527Sdavid.guillen@arm.comElfFile('elf_getbase.c') 5211527Sdavid.guillen@arm.comElfFile('elf_getident.c') 5311527Sdavid.guillen@arm.comElfFile('elf_hash.c') 5411527Sdavid.guillen@arm.comElfFile('elf_kind.c') 5511527Sdavid.guillen@arm.comElfFile('elf_memory.c') 5611527Sdavid.guillen@arm.comElfFile('elf_next.c') 5711527Sdavid.guillen@arm.comElfFile('elf_phnum.c') 5811527Sdavid.guillen@arm.comElfFile('elf_rand.c') 5911527Sdavid.guillen@arm.comElfFile('elf_rawfile.c') 6011527Sdavid.guillen@arm.comElfFile('elf_scn.c') 6111527Sdavid.guillen@arm.comElfFile('elf_shnum.c') 6211527Sdavid.guillen@arm.comElfFile('elf_shstrndx.c') 6311527Sdavid.guillen@arm.comElfFile('elf_strptr.c') 6411527Sdavid.guillen@arm.comElfFile('elf_update.c') 6511527Sdavid.guillen@arm.comElfFile('elf_version.c') 6611527Sdavid.guillen@arm.comElfFile('gelf_checksum.c') 6711527Sdavid.guillen@arm.comElfFile('gelf_dyn.c') 6811527Sdavid.guillen@arm.comElfFile('gelf_ehdr.c') 6911527Sdavid.guillen@arm.comElfFile('gelf_fsize.c') 7011527Sdavid.guillen@arm.comElfFile('gelf_getclass.c') 7111527Sdavid.guillen@arm.comElfFile('gelf_phdr.c') 7211527Sdavid.guillen@arm.comElfFile('gelf_rel.c') 7311527Sdavid.guillen@arm.comElfFile('gelf_rela.c') 7411527Sdavid.guillen@arm.comElfFile('gelf_shdr.c') 7511527Sdavid.guillen@arm.comElfFile('gelf_sym.c') 7611527Sdavid.guillen@arm.comElfFile('gelf_symshndx.c') 7711527Sdavid.guillen@arm.comElfFile('gelf_xlate.c') 7811527Sdavid.guillen@arm.comElfFile('libelf.c') 7911527Sdavid.guillen@arm.comElfFile('libelf_align.c') 8011527Sdavid.guillen@arm.comElfFile('libelf_allocate.c') 8111527Sdavid.guillen@arm.comElfFile('libelf_ar.c') 8211527Sdavid.guillen@arm.comElfFile('libelf_checksum.c') 8311527Sdavid.guillen@arm.comElfFile('libelf_data.c') 8411527Sdavid.guillen@arm.comElfFile('libelf_ehdr.c') 8511527Sdavid.guillen@arm.comElfFile('libelf_extended.c') 8611527Sdavid.guillen@arm.comElfFile('libelf_phdr.c') 8711527Sdavid.guillen@arm.comElfFile('libelf_shdr.c') 8811527Sdavid.guillen@arm.comElfFile('libelf_xlate.c') 8911527Sdavid.guillen@arm.com 9011527Sdavid.guillen@arm.comElfFile('libelf_convert.c') 9111527Sdavid.guillen@arm.comElfFile('libelf_fsize.c') 9211527Sdavid.guillen@arm.comElfFile('libelf_msize.c') 9311527Sdavid.guillen@arm.com 9411527Sdavid.guillen@arm.comm4env = main.Clone() 9511527Sdavid.guillen@arm.comif m4env['GCC']: 9611527Sdavid.guillen@arm.com if compareVersions(m4env['GCC_VERSION'], '4') >= 0: 9711527Sdavid.guillen@arm.com m4env.Append(CCFLAGS=['-Wno-pointer-sign']) 9811527Sdavid.guillen@arm.com if compareVersions(m4env['GCC_VERSION'], '4.6') >= 0: 9911527Sdavid.guillen@arm.com m4env.Append(CCFLAGS=['-Wno-unused-but-set-variable', 10011527Sdavid.guillen@arm.com '-Wno-implicit-function-declaration']) 10111527Sdavid.guillen@arm.comif m4env['CLANG']: 10211527Sdavid.guillen@arm.com m4env.Append(CCFLAGS=['-Wno-initializer-overrides', '-Wno-pointer-sign']) 10311527Sdavid.guillen@arm.comm4env.Append(CCFLAGS=['-Wno-implicit']) 10411527Sdavid.guillen@arm.comdel m4env['CPPPATH'] 10511527Sdavid.guillen@arm.com 10611527Sdavid.guillen@arm.com# If we have gm4 use it 10711527Sdavid.guillen@arm.comif m4env.Detect('gm4'): 10811527Sdavid.guillen@arm.com m4env['M4'] = 'gm4' 10911527Sdavid.guillen@arm.com 11011527Sdavid.guillen@arm.com# Check that m4 is available 11111527Sdavid.guillen@arm.comimport SCons.Tool.m4 11211527Sdavid.guillen@arm.comif not SCons.Tool.m4.exists(m4env): 11311527Sdavid.guillen@arm.com print "Error: Can't find version of M4 macro processor. " + \ 11411527Sdavid.guillen@arm.com "Please install M4 and try again." 11511527Sdavid.guillen@arm.com Exit(1) 11611527Sdavid.guillen@arm.com 11711527Sdavid.guillen@arm.comm4env.Append(M4FLAGS=['-DSRCDIR=%s' % Dir('.').path]) 11811527Sdavid.guillen@arm.comm4env['M4COM'] = '$M4 $M4FLAGS $SOURCES > $TARGET' 11911527Sdavid.guillen@arm.comm4env.M4(target=File('libelf_convert.c'), 12011527Sdavid.guillen@arm.com source=[File('elf_types.m4'), File('libelf_convert.m4')]) 12111527Sdavid.guillen@arm.comm4env.M4(target=File('libelf_fsize.c'), 12211527Sdavid.guillen@arm.com source=[File('elf_types.m4'), File('libelf_fsize.m4')]) 12311527Sdavid.guillen@arm.comm4env.M4(target=File('libelf_msize.c'), 12411527Sdavid.guillen@arm.com source=[File('elf_types.m4'), File('libelf_msize.m4')]) 12511527Sdavid.guillen@arm.com 12611527Sdavid.guillen@arm.com# Build libelf as a static library with PIC code so it can be linked 12711527Sdavid.guillen@arm.com# into either m5 or the library 12811527Sdavid.guillen@arm.comm4env.Library('elf', [m4env.SharedObject(f) for f in elf_files]) 12911527Sdavid.guillen@arm.com 13011527Sdavid.guillen@arm.commain.Prepend(CPPPATH=Dir('.')) 13111527Sdavid.guillen@arm.commain.Append(LIBS=['elf']) 13211527Sdavid.guillen@arm.commain.Prepend(LIBPATH=[Dir('.')]) 13311527Sdavid.guillen@arm.com 13411527Sdavid.guillen@arm.com