SConscript revision 5190
112866Sgabeblack@google.com# -*- mode:python -*-
212866Sgabeblack@google.com
312866Sgabeblack@google.com# Copyright (c) 2004-2005 The Regents of The University of Michigan
412866Sgabeblack@google.com# All rights reserved.
512866Sgabeblack@google.com#
612866Sgabeblack@google.com# Redistribution and use in source and binary forms, with or without
712866Sgabeblack@google.com# modification, are permitted provided that the following conditions are
812866Sgabeblack@google.com# met: redistributions of source code must retain the above copyright
912866Sgabeblack@google.com# notice, this list of conditions and the following disclaimer;
1012866Sgabeblack@google.com# redistributions in binary form must reproduce the above copyright
1112866Sgabeblack@google.com# notice, this list of conditions and the following disclaimer in the
1212866Sgabeblack@google.com# documentation and/or other materials provided with the distribution;
1312866Sgabeblack@google.com# neither the name of the copyright holders nor the names of its
1412866Sgabeblack@google.com# contributors may be used to endorse or promote products derived from
1512866Sgabeblack@google.com# this software without specific prior written permission.
1612866Sgabeblack@google.com#
1712866Sgabeblack@google.com# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1812866Sgabeblack@google.com# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1912866Sgabeblack@google.com# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
2012866Sgabeblack@google.com# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2112866Sgabeblack@google.com# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2212866Sgabeblack@google.com# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2312866Sgabeblack@google.com# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2412866Sgabeblack@google.com# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2512866Sgabeblack@google.com# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2612866Sgabeblack@google.com# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2712866Sgabeblack@google.com# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2812866Sgabeblack@google.com#
2912866Sgabeblack@google.com# Authors: Nathan Binkert
3012866Sgabeblack@google.com
3112866Sgabeblack@google.comimport os, subprocess
3212866Sgabeblack@google.com
3312866Sgabeblack@google.comImport('env')
3412866Sgabeblack@google.com
3512866Sgabeblack@google.comelf_files = []
3612866Sgabeblack@google.comdef ElfFile(filename):
3712866Sgabeblack@google.com    elf_files.append(File(filename))
3812866Sgabeblack@google.com
3912866Sgabeblack@google.comElfFile('elf_begin.c')
4012866Sgabeblack@google.comElfFile('elf_cntl.c')
4112866Sgabeblack@google.comElfFile('elf_data.c')
4212866Sgabeblack@google.comElfFile('elf_end.c')
4312866Sgabeblack@google.comElfFile('elf_fill.c')
4412866Sgabeblack@google.comElfFile('elf_flag.c')
4512866Sgabeblack@google.comElfFile('elf_getarhdr.c')
4612866Sgabeblack@google.comElfFile('elf_getarsym.c')
4712866Sgabeblack@google.comElfFile('elf_getbase.c')
4812866Sgabeblack@google.comElfFile('elf_getident.c')
4912866Sgabeblack@google.comElfFile('elf_hash.c')
5012866Sgabeblack@google.comElfFile('elf_kind.c')
5112866Sgabeblack@google.comElfFile('elf_memory.c')
5212866Sgabeblack@google.comElfFile('elf_next.c')
5312866Sgabeblack@google.comElfFile('elf_phnum.c')
5412866Sgabeblack@google.comElfFile('elf_rand.c')
5512866Sgabeblack@google.comElfFile('elf_rawfile.c')
5612866Sgabeblack@google.comElfFile('elf_scn.c')
5712866Sgabeblack@google.comElfFile('elf_shnum.c')
5812866Sgabeblack@google.comElfFile('elf_shstrndx.c')
5912866Sgabeblack@google.comElfFile('elf_strptr.c')
6012866Sgabeblack@google.comElfFile('elf_update.c')
6112866Sgabeblack@google.comElfFile('elf_version.c')
6212866Sgabeblack@google.comElfFile('gelf_checksum.c')
6312866Sgabeblack@google.comElfFile('gelf_dyn.c')
6412866Sgabeblack@google.comElfFile('gelf_ehdr.c')
6512866Sgabeblack@google.comElfFile('gelf_fsize.c')
6612866Sgabeblack@google.comElfFile('gelf_getclass.c')
6712866Sgabeblack@google.comElfFile('gelf_phdr.c')
6812866Sgabeblack@google.comElfFile('gelf_rel.c')
6912866Sgabeblack@google.comElfFile('gelf_rela.c')
7012866Sgabeblack@google.comElfFile('gelf_shdr.c')
7112866Sgabeblack@google.comElfFile('gelf_sym.c')
7212866Sgabeblack@google.comElfFile('gelf_symshndx.c')
7312866Sgabeblack@google.comElfFile('gelf_xlate.c')
7412866Sgabeblack@google.comElfFile('libelf.c')
7512866Sgabeblack@google.comElfFile('libelf_align.c')
7612866Sgabeblack@google.comElfFile('libelf_allocate.c')
7712866Sgabeblack@google.comElfFile('libelf_ar.c')
7812866Sgabeblack@google.comElfFile('libelf_checksum.c')
7912866Sgabeblack@google.comElfFile('libelf_data.c')
8012866Sgabeblack@google.comElfFile('libelf_ehdr.c')
8112866Sgabeblack@google.comElfFile('libelf_extended.c')
8212866Sgabeblack@google.comElfFile('libelf_phdr.c')
8312866Sgabeblack@google.comElfFile('libelf_shdr.c')
8412866Sgabeblack@google.comElfFile('libelf_xlate.c')
8512866Sgabeblack@google.com
8612866Sgabeblack@google.comElfFile('libelf_convert.c')
8712866Sgabeblack@google.comElfFile('libelf_fsize.c')
8812866Sgabeblack@google.comElfFile('libelf_msize.c')
8912866Sgabeblack@google.com
9012866Sgabeblack@google.comm4env = Environment(ENV=os.environ)
9112866Sgabeblack@google.comif env.get('CC'):
9212866Sgabeblack@google.com    m4env['CC'] = env['CC']
9312866Sgabeblack@google.comif env.get('CXX'):
9412866Sgabeblack@google.com    m4env['CXX'] = env['CXX']
9512866Sgabeblack@google.com
9612866Sgabeblack@google.com# If we have gm4 use it
9712866Sgabeblack@google.comif m4env.Detect('gm4'):
9812866Sgabeblack@google.com    m4env['M4'] = 'gm4'
9912866Sgabeblack@google.com
10012866Sgabeblack@google.com# Check that m4 is available
10112866Sgabeblack@google.comimport SCons.Tool.m4
10212866Sgabeblack@google.comif not SCons.Tool.m4.exists(m4env):
10312866Sgabeblack@google.com   print "Error: Can't find version of M4 macro processor.  " + \
10412866Sgabeblack@google.com         "Please install M4 and try again."
10512866Sgabeblack@google.com   Exit(1)
10612866Sgabeblack@google.com
10712866Sgabeblack@google.comm4env.Append(M4FLAGS='-DSRCDIR=%s' % Dir('.').path)
10812866Sgabeblack@google.comm4env['M4COM'] = '$M4 $M4FLAGS $SOURCES > $TARGET'
10912866Sgabeblack@google.comm4env.M4(target=File('libelf_convert.c'),
11012866Sgabeblack@google.com         source=[File('elf_types.m4'), File('libelf_convert.m4')])
11112866Sgabeblack@google.comm4env.M4(target=File('libelf_fsize.c'),
11212866Sgabeblack@google.com         source=[File('elf_types.m4'), File('libelf_fsize.m4')])
11312866Sgabeblack@google.comm4env.M4(target=File('libelf_msize.c'),
11412866Sgabeblack@google.com         source=[File('elf_types.m4'), File('libelf_msize.m4')])
11512866Sgabeblack@google.comm4env.Library('elf', elf_files)
11612866Sgabeblack@google.com
11712866Sgabeblack@google.comenv.Append(CPPPATH=Dir('.'))
11812866Sgabeblack@google.comenv.Append(LIBS=['elf'])
11912866Sgabeblack@google.comenv.Append(LIBPATH=[Dir('.')])
12012866Sgabeblack@google.com
12112866Sgabeblack@google.com