SConscript revision 4781:59a75bd0ddf4
12023SN/A# -*- mode:python -*-
22023SN/A
32023SN/A# Copyright (c) 2004-2005 The Regents of The University of Michigan
42023SN/A# All rights reserved.
52023SN/A#
62023SN/A# Redistribution and use in source and binary forms, with or without
72023SN/A# modification, are permitted provided that the following conditions are
82023SN/A# met: redistributions of source code must retain the above copyright
92023SN/A# notice, this list of conditions and the following disclaimer;
102023SN/A# redistributions in binary form must reproduce the above copyright
112023SN/A# notice, this list of conditions and the following disclaimer in the
122023SN/A# documentation and/or other materials provided with the distribution;
132023SN/A# neither the name of the copyright holders nor the names of its
142023SN/A# contributors may be used to endorse or promote products derived from
152023SN/A# this software without specific prior written permission.
162023SN/A#
172023SN/A# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
182023SN/A# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
192023SN/A# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
202023SN/A# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
212023SN/A# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
222023SN/A# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
232023SN/A# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
242023SN/A# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
252023SN/A# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
262023SN/A# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
272023SN/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
312023SN/Aimport os, subprocess
322023SN/A
332023SN/AImport('env')
342023SN/A
352023SN/Aelf_files = []
362023SN/Adef ElfFile(filename):
372023SN/A    elf_files.append(File(filename))
382023SN/A
392023SN/AElfFile('elf_begin.c')
402023SN/AElfFile('elf_cntl.c')
412023SN/AElfFile('elf_data.c')
422023SN/AElfFile('elf_end.c')
432023SN/AElfFile('elf_fill.c')
442023SN/AElfFile('elf_flag.c')
452023SN/AElfFile('elf_getarhdr.c')
462023SN/AElfFile('elf_getarsym.c')
472023SN/AElfFile('elf_getbase.c')
482023SN/AElfFile('elf_getident.c')
492152SN/AElfFile('elf_hash.c')
502152SN/AElfFile('elf_kind.c')
513592Sgblack@eecs.umich.eduElfFile('elf_memory.c')
523592Sgblack@eecs.umich.eduElfFile('elf_next.c')
533586Sgblack@eecs.umich.eduElfFile('elf_phnum.c')
543592Sgblack@eecs.umich.eduElfFile('elf_rand.c')
553960Sgblack@eecs.umich.eduElfFile('elf_rawfile.c')
562023SN/AElfFile('elf_scn.c')
572023SN/AElfFile('elf_shnum.c')
582023SN/AElfFile('elf_shstrndx.c')
592152SN/AElfFile('elf_strptr.c')
602152SN/AElfFile('elf_update.c')
612152SN/AElfFile('elf_version.c')
623592Sgblack@eecs.umich.eduElfFile('gelf_checksum.c')
633565Sgblack@eecs.umich.eduElfFile('gelf_dyn.c')
643457Sgblack@eecs.umich.eduElfFile('gelf_ehdr.c')
653565Sgblack@eecs.umich.eduElfFile('gelf_fsize.c')
663592Sgblack@eecs.umich.eduElfFile('gelf_getclass.c')
672152SN/AElfFile('gelf_phdr.c')
683592Sgblack@eecs.umich.eduElfFile('gelf_rel.c')
692152SN/AElfFile('gelf_rela.c')
702221SN/AElfFile('gelf_shdr.c')
713592Sgblack@eecs.umich.eduElfFile('gelf_sym.c')
722221SN/AElfFile('gelf_symshndx.c')
733592Sgblack@eecs.umich.eduElfFile('gelf_xlate.c')
742023SN/AElfFile('libelf.c')
752023SN/AElfFile('libelf_align.c')
762023SN/AElfFile('libelf_allocate.c')
772023SN/AElfFile('libelf_ar.c')
782152SN/AElfFile('libelf_checksum.c')
792553SN/AElfFile('libelf_data.c')
802221SN/AElfFile('libelf_ehdr.c')
812553SN/AElfFile('libelf_extended.c')
822221SN/AElfFile('libelf_phdr.c')
832207SN/AElfFile('libelf_shdr.c')
842023SN/AElfFile('libelf_xlate.c')
852023SN/A
862023SN/AElfFile('libelf_convert.c')
872152SN/AElfFile('libelf_fsize.c')
882023SN/AElfFile('libelf_msize.c')
892023SN/A
902152SN/Am4env = Environment(ENV=os.environ)
912023SN/Aif env.get('CC'):
922152SN/A    m4env['CC'] = env['CC']
932152SN/Aif env.get('CXX'):
942152SN/A    m4env['CXX'] = env['CXX']
952152SN/A
962152SN/A# If we have gm4 use it
972152SN/Aif m4env.Detect('gm4'):
982152SN/A    m4env['M4'] = 'gm4'
992152SN/A
1002152SN/A# Check that m4 is available
1012152SN/Aimport SCons.Tool.m4
1022152SN/Aif not SCons.Tool.m4.exists(m4env):
1032023SN/A   print "Error: Can't find version of M4 macro processor.  " + \
1042023SN/A         "Please install M4 and try again."
105   Exit(1)
106
107m4env.Append(M4FLAGS='-DSRCDIR=%s' % Dir('.').path)
108m4env['M4COM'] = '$M4 $M4FLAGS $SOURCES > $TARGET'
109m4env.M4(target=File('libelf_convert.c'),
110         source=[File('elf_types.m4'), File('libelf_convert.m4')])
111m4env.M4(target=File('libelf_fsize.c'),
112         source=[File('elf_types.m4'), File('libelf_fsize.m4')])
113m4env.M4(target=File('libelf_msize.c'),
114         source=[File('elf_types.m4'), File('libelf_msize.m4')])
115m4env.Library('elf', elf_files)
116
117env.Append(CPPPATH=Dir('.'))
118env.Append(LIBS=['elf'])
119env.Append(LIBPATH=[Dir('.')])
120
121