SConscript revision 12605
16019Shines@cs.fsu.edu# -*- mode:python -*- 26019Shines@cs.fsu.edu 36019Shines@cs.fsu.edu# Copyright (c) 2004-2005 The Regents of The University of Michigan 46019Shines@cs.fsu.edu# All rights reserved. 56019Shines@cs.fsu.edu# 66019Shines@cs.fsu.edu# Redistribution and use in source and binary forms, with or without 76019Shines@cs.fsu.edu# modification, are permitted provided that the following conditions are 86019Shines@cs.fsu.edu# met: redistributions of source code must retain the above copyright 96019Shines@cs.fsu.edu# notice, this list of conditions and the following disclaimer; 106019Shines@cs.fsu.edu# redistributions in binary form must reproduce the above copyright 116019Shines@cs.fsu.edu# notice, this list of conditions and the following disclaimer in the 126019Shines@cs.fsu.edu# documentation and/or other materials provided with the distribution; 136019Shines@cs.fsu.edu# neither the name of the copyright holders nor the names of its 146019Shines@cs.fsu.edu# contributors may be used to endorse or promote products derived from 156019Shines@cs.fsu.edu# this software without specific prior written permission. 166019Shines@cs.fsu.edu# 176019Shines@cs.fsu.edu# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 186019Shines@cs.fsu.edu# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 196019Shines@cs.fsu.edu# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 206019Shines@cs.fsu.edu# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 216019Shines@cs.fsu.edu# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 226019Shines@cs.fsu.edu# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 236019Shines@cs.fsu.edu# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 246019Shines@cs.fsu.edu# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 256019Shines@cs.fsu.edu# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 266019Shines@cs.fsu.edu# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 276019Shines@cs.fsu.edu# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 286019Shines@cs.fsu.edu# 296019Shines@cs.fsu.edu# Authors: Nathan Binkert 306019Shines@cs.fsu.edu 316019Shines@cs.fsu.edufrom __future__ import print_function 326019Shines@cs.fsu.edu 336019Shines@cs.fsu.eduimport os, subprocess 346019Shines@cs.fsu.edu 356019Shines@cs.fsu.eduImport('main') 366019Shines@cs.fsu.edu 376019Shines@cs.fsu.edufrom m5.util import compareVersions 386253Sgblack@eecs.umich.edu 396253Sgblack@eecs.umich.eduelf_files = [] 406253Sgblack@eecs.umich.edudef ElfFile(filename): 416253Sgblack@eecs.umich.edu elf_files.append(File(filename)) 426397Sgblack@eecs.umich.edu 436019Shines@cs.fsu.eduElfFile('elf_begin.c') 446019Shines@cs.fsu.eduElfFile('elf_cntl.c') 456019Shines@cs.fsu.eduElfFile('elf_data.c') 466019Shines@cs.fsu.eduElfFile('elf_end.c') 476397Sgblack@eecs.umich.eduElfFile('elf_errmsg.c') 486019Shines@cs.fsu.eduElfFile('elf_errno.c') 496397Sgblack@eecs.umich.eduElfFile('elf_fill.c') 506019Shines@cs.fsu.eduElfFile('elf_flag.c') 516019Shines@cs.fsu.eduElfFile('elf_getarhdr.c') 526019Shines@cs.fsu.eduElfFile('elf_getarsym.c') 536019Shines@cs.fsu.eduElfFile('elf_getbase.c') 546019Shines@cs.fsu.eduElfFile('elf_getident.c') 556019Shines@cs.fsu.eduElfFile('elf_hash.c') 566019Shines@cs.fsu.eduElfFile('elf_kind.c') 576019Shines@cs.fsu.eduElfFile('elf_memory.c') 586019Shines@cs.fsu.eduElfFile('elf_next.c') 596019Shines@cs.fsu.eduElfFile('elf_phnum.c') 606019Shines@cs.fsu.eduElfFile('elf_rand.c') 616019Shines@cs.fsu.eduElfFile('elf_rawfile.c') 626019Shines@cs.fsu.eduElfFile('elf_scn.c') 636019Shines@cs.fsu.eduElfFile('elf_shnum.c') 646019Shines@cs.fsu.eduElfFile('elf_shstrndx.c') 656019Shines@cs.fsu.eduElfFile('elf_strptr.c') 666019Shines@cs.fsu.eduElfFile('elf_update.c') 67ElfFile('elf_version.c') 68ElfFile('gelf_checksum.c') 69ElfFile('gelf_dyn.c') 70ElfFile('gelf_ehdr.c') 71ElfFile('gelf_fsize.c') 72ElfFile('gelf_getclass.c') 73ElfFile('gelf_phdr.c') 74ElfFile('gelf_rel.c') 75ElfFile('gelf_rela.c') 76ElfFile('gelf_shdr.c') 77ElfFile('gelf_sym.c') 78ElfFile('gelf_symshndx.c') 79ElfFile('gelf_xlate.c') 80ElfFile('libelf.c') 81ElfFile('libelf_align.c') 82ElfFile('libelf_allocate.c') 83ElfFile('libelf_ar.c') 84ElfFile('libelf_checksum.c') 85ElfFile('libelf_data.c') 86ElfFile('libelf_ehdr.c') 87ElfFile('libelf_extended.c') 88ElfFile('libelf_phdr.c') 89ElfFile('libelf_shdr.c') 90ElfFile('libelf_xlate.c') 91 92ElfFile('libelf_convert.c') 93ElfFile('libelf_fsize.c') 94ElfFile('libelf_msize.c') 95 96m4env = main.Clone() 97if m4env['GCC']: 98 m4env.Append(CCFLAGS=['-Wno-pointer-sign', 99 '-Wno-unused-but-set-variable', 100 '-Wno-implicit-function-declaration', 101 '-Wno-override-init']) 102if m4env['CLANG']: 103 m4env.Append(CCFLAGS=['-Wno-initializer-overrides', '-Wno-pointer-sign']) 104 # clang defaults to c99 (while gcc defaults to gnu89) and there is a 105 # difference in the handling of inlining functions which causes 106 # linking problems with multiple definitions of the symbols in 107 # sysmacros.h for older versions of glibc 108 m4env.Append(CCFLAGS=['-std=gnu89']) 109m4env.Append(CCFLAGS=['-Wno-implicit']) 110del m4env['CPPPATH'] 111 112# If we have gm4 use it 113if m4env.Detect('gm4'): 114 m4env['M4'] = 'gm4' 115 116# Check that m4 is available 117import SCons.Tool.m4 118if not SCons.Tool.m4.exists(m4env): 119 print("Error: Can't find version of M4 macro processor. " + 120 "Please install M4 and try again.") 121 Exit(1) 122 123m4env.Append(M4FLAGS=['-DSRCDIR=%s' % Dir('.').path]) 124m4env['M4COM'] = '$M4 $M4FLAGS $SOURCES > $TARGET' 125m4env.M4(target=File('libelf_convert.c'), 126 source=[File('elf_types.m4'), File('libelf_convert.m4')]) 127m4env.M4(target=File('libelf_fsize.c'), 128 source=[File('elf_types.m4'), File('libelf_fsize.m4')]) 129m4env.M4(target=File('libelf_msize.c'), 130 source=[File('elf_types.m4'), File('libelf_msize.m4')]) 131 132# Build libelf as a static library with PIC code so it can be linked 133# into either m5 or the library 134m4env.Library('elf', [m4env.SharedObject(f) for f in elf_files]) 135 136main.Prepend(CPPPATH=Dir('.')) 137main.Append(LIBS=['elf']) 138main.Prepend(LIBPATH=[Dir('.')]) 139 140