SConscript revision 4496:7fe59ed05a61
12817Sksewell@umich.edu# -*- mode:python -*-
22817Sksewell@umich.edu
32817Sksewell@umich.edu# Copyright (c) 2004-2005 The Regents of The University of Michigan
42817Sksewell@umich.edu# All rights reserved.
52817Sksewell@umich.edu#
62817Sksewell@umich.edu# Redistribution and use in source and binary forms, with or without
72817Sksewell@umich.edu# modification, are permitted provided that the following conditions are
82817Sksewell@umich.edu# met: redistributions of source code must retain the above copyright
92817Sksewell@umich.edu# notice, this list of conditions and the following disclaimer;
102817Sksewell@umich.edu# redistributions in binary form must reproduce the above copyright
112817Sksewell@umich.edu# notice, this list of conditions and the following disclaimer in the
122817Sksewell@umich.edu# documentation and/or other materials provided with the distribution;
132817Sksewell@umich.edu# neither the name of the copyright holders nor the names of its
142817Sksewell@umich.edu# contributors may be used to endorse or promote products derived from
152817Sksewell@umich.edu# this software without specific prior written permission.
162817Sksewell@umich.edu#
172817Sksewell@umich.edu# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
182817Sksewell@umich.edu# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
192817Sksewell@umich.edu# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
202817Sksewell@umich.edu# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
212817Sksewell@umich.edu# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
222817Sksewell@umich.edu# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
232817Sksewell@umich.edu# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
242817Sksewell@umich.edu# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
252817Sksewell@umich.edu# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
262817Sksewell@umich.edu# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
272817Sksewell@umich.edu# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
282817Sksewell@umich.edu#
292817Sksewell@umich.edu# Authors: Nathan Binkert
302817Sksewell@umich.edu
312817Sksewell@umich.eduimport os, subprocess
322817Sksewell@umich.edu
332817Sksewell@umich.eduImport('env')
342817Sksewell@umich.edu
352817Sksewell@umich.eduelf_files = []
362817Sksewell@umich.edudef ElfFile(filename):
372817Sksewell@umich.edu    elf_files.append(File(filename))
382817Sksewell@umich.edu    
392817Sksewell@umich.eduElfFile('elf_begin.c')
402817Sksewell@umich.eduElfFile('elf_cntl.c')
412817Sksewell@umich.eduElfFile('elf_data.c')
422817Sksewell@umich.eduElfFile('elf_end.c')
432817Sksewell@umich.eduElfFile('elf_fill.c')
442817Sksewell@umich.eduElfFile('elf_flag.c')
452817Sksewell@umich.eduElfFile('elf_getarhdr.c')
462817Sksewell@umich.eduElfFile('elf_getarsym.c')
472817Sksewell@umich.eduElfFile('elf_getbase.c')
482817Sksewell@umich.eduElfFile('elf_getident.c')
492817Sksewell@umich.eduElfFile('elf_hash.c')
502817Sksewell@umich.eduElfFile('elf_kind.c')
512817Sksewell@umich.eduElfFile('elf_memory.c')
522817Sksewell@umich.eduElfFile('elf_next.c')
532817Sksewell@umich.eduElfFile('elf_phnum.c')
542817Sksewell@umich.eduElfFile('elf_rand.c')
552935Sksewell@umich.eduElfFile('elf_rawfile.c')
562935Sksewell@umich.eduElfFile('elf_scn.c')
572935Sksewell@umich.eduElfFile('elf_shnum.c')
582935Sksewell@umich.eduElfFile('elf_shstrndx.c')
592935Sksewell@umich.eduElfFile('elf_strptr.c')
602935Sksewell@umich.eduElfFile('elf_update.c')
612817Sksewell@umich.eduElfFile('elf_version.c')
622978Sgblack@eecs.umich.eduElfFile('gelf_checksum.c')
632978Sgblack@eecs.umich.eduElfFile('gelf_dyn.c')
642978Sgblack@eecs.umich.eduElfFile('gelf_ehdr.c')
652978Sgblack@eecs.umich.eduElfFile('gelf_fsize.c')
662978Sgblack@eecs.umich.eduElfFile('gelf_getclass.c')
672978Sgblack@eecs.umich.eduElfFile('gelf_phdr.c')
682817Sksewell@umich.eduElfFile('gelf_rel.c')
692817Sksewell@umich.eduElfFile('gelf_rela.c')
702817Sksewell@umich.eduElfFile('gelf_shdr.c')
712817Sksewell@umich.eduElfFile('gelf_sym.c')
722817Sksewell@umich.eduElfFile('gelf_symshndx.c')
732817Sksewell@umich.eduElfFile('gelf_xlate.c')
742817Sksewell@umich.eduElfFile('libelf.c')
752817Sksewell@umich.eduElfFile('libelf_align.c')
762817Sksewell@umich.eduElfFile('libelf_allocate.c')
772817Sksewell@umich.eduElfFile('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 = Environment(ENV=os.environ)
91if env.get('CC'):
92    m4env['CC'] = env['CC']
93if env.get('CXX'):
94    m4env['CXX'] = env['CXX']
95
96# If we have gm4 use it
97if subprocess.Popen("gm4 --version", shell=True, stdout=subprocess.PIPE, 
98                     stderr=subprocess.STDOUT, close_fds=True).communicate()[0].find('GNU') >= 0:
99    m4env['M4'] = 'gm4'
100
101# Check that m4 is available
102if not m4env.get('M4'):
103   print "Error: Can't find version of M4 macro processor. Please install M4 and try again."
104   Exit(1)
105
106m4env.Append(M4FLAGS='-DSRCDIR=%s' % Dir('.').path)
107m4env['M4COM'] = '$M4 $M4FLAGS $SOURCES > $TARGET'
108m4env.M4(target=File('libelf_convert.c'),
109         source=[File('elf_types.m4'), File('libelf_convert.m4')])
110m4env.M4(target=File('libelf_fsize.c'),
111         source=[File('elf_types.m4'), File('libelf_fsize.m4')])
112m4env.M4(target=File('libelf_msize.c'),
113         source=[File('elf_types.m4'), File('libelf_msize.m4')])
114m4env.Library('elf', elf_files)
115
116env.Append(CPPPATH=Dir('.'))
117env.Append(LIBS=['elf'])
118env.Append(LIBPATH=[Dir('.')])
119
120