SConscript revision 12563
14484Sbinkertn@umich.edu# -*- mode:python -*- 24484Sbinkertn@umich.edu 34484Sbinkertn@umich.edu# Copyright (c) 2004-2005 The Regents of The University of Michigan 44484Sbinkertn@umich.edu# All rights reserved. 54484Sbinkertn@umich.edu# 64484Sbinkertn@umich.edu# Redistribution and use in source and binary forms, with or without 74484Sbinkertn@umich.edu# modification, are permitted provided that the following conditions are 84484Sbinkertn@umich.edu# met: redistributions of source code must retain the above copyright 94484Sbinkertn@umich.edu# notice, this list of conditions and the following disclaimer; 104484Sbinkertn@umich.edu# redistributions in binary form must reproduce the above copyright 114484Sbinkertn@umich.edu# notice, this list of conditions and the following disclaimer in the 124484Sbinkertn@umich.edu# documentation and/or other materials provided with the distribution; 134484Sbinkertn@umich.edu# neither the name of the copyright holders nor the names of its 144484Sbinkertn@umich.edu# contributors may be used to endorse or promote products derived from 154484Sbinkertn@umich.edu# this software without specific prior written permission. 164484Sbinkertn@umich.edu# 174484Sbinkertn@umich.edu# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 184484Sbinkertn@umich.edu# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 194484Sbinkertn@umich.edu# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 204484Sbinkertn@umich.edu# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 214484Sbinkertn@umich.edu# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 224484Sbinkertn@umich.edu# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 234484Sbinkertn@umich.edu# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 244484Sbinkertn@umich.edu# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 254484Sbinkertn@umich.edu# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 264484Sbinkertn@umich.edu# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 274484Sbinkertn@umich.edu# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 284484Sbinkertn@umich.edu# 294484Sbinkertn@umich.edu# Authors: Nathan Binkert 304484Sbinkertn@umich.edu 3112563Sgabeblack@google.comfrom __future__ import print_function 3212563Sgabeblack@google.com 334494Ssaidi@eecs.umich.eduimport os, subprocess 344484Sbinkertn@umich.edu 356121Snate@binkert.orgImport('main') 364484Sbinkertn@umich.edu 378946Sandreas.hansson@arm.comfrom m5.util import compareVersions 388946Sandreas.hansson@arm.com 394484Sbinkertn@umich.eduelf_files = [] 404484Sbinkertn@umich.edudef ElfFile(filename): 414484Sbinkertn@umich.edu elf_files.append(File(filename)) 424781Snate@binkert.org 434484Sbinkertn@umich.eduElfFile('elf_begin.c') 444484Sbinkertn@umich.eduElfFile('elf_cntl.c') 454484Sbinkertn@umich.eduElfFile('elf_data.c') 464484Sbinkertn@umich.eduElfFile('elf_end.c') 478349Sgblack@eecs.umich.eduElfFile('elf_errmsg.c') 488349Sgblack@eecs.umich.eduElfFile('elf_errno.c') 494484Sbinkertn@umich.eduElfFile('elf_fill.c') 504484Sbinkertn@umich.eduElfFile('elf_flag.c') 514484Sbinkertn@umich.eduElfFile('elf_getarhdr.c') 524484Sbinkertn@umich.eduElfFile('elf_getarsym.c') 534484Sbinkertn@umich.eduElfFile('elf_getbase.c') 544484Sbinkertn@umich.eduElfFile('elf_getident.c') 554484Sbinkertn@umich.eduElfFile('elf_hash.c') 564484Sbinkertn@umich.eduElfFile('elf_kind.c') 574484Sbinkertn@umich.eduElfFile('elf_memory.c') 584484Sbinkertn@umich.eduElfFile('elf_next.c') 594484Sbinkertn@umich.eduElfFile('elf_phnum.c') 604484Sbinkertn@umich.eduElfFile('elf_rand.c') 614484Sbinkertn@umich.eduElfFile('elf_rawfile.c') 624484Sbinkertn@umich.eduElfFile('elf_scn.c') 634484Sbinkertn@umich.eduElfFile('elf_shnum.c') 644484Sbinkertn@umich.eduElfFile('elf_shstrndx.c') 654484Sbinkertn@umich.eduElfFile('elf_strptr.c') 664484Sbinkertn@umich.eduElfFile('elf_update.c') 674484Sbinkertn@umich.eduElfFile('elf_version.c') 684484Sbinkertn@umich.eduElfFile('gelf_checksum.c') 694484Sbinkertn@umich.eduElfFile('gelf_dyn.c') 704484Sbinkertn@umich.eduElfFile('gelf_ehdr.c') 714484Sbinkertn@umich.eduElfFile('gelf_fsize.c') 724484Sbinkertn@umich.eduElfFile('gelf_getclass.c') 734484Sbinkertn@umich.eduElfFile('gelf_phdr.c') 744484Sbinkertn@umich.eduElfFile('gelf_rel.c') 754484Sbinkertn@umich.eduElfFile('gelf_rela.c') 764484Sbinkertn@umich.eduElfFile('gelf_shdr.c') 774484Sbinkertn@umich.eduElfFile('gelf_sym.c') 784484Sbinkertn@umich.eduElfFile('gelf_symshndx.c') 794484Sbinkertn@umich.eduElfFile('gelf_xlate.c') 804484Sbinkertn@umich.eduElfFile('libelf.c') 814484Sbinkertn@umich.eduElfFile('libelf_align.c') 824484Sbinkertn@umich.eduElfFile('libelf_allocate.c') 834484Sbinkertn@umich.eduElfFile('libelf_ar.c') 844484Sbinkertn@umich.eduElfFile('libelf_checksum.c') 854484Sbinkertn@umich.eduElfFile('libelf_data.c') 864484Sbinkertn@umich.eduElfFile('libelf_ehdr.c') 874484Sbinkertn@umich.eduElfFile('libelf_extended.c') 884484Sbinkertn@umich.eduElfFile('libelf_phdr.c') 894484Sbinkertn@umich.eduElfFile('libelf_shdr.c') 904484Sbinkertn@umich.eduElfFile('libelf_xlate.c') 914484Sbinkertn@umich.edu 924484Sbinkertn@umich.eduElfFile('libelf_convert.c') 934484Sbinkertn@umich.eduElfFile('libelf_fsize.c') 944484Sbinkertn@umich.eduElfFile('libelf_msize.c') 954484Sbinkertn@umich.edu 966121Snate@binkert.orgm4env = main.Clone() 976121Snate@binkert.orgif m4env['GCC']: 9811294Sandreas.hansson@arm.com m4env.Append(CCFLAGS=['-Wno-pointer-sign', 9911294Sandreas.hansson@arm.com '-Wno-unused-but-set-variable', 10011294Sandreas.hansson@arm.com '-Wno-implicit-function-declaration', 10111294Sandreas.hansson@arm.com '-Wno-override-init']) 1028737Skoansin.tan@gmail.comif m4env['CLANG']: 1038737Skoansin.tan@gmail.com m4env.Append(CCFLAGS=['-Wno-initializer-overrides', '-Wno-pointer-sign']) 1049388Sandreas.hansson@arm.com # clang defaults to c99 (while gcc defaults to gnu89) and there is a 1059388Sandreas.hansson@arm.com # difference in the handling of inlining functions which causes 1069388Sandreas.hansson@arm.com # linking problems with multiple definitions of the symbols in 1079388Sandreas.hansson@arm.com # sysmacros.h for older versions of glibc 1089388Sandreas.hansson@arm.com m4env.Append(CCFLAGS=['-std=gnu89']) 1095765Snate@binkert.orgm4env.Append(CCFLAGS=['-Wno-implicit']) 1105397Ssaidi@eecs.umich.edudel m4env['CPPPATH'] 1115274Ssaidi@eecs.umich.edu 1124494Ssaidi@eecs.umich.edu# If we have gm4 use it 1134504Ssaidi@eecs.umich.eduif m4env.Detect('gm4'): 1144494Ssaidi@eecs.umich.edu m4env['M4'] = 'gm4' 1154494Ssaidi@eecs.umich.edu 1164496Ssaidi@eecs.umich.edu# Check that m4 is available 1174504Ssaidi@eecs.umich.eduimport SCons.Tool.m4 1184504Ssaidi@eecs.umich.eduif not SCons.Tool.m4.exists(m4env): 11912563Sgabeblack@google.com print("Error: Can't find version of M4 macro processor. " + 12012563Sgabeblack@google.com "Please install M4 and try again.") 1214496Ssaidi@eecs.umich.edu Exit(1) 1224496Ssaidi@eecs.umich.edu 1237739Sgblack@eecs.umich.edum4env.Append(M4FLAGS=['-DSRCDIR=%s' % Dir('.').path]) 1244487Sstever@eecs.umich.edum4env['M4COM'] = '$M4 $M4FLAGS $SOURCES > $TARGET' 1254484Sbinkertn@umich.edum4env.M4(target=File('libelf_convert.c'), 1264484Sbinkertn@umich.edu source=[File('elf_types.m4'), File('libelf_convert.m4')]) 1274484Sbinkertn@umich.edum4env.M4(target=File('libelf_fsize.c'), 1284484Sbinkertn@umich.edu source=[File('elf_types.m4'), File('libelf_fsize.m4')]) 1294484Sbinkertn@umich.edum4env.M4(target=File('libelf_msize.c'), 1304484Sbinkertn@umich.edu source=[File('elf_types.m4'), File('libelf_msize.m4')]) 1315601Snate@binkert.org 1325601Snate@binkert.org# Build libelf as a static library with PIC code so it can be linked 1335601Snate@binkert.org# into either m5 or the library 1345601Snate@binkert.orgm4env.Library('elf', [m4env.SharedObject(f) for f in elf_files]) 1354484Sbinkertn@umich.edu 1366121Snate@binkert.orgmain.Prepend(CPPPATH=Dir('.')) 1376121Snate@binkert.orgmain.Append(LIBS=['elf']) 1386121Snate@binkert.orgmain.Prepend(LIBPATH=[Dir('.')]) 1394494Ssaidi@eecs.umich.edu 140