SConscript revision 4504:936dfda07b50
1955SN/A# -*- mode:python -*-
2955SN/A
31762SN/A# Copyright (c) 2004-2005 The Regents of The University of Michigan
4955SN/A# All rights reserved.
5955SN/A#
6955SN/A# Redistribution and use in source and binary forms, with or without
7955SN/A# modification, are permitted provided that the following conditions are
8955SN/A# met: redistributions of source code must retain the above copyright
9955SN/A# notice, this list of conditions and the following disclaimer;
10955SN/A# redistributions in binary form must reproduce the above copyright
11955SN/A# notice, this list of conditions and the following disclaimer in the
12955SN/A# documentation and/or other materials provided with the distribution;
13955SN/A# neither the name of the copyright holders nor the names of its
14955SN/A# contributors may be used to endorse or promote products derived from
15955SN/A# this software without specific prior written permission.
16955SN/A#
17955SN/A# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18955SN/A# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19955SN/A# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20955SN/A# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21955SN/A# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22955SN/A# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23955SN/A# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24955SN/A# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25955SN/A# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26955SN/A# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27955SN/A# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28955SN/A#
29955SN/A# Authors: Nathan Binkert
30955SN/A
31955SN/Aimport os, subprocess
32955SN/A
332632Sstever@eecs.umich.eduImport('env')
342632Sstever@eecs.umich.edu
352632Sstever@eecs.umich.eduelf_files = []
362632Sstever@eecs.umich.edudef ElfFile(filename):
37955SN/A    elf_files.append(File(filename))
382632Sstever@eecs.umich.edu    
392632Sstever@eecs.umich.eduElfFile('elf_begin.c')
402632Sstever@eecs.umich.eduElfFile('elf_cntl.c')
412632Sstever@eecs.umich.eduElfFile('elf_data.c')
422632Sstever@eecs.umich.eduElfFile('elf_end.c')
432632Sstever@eecs.umich.eduElfFile('elf_fill.c')
442632Sstever@eecs.umich.eduElfFile('elf_flag.c')
452632Sstever@eecs.umich.eduElfFile('elf_getarhdr.c')
462632Sstever@eecs.umich.eduElfFile('elf_getarsym.c')
472632Sstever@eecs.umich.eduElfFile('elf_getbase.c')
482632Sstever@eecs.umich.eduElfFile('elf_getident.c')
492632Sstever@eecs.umich.eduElfFile('elf_hash.c')
502632Sstever@eecs.umich.eduElfFile('elf_kind.c')
512632Sstever@eecs.umich.eduElfFile('elf_memory.c')
522632Sstever@eecs.umich.eduElfFile('elf_next.c')
532632Sstever@eecs.umich.eduElfFile('elf_phnum.c')
542632Sstever@eecs.umich.eduElfFile('elf_rand.c')
552632Sstever@eecs.umich.eduElfFile('elf_rawfile.c')
562632Sstever@eecs.umich.eduElfFile('elf_scn.c')
572632Sstever@eecs.umich.eduElfFile('elf_shnum.c')
58955SN/AElfFile('elf_shstrndx.c')
59955SN/AElfFile('elf_strptr.c')
60955SN/AElfFile('elf_update.c')
61955SN/AElfFile('elf_version.c')
62955SN/AElfFile('gelf_checksum.c')
63955SN/AElfFile('gelf_dyn.c')
64955SN/AElfFile('gelf_ehdr.c')
651858SN/AElfFile('gelf_fsize.c')
661858SN/AElfFile('gelf_getclass.c')
672632Sstever@eecs.umich.eduElfFile('gelf_phdr.c')
681852SN/AElfFile('gelf_rel.c')
69955SN/AElfFile('gelf_rela.c')
70955SN/AElfFile('gelf_shdr.c')
71955SN/AElfFile('gelf_sym.c')
722632Sstever@eecs.umich.eduElfFile('gelf_symshndx.c')
732632Sstever@eecs.umich.eduElfFile('gelf_xlate.c')
74955SN/AElfFile('libelf.c')
751533SN/AElfFile('libelf_align.c')
762632Sstever@eecs.umich.eduElfFile('libelf_allocate.c')
771533SN/AElfFile('libelf_ar.c')
78955SN/AElfFile('libelf_checksum.c')
79955SN/AElfFile('libelf_data.c')
802632Sstever@eecs.umich.eduElfFile('libelf_ehdr.c')
812632Sstever@eecs.umich.eduElfFile('libelf_extended.c')
82955SN/AElfFile('libelf_phdr.c')
83955SN/AElfFile('libelf_shdr.c')
84955SN/AElfFile('libelf_xlate.c')
85955SN/A
862632Sstever@eecs.umich.eduElfFile('libelf_convert.c')
87955SN/AElfFile('libelf_fsize.c')
882632Sstever@eecs.umich.eduElfFile('libelf_msize.c')
89955SN/A
90955SN/Am4env = Environment(ENV=os.environ)
912632Sstever@eecs.umich.eduif env.get('CC'):
922632Sstever@eecs.umich.edu    m4env['CC'] = env['CC']
932632Sstever@eecs.umich.eduif env.get('CXX'):
942632Sstever@eecs.umich.edu    m4env['CXX'] = env['CXX']
952632Sstever@eecs.umich.edu
962632Sstever@eecs.umich.edu# If we have gm4 use it
972632Sstever@eecs.umich.eduif m4env.Detect('gm4'):
982632Sstever@eecs.umich.edu    m4env['M4'] = 'gm4'
992632Sstever@eecs.umich.edu
1002632Sstever@eecs.umich.edu# Check that m4 is available
1012632Sstever@eecs.umich.eduimport SCons.Tool.m4
1022632Sstever@eecs.umich.eduif not SCons.Tool.m4.exists(m4env):
1032632Sstever@eecs.umich.edu   print "Error: Can't find version of M4 macro processor.  " + \
1042632Sstever@eecs.umich.edu         "Please install M4 and try again."
1052632Sstever@eecs.umich.edu   Exit(1)
1062632Sstever@eecs.umich.edu
1072632Sstever@eecs.umich.edum4env.Append(M4FLAGS='-DSRCDIR=%s' % Dir('.').path)
1082634Sstever@eecs.umich.edum4env['M4COM'] = '$M4 $M4FLAGS $SOURCES > $TARGET'
1092634Sstever@eecs.umich.edum4env.M4(target=File('libelf_convert.c'),
1102632Sstever@eecs.umich.edu         source=[File('elf_types.m4'), File('libelf_convert.m4')])
1112638Sstever@eecs.umich.edum4env.M4(target=File('libelf_fsize.c'),
1122632Sstever@eecs.umich.edu         source=[File('elf_types.m4'), File('libelf_fsize.m4')])
1132632Sstever@eecs.umich.edum4env.M4(target=File('libelf_msize.c'),
1142632Sstever@eecs.umich.edu         source=[File('elf_types.m4'), File('libelf_msize.m4')])
1152632Sstever@eecs.umich.edum4env.Library('elf', elf_files)
1162632Sstever@eecs.umich.edu
1172632Sstever@eecs.umich.eduenv.Append(CPPPATH=Dir('.'))
1181858SN/Aenv.Append(LIBS=['elf'])
1192638Sstever@eecs.umich.eduenv.Append(LIBPATH=[Dir('.')])
1202638Sstever@eecs.umich.edu
1212638Sstever@eecs.umich.edu