SConscript revision 5274:7888bf966443
12139SN/A# -*- mode:python -*-
22139SN/A
32139SN/A# Copyright (c) 2004-2005 The Regents of The University of Michigan
42139SN/A# All rights reserved.
52139SN/A#
62139SN/A# Redistribution and use in source and binary forms, with or without
72139SN/A# modification, are permitted provided that the following conditions are
82139SN/A# met: redistributions of source code must retain the above copyright
92139SN/A# notice, this list of conditions and the following disclaimer;
102139SN/A# redistributions in binary form must reproduce the above copyright
112139SN/A# notice, this list of conditions and the following disclaimer in the
122139SN/A# documentation and/or other materials provided with the distribution;
132139SN/A# neither the name of the copyright holders nor the names of its
142139SN/A# contributors may be used to endorse or promote products derived from
152139SN/A# this software without specific prior written permission.
162139SN/A#
172139SN/A# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
182139SN/A# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
192139SN/A# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
202139SN/A# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
212139SN/A# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
222139SN/A# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
232139SN/A# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
242139SN/A# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
252139SN/A# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
262139SN/A# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
272139SN/A# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
282665Ssaidi@eecs.umich.edu#
292665Ssaidi@eecs.umich.edu# Authors: Nathan Binkert
302139SN/A
314202Sbinkertn@umich.eduimport os, subprocess
322139SN/A
334202Sbinkertn@umich.eduImport('env')
342152SN/A
352152SN/Aelf_files = []
362139SN/Adef ElfFile(filename):
372139SN/A    elf_files.append(File(filename))
382139SN/A
392139SN/AElfFile('elf_begin.c')
402139SN/AElfFile('elf_cntl.c')
412152SN/AElfFile('elf_data.c')
422152SN/AElfFile('elf_end.c')
432139SN/AElfFile('elf_fill.c')
442139SN/AElfFile('elf_flag.c')
452139SN/AElfFile('elf_getarhdr.c')
464781Snate@binkert.orgElfFile('elf_getarsym.c')
474781Snate@binkert.orgElfFile('elf_getbase.c')
484781Snate@binkert.orgElfFile('elf_getident.c')
496313Sgblack@eecs.umich.eduElfFile('elf_hash.c')
504781Snate@binkert.orgElfFile('elf_kind.c')
514781Snate@binkert.orgElfFile('elf_memory.c')
523170Sstever@eecs.umich.eduElfFile('elf_next.c')
535664Sgblack@eecs.umich.eduElfFile('elf_phnum.c')
543806Ssaidi@eecs.umich.eduElfFile('elf_rand.c')
556179Sksewell@umich.eduElfFile('elf_rawfile.c')
564781Snate@binkert.orgElfFile('elf_scn.c')
574781Snate@binkert.orgElfFile('elf_shnum.c')
586329Sgblack@eecs.umich.eduElfFile('elf_shstrndx.c')
594781Snate@binkert.orgElfFile('elf_strptr.c')
604781Snate@binkert.orgElfFile('elf_update.c')
614781Snate@binkert.orgElfFile('elf_version.c')
624781Snate@binkert.orgElfFile('gelf_checksum.c')
634781Snate@binkert.orgElfFile('gelf_dyn.c')
644781Snate@binkert.orgElfFile('gelf_ehdr.c')
652139SN/AElfFile('gelf_fsize.c')
662139SN/AElfFile('gelf_getclass.c')
673546Sgblack@eecs.umich.eduElfFile('gelf_phdr.c')
684202Sbinkertn@umich.eduElfFile('gelf_rel.c')
692152SN/AElfFile('gelf_rela.c')
702152SN/AElfFile('gelf_shdr.c')
712152SN/AElfFile('gelf_sym.c')
722152SN/AElfFile('gelf_symshndx.c')
732152SN/AElfFile('gelf_xlate.c')
742152SN/AElfFile('libelf.c')
752152SN/AElfFile('libelf_align.c')
762152SN/AElfFile('libelf_allocate.c')
772152SN/AElfFile('libelf_ar.c')
782152SN/AElfFile('libelf_checksum.c')
792152SN/AElfFile('libelf_data.c')
802152SN/AElfFile('libelf_ehdr.c')
812504SN/AElfFile('libelf_extended.c')
822504SN/AElfFile('libelf_phdr.c')
832504SN/AElfFile('libelf_shdr.c')
842504SN/AElfFile('libelf_xlate.c')
852152SN/A
862504SN/AElfFile('libelf_convert.c')
872152SN/AElfFile('libelf_fsize.c')
882152SN/AElfFile('libelf_msize.c')
892152SN/A
902152SN/Am4env = Environment(ENV=os.environ)
912152SN/A
922152SN/Aif env.get('CC'):
932152SN/A    m4env['CC'] = env['CC']
942152SN/Aif env.get('CXX'):
952632Sstever@eecs.umich.edu    m4env['CXX'] = env['CXX']
962155SN/A
972155SN/Aif env.get('OSX64bit'):
982155SN/A    m4env.Append(CFLAGS='-arch x86_64')
992155SN/A    m4env.Append(LINKFLAGS='-arch x86_64')
1002155SN/A
1012155SN/A# If we have gm4 use it
1025228Sgblack@eecs.umich.eduif m4env.Detect('gm4'):
1032155SN/A    m4env['M4'] = 'gm4'
1042155SN/A
1052155SN/A# Check that m4 is available
1062152SN/Aimport SCons.Tool.m4
1072766Sktlim@umich.eduif not SCons.Tool.m4.exists(m4env):
1082766Sktlim@umich.edu   print "Error: Can't find version of M4 macro processor.  " + \
1092766Sktlim@umich.edu         "Please install M4 and try again."
1102766Sktlim@umich.edu   Exit(1)
1112766Sktlim@umich.edu
1122152SN/Am4env.Append(M4FLAGS='-DSRCDIR=%s' % Dir('.').path)
1132152SN/Am4env['M4COM'] = '$M4 $M4FLAGS $SOURCES > $TARGET'
1142152SN/Am4env.M4(target=File('libelf_convert.c'),
1152155SN/A         source=[File('elf_types.m4'), File('libelf_convert.m4')])
1162152SN/Am4env.M4(target=File('libelf_fsize.c'),
1172152SN/A         source=[File('elf_types.m4'), File('libelf_fsize.m4')])
1182718Sstever@eecs.umich.edum4env.M4(target=File('libelf_msize.c'),
1192921Sktlim@umich.edu         source=[File('elf_types.m4'), File('libelf_msize.m4')])
1202921Sktlim@umich.edum4env.Library('elf', elf_files)
1212921Sktlim@umich.edu
1222921Sktlim@umich.eduenv.Append(CPPPATH=Dir('.'))
1232921Sktlim@umich.eduenv.Append(LIBS=['elf'])
1242921Sktlim@umich.eduenv.Append(LIBPATH=[Dir('.')])
1252921Sktlim@umich.edu
1262921Sktlim@umich.edu