SConscript revision 9340
112336Sjason@lowepower.com# -*- mode:python -*-
212336Sjason@lowepower.com
312336Sjason@lowepower.com# Copyright (c) 2004-2005 The Regents of The University of Michigan
412336Sjason@lowepower.com# All rights reserved.
512336Sjason@lowepower.com#
612336Sjason@lowepower.com# Redistribution and use in source and binary forms, with or without
712336Sjason@lowepower.com# modification, are permitted provided that the following conditions are
812336Sjason@lowepower.com# met: redistributions of source code must retain the above copyright
912336Sjason@lowepower.com# notice, this list of conditions and the following disclaimer;
1012336Sjason@lowepower.com# redistributions in binary form must reproduce the above copyright
1112336Sjason@lowepower.com# notice, this list of conditions and the following disclaimer in the
1212336Sjason@lowepower.com# documentation and/or other materials provided with the distribution;
1312336Sjason@lowepower.com# neither the name of the copyright holders nor the names of its
1412336Sjason@lowepower.com# contributors may be used to endorse or promote products derived from
1512336Sjason@lowepower.com# this software without specific prior written permission.
1612336Sjason@lowepower.com#
1712336Sjason@lowepower.com# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1812336Sjason@lowepower.com# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1912336Sjason@lowepower.com# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
2012336Sjason@lowepower.com# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2112336Sjason@lowepower.com# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2212336Sjason@lowepower.com# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2312336Sjason@lowepower.com# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2412336Sjason@lowepower.com# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2512336Sjason@lowepower.com# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2612336Sjason@lowepower.com# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2712336Sjason@lowepower.com# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2812336Sjason@lowepower.com#
2912336Sjason@lowepower.com# Authors: Nathan Binkert
3012336Sjason@lowepower.com
3112336Sjason@lowepower.comimport os, subprocess
3212336Sjason@lowepower.com
3312337Sjason@lowepower.comImport('main')
3412338Sjason@lowepower.com
3512336Sjason@lowepower.comfrom m5.util import compareVersions
3612336Sjason@lowepower.com
3712337Sjason@lowepower.comelf_files = []
3812337Sjason@lowepower.comdef ElfFile(filename):
3912338Sjason@lowepower.com    elf_files.append(File(filename))
4012337Sjason@lowepower.com
4112337Sjason@lowepower.comElfFile('elf_begin.c')
4212338Sjason@lowepower.comElfFile('elf_cntl.c')
43ElfFile('elf_data.c')
44ElfFile('elf_end.c')
45ElfFile('elf_errmsg.c')
46ElfFile('elf_errno.c')
47ElfFile('elf_fill.c')
48ElfFile('elf_flag.c')
49ElfFile('elf_getarhdr.c')
50ElfFile('elf_getarsym.c')
51ElfFile('elf_getbase.c')
52ElfFile('elf_getident.c')
53ElfFile('elf_hash.c')
54ElfFile('elf_kind.c')
55ElfFile('elf_memory.c')
56ElfFile('elf_next.c')
57ElfFile('elf_phnum.c')
58ElfFile('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    if compareVersions(m4env['GCC_VERSION'], '4') >= 0:
97        m4env.Append(CCFLAGS=['-Wno-pointer-sign'])
98    if compareVersions(m4env['GCC_VERSION'], '4.6') >= 0:
99        m4env.Append(CCFLAGS=['-Wno-unused-but-set-variable',
100                              '-Wno-implicit-function-declaration'])
101if m4env['CLANG']:
102    m4env.Append(CCFLAGS=['-Wno-initializer-overrides', '-Wno-pointer-sign'])
103m4env.Append(CCFLAGS=['-Wno-implicit'])
104del m4env['CPPPATH']
105
106# If we have gm4 use it
107if m4env.Detect('gm4'):
108    m4env['M4'] = 'gm4'
109
110# Check that m4 is available
111import SCons.Tool.m4
112if not SCons.Tool.m4.exists(m4env):
113   print "Error: Can't find version of M4 macro processor.  " + \
114         "Please install M4 and try again."
115   Exit(1)
116
117m4env.Append(M4FLAGS=['-DSRCDIR=%s' % Dir('.').path])
118m4env['M4COM'] = '$M4 $M4FLAGS $SOURCES > $TARGET'
119m4env.M4(target=File('libelf_convert.c'),
120         source=[File('elf_types.m4'), File('libelf_convert.m4')])
121m4env.M4(target=File('libelf_fsize.c'),
122         source=[File('elf_types.m4'), File('libelf_fsize.m4')])
123m4env.M4(target=File('libelf_msize.c'),
124         source=[File('elf_types.m4'), File('libelf_msize.m4')])
125
126# Build libelf as a static library with PIC code so it can be linked
127# into either m5 or the library
128m4env.Library('elf', [m4env.SharedObject(f) for f in elf_files])
129
130main.Prepend(CPPPATH=Dir('.'))
131main.Append(LIBS=['elf'])
132main.Prepend(LIBPATH=[Dir('.')])
133
134