SConscript revision 5548
16157Snate@binkert.org# -*- mode:python -*-
26157Snate@binkert.org
36157Snate@binkert.org# Copyright (c) 2004-2005 The Regents of The University of Michigan
46157Snate@binkert.org# All rights reserved.
56157Snate@binkert.org#
66157Snate@binkert.org# Redistribution and use in source and binary forms, with or without
76157Snate@binkert.org# modification, are permitted provided that the following conditions are
86157Snate@binkert.org# met: redistributions of source code must retain the above copyright
96157Snate@binkert.org# notice, this list of conditions and the following disclaimer;
106157Snate@binkert.org# redistributions in binary form must reproduce the above copyright
116157Snate@binkert.org# notice, this list of conditions and the following disclaimer in the
126157Snate@binkert.org# documentation and/or other materials provided with the distribution;
136157Snate@binkert.org# neither the name of the copyright holders nor the names of its
146157Snate@binkert.org# contributors may be used to endorse or promote products derived from
156157Snate@binkert.org# this software without specific prior written permission.
166157Snate@binkert.org#
176157Snate@binkert.org# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
186157Snate@binkert.org# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
196157Snate@binkert.org# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
206157Snate@binkert.org# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
216157Snate@binkert.org# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
226157Snate@binkert.org# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
236157Snate@binkert.org# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
246157Snate@binkert.org# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
256157Snate@binkert.org# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
266157Snate@binkert.org# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
276157Snate@binkert.org# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
286157Snate@binkert.org#
296157Snate@binkert.org# Authors: Nathan Binkert
306157Snate@binkert.org
316157Snate@binkert.orgimport os, subprocess
326157Snate@binkert.org
336168Snate@binkert.orgImport('env')
346168Snate@binkert.org
356168Snate@binkert.orgelf_files = []
366876Ssteve.reinhardt@amd.comdef ElfFile(filename):
376876Ssteve.reinhardt@amd.com    elf_files.append(File(filename))
386876Ssteve.reinhardt@amd.com
396876Ssteve.reinhardt@amd.comElfFile('elf_begin.c')
406876Ssteve.reinhardt@amd.comElfFile('elf_cntl.c')
416876Ssteve.reinhardt@amd.comElfFile('elf_data.c')
426286Snate@binkert.orgElfFile('elf_end.c')
436157Snate@binkert.orgElfFile('elf_fill.c')
447025SBrad.Beckmann@amd.comElfFile('elf_flag.c')
456782SBrad.Beckmann@amd.comElfFile('elf_getarhdr.c')
466157Snate@binkert.orgElfFile('elf_getarsym.c')
476157Snate@binkert.orgElfFile('elf_getbase.c')
486797SBrad.Beckmann@amd.comElfFile('elf_getident.c')
496286Snate@binkert.orgElfFile('elf_hash.c')
506157Snate@binkert.orgElfFile('elf_kind.c')
516157Snate@binkert.orgElfFile('elf_memory.c')
526157Snate@binkert.orgElfFile('elf_next.c')
537023SBrad.Beckmann@amd.comElfFile('elf_phnum.c')
547023SBrad.Beckmann@amd.comElfFile('elf_rand.c')
557544SBrad.Beckmann@amd.comElfFile('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.Copy()
91del m4env['CCFLAGS']
92del m4env['CPPPATH']
93
94# If we have gm4 use it
95if m4env.Detect('gm4'):
96    m4env['M4'] = 'gm4'
97
98# Check that m4 is available
99import SCons.Tool.m4
100if not SCons.Tool.m4.exists(m4env):
101   print "Error: Can't find version of M4 macro processor.  " + \
102         "Please install M4 and try again."
103   Exit(1)
104
105m4env.Append(M4FLAGS='-DSRCDIR=%s' % Dir('.').path)
106m4env['M4COM'] = '$M4 $M4FLAGS $SOURCES > $TARGET'
107m4env.M4(target=File('libelf_convert.c'),
108         source=[File('elf_types.m4'), File('libelf_convert.m4')])
109m4env.M4(target=File('libelf_fsize.c'),
110         source=[File('elf_types.m4'), File('libelf_fsize.m4')])
111m4env.M4(target=File('libelf_msize.c'),
112         source=[File('elf_types.m4'), File('libelf_msize.m4')])
113m4env.Library('elf', elf_files)
114
115env.Append(CPPPATH=Dir('.'))
116env.Append(LIBS=['elf'])
117env.Append(LIBPATH=[Dir('.')])
118
119