SConscript revision 11294
12391SN/A# -*- mode:python -*- 210482Sandreas.hansson@arm.com 37733SAli.Saidi@ARM.com# Copyright (c) 2004-2005 The Regents of The University of Michigan 47733SAli.Saidi@ARM.com# All rights reserved. 57733SAli.Saidi@ARM.com# 67733SAli.Saidi@ARM.com# Redistribution and use in source and binary forms, with or without 77733SAli.Saidi@ARM.com# modification, are permitted provided that the following conditions are 87733SAli.Saidi@ARM.com# met: redistributions of source code must retain the above copyright 97733SAli.Saidi@ARM.com# notice, this list of conditions and the following disclaimer; 107733SAli.Saidi@ARM.com# redistributions in binary form must reproduce the above copyright 117733SAli.Saidi@ARM.com# notice, this list of conditions and the following disclaimer in the 127733SAli.Saidi@ARM.com# documentation and/or other materials provided with the distribution; 137733SAli.Saidi@ARM.com# neither the name of the copyright holders nor the names of its 142391SN/A# contributors may be used to endorse or promote products derived from 152391SN/A# this software without specific prior written permission. 162391SN/A# 172391SN/A# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 182391SN/A# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 192391SN/A# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 202391SN/A# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 212391SN/A# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 222391SN/A# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 232391SN/A# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 242391SN/A# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 252391SN/A# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 262391SN/A# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 272391SN/A# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 282391SN/A# 292391SN/A# Authors: Nathan Binkert 302391SN/A 312391SN/Aimport os, subprocess 322391SN/A 332391SN/AImport('main') 342391SN/A 352391SN/Afrom m5.util import compareVersions 362665Ssaidi@eecs.umich.edu 378931Sandreas.hansson@arm.comelf_files = [] 382391SN/Adef ElfFile(filename): 392391SN/A elf_files.append(File(filename)) 409293Sandreas.hansson@arm.com 419293Sandreas.hansson@arm.comElfFile('elf_begin.c') 429293Sandreas.hansson@arm.comElfFile('elf_cntl.c') 439293Sandreas.hansson@arm.comElfFile('elf_data.c') 449293Sandreas.hansson@arm.comElfFile('elf_end.c') 459293Sandreas.hansson@arm.comElfFile('elf_errmsg.c') 469293Sandreas.hansson@arm.comElfFile('elf_errno.c') 479293Sandreas.hansson@arm.comElfFile('elf_fill.c') 489293Sandreas.hansson@arm.comElfFile('elf_flag.c') 499293Sandreas.hansson@arm.comElfFile('elf_getarhdr.c') 509293Sandreas.hansson@arm.comElfFile('elf_getarsym.c') 519293Sandreas.hansson@arm.comElfFile('elf_getbase.c') 529293Sandreas.hansson@arm.comElfFile('elf_getident.c') 539356Snilay@cs.wisc.eduElfFile('elf_hash.c') 5410405Sandreas.hansson@arm.comElfFile('elf_kind.c') 559293Sandreas.hansson@arm.comElfFile('elf_memory.c') 569293Sandreas.hansson@arm.comElfFile('elf_next.c') 572394SN/AElfFile('elf_phnum.c') 582394SN/AElfFile('elf_rand.c') 592391SN/AElfFile('elf_rawfile.c') 602391SN/AElfFile('elf_scn.c') 619293Sandreas.hansson@arm.comElfFile('elf_shnum.c') 629293Sandreas.hansson@arm.comElfFile('elf_shstrndx.c') 6310699Sandreas.hansson@arm.comElfFile('elf_strptr.c') 642391SN/AElfFile('elf_update.c') 659293Sandreas.hansson@arm.comElfFile('elf_version.c') 669293Sandreas.hansson@arm.comElfFile('gelf_checksum.c') 6710482Sandreas.hansson@arm.comElfFile('gelf_dyn.c') 688931Sandreas.hansson@arm.comElfFile('gelf_ehdr.c') 6910482Sandreas.hansson@arm.comElfFile('gelf_fsize.c') 7010482Sandreas.hansson@arm.comElfFile('gelf_getclass.c') 712391SN/AElfFile('gelf_phdr.c') 728931Sandreas.hansson@arm.comElfFile('gelf_rel.c') 7310482Sandreas.hansson@arm.comElfFile('gelf_rela.c') 748931Sandreas.hansson@arm.comElfFile('gelf_shdr.c') 758931Sandreas.hansson@arm.comElfFile('gelf_sym.c') 768931Sandreas.hansson@arm.comElfFile('gelf_symshndx.c') 7710482Sandreas.hansson@arm.comElfFile('gelf_xlate.c') 7810482Sandreas.hansson@arm.comElfFile('libelf.c') 7910482Sandreas.hansson@arm.comElfFile('libelf_align.c') 809293Sandreas.hansson@arm.comElfFile('libelf_allocate.c') 819293Sandreas.hansson@arm.comElfFile('libelf_ar.c') 829293Sandreas.hansson@arm.comElfFile('libelf_checksum.c') 839293Sandreas.hansson@arm.comElfFile('libelf_data.c') 8410482Sandreas.hansson@arm.comElfFile('libelf_ehdr.c') 8510482Sandreas.hansson@arm.comElfFile('libelf_extended.c') 8610482Sandreas.hansson@arm.comElfFile('libelf_phdr.c') 8710482Sandreas.hansson@arm.comElfFile('libelf_shdr.c') 8810482Sandreas.hansson@arm.comElfFile('libelf_xlate.c') 8910482Sandreas.hansson@arm.com 9010482Sandreas.hansson@arm.comElfFile('libelf_convert.c') 9110482Sandreas.hansson@arm.comElfFile('libelf_fsize.c') 929293Sandreas.hansson@arm.comElfFile('libelf_msize.c') 939293Sandreas.hansson@arm.com 949293Sandreas.hansson@arm.comm4env = main.Clone() 959293Sandreas.hansson@arm.comif m4env['GCC']: 9610482Sandreas.hansson@arm.com m4env.Append(CCFLAGS=['-Wno-pointer-sign', 9710482Sandreas.hansson@arm.com '-Wno-unused-but-set-variable', 988931Sandreas.hansson@arm.com '-Wno-implicit-function-declaration', 999293Sandreas.hansson@arm.com '-Wno-override-init']) 1009293Sandreas.hansson@arm.comif m4env['CLANG']: 10110070Sandreas.hansson@arm.com m4env.Append(CCFLAGS=['-Wno-initializer-overrides', '-Wno-pointer-sign']) 10210070Sandreas.hansson@arm.com # clang defaults to c99 (while gcc defaults to gnu89) and there is a 10310070Sandreas.hansson@arm.com # difference in the handling of inlining functions which causes 1049565Sandreas.hansson@arm.com # linking problems with multiple definitions of the symbols in 1059293Sandreas.hansson@arm.com # sysmacros.h for older versions of glibc 10610482Sandreas.hansson@arm.com m4env.Append(CCFLAGS=['-std=gnu89']) 1079293Sandreas.hansson@arm.comm4env.Append(CCFLAGS=['-Wno-implicit']) 1089293Sandreas.hansson@arm.comdel m4env['CPPPATH'] 10910482Sandreas.hansson@arm.com 1109565Sandreas.hansson@arm.com# If we have gm4 use it 11110482Sandreas.hansson@arm.comif m4env.Detect('gm4'): 1129565Sandreas.hansson@arm.com m4env['M4'] = 'gm4' 1139565Sandreas.hansson@arm.com 1149565Sandreas.hansson@arm.com# Check that m4 is available 1159565Sandreas.hansson@arm.comimport SCons.Tool.m4 11610482Sandreas.hansson@arm.comif not SCons.Tool.m4.exists(m4env): 1179565Sandreas.hansson@arm.com print "Error: Can't find version of M4 macro processor. " + \ 1189565Sandreas.hansson@arm.com "Please install M4 and try again." 1199565Sandreas.hansson@arm.com Exit(1) 1209565Sandreas.hansson@arm.com 1219565Sandreas.hansson@arm.comm4env.Append(M4FLAGS=['-DSRCDIR=%s' % Dir('.').path]) 12210482Sandreas.hansson@arm.comm4env['M4COM'] = '$M4 $M4FLAGS $SOURCES > $TARGET' 12310482Sandreas.hansson@arm.comm4env.M4(target=File('libelf_convert.c'), 1249565Sandreas.hansson@arm.com source=[File('elf_types.m4'), File('libelf_convert.m4')]) 12510482Sandreas.hansson@arm.comm4env.M4(target=File('libelf_fsize.c'), 12610482Sandreas.hansson@arm.com source=[File('elf_types.m4'), File('libelf_fsize.m4')]) 1279565Sandreas.hansson@arm.comm4env.M4(target=File('libelf_msize.c'), 1289293Sandreas.hansson@arm.com source=[File('elf_types.m4'), File('libelf_msize.m4')]) 1299293Sandreas.hansson@arm.com 1309565Sandreas.hansson@arm.com# Build libelf as a static library with PIC code so it can be linked 1319565Sandreas.hansson@arm.com# into either m5 or the library 1329565Sandreas.hansson@arm.comm4env.Library('elf', [m4env.SharedObject(f) for f in elf_files]) 1339565Sandreas.hansson@arm.com 1349565Sandreas.hansson@arm.commain.Prepend(CPPPATH=Dir('.')) 1359565Sandreas.hansson@arm.commain.Append(LIBS=['elf']) 1369565Sandreas.hansson@arm.commain.Prepend(LIBPATH=[Dir('.')]) 1379293Sandreas.hansson@arm.com 1389293Sandreas.hansson@arm.com