SConscript revision 8737:770ccf3af571
1955SN/A# -*- mode:python -*- 2955SN/A 39812Sandreas.hansson@arm.com# Copyright (c) 2004-2005 The Regents of The University of Michigan 49812Sandreas.hansson@arm.com# All rights reserved. 59812Sandreas.hansson@arm.com# 69812Sandreas.hansson@arm.com# Redistribution and use in source and binary forms, with or without 79812Sandreas.hansson@arm.com# modification, are permitted provided that the following conditions are 89812Sandreas.hansson@arm.com# met: redistributions of source code must retain the above copyright 99812Sandreas.hansson@arm.com# notice, this list of conditions and the following disclaimer; 109812Sandreas.hansson@arm.com# redistributions in binary form must reproduce the above copyright 119812Sandreas.hansson@arm.com# notice, this list of conditions and the following disclaimer in the 129812Sandreas.hansson@arm.com# documentation and/or other materials provided with the distribution; 139812Sandreas.hansson@arm.com# neither the name of the copyright holders nor the names of its 149812Sandreas.hansson@arm.com# contributors may be used to endorse or promote products derived from 157816Ssteve.reinhardt@amd.com# this software without specific prior written permission. 165871Snate@binkert.org# 171762SN/A# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18955SN/A# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19955SN/A# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20955SN/A# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21955SN/A# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22955SN/A# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23955SN/A# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24955SN/A# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25955SN/A# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26955SN/A# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27955SN/A# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28955SN/A# 29955SN/A# Authors: Nathan Binkert 30955SN/A 31955SN/Aimport os, subprocess 32955SN/A 33955SN/AImport('main') 34955SN/A 35955SN/Aelf_files = [] 36955SN/Adef ElfFile(filename): 37955SN/A elf_files.append(File(filename)) 38955SN/A 39955SN/AElfFile('elf_begin.c') 40955SN/AElfFile('elf_cntl.c') 41955SN/AElfFile('elf_data.c') 422665Ssaidi@eecs.umich.eduElfFile('elf_end.c') 432665Ssaidi@eecs.umich.eduElfFile('elf_errmsg.c') 445863Snate@binkert.orgElfFile('elf_errno.c') 45955SN/AElfFile('elf_fill.c') 46955SN/AElfFile('elf_flag.c') 47955SN/AElfFile('elf_getarhdr.c') 48955SN/AElfFile('elf_getarsym.c') 49955SN/AElfFile('elf_getbase.c') 508878Ssteve.reinhardt@amd.comElfFile('elf_getident.c') 512632Sstever@eecs.umich.eduElfFile('elf_hash.c') 528878Ssteve.reinhardt@amd.comElfFile('elf_kind.c') 532632Sstever@eecs.umich.eduElfFile('elf_memory.c') 54955SN/AElfFile('elf_next.c') 558878Ssteve.reinhardt@amd.comElfFile('elf_phnum.c') 562632Sstever@eecs.umich.eduElfFile('elf_rand.c') 572761Sstever@eecs.umich.eduElfFile('elf_rawfile.c') 582632Sstever@eecs.umich.eduElfFile('elf_scn.c') 592632Sstever@eecs.umich.eduElfFile('elf_shnum.c') 602632Sstever@eecs.umich.eduElfFile('elf_shstrndx.c') 612761Sstever@eecs.umich.eduElfFile('elf_strptr.c') 622761Sstever@eecs.umich.eduElfFile('elf_update.c') 632761Sstever@eecs.umich.eduElfFile('elf_version.c') 648878Ssteve.reinhardt@amd.comElfFile('gelf_checksum.c') 658878Ssteve.reinhardt@amd.comElfFile('gelf_dyn.c') 662761Sstever@eecs.umich.eduElfFile('gelf_ehdr.c') 672761Sstever@eecs.umich.eduElfFile('gelf_fsize.c') 682761Sstever@eecs.umich.eduElfFile('gelf_getclass.c') 692761Sstever@eecs.umich.eduElfFile('gelf_phdr.c') 702761Sstever@eecs.umich.eduElfFile('gelf_rel.c') 718878Ssteve.reinhardt@amd.comElfFile('gelf_rela.c') 728878Ssteve.reinhardt@amd.comElfFile('gelf_shdr.c') 732632Sstever@eecs.umich.eduElfFile('gelf_sym.c') 742632Sstever@eecs.umich.eduElfFile('gelf_symshndx.c') 758878Ssteve.reinhardt@amd.comElfFile('gelf_xlate.c') 768878Ssteve.reinhardt@amd.comElfFile('libelf.c') 772632Sstever@eecs.umich.eduElfFile('libelf_align.c') 78955SN/AElfFile('libelf_allocate.c') 79955SN/AElfFile('libelf_ar.c') 80955SN/AElfFile('libelf_checksum.c') 815863Snate@binkert.orgElfFile('libelf_data.c') 825863Snate@binkert.orgElfFile('libelf_ehdr.c') 835863Snate@binkert.orgElfFile('libelf_extended.c') 845863Snate@binkert.orgElfFile('libelf_phdr.c') 855863Snate@binkert.orgElfFile('libelf_shdr.c') 865863Snate@binkert.orgElfFile('libelf_xlate.c') 875863Snate@binkert.org 885863Snate@binkert.orgElfFile('libelf_convert.c') 895863Snate@binkert.orgElfFile('libelf_fsize.c') 905863Snate@binkert.orgElfFile('libelf_msize.c') 915863Snate@binkert.org 928878Ssteve.reinhardt@amd.comm4env = main.Clone() 935863Snate@binkert.orgif m4env['GCC']: 945863Snate@binkert.org major,minor,dot = [int(x) for x in m4env['GCC_VERSION'].split('.')] 955863Snate@binkert.org if major >= 4: 969812Sandreas.hansson@arm.com m4env.Append(CCFLAGS=['-Wno-pointer-sign']) 979812Sandreas.hansson@arm.comif m4env['CLANG']: 985863Snate@binkert.org m4env.Append(CCFLAGS=['-Wno-initializer-overrides', '-Wno-pointer-sign']) 999812Sandreas.hansson@arm.comm4env.Append(CCFLAGS=['-Wno-implicit']) 1005863Snate@binkert.orgdel m4env['CPPPATH'] 1015863Snate@binkert.org 1025863Snate@binkert.org# If we have gm4 use it 1039812Sandreas.hansson@arm.comif m4env.Detect('gm4'): 1049812Sandreas.hansson@arm.com m4env['M4'] = 'gm4' 1055863Snate@binkert.org 1065863Snate@binkert.org# Check that m4 is available 1078878Ssteve.reinhardt@amd.comimport SCons.Tool.m4 1085863Snate@binkert.orgif not SCons.Tool.m4.exists(m4env): 1095863Snate@binkert.org print "Error: Can't find version of M4 macro processor. " + \ 1105863Snate@binkert.org "Please install M4 and try again." 1116654Snate@binkert.org Exit(1) 11210196SCurtis.Dunham@arm.com 113955SN/Am4env.Append(M4FLAGS=['-DSRCDIR=%s' % Dir('.').path]) 1145396Ssaidi@eecs.umich.edum4env['M4COM'] = '$M4 $M4FLAGS $SOURCES > $TARGET' 1155863Snate@binkert.orgm4env.M4(target=File('libelf_convert.c'), 1165863Snate@binkert.org source=[File('elf_types.m4'), File('libelf_convert.m4')]) 1174202Sbinkertn@umich.edum4env.M4(target=File('libelf_fsize.c'), 1185863Snate@binkert.org source=[File('elf_types.m4'), File('libelf_fsize.m4')]) 1195863Snate@binkert.orgm4env.M4(target=File('libelf_msize.c'), 1205863Snate@binkert.org source=[File('elf_types.m4'), File('libelf_msize.m4')]) 1215863Snate@binkert.org 122955SN/A# Build libelf as a static library with PIC code so it can be linked 1236654Snate@binkert.org# into either m5 or the library 1245273Sstever@gmail.comm4env.Library('elf', [m4env.SharedObject(f) for f in elf_files]) 1255871Snate@binkert.org 1265273Sstever@gmail.commain.Prepend(CPPPATH=Dir('.')) 1276655Snate@binkert.orgmain.Append(LIBS=['elf']) 1288878Ssteve.reinhardt@amd.commain.Prepend(LIBPATH=[Dir('.')]) 1296655Snate@binkert.org 1306655Snate@binkert.org