SConscript revision 6019
16019Shines@cs.fsu.edu# -*- mode:python -*-
26019Shines@cs.fsu.edu
36019Shines@cs.fsu.edu# Copyright (c) 2004-2005 The Regents of The University of Michigan
46019Shines@cs.fsu.edu# All rights reserved.
56019Shines@cs.fsu.edu#
66019Shines@cs.fsu.edu# Redistribution and use in source and binary forms, with or without
76019Shines@cs.fsu.edu# modification, are permitted provided that the following conditions are
86019Shines@cs.fsu.edu# met: redistributions of source code must retain the above copyright
96019Shines@cs.fsu.edu# notice, this list of conditions and the following disclaimer;
106019Shines@cs.fsu.edu# redistributions in binary form must reproduce the above copyright
116019Shines@cs.fsu.edu# notice, this list of conditions and the following disclaimer in the
126019Shines@cs.fsu.edu# documentation and/or other materials provided with the distribution;
136019Shines@cs.fsu.edu# neither the name of the copyright holders nor the names of its
146019Shines@cs.fsu.edu# contributors may be used to endorse or promote products derived from
156019Shines@cs.fsu.edu# this software without specific prior written permission.
166019Shines@cs.fsu.edu#
176019Shines@cs.fsu.edu# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
186019Shines@cs.fsu.edu# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
196019Shines@cs.fsu.edu# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
206019Shines@cs.fsu.edu# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
216019Shines@cs.fsu.edu# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
226019Shines@cs.fsu.edu# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
236019Shines@cs.fsu.edu# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
246019Shines@cs.fsu.edu# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
256019Shines@cs.fsu.edu# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
266019Shines@cs.fsu.edu# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
276019Shines@cs.fsu.edu# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
286019Shines@cs.fsu.edu#
296019Shines@cs.fsu.edu# Authors: Nathan Binkert
306019Shines@cs.fsu.edu
316019Shines@cs.fsu.eduimport os, subprocess
326019Shines@cs.fsu.edu
336019Shines@cs.fsu.eduImport('env')
346019Shines@cs.fsu.edu
356019Shines@cs.fsu.eduelf_files = []
366019Shines@cs.fsu.edudef ElfFile(filename):
376019Shines@cs.fsu.edu    elf_files.append(File(filename))
386019Shines@cs.fsu.edu
396019Shines@cs.fsu.eduElfFile('elf_begin.c')
406019Shines@cs.fsu.eduElfFile('elf_cntl.c')
416019Shines@cs.fsu.eduElfFile('elf_data.c')
426019Shines@cs.fsu.eduElfFile('elf_end.c')
436019Shines@cs.fsu.eduElfFile('elf_fill.c')
446019Shines@cs.fsu.eduElfFile('elf_flag.c')
456019Shines@cs.fsu.eduElfFile('elf_getarhdr.c')
466019Shines@cs.fsu.eduElfFile('elf_getarsym.c')
476019Shines@cs.fsu.eduElfFile('elf_getbase.c')
486019Shines@cs.fsu.eduElfFile('elf_getident.c')
496019Shines@cs.fsu.eduElfFile('elf_hash.c')
506019Shines@cs.fsu.eduElfFile('elf_kind.c')
516019Shines@cs.fsu.eduElfFile('elf_memory.c')
526019Shines@cs.fsu.eduElfFile('elf_next.c')
536019Shines@cs.fsu.eduElfFile('elf_phnum.c')
546019Shines@cs.fsu.eduElfFile('elf_rand.c')
556019Shines@cs.fsu.eduElfFile('elf_rawfile.c')
566019Shines@cs.fsu.eduElfFile('elf_scn.c')
576019Shines@cs.fsu.eduElfFile('elf_shnum.c')
586019Shines@cs.fsu.eduElfFile('elf_shstrndx.c')
596019Shines@cs.fsu.eduElfFile('elf_strptr.c')
606019Shines@cs.fsu.eduElfFile('elf_update.c')
616019Shines@cs.fsu.eduElfFile('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)
91
92if env.get('CC'):
93    m4env['CC'] = env['CC']
94if env.get('CXX'):
95    m4env['CXX'] = env['CXX']
96
97if env.get('OSX64bit'):
98    m4env.Append(CFLAGS='-arch x86_64')
99    m4env.Append(LINKFLAGS='-arch x86_64')
100
101# If we have gm4 use it
102if m4env.Detect('gm4'):
103    m4env['M4'] = 'gm4'
104
105# Check that m4 is available
106import SCons.Tool.m4
107if not SCons.Tool.m4.exists(m4env):
108   print "Error: Can't find version of M4 macro processor.  " + \
109         "Please install M4 and try again."
110   Exit(1)
111
112m4env.Append(M4FLAGS='-DSRCDIR=%s' % Dir('.').path)
113m4env['M4COM'] = '$M4 $M4FLAGS $SOURCES > $TARGET'
114m4env.M4(target=File('libelf_convert.c'),
115         source=[File('elf_types.m4'), File('libelf_convert.m4')])
116m4env.M4(target=File('libelf_fsize.c'),
117         source=[File('elf_types.m4'), File('libelf_fsize.m4')])
118m4env.M4(target=File('libelf_msize.c'),
119         source=[File('elf_types.m4'), File('libelf_msize.m4')])
120m4env.Library('elf', elf_files)
121
122env.Append(CPPPATH=Dir('.'))
123env.Append(LIBS=['elf'])
124env.Append(LIBPATH=[Dir('.')])
125
126