SConscript revision 9003
1955SN/A# -*- mode:python -*-
2955SN/A
313576Sciro.santilli@arm.com# Copyright (c) 2004-2005 The Regents of The University of Michigan
413576Sciro.santilli@arm.com# All rights reserved.
513576Sciro.santilli@arm.com#
613576Sciro.santilli@arm.com# Redistribution and use in source and binary forms, with or without
713576Sciro.santilli@arm.com# modification, are permitted provided that the following conditions are
813576Sciro.santilli@arm.com# met: redistributions of source code must retain the above copyright
913576Sciro.santilli@arm.com# notice, this list of conditions and the following disclaimer;
1013576Sciro.santilli@arm.com# redistributions in binary form must reproduce the above copyright
1113576Sciro.santilli@arm.com# notice, this list of conditions and the following disclaimer in the
1213576Sciro.santilli@arm.com# documentation and/or other materials provided with the distribution;
1313576Sciro.santilli@arm.com# neither the name of the copyright holders nor the names of its
141762SN/A# contributors may be used to endorse or promote products derived from
15955SN/A# this software without specific prior written permission.
16955SN/A#
17955SN/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/Afrom m5.util import compareVersions
36955SN/A
37955SN/Aelf_files = []
38955SN/Adef ElfFile(filename):
392665Ssaidi@eecs.umich.edu    elf_files.append(File(filename))
404762Snate@binkert.org
41955SN/AElfFile('elf_begin.c')
4212563Sgabeblack@google.comElfFile('elf_cntl.c')
4312563Sgabeblack@google.comElfFile('elf_data.c')
445522Snate@binkert.orgElfFile('elf_end.c')
456143Snate@binkert.orgElfFile('elf_errmsg.c')
4612371Sgabeblack@google.comElfFile('elf_errno.c')
474762Snate@binkert.orgElfFile('elf_fill.c')
485522Snate@binkert.orgElfFile('elf_flag.c')
49955SN/AElfFile('elf_getarhdr.c')
505522Snate@binkert.orgElfFile('elf_getarsym.c')
5111974Sgabeblack@google.comElfFile('elf_getbase.c')
52955SN/AElfFile('elf_getident.c')
535522Snate@binkert.orgElfFile('elf_hash.c')
544202Sbinkertn@umich.eduElfFile('elf_kind.c')
555742Snate@binkert.orgElfFile('elf_memory.c')
56955SN/AElfFile('elf_next.c')
574381Sbinkertn@umich.eduElfFile('elf_phnum.c')
584381Sbinkertn@umich.eduElfFile('elf_rand.c')
5912246Sgabeblack@google.comElfFile('elf_rawfile.c')
6012246Sgabeblack@google.comElfFile('elf_scn.c')
618334Snate@binkert.orgElfFile('elf_shnum.c')
62955SN/AElfFile('elf_shstrndx.c')
63955SN/AElfFile('elf_strptr.c')
644202Sbinkertn@umich.eduElfFile('elf_update.c')
65955SN/AElfFile('elf_version.c')
664382Sbinkertn@umich.eduElfFile('gelf_checksum.c')
674382Sbinkertn@umich.eduElfFile('gelf_dyn.c')
684382Sbinkertn@umich.eduElfFile('gelf_ehdr.c')
696654Snate@binkert.orgElfFile('gelf_fsize.c')
705517Snate@binkert.orgElfFile('gelf_getclass.c')
718614Sgblack@eecs.umich.eduElfFile('gelf_phdr.c')
727674Snate@binkert.orgElfFile('gelf_rel.c')
736143Snate@binkert.orgElfFile('gelf_rela.c')
746143Snate@binkert.orgElfFile('gelf_shdr.c')
756143Snate@binkert.orgElfFile('gelf_sym.c')
7612302Sgabeblack@google.comElfFile('gelf_symshndx.c')
7712302Sgabeblack@google.comElfFile('gelf_xlate.c')
7812302Sgabeblack@google.comElfFile('libelf.c')
7912371Sgabeblack@google.comElfFile('libelf_align.c')
8012371Sgabeblack@google.comElfFile('libelf_allocate.c')
8112371Sgabeblack@google.comElfFile('libelf_ar.c')
8212371Sgabeblack@google.comElfFile('libelf_checksum.c')
8312371Sgabeblack@google.comElfFile('libelf_data.c')
8412371Sgabeblack@google.comElfFile('libelf_ehdr.c')
8512371Sgabeblack@google.comElfFile('libelf_extended.c')
8612371Sgabeblack@google.comElfFile('libelf_phdr.c')
8712371Sgabeblack@google.comElfFile('libelf_shdr.c')
8812371Sgabeblack@google.comElfFile('libelf_xlate.c')
8912371Sgabeblack@google.com
9012371Sgabeblack@google.comElfFile('libelf_convert.c')
9112371Sgabeblack@google.comElfFile('libelf_fsize.c')
9212371Sgabeblack@google.comElfFile('libelf_msize.c')
9312371Sgabeblack@google.com
9412371Sgabeblack@google.comm4env = main.Clone()
9512371Sgabeblack@google.comif m4env['GCC']:
9612371Sgabeblack@google.com    if compareVersions(m4env['GCC_VERSION'], '4') >= 0:
9712371Sgabeblack@google.com        m4env.Append(CCFLAGS=['-Wno-pointer-sign'])
9812371Sgabeblack@google.com    if compareVersions(m4env['GCC_VERSION'], '4.6') >= 0:
9912371Sgabeblack@google.com        m4env.Append(CCFLAGS=['-Wno-unused-but-set-variable',
10012371Sgabeblack@google.com                              '-Wno-implicit-function-declaration'])
10112371Sgabeblack@google.comif m4env['CLANG']:
10212371Sgabeblack@google.com    m4env.Append(CCFLAGS=['-Wno-initializer-overrides', '-Wno-pointer-sign'])
10312371Sgabeblack@google.comm4env.Append(CCFLAGS=['-Wno-implicit'])
10412371Sgabeblack@google.comdel m4env['CPPPATH']
10512371Sgabeblack@google.com
10612371Sgabeblack@google.com# If we have gm4 use it
10712371Sgabeblack@google.comif m4env.Detect('gm4'):
10812371Sgabeblack@google.com    m4env['M4'] = 'gm4'
10912371Sgabeblack@google.com
11012371Sgabeblack@google.com# Check that m4 is available
11112371Sgabeblack@google.comimport SCons.Tool.m4
11212371Sgabeblack@google.comif not SCons.Tool.m4.exists(m4env):
11312371Sgabeblack@google.com   print "Error: Can't find version of M4 macro processor.  " + \
11412371Sgabeblack@google.com         "Please install M4 and try again."
11512371Sgabeblack@google.com   Exit(1)
11612371Sgabeblack@google.com
11712371Sgabeblack@google.comm4env.Append(M4FLAGS=['-DSRCDIR=%s' % Dir('.').path])
11812371Sgabeblack@google.comm4env['M4COM'] = '$M4 $M4FLAGS $SOURCES > $TARGET'
11912371Sgabeblack@google.comm4env.M4(target=File('libelf_convert.c'),
12012371Sgabeblack@google.com         source=[File('elf_types.m4'), File('libelf_convert.m4')])
12112371Sgabeblack@google.comm4env.M4(target=File('libelf_fsize.c'),
12212371Sgabeblack@google.com         source=[File('elf_types.m4'), File('libelf_fsize.m4')])
12312371Sgabeblack@google.comm4env.M4(target=File('libelf_msize.c'),
12412371Sgabeblack@google.com         source=[File('elf_types.m4'), File('libelf_msize.m4')])
12512371Sgabeblack@google.com
12612302Sgabeblack@google.com# Build libelf as a static library with PIC code so it can be linked
12712371Sgabeblack@google.com# into either m5 or the library
12812302Sgabeblack@google.comm4env.Library('elf', [m4env.SharedObject(f) for f in elf_files])
12912371Sgabeblack@google.com
13012302Sgabeblack@google.commain.Prepend(CPPPATH=Dir('.'))
13112302Sgabeblack@google.commain.Append(LIBS=['elf'])
13212371Sgabeblack@google.commain.Prepend(LIBPATH=[Dir('.')])
13312371Sgabeblack@google.com
13412371Sgabeblack@google.com