SConscript revision 5882
16757SAli.Saidi@ARM.com# -*- mode:python -*-
26757SAli.Saidi@ARM.com
36757SAli.Saidi@ARM.com# Copyright (c) 2004-2005 The Regents of The University of Michigan
46757SAli.Saidi@ARM.com# All rights reserved.
56757SAli.Saidi@ARM.com#
67090SAli.Saidi@ARM.com# Redistribution and use in source and binary forms, with or without
77090SAli.Saidi@ARM.com# modification, are permitted provided that the following conditions are
87090SAli.Saidi@ARM.com# met: redistributions of source code must retain the above copyright
97090SAli.Saidi@ARM.com# notice, this list of conditions and the following disclaimer;
107090SAli.Saidi@ARM.com# redistributions in binary form must reproduce the above copyright
117090SAli.Saidi@ARM.com# notice, this list of conditions and the following disclaimer in the
127090SAli.Saidi@ARM.com# documentation and/or other materials provided with the distribution;
137090SAli.Saidi@ARM.com# neither the name of the copyright holders nor the names of its
147090SAli.Saidi@ARM.com# contributors may be used to endorse or promote products derived from
156757SAli.Saidi@ARM.com# this software without specific prior written permission.
166757SAli.Saidi@ARM.com#
176757SAli.Saidi@ARM.com# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
186757SAli.Saidi@ARM.com# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
196757SAli.Saidi@ARM.com# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
206757SAli.Saidi@ARM.com# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
216757SAli.Saidi@ARM.com# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
226757SAli.Saidi@ARM.com# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
236757SAli.Saidi@ARM.com# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
246757SAli.Saidi@ARM.com# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
256757SAli.Saidi@ARM.com# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
266757SAli.Saidi@ARM.com# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
276757SAli.Saidi@ARM.com# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
286757SAli.Saidi@ARM.com#
296757SAli.Saidi@ARM.com# Authors: Nathan Binkert
306757SAli.Saidi@ARM.com
316757SAli.Saidi@ARM.comimport os, subprocess
326757SAli.Saidi@ARM.com
336757SAli.Saidi@ARM.comImport('env')
346757SAli.Saidi@ARM.com
356757SAli.Saidi@ARM.comelf_files = []
366757SAli.Saidi@ARM.comdef ElfFile(filename):
376757SAli.Saidi@ARM.com    elf_files.append(File(filename))
386757SAli.Saidi@ARM.com
396757SAli.Saidi@ARM.comElfFile('elf_begin.c')
406757SAli.Saidi@ARM.comElfFile('elf_cntl.c')
416757SAli.Saidi@ARM.comElfFile('elf_data.c')
426757SAli.Saidi@ARM.comElfFile('elf_end.c')
436757SAli.Saidi@ARM.comElfFile('elf_fill.c')
446757SAli.Saidi@ARM.comElfFile('elf_flag.c')
456757SAli.Saidi@ARM.comElfFile('elf_getarhdr.c')
46ElfFile('elf_getarsym.c')
47ElfFile('elf_getbase.c')
48ElfFile('elf_getident.c')
49ElfFile('elf_hash.c')
50ElfFile('elf_kind.c')
51ElfFile('elf_memory.c')
52ElfFile('elf_next.c')
53ElfFile('elf_phnum.c')
54ElfFile('elf_rand.c')
55ElfFile('elf_rawfile.c')
56ElfFile('elf_scn.c')
57ElfFile('elf_shnum.c')
58ElfFile('elf_shstrndx.c')
59ElfFile('elf_strptr.c')
60ElfFile('elf_update.c')
61ElfFile('elf_version.c')
62ElfFile('gelf_checksum.c')
63ElfFile('gelf_dyn.c')
64ElfFile('gelf_ehdr.c')
65ElfFile('gelf_fsize.c')
66ElfFile('gelf_getclass.c')
67ElfFile('gelf_phdr.c')
68ElfFile('gelf_rel.c')
69ElfFile('gelf_rela.c')
70ElfFile('gelf_shdr.c')
71ElfFile('gelf_sym.c')
72ElfFile('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 = env.Clone()
91if env['GCC']:
92    major,minor,dot = [ int(x) for x in env['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
122env.Append(CPPPATH=Dir('.'))
123env.Append(LIBS=['elf'])
124env.Append(LIBPATH=[Dir('.')])
125
126