SConscript revision 8951
112027Sjungma@eit.uni-kl.de# -*- mode:python -*-
212027Sjungma@eit.uni-kl.de
312027Sjungma@eit.uni-kl.de# Copyright (c) 2004-2005 The Regents of The University of Michigan
412027Sjungma@eit.uni-kl.de# All rights reserved.
512027Sjungma@eit.uni-kl.de#
612027Sjungma@eit.uni-kl.de# Redistribution and use in source and binary forms, with or without
712027Sjungma@eit.uni-kl.de# modification, are permitted provided that the following conditions are
812027Sjungma@eit.uni-kl.de# met: redistributions of source code must retain the above copyright
912027Sjungma@eit.uni-kl.de# notice, this list of conditions and the following disclaimer;
1012027Sjungma@eit.uni-kl.de# redistributions in binary form must reproduce the above copyright
1112027Sjungma@eit.uni-kl.de# notice, this list of conditions and the following disclaimer in the
1212027Sjungma@eit.uni-kl.de# documentation and/or other materials provided with the distribution;
1312027Sjungma@eit.uni-kl.de# neither the name of the copyright holders nor the names of its
1412027Sjungma@eit.uni-kl.de# contributors may be used to endorse or promote products derived from
1512027Sjungma@eit.uni-kl.de# this software without specific prior written permission.
1612027Sjungma@eit.uni-kl.de#
1712027Sjungma@eit.uni-kl.de# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1812027Sjungma@eit.uni-kl.de# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1912027Sjungma@eit.uni-kl.de# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
2012027Sjungma@eit.uni-kl.de# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2112027Sjungma@eit.uni-kl.de# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2212027Sjungma@eit.uni-kl.de# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2312027Sjungma@eit.uni-kl.de# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2412027Sjungma@eit.uni-kl.de# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2512027Sjungma@eit.uni-kl.de# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2612027Sjungma@eit.uni-kl.de# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2712027Sjungma@eit.uni-kl.de# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2812027Sjungma@eit.uni-kl.de#
2912027Sjungma@eit.uni-kl.de# Authors: Nathan Binkert
3012027Sjungma@eit.uni-kl.de
3112027Sjungma@eit.uni-kl.deimport os, subprocess
3212027Sjungma@eit.uni-kl.de
3312027Sjungma@eit.uni-kl.deImport('main')
3412027Sjungma@eit.uni-kl.de
3512027Sjungma@eit.uni-kl.defrom m5.util import compareVersions
3612027Sjungma@eit.uni-kl.de
3712027Sjungma@eit.uni-kl.deelf_files = []
3812027Sjungma@eit.uni-kl.dedef ElfFile(filename):
3912027Sjungma@eit.uni-kl.de    elf_files.append(File(filename))
4012027Sjungma@eit.uni-kl.de
4112027Sjungma@eit.uni-kl.deElfFile('elf_begin.c')
4212027Sjungma@eit.uni-kl.deElfFile('elf_cntl.c')
4312027Sjungma@eit.uni-kl.deElfFile('elf_data.c')
4412027Sjungma@eit.uni-kl.deElfFile('elf_end.c')
4512027Sjungma@eit.uni-kl.deElfFile('elf_errmsg.c')
4612027Sjungma@eit.uni-kl.deElfFile('elf_errno.c')
4712027Sjungma@eit.uni-kl.deElfFile('elf_fill.c')
4812027Sjungma@eit.uni-kl.deElfFile('elf_flag.c')
4912027Sjungma@eit.uni-kl.deElfFile('elf_getarhdr.c')
5012027Sjungma@eit.uni-kl.deElfFile('elf_getarsym.c')
5112027Sjungma@eit.uni-kl.deElfFile('elf_getbase.c')
5212027Sjungma@eit.uni-kl.deElfFile('elf_getident.c')
5312027Sjungma@eit.uni-kl.deElfFile('elf_hash.c')
5412027Sjungma@eit.uni-kl.deElfFile('elf_kind.c')
5512027Sjungma@eit.uni-kl.deElfFile('elf_memory.c')
5612027Sjungma@eit.uni-kl.deElfFile('elf_next.c')
5712027Sjungma@eit.uni-kl.deElfFile('elf_phnum.c')
5812027Sjungma@eit.uni-kl.deElfFile('elf_rand.c')
5912027Sjungma@eit.uni-kl.deElfFile('elf_rawfile.c')
6012027Sjungma@eit.uni-kl.deElfFile('elf_scn.c')
6112027Sjungma@eit.uni-kl.deElfFile('elf_shnum.c')
6212027Sjungma@eit.uni-kl.deElfFile('elf_shstrndx.c')
6312027Sjungma@eit.uni-kl.deElfFile('elf_strptr.c')
6412027Sjungma@eit.uni-kl.deElfFile('elf_update.c')
6512027Sjungma@eit.uni-kl.deElfFile('elf_version.c')
6612027Sjungma@eit.uni-kl.deElfFile('gelf_checksum.c')
6712027Sjungma@eit.uni-kl.deElfFile('gelf_dyn.c')
6812027Sjungma@eit.uni-kl.deElfFile('gelf_ehdr.c')
6912027Sjungma@eit.uni-kl.deElfFile('gelf_fsize.c')
7012027Sjungma@eit.uni-kl.deElfFile('gelf_getclass.c')
7112027Sjungma@eit.uni-kl.deElfFile('gelf_phdr.c')
7212027Sjungma@eit.uni-kl.deElfFile('gelf_rel.c')
7312027Sjungma@eit.uni-kl.deElfFile('gelf_rela.c')
7412027Sjungma@eit.uni-kl.deElfFile('gelf_shdr.c')
7512027Sjungma@eit.uni-kl.deElfFile('gelf_sym.c')
7612027Sjungma@eit.uni-kl.deElfFile('gelf_symshndx.c')
7712027Sjungma@eit.uni-kl.deElfFile('gelf_xlate.c')
7812027Sjungma@eit.uni-kl.deElfFile('libelf.c')
7912027Sjungma@eit.uni-kl.deElfFile('libelf_align.c')
8012027Sjungma@eit.uni-kl.deElfFile('libelf_allocate.c')
8112027Sjungma@eit.uni-kl.deElfFile('libelf_ar.c')
8212027Sjungma@eit.uni-kl.deElfFile('libelf_checksum.c')
8312027Sjungma@eit.uni-kl.deElfFile('libelf_data.c')
8412027Sjungma@eit.uni-kl.deElfFile('libelf_ehdr.c')
8512027Sjungma@eit.uni-kl.deElfFile('libelf_extended.c')
8612027Sjungma@eit.uni-kl.deElfFile('libelf_phdr.c')
8712027Sjungma@eit.uni-kl.deElfFile('libelf_shdr.c')
8812027Sjungma@eit.uni-kl.deElfFile('libelf_xlate.c')
8912027Sjungma@eit.uni-kl.de
9012027Sjungma@eit.uni-kl.deElfFile('libelf_convert.c')
9112027Sjungma@eit.uni-kl.deElfFile('libelf_fsize.c')
9212027Sjungma@eit.uni-kl.deElfFile('libelf_msize.c')
9312027Sjungma@eit.uni-kl.de
9412027Sjungma@eit.uni-kl.dem4env = main.Clone()
9512027Sjungma@eit.uni-kl.deif m4env['GCC']:
9612027Sjungma@eit.uni-kl.de    if compareVersions(m4env['GCC_VERSION'], '4') >= 0:
9712027Sjungma@eit.uni-kl.de        m4env.Append(CCFLAGS=['-Wno-pointer-sign'])
9812027Sjungma@eit.uni-kl.de    if compareVersions(m4env['GCC_VERSION'], '4.6') >= 0:
9912027Sjungma@eit.uni-kl.de        m4env.Append(CCFLAGS=['-Wno-unused-but-set-variable',
10012027Sjungma@eit.uni-kl.de                              '-Wno-implicit-function-declaration'])
10112027Sjungma@eit.uni-kl.deif m4env['CLANG']:
10212027Sjungma@eit.uni-kl.de    m4env.Append(CCFLAGS=['-Wno-initializer-overrides', '-Wno-pointer-sign'])
10312027Sjungma@eit.uni-kl.dem4env.Append(CCFLAGS=['-Wno-implicit'])
10412027Sjungma@eit.uni-kl.dedel m4env['CPPPATH']
10512027Sjungma@eit.uni-kl.de
10612027Sjungma@eit.uni-kl.de# If we have gm4 use it
10712027Sjungma@eit.uni-kl.deif m4env.Detect('gm4'):
10812027Sjungma@eit.uni-kl.de    m4env['M4'] = 'gm4'
10912027Sjungma@eit.uni-kl.de
11012027Sjungma@eit.uni-kl.de# Check that m4 is available
11112027Sjungma@eit.uni-kl.deimport SCons.Tool.m4
11212027Sjungma@eit.uni-kl.deif not SCons.Tool.m4.exists(m4env):
11312027Sjungma@eit.uni-kl.de   print "Error: Can't find version of M4 macro processor.  " + \
11412027Sjungma@eit.uni-kl.de         "Please install M4 and try again."
11512027Sjungma@eit.uni-kl.de   Exit(1)
11612027Sjungma@eit.uni-kl.de
11712027Sjungma@eit.uni-kl.dem4env.Append(M4FLAGS=['-DSRCDIR=%s' % Dir('.').path])
11812027Sjungma@eit.uni-kl.dem4env['M4COM'] = '$M4 $M4FLAGS $SOURCES > $TARGET'
11912027Sjungma@eit.uni-kl.dem4env.M4(target=File('libelf_convert.c'),
12012027Sjungma@eit.uni-kl.de         source=[File('elf_types.m4'), File('libelf_convert.m4')])
12112027Sjungma@eit.uni-kl.dem4env.M4(target=File('libelf_fsize.c'),
12212027Sjungma@eit.uni-kl.de         source=[File('elf_types.m4'), File('libelf_fsize.m4')])
12312027Sjungma@eit.uni-kl.dem4env.M4(target=File('libelf_msize.c'),
12412027Sjungma@eit.uni-kl.de         source=[File('elf_types.m4'), File('libelf_msize.m4')])
12512027Sjungma@eit.uni-kl.de
12612027Sjungma@eit.uni-kl.de# Build libelf as a static library with PIC code so it can be linked
12712027Sjungma@eit.uni-kl.de# into either m5 or the library
12812027Sjungma@eit.uni-kl.dem4env.Library('elf', [m4env.SharedObject(f) for f in elf_files])
12912027Sjungma@eit.uni-kl.de
13012027Sjungma@eit.uni-kl.demain.Prepend(CPPPATH=Dir('.'))
13112027Sjungma@eit.uni-kl.demain.Append(LIBS=['elf'])
13212027Sjungma@eit.uni-kl.demain.Prepend(LIBPATH=[Dir('.')])
13312027Sjungma@eit.uni-kl.de
13412027Sjungma@eit.uni-kl.de