SConscript revision 11294
112047Schristian.menard@tu-dresden.de# -*- mode:python -*-
212047Schristian.menard@tu-dresden.de
312047Schristian.menard@tu-dresden.de# Copyright (c) 2004-2005 The Regents of The University of Michigan
412047Schristian.menard@tu-dresden.de# All rights reserved.
512047Schristian.menard@tu-dresden.de#
612047Schristian.menard@tu-dresden.de# Redistribution and use in source and binary forms, with or without
712047Schristian.menard@tu-dresden.de# modification, are permitted provided that the following conditions are
812047Schristian.menard@tu-dresden.de# met: redistributions of source code must retain the above copyright
912047Schristian.menard@tu-dresden.de# notice, this list of conditions and the following disclaimer;
1012047Schristian.menard@tu-dresden.de# redistributions in binary form must reproduce the above copyright
1112047Schristian.menard@tu-dresden.de# notice, this list of conditions and the following disclaimer in the
1212047Schristian.menard@tu-dresden.de# documentation and/or other materials provided with the distribution;
1312047Schristian.menard@tu-dresden.de# neither the name of the copyright holders nor the names of its
1412047Schristian.menard@tu-dresden.de# contributors may be used to endorse or promote products derived from
1512047Schristian.menard@tu-dresden.de# this software without specific prior written permission.
1612047Schristian.menard@tu-dresden.de#
1712047Schristian.menard@tu-dresden.de# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1812047Schristian.menard@tu-dresden.de# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1912047Schristian.menard@tu-dresden.de# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
2012047Schristian.menard@tu-dresden.de# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2112047Schristian.menard@tu-dresden.de# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2212047Schristian.menard@tu-dresden.de# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2312047Schristian.menard@tu-dresden.de# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2412047Schristian.menard@tu-dresden.de# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2512047Schristian.menard@tu-dresden.de# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2612047Schristian.menard@tu-dresden.de# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2712047Schristian.menard@tu-dresden.de# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2812047Schristian.menard@tu-dresden.de#
2912047Schristian.menard@tu-dresden.de# Authors: Nathan Binkert
3012047Schristian.menard@tu-dresden.de
3112047Schristian.menard@tu-dresden.deimport os, subprocess
3212047Schristian.menard@tu-dresden.de
3312047Schristian.menard@tu-dresden.deImport('main')
3412047Schristian.menard@tu-dresden.de
3512047Schristian.menard@tu-dresden.defrom m5.util import compareVersions
3612047Schristian.menard@tu-dresden.de
3712047Schristian.menard@tu-dresden.deelf_files = []
3812047Schristian.menard@tu-dresden.dedef ElfFile(filename):
3912047Schristian.menard@tu-dresden.de    elf_files.append(File(filename))
4012047Schristian.menard@tu-dresden.de
4112047Schristian.menard@tu-dresden.deElfFile('elf_begin.c')
4212047Schristian.menard@tu-dresden.deElfFile('elf_cntl.c')
4312047Schristian.menard@tu-dresden.deElfFile('elf_data.c')
4412047Schristian.menard@tu-dresden.deElfFile('elf_end.c')
4512047Schristian.menard@tu-dresden.deElfFile('elf_errmsg.c')
4612047Schristian.menard@tu-dresden.deElfFile('elf_errno.c')
4712047Schristian.menard@tu-dresden.deElfFile('elf_fill.c')
4812047Schristian.menard@tu-dresden.deElfFile('elf_flag.c')
4912047Schristian.menard@tu-dresden.deElfFile('elf_getarhdr.c')
5012047Schristian.menard@tu-dresden.deElfFile('elf_getarsym.c')
5112047Schristian.menard@tu-dresden.deElfFile('elf_getbase.c')
5212047Schristian.menard@tu-dresden.deElfFile('elf_getident.c')
5312047Schristian.menard@tu-dresden.deElfFile('elf_hash.c')
5412047Schristian.menard@tu-dresden.deElfFile('elf_kind.c')
5512047Schristian.menard@tu-dresden.deElfFile('elf_memory.c')
5612047Schristian.menard@tu-dresden.deElfFile('elf_next.c')
5712047Schristian.menard@tu-dresden.deElfFile('elf_phnum.c')
5812047Schristian.menard@tu-dresden.deElfFile('elf_rand.c')
59ElfFile('elf_rawfile.c')
60ElfFile('elf_scn.c')
61ElfFile('elf_shnum.c')
62ElfFile('elf_shstrndx.c')
63ElfFile('elf_strptr.c')
64ElfFile('elf_update.c')
65ElfFile('elf_version.c')
66ElfFile('gelf_checksum.c')
67ElfFile('gelf_dyn.c')
68ElfFile('gelf_ehdr.c')
69ElfFile('gelf_fsize.c')
70ElfFile('gelf_getclass.c')
71ElfFile('gelf_phdr.c')
72ElfFile('gelf_rel.c')
73ElfFile('gelf_rela.c')
74ElfFile('gelf_shdr.c')
75ElfFile('gelf_sym.c')
76ElfFile('gelf_symshndx.c')
77ElfFile('gelf_xlate.c')
78ElfFile('libelf.c')
79ElfFile('libelf_align.c')
80ElfFile('libelf_allocate.c')
81ElfFile('libelf_ar.c')
82ElfFile('libelf_checksum.c')
83ElfFile('libelf_data.c')
84ElfFile('libelf_ehdr.c')
85ElfFile('libelf_extended.c')
86ElfFile('libelf_phdr.c')
87ElfFile('libelf_shdr.c')
88ElfFile('libelf_xlate.c')
89
90ElfFile('libelf_convert.c')
91ElfFile('libelf_fsize.c')
92ElfFile('libelf_msize.c')
93
94m4env = main.Clone()
95if m4env['GCC']:
96    m4env.Append(CCFLAGS=['-Wno-pointer-sign',
97                          '-Wno-unused-but-set-variable',
98                          '-Wno-implicit-function-declaration',
99                          '-Wno-override-init'])
100if m4env['CLANG']:
101    m4env.Append(CCFLAGS=['-Wno-initializer-overrides', '-Wno-pointer-sign'])
102    # clang defaults to c99 (while gcc defaults to gnu89) and there is a
103    # difference in the handling of inlining functions which causes
104    # linking problems with multiple definitions of the symbols in
105    # sysmacros.h for older versions of glibc
106    m4env.Append(CCFLAGS=['-std=gnu89'])
107m4env.Append(CCFLAGS=['-Wno-implicit'])
108del m4env['CPPPATH']
109
110# If we have gm4 use it
111if m4env.Detect('gm4'):
112    m4env['M4'] = 'gm4'
113
114# Check that m4 is available
115import SCons.Tool.m4
116if not SCons.Tool.m4.exists(m4env):
117   print "Error: Can't find version of M4 macro processor.  " + \
118         "Please install M4 and try again."
119   Exit(1)
120
121m4env.Append(M4FLAGS=['-DSRCDIR=%s' % Dir('.').path])
122m4env['M4COM'] = '$M4 $M4FLAGS $SOURCES > $TARGET'
123m4env.M4(target=File('libelf_convert.c'),
124         source=[File('elf_types.m4'), File('libelf_convert.m4')])
125m4env.M4(target=File('libelf_fsize.c'),
126         source=[File('elf_types.m4'), File('libelf_fsize.m4')])
127m4env.M4(target=File('libelf_msize.c'),
128         source=[File('elf_types.m4'), File('libelf_msize.m4')])
129
130# Build libelf as a static library with PIC code so it can be linked
131# into either m5 or the library
132m4env.Library('elf', [m4env.SharedObject(f) for f in elf_files])
133
134main.Prepend(CPPPATH=Dir('.'))
135main.Append(LIBS=['elf'])
136main.Prepend(LIBPATH=[Dir('.')])
137
138