SConscript revision 5647
12086SN/A# -*- mode:python -*-
22086SN/A
32086SN/A# Copyright (c) 2004-2005 The Regents of The University of Michigan
42086SN/A# All rights reserved.
52086SN/A#
62086SN/A# Redistribution and use in source and binary forms, with or without
72086SN/A# modification, are permitted provided that the following conditions are
82086SN/A# met: redistributions of source code must retain the above copyright
92086SN/A# notice, this list of conditions and the following disclaimer;
102086SN/A# redistributions in binary form must reproduce the above copyright
112086SN/A# notice, this list of conditions and the following disclaimer in the
122086SN/A# documentation and/or other materials provided with the distribution;
132086SN/A# neither the name of the copyright holders nor the names of its
142086SN/A# contributors may be used to endorse or promote products derived from
152086SN/A# this software without specific prior written permission.
162086SN/A#
172086SN/A# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
182086SN/A# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
192086SN/A# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
202086SN/A# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
212086SN/A# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
222086SN/A# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
232086SN/A# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
242086SN/A# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
252086SN/A# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
262086SN/A# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
272086SN/A# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
282665Ssaidi@eecs.umich.edu#
292665Ssaidi@eecs.umich.edu# Authors: Nathan Binkert
302665Ssaidi@eecs.umich.edu
312086SN/Aimport os, subprocess
324202Sbinkertn@umich.edu
332086SN/AImport('env')
344202Sbinkertn@umich.edu
354202Sbinkertn@umich.eduelf_files = []
369022Sgblack@eecs.umich.edudef ElfFile(filename):
374202Sbinkertn@umich.edu    elf_files.append(File(filename))
388745Sgblack@eecs.umich.edu
396313Sgblack@eecs.umich.eduElfFile('elf_begin.c')
408778Sgblack@eecs.umich.eduElfFile('elf_cntl.c')
418778Sgblack@eecs.umich.eduElfFile('elf_data.c')
428778Sgblack@eecs.umich.eduElfFile('elf_end.c')
436365Sgblack@eecs.umich.eduElfFile('elf_fill.c')
444997Sgblack@eecs.umich.eduElfFile('elf_flag.c')
458778Sgblack@eecs.umich.eduElfFile('elf_getarhdr.c')
464202Sbinkertn@umich.eduElfFile('elf_getarsym.c')
478778Sgblack@eecs.umich.eduElfFile('elf_getbase.c')
488778Sgblack@eecs.umich.eduElfFile('elf_getident.c')
498778Sgblack@eecs.umich.eduElfFile('elf_hash.c')
504997Sgblack@eecs.umich.eduElfFile('elf_kind.c')
518747Sgblack@eecs.umich.eduElfFile('elf_memory.c')
524826Ssaidi@eecs.umich.eduElfFile('elf_next.c')
538760Sgblack@eecs.umich.eduElfFile('elf_phnum.c')
542086SN/AElfFile('elf_rand.c')
558745Sgblack@eecs.umich.eduElfFile('elf_rawfile.c')
569384SAndreas.Sandberg@arm.comElfFile('elf_scn.c')
576365Sgblack@eecs.umich.eduElfFile('elf_shnum.c')
588778Sgblack@eecs.umich.eduElfFile('elf_shstrndx.c')
598745Sgblack@eecs.umich.eduElfFile('elf_strptr.c')
606365Sgblack@eecs.umich.eduElfFile('elf_update.c')
618335Snate@binkert.orgElfFile('elf_version.c')
628335Snate@binkert.orgElfFile('gelf_checksum.c')
634997Sgblack@eecs.umich.eduElfFile('gelf_dyn.c')
6410196SCurtis.Dunham@arm.comElfFile('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')])
113
114# Build libelf as a static library with PIC code so it can be linked
115# into either m5 or the library
116m4env.Library('elf', [m4env.SharedObject(f) for f in elf_files])
117
118env.Append(CPPPATH=Dir('.'))
119env.Append(LIBS=['elf'])
120env.Append(LIBPATH=[Dir('.')])
121
122