SConscript revision 6313
111986Sandreas.sandberg@arm.com# -*- mode:python -*-
211986Sandreas.sandberg@arm.com
311986Sandreas.sandberg@arm.com# Copyright (c) 2004-2005 The Regents of The University of Michigan
411986Sandreas.sandberg@arm.com# All rights reserved.
511986Sandreas.sandberg@arm.com#
611986Sandreas.sandberg@arm.com# Redistribution and use in source and binary forms, with or without
711986Sandreas.sandberg@arm.com# modification, are permitted provided that the following conditions are
811986Sandreas.sandberg@arm.com# met: redistributions of source code must retain the above copyright
911986Sandreas.sandberg@arm.com# notice, this list of conditions and the following disclaimer;
1011986Sandreas.sandberg@arm.com# redistributions in binary form must reproduce the above copyright
1111986Sandreas.sandberg@arm.com# notice, this list of conditions and the following disclaimer in the
1211986Sandreas.sandberg@arm.com# documentation and/or other materials provided with the distribution;
1311986Sandreas.sandberg@arm.com# neither the name of the copyright holders nor the names of its
1411986Sandreas.sandberg@arm.com# contributors may be used to endorse or promote products derived from
1511986Sandreas.sandberg@arm.com# this software without specific prior written permission.
1611986Sandreas.sandberg@arm.com#
1711986Sandreas.sandberg@arm.com# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1811986Sandreas.sandberg@arm.com# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1911986Sandreas.sandberg@arm.com# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
2011986Sandreas.sandberg@arm.com# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2111986Sandreas.sandberg@arm.com# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2211986Sandreas.sandberg@arm.com# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2311986Sandreas.sandberg@arm.com# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2411986Sandreas.sandberg@arm.com# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2511986Sandreas.sandberg@arm.com# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2611986Sandreas.sandberg@arm.com# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2711986Sandreas.sandberg@arm.com# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2811986Sandreas.sandberg@arm.com#
2911986Sandreas.sandberg@arm.com# Authors: Nathan Binkert
3011986Sandreas.sandberg@arm.com
3111986Sandreas.sandberg@arm.comimport os, subprocess
3211986Sandreas.sandberg@arm.com
3311986Sandreas.sandberg@arm.comImport('main')
3411986Sandreas.sandberg@arm.com
3512391Sjason@lowepower.comelf_files = []
3611986Sandreas.sandberg@arm.comdef ElfFile(filename):
3712391Sjason@lowepower.com    elf_files.append(File(filename))
3812391Sjason@lowepower.com
3912391Sjason@lowepower.comElfFile('elf_begin.c')
4012391Sjason@lowepower.comElfFile('elf_cntl.c')
4112391Sjason@lowepower.comElfFile('elf_data.c')
4212391Sjason@lowepower.comElfFile('elf_end.c')
4312391Sjason@lowepower.comElfFile('elf_fill.c')
4412391Sjason@lowepower.comElfFile('elf_flag.c')
4512391Sjason@lowepower.comElfFile('elf_getarhdr.c')
4612391Sjason@lowepower.comElfFile('elf_getarsym.c')
4711986Sandreas.sandberg@arm.comElfFile('elf_getbase.c')
4811986Sandreas.sandberg@arm.comElfFile('elf_getident.c')
4912391Sjason@lowepower.comElfFile('elf_hash.c')
5011986Sandreas.sandberg@arm.comElfFile('elf_kind.c')
5111986Sandreas.sandberg@arm.comElfFile('elf_memory.c')
5212391Sjason@lowepower.comElfFile('elf_next.c')
5312391Sjason@lowepower.comElfFile('elf_phnum.c')
5412391Sjason@lowepower.comElfFile('elf_rand.c')
5512391Sjason@lowepower.comElfFile('elf_rawfile.c')
5612391Sjason@lowepower.comElfFile('elf_scn.c')
5712391Sjason@lowepower.comElfFile('elf_shnum.c')
5812391Sjason@lowepower.comElfFile('elf_shstrndx.c')
5912391Sjason@lowepower.comElfFile('elf_strptr.c')
6012391Sjason@lowepower.comElfFile('elf_update.c')
6112391Sjason@lowepower.comElfFile('elf_version.c')
6212391Sjason@lowepower.comElfFile('gelf_checksum.c')
6312391Sjason@lowepower.comElfFile('gelf_dyn.c')
6412391Sjason@lowepower.comElfFile('gelf_ehdr.c')
6511986Sandreas.sandberg@arm.comElfFile('gelf_fsize.c')
6611986Sandreas.sandberg@arm.comElfFile('gelf_getclass.c')
6711986Sandreas.sandberg@arm.comElfFile('gelf_phdr.c')
6811986Sandreas.sandberg@arm.comElfFile('gelf_rel.c')
6911986Sandreas.sandberg@arm.comElfFile('gelf_rela.c')
7011986Sandreas.sandberg@arm.comElfFile('gelf_shdr.c')
7111986Sandreas.sandberg@arm.comElfFile('gelf_sym.c')
7211986Sandreas.sandberg@arm.comElfFile('gelf_symshndx.c')
7311986Sandreas.sandberg@arm.comElfFile('gelf_xlate.c')
7411986Sandreas.sandberg@arm.comElfFile('libelf.c')
7512391Sjason@lowepower.comElfFile('libelf_align.c')
7611986Sandreas.sandberg@arm.comElfFile('libelf_allocate.c')
7711986Sandreas.sandberg@arm.comElfFile('libelf_ar.c')
7812391Sjason@lowepower.comElfFile('libelf_checksum.c')
7911986Sandreas.sandberg@arm.comElfFile('libelf_data.c')
8011986Sandreas.sandberg@arm.comElfFile('libelf_ehdr.c')
8111986Sandreas.sandberg@arm.comElfFile('libelf_extended.c')
8211986Sandreas.sandberg@arm.comElfFile('libelf_phdr.c')
8312391Sjason@lowepower.comElfFile('libelf_shdr.c')
8412391Sjason@lowepower.comElfFile('libelf_xlate.c')
8511986Sandreas.sandberg@arm.com
8612391Sjason@lowepower.comElfFile('libelf_convert.c')
8712391Sjason@lowepower.comElfFile('libelf_fsize.c')
8811986Sandreas.sandberg@arm.comElfFile('libelf_msize.c')
8911986Sandreas.sandberg@arm.com
9011986Sandreas.sandberg@arm.comm4env = main.Clone()
9111986Sandreas.sandberg@arm.comif m4env['GCC']:
9211986Sandreas.sandberg@arm.com    major,minor,dot = [ int(x) for x in m4env['CXXVERSION'].split('.')]
9311986Sandreas.sandberg@arm.com    if major >= 4:
9411986Sandreas.sandberg@arm.com        m4env.Append(CCFLAGS=['-Wno-pointer-sign'])
9511986Sandreas.sandberg@arm.comm4env.Append(CCFLAGS=['-Wno-implicit'])
9611986Sandreas.sandberg@arm.comdel m4env['CPPPATH']
9711986Sandreas.sandberg@arm.com
9811986Sandreas.sandberg@arm.com# If we have gm4 use it
9911986Sandreas.sandberg@arm.comif m4env.Detect('gm4'):
10011986Sandreas.sandberg@arm.com    m4env['M4'] = 'gm4'
10111986Sandreas.sandberg@arm.com
10211986Sandreas.sandberg@arm.com# Check that m4 is available
10311986Sandreas.sandberg@arm.comimport SCons.Tool.m4
10411986Sandreas.sandberg@arm.comif not SCons.Tool.m4.exists(m4env):
10511986Sandreas.sandberg@arm.com   print "Error: Can't find version of M4 macro processor.  " + \
10611986Sandreas.sandberg@arm.com         "Please install M4 and try again."
10712391Sjason@lowepower.com   Exit(1)
10812391Sjason@lowepower.com
10911986Sandreas.sandberg@arm.comm4env.Append(M4FLAGS='-DSRCDIR=%s' % Dir('.').path)
11011986Sandreas.sandberg@arm.comm4env['M4COM'] = '$M4 $M4FLAGS $SOURCES > $TARGET'
11111986Sandreas.sandberg@arm.comm4env.M4(target=File('libelf_convert.c'),
11212391Sjason@lowepower.com         source=[File('elf_types.m4'), File('libelf_convert.m4')])
11311986Sandreas.sandberg@arm.comm4env.M4(target=File('libelf_fsize.c'),
11411986Sandreas.sandberg@arm.com         source=[File('elf_types.m4'), File('libelf_fsize.m4')])
11511986Sandreas.sandberg@arm.comm4env.M4(target=File('libelf_msize.c'),
11611986Sandreas.sandberg@arm.com         source=[File('elf_types.m4'), File('libelf_msize.m4')])
11712391Sjason@lowepower.com
11812391Sjason@lowepower.com# Build libelf as a static library with PIC code so it can be linked
11911986Sandreas.sandberg@arm.com# into either m5 or the library
12012391Sjason@lowepower.comm4env.Library('elf', [m4env.SharedObject(f) for f in elf_files])
12112391Sjason@lowepower.com
12212391Sjason@lowepower.commain.Prepend(CPPPATH=Dir('.'))
12311986Sandreas.sandberg@arm.commain.Append(LIBS=['elf'])
12411986Sandreas.sandberg@arm.commain.Prepend(LIBPATH=[Dir('.')])
12511986Sandreas.sandberg@arm.com
12611986Sandreas.sandberg@arm.com