SConscript revision 9152
1955SN/A# -*- mode:python -*-
2955SN/A
31762SN/A# Copyright (c) 2004-2005 The Regents of The University of Michigan
4955SN/A# All rights reserved.
5955SN/A#
6955SN/A# Redistribution and use in source and binary forms, with or without
7955SN/A# modification, are permitted provided that the following conditions are
8955SN/A# met: redistributions of source code must retain the above copyright
9955SN/A# notice, this list of conditions and the following disclaimer;
10955SN/A# redistributions in binary form must reproduce the above copyright
11955SN/A# notice, this list of conditions and the following disclaimer in the
12955SN/A# documentation and/or other materials provided with the distribution;
13955SN/A# neither the name of the copyright holders nor the names of its
14955SN/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.
282665Ssaidi@eecs.umich.edu#
294762Snate@binkert.org# Authors: Nathan Binkert
30955SN/A
315522Snate@binkert.orgimport os, subprocess
326143Snate@binkert.org
334762Snate@binkert.orgImport('main')
345522Snate@binkert.org
35955SN/Afrom m5.util import compareVersions
365522Snate@binkert.org
37955SN/Aelf_files = []
385522Snate@binkert.orgdef ElfFile(filename):
394202Sbinkertn@umich.edu    elf_files.append(File(filename))
405742Snate@binkert.org
41955SN/AElfFile('elf_begin.c')
424381Sbinkertn@umich.eduElfFile('elf_cntl.c')
434381Sbinkertn@umich.eduElfFile('elf_data.c')
448334Snate@binkert.orgElfFile('elf_end.c')
45955SN/AElfFile('elf_errmsg.c')
46955SN/AElfFile('elf_errno.c')
474202Sbinkertn@umich.eduElfFile('elf_fill.c')
48955SN/AElfFile('elf_flag.c')
494382Sbinkertn@umich.eduElfFile('elf_getarhdr.c')
504382Sbinkertn@umich.eduElfFile('elf_getarsym.c')
514382Sbinkertn@umich.eduElfFile('elf_getbase.c')
526654Snate@binkert.orgElfFile('elf_getident.c')
535517Snate@binkert.orgElfFile('elf_hash.c')
548614Sgblack@eecs.umich.eduElfFile('elf_kind.c')
557674Snate@binkert.orgElfFile('elf_memory.c')
566143Snate@binkert.orgElfFile('elf_next.c')
576143Snate@binkert.orgElfFile('elf_phnum.c')
586143Snate@binkert.orgElfFile('elf_rand.c')
598233Snate@binkert.orgElfFile('elf_rawfile.c')
608233Snate@binkert.orgElfFile('elf_scn.c')
618233Snate@binkert.orgElfFile('elf_shnum.c')
628233Snate@binkert.orgElfFile('elf_shstrndx.c')
638233Snate@binkert.orgElfFile('elf_strptr.c')
648334Snate@binkert.orgElfFile('elf_update.c')
658334Snate@binkert.orgElfFile('elf_version.c')
668233Snate@binkert.orgElfFile('gelf_checksum.c')
678233Snate@binkert.orgElfFile('gelf_dyn.c')
688233Snate@binkert.orgElfFile('gelf_ehdr.c')
698233Snate@binkert.orgElfFile('gelf_fsize.c')
708233Snate@binkert.orgElfFile('gelf_getclass.c')
718233Snate@binkert.orgElfFile('gelf_phdr.c')
726143Snate@binkert.orgElfFile('gelf_rel.c')
738233Snate@binkert.orgElfFile('gelf_rela.c')
748233Snate@binkert.orgElfFile('gelf_shdr.c')
758233Snate@binkert.orgElfFile('gelf_sym.c')
766143Snate@binkert.orgElfFile('gelf_symshndx.c')
776143Snate@binkert.orgElfFile('gelf_xlate.c')
786143Snate@binkert.orgElfFile('libelf.c')
796143Snate@binkert.orgElfFile('libelf_align.c')
808233Snate@binkert.orgElfFile('libelf_allocate.c')
818233Snate@binkert.orgElfFile('libelf_ar.c')
828233Snate@binkert.orgElfFile('libelf_checksum.c')
836143Snate@binkert.orgElfFile('libelf_data.c')
848233Snate@binkert.orgElfFile('libelf_ehdr.c')
858233Snate@binkert.orgElfFile('libelf_extended.c')
868233Snate@binkert.orgElfFile('libelf_phdr.c')
878233Snate@binkert.orgElfFile('libelf_shdr.c')
886143Snate@binkert.orgElfFile('libelf_xlate.c')
896143Snate@binkert.org
906143Snate@binkert.orgElfFile('libelf_convert.c')
914762Snate@binkert.orgElfFile('libelf_fsize.c')
926143Snate@binkert.orgElfFile('libelf_msize.c')
938233Snate@binkert.org
948233Snate@binkert.orgm4env = main.Clone()
958233Snate@binkert.orgif m4env['GCC']:
968233Snate@binkert.org    if compareVersions(m4env['GCC_VERSION'], '4') >= 0:
978233Snate@binkert.org        m4env.Append(CCFLAGS=['-Wno-pointer-sign'])
986143Snate@binkert.org    if compareVersions(m4env['GCC_VERSION'], '4.6') >= 0:
998233Snate@binkert.org        m4env.Append(CCFLAGS=['-Wno-unused-but-set-variable',
1008233Snate@binkert.org                              '-Wno-implicit-function-declaration'])
1018233Snate@binkert.orgif m4env['CLANG']:
1028233Snate@binkert.org    m4env.Append(CCFLAGS=['-Wno-initializer-overrides', '-Wno-pointer-sign'])
1036143Snate@binkert.orgm4env.Append(CCFLAGS=['-Wno-implicit'])
1046143Snate@binkert.orgdel m4env['CPPPATH']
1056143Snate@binkert.org
1066143Snate@binkert.org# If we have gm4 use it
1076143Snate@binkert.orgif m4env.Detect('gm4'):
1086143Snate@binkert.org    m4env['M4'] = 'gm4'
1096143Snate@binkert.org
1106143Snate@binkert.org# Check that m4 is available
1116143Snate@binkert.orgimport SCons.Tool.m4
1127065Snate@binkert.orgif not SCons.Tool.m4.exists(m4env):
1136143Snate@binkert.org   print "Error: Can't find version of M4 macro processor.  " + \
1148233Snate@binkert.org         "Please install M4 and try again."
1158233Snate@binkert.org   Exit(1)
1168233Snate@binkert.org
1178233Snate@binkert.orgm4env.Append(M4FLAGS=['-DSRCDIR=%s' % Dir('.').path])
1188233Snate@binkert.orgm4env['M4COM'] = '$M4 $M4FLAGS $SOURCES > $TARGET'
1198233Snate@binkert.orgm4env.M4(target=File('libelf_convert.c'),
1208233Snate@binkert.org         source=[File('elf_types.m4'), File('libelf_convert.m4')])
1218233Snate@binkert.orgm4env.M4(target=File('libelf_fsize.c'),
1228233Snate@binkert.org         source=[File('elf_types.m4'), File('libelf_fsize.m4')])
1238233Snate@binkert.orgm4env.M4(target=File('libelf_msize.c'),
1248233Snate@binkert.org         source=[File('elf_types.m4'), File('libelf_msize.m4')])
1258233Snate@binkert.org
1268233Snate@binkert.org# Build libelf as a static library with PIC code so it can be linked
1278233Snate@binkert.org# into either m5 or the library
1288233Snate@binkert.orgm4env.Library('elf', [m4env.SharedObject(f) for f in elf_files])
1298233Snate@binkert.org
1308233Snate@binkert.orgmain.Prepend(CPPPATH=Dir('.'))
1318233Snate@binkert.orgmain.Append(LIBS=['elf'])
1328233Snate@binkert.orgmain.Prepend(LIBPATH=[Dir('.')])
1338233Snate@binkert.org
1348233Snate@binkert.org