SConscript revision 6313
112855Sgabeblack@google.com# -*- mode:python -*-
212855Sgabeblack@google.com
312855Sgabeblack@google.com# Copyright (c) 2004-2005 The Regents of The University of Michigan
412855Sgabeblack@google.com# All rights reserved.
512855Sgabeblack@google.com#
612855Sgabeblack@google.com# Redistribution and use in source and binary forms, with or without
712855Sgabeblack@google.com# modification, are permitted provided that the following conditions are
812855Sgabeblack@google.com# met: redistributions of source code must retain the above copyright
912855Sgabeblack@google.com# notice, this list of conditions and the following disclaimer;
1012855Sgabeblack@google.com# redistributions in binary form must reproduce the above copyright
1112855Sgabeblack@google.com# notice, this list of conditions and the following disclaimer in the
1212855Sgabeblack@google.com# documentation and/or other materials provided with the distribution;
1312855Sgabeblack@google.com# neither the name of the copyright holders nor the names of its
1412855Sgabeblack@google.com# contributors may be used to endorse or promote products derived from
1512855Sgabeblack@google.com# this software without specific prior written permission.
1612855Sgabeblack@google.com#
1712855Sgabeblack@google.com# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1812855Sgabeblack@google.com# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1912855Sgabeblack@google.com# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
2012855Sgabeblack@google.com# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2112855Sgabeblack@google.com# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2212855Sgabeblack@google.com# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2312855Sgabeblack@google.com# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2412855Sgabeblack@google.com# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2512855Sgabeblack@google.com# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2612855Sgabeblack@google.com# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2712855Sgabeblack@google.com# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2812855Sgabeblack@google.com#
2912855Sgabeblack@google.com# Authors: Nathan Binkert
3012855Sgabeblack@google.com
3112855Sgabeblack@google.comimport os, subprocess
3212855Sgabeblack@google.com
3312855Sgabeblack@google.comImport('main')
3412855Sgabeblack@google.com
3512855Sgabeblack@google.comelf_files = []
3612855Sgabeblack@google.comdef ElfFile(filename):
3712855Sgabeblack@google.com    elf_files.append(File(filename))
3812855Sgabeblack@google.com
3912855Sgabeblack@google.comElfFile('elf_begin.c')
4012855Sgabeblack@google.comElfFile('elf_cntl.c')
4112855Sgabeblack@google.comElfFile('elf_data.c')
4212855Sgabeblack@google.comElfFile('elf_end.c')
4312855Sgabeblack@google.comElfFile('elf_fill.c')
4412855Sgabeblack@google.comElfFile('elf_flag.c')
4512855Sgabeblack@google.comElfFile('elf_getarhdr.c')
4612855Sgabeblack@google.comElfFile('elf_getarsym.c')
4712855Sgabeblack@google.comElfFile('elf_getbase.c')
4812855Sgabeblack@google.comElfFile('elf_getident.c')
4912855Sgabeblack@google.comElfFile('elf_hash.c')
5012855Sgabeblack@google.comElfFile('elf_kind.c')
5112855Sgabeblack@google.comElfFile('elf_memory.c')
5212855Sgabeblack@google.comElfFile('elf_next.c')
5312855Sgabeblack@google.comElfFile('elf_phnum.c')
5412855Sgabeblack@google.comElfFile('elf_rand.c')
5512855Sgabeblack@google.comElfFile('elf_rawfile.c')
5612855Sgabeblack@google.comElfFile('elf_scn.c')
5712855Sgabeblack@google.comElfFile('elf_shnum.c')
5812855Sgabeblack@google.comElfFile('elf_shstrndx.c')
5912855Sgabeblack@google.comElfFile('elf_strptr.c')
6012855Sgabeblack@google.comElfFile('elf_update.c')
6112855Sgabeblack@google.comElfFile('elf_version.c')
6212855Sgabeblack@google.comElfFile('gelf_checksum.c')
6312855Sgabeblack@google.comElfFile('gelf_dyn.c')
6412855Sgabeblack@google.comElfFile('gelf_ehdr.c')
6512855Sgabeblack@google.comElfFile('gelf_fsize.c')
6612855Sgabeblack@google.comElfFile('gelf_getclass.c')
6712855Sgabeblack@google.comElfFile('gelf_phdr.c')
6812855Sgabeblack@google.comElfFile('gelf_rel.c')
6912855Sgabeblack@google.comElfFile('gelf_rela.c')
7012855Sgabeblack@google.comElfFile('gelf_shdr.c')
7112855Sgabeblack@google.comElfFile('gelf_sym.c')
7212855Sgabeblack@google.comElfFile('gelf_symshndx.c')
73ElfFile('gelf_xlate.c')
74ElfFile('libelf.c')
75ElfFile('libelf_align.c')
76ElfFile('libelf_allocate.c')
77ElfFile('libelf_ar.c')
78ElfFile('libelf_checksum.c')
79ElfFile('libelf_data.c')
80ElfFile('libelf_ehdr.c')
81ElfFile('libelf_extended.c')
82ElfFile('libelf_phdr.c')
83ElfFile('libelf_shdr.c')
84ElfFile('libelf_xlate.c')
85
86ElfFile('libelf_convert.c')
87ElfFile('libelf_fsize.c')
88ElfFile('libelf_msize.c')
89
90m4env = main.Clone()
91if m4env['GCC']:
92    major,minor,dot = [ int(x) for x in m4env['CXXVERSION'].split('.')]
93    if major >= 4:
94        m4env.Append(CCFLAGS=['-Wno-pointer-sign'])
95m4env.Append(CCFLAGS=['-Wno-implicit'])
96del m4env['CPPPATH']
97
98# If we have gm4 use it
99if m4env.Detect('gm4'):
100    m4env['M4'] = 'gm4'
101
102# Check that m4 is available
103import SCons.Tool.m4
104if not SCons.Tool.m4.exists(m4env):
105   print "Error: Can't find version of M4 macro processor.  " + \
106         "Please install M4 and try again."
107   Exit(1)
108
109m4env.Append(M4FLAGS='-DSRCDIR=%s' % Dir('.').path)
110m4env['M4COM'] = '$M4 $M4FLAGS $SOURCES > $TARGET'
111m4env.M4(target=File('libelf_convert.c'),
112         source=[File('elf_types.m4'), File('libelf_convert.m4')])
113m4env.M4(target=File('libelf_fsize.c'),
114         source=[File('elf_types.m4'), File('libelf_fsize.m4')])
115m4env.M4(target=File('libelf_msize.c'),
116         source=[File('elf_types.m4'), File('libelf_msize.m4')])
117
118# Build libelf as a static library with PIC code so it can be linked
119# into either m5 or the library
120m4env.Library('elf', [m4env.SharedObject(f) for f in elf_files])
121
122main.Prepend(CPPPATH=Dir('.'))
123main.Append(LIBS=['elf'])
124main.Prepend(LIBPATH=[Dir('.')])
125
126