SConscript revision 4500
14484Sbinkertn@umich.edu# -*- mode:python -*-
24484Sbinkertn@umich.edu
34484Sbinkertn@umich.edu# Copyright (c) 2004-2005 The Regents of The University of Michigan
44484Sbinkertn@umich.edu# All rights reserved.
54484Sbinkertn@umich.edu#
64484Sbinkertn@umich.edu# Redistribution and use in source and binary forms, with or without
74484Sbinkertn@umich.edu# modification, are permitted provided that the following conditions are
84484Sbinkertn@umich.edu# met: redistributions of source code must retain the above copyright
94484Sbinkertn@umich.edu# notice, this list of conditions and the following disclaimer;
104484Sbinkertn@umich.edu# redistributions in binary form must reproduce the above copyright
114484Sbinkertn@umich.edu# notice, this list of conditions and the following disclaimer in the
124484Sbinkertn@umich.edu# documentation and/or other materials provided with the distribution;
134484Sbinkertn@umich.edu# neither the name of the copyright holders nor the names of its
144484Sbinkertn@umich.edu# contributors may be used to endorse or promote products derived from
154484Sbinkertn@umich.edu# this software without specific prior written permission.
164484Sbinkertn@umich.edu#
174484Sbinkertn@umich.edu# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
184484Sbinkertn@umich.edu# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
194484Sbinkertn@umich.edu# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
204484Sbinkertn@umich.edu# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
214484Sbinkertn@umich.edu# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
224484Sbinkertn@umich.edu# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
234484Sbinkertn@umich.edu# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
244484Sbinkertn@umich.edu# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
254484Sbinkertn@umich.edu# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
264484Sbinkertn@umich.edu# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
274484Sbinkertn@umich.edu# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
284484Sbinkertn@umich.edu#
294484Sbinkertn@umich.edu# Authors: Nathan Binkert
304484Sbinkertn@umich.edu
314494Ssaidi@eecs.umich.eduimport os, subprocess
324484Sbinkertn@umich.edu
334484Sbinkertn@umich.eduImport('env')
344484Sbinkertn@umich.edu
354484Sbinkertn@umich.eduelf_files = []
364484Sbinkertn@umich.edudef ElfFile(filename):
374484Sbinkertn@umich.edu    elf_files.append(File(filename))
384484Sbinkertn@umich.edu    
394484Sbinkertn@umich.eduElfFile('elf_begin.c')
404484Sbinkertn@umich.eduElfFile('elf_cntl.c')
414484Sbinkertn@umich.eduElfFile('elf_data.c')
424484Sbinkertn@umich.eduElfFile('elf_end.c')
434484Sbinkertn@umich.eduElfFile('elf_fill.c')
444484Sbinkertn@umich.eduElfFile('elf_flag.c')
454484Sbinkertn@umich.eduElfFile('elf_getarhdr.c')
464484Sbinkertn@umich.eduElfFile('elf_getarsym.c')
474484Sbinkertn@umich.eduElfFile('elf_getbase.c')
484484Sbinkertn@umich.eduElfFile('elf_getident.c')
494484Sbinkertn@umich.eduElfFile('elf_hash.c')
504484Sbinkertn@umich.eduElfFile('elf_kind.c')
514484Sbinkertn@umich.eduElfFile('elf_memory.c')
524484Sbinkertn@umich.eduElfFile('elf_next.c')
534484Sbinkertn@umich.eduElfFile('elf_phnum.c')
544484Sbinkertn@umich.eduElfFile('elf_rand.c')
554484Sbinkertn@umich.eduElfFile('elf_rawfile.c')
564484Sbinkertn@umich.eduElfFile('elf_scn.c')
574484Sbinkertn@umich.eduElfFile('elf_shnum.c')
584484Sbinkertn@umich.eduElfFile('elf_shstrndx.c')
594484Sbinkertn@umich.eduElfFile('elf_strptr.c')
604484Sbinkertn@umich.eduElfFile('elf_update.c')
614484Sbinkertn@umich.eduElfFile('elf_version.c')
624484Sbinkertn@umich.eduElfFile('gelf_checksum.c')
634484Sbinkertn@umich.eduElfFile('gelf_dyn.c')
644484Sbinkertn@umich.eduElfFile('gelf_ehdr.c')
654484Sbinkertn@umich.eduElfFile('gelf_fsize.c')
664484Sbinkertn@umich.eduElfFile('gelf_getclass.c')
674484Sbinkertn@umich.eduElfFile('gelf_phdr.c')
684484Sbinkertn@umich.eduElfFile('gelf_rel.c')
694484Sbinkertn@umich.eduElfFile('gelf_rela.c')
704484Sbinkertn@umich.eduElfFile('gelf_shdr.c')
714484Sbinkertn@umich.eduElfFile('gelf_sym.c')
724484Sbinkertn@umich.eduElfFile('gelf_symshndx.c')
734484Sbinkertn@umich.eduElfFile('gelf_xlate.c')
744484Sbinkertn@umich.eduElfFile('libelf.c')
754484Sbinkertn@umich.eduElfFile('libelf_align.c')
764484Sbinkertn@umich.eduElfFile('libelf_allocate.c')
774484Sbinkertn@umich.eduElfFile('libelf_ar.c')
784484Sbinkertn@umich.eduElfFile('libelf_checksum.c')
794484Sbinkertn@umich.eduElfFile('libelf_data.c')
804484Sbinkertn@umich.eduElfFile('libelf_ehdr.c')
814484Sbinkertn@umich.eduElfFile('libelf_extended.c')
824484Sbinkertn@umich.eduElfFile('libelf_phdr.c')
834484Sbinkertn@umich.eduElfFile('libelf_shdr.c')
844484Sbinkertn@umich.eduElfFile('libelf_xlate.c')
854484Sbinkertn@umich.edu
864484Sbinkertn@umich.eduElfFile('libelf_convert.c')
874484Sbinkertn@umich.eduElfFile('libelf_fsize.c')
884484Sbinkertn@umich.eduElfFile('libelf_msize.c')
894484Sbinkertn@umich.edu
904484Sbinkertn@umich.edum4env = Environment(ENV=os.environ)
914494Ssaidi@eecs.umich.eduif env.get('CC'):
924494Ssaidi@eecs.umich.edu    m4env['CC'] = env['CC']
934494Ssaidi@eecs.umich.eduif env.get('CXX'):
944494Ssaidi@eecs.umich.edu    m4env['CXX'] = env['CXX']
954496Ssaidi@eecs.umich.edu
964494Ssaidi@eecs.umich.edu# If we have gm4 use it
974500Sbinkertn@umich.edusubp = subprocess.Popen("gm4 --version", shell=True, stdout=subprocess.PIPE, 
984500Sbinkertn@umich.edu                        stderr=subprocess.STDOUT, close_fds=True)
994500Sbinkertn@umich.eduif subp.communicate()[0].find('GNU') >= 0:
1004494Ssaidi@eecs.umich.edu    m4env['M4'] = 'gm4'
1014494Ssaidi@eecs.umich.edu
1024496Ssaidi@eecs.umich.edu# Check that m4 is available
1034496Ssaidi@eecs.umich.eduif not m4env.get('M4'):
1044500Sbinkertn@umich.edu   print "Error: Can't find version of M4 macro processor.  " + \
1054500Sbinkertn@umich.edu         "Please install M4 and try again."
1064496Ssaidi@eecs.umich.edu   Exit(1)
1074496Ssaidi@eecs.umich.edu
1084487Sstever@eecs.umich.edum4env.Append(M4FLAGS='-DSRCDIR=%s' % Dir('.').path)
1094487Sstever@eecs.umich.edum4env['M4COM'] = '$M4 $M4FLAGS $SOURCES > $TARGET'
1104484Sbinkertn@umich.edum4env.M4(target=File('libelf_convert.c'),
1114484Sbinkertn@umich.edu         source=[File('elf_types.m4'), File('libelf_convert.m4')])
1124484Sbinkertn@umich.edum4env.M4(target=File('libelf_fsize.c'),
1134484Sbinkertn@umich.edu         source=[File('elf_types.m4'), File('libelf_fsize.m4')])
1144484Sbinkertn@umich.edum4env.M4(target=File('libelf_msize.c'),
1154484Sbinkertn@umich.edu         source=[File('elf_types.m4'), File('libelf_msize.m4')])
1164484Sbinkertn@umich.edum4env.Library('elf', elf_files)
1174484Sbinkertn@umich.edu
1184484Sbinkertn@umich.eduenv.Append(CPPPATH=Dir('.'))
1194484Sbinkertn@umich.eduenv.Append(LIBS=['elf'])
1204484Sbinkertn@umich.eduenv.Append(LIBPATH=[Dir('.')])
1214494Ssaidi@eecs.umich.edu
122