SConscript revision 4496:7fe59ed05a61
1# -*- mode:python -*- 2 3# Copyright (c) 2004-2005 The Regents of The University of Michigan 4# All rights reserved. 5# 6# Redistribution and use in source and binary forms, with or without 7# modification, are permitted provided that the following conditions are 8# met: redistributions of source code must retain the above copyright 9# notice, this list of conditions and the following disclaimer; 10# redistributions in binary form must reproduce the above copyright 11# notice, this list of conditions and the following disclaimer in the 12# documentation and/or other materials provided with the distribution; 13# neither the name of the copyright holders nor the names of its 14# contributors may be used to endorse or promote products derived from 15# this software without specific prior written permission. 16# 17# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28# 29# Authors: Nathan Binkert 30 31import os, subprocess 32 33Import('env') 34 35elf_files = [] 36def ElfFile(filename): 37 elf_files.append(File(filename)) 38 39ElfFile('elf_begin.c') 40ElfFile('elf_cntl.c') 41ElfFile('elf_data.c') 42ElfFile('elf_end.c') 43ElfFile('elf_fill.c') 44ElfFile('elf_flag.c') 45ElfFile('elf_getarhdr.c') 46ElfFile('elf_getarsym.c') 47ElfFile('elf_getbase.c') 48ElfFile('elf_getident.c') 49ElfFile('elf_hash.c') 50ElfFile('elf_kind.c') 51ElfFile('elf_memory.c') 52ElfFile('elf_next.c') 53ElfFile('elf_phnum.c') 54ElfFile('elf_rand.c') 55ElfFile('elf_rawfile.c') 56ElfFile('elf_scn.c') 57ElfFile('elf_shnum.c') 58ElfFile('elf_shstrndx.c') 59ElfFile('elf_strptr.c') 60ElfFile('elf_update.c') 61ElfFile('elf_version.c') 62ElfFile('gelf_checksum.c') 63ElfFile('gelf_dyn.c') 64ElfFile('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 = 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