SConscript revision 9850
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('main')
342152SN/A
352152SN/Afrom m5.util import compareVersions
362139SN/A
372139SN/Aelf_files = []
382139SN/Adef ElfFile(filename):
392139SN/A    elf_files.append(File(filename))
402139SN/A
412152SN/AElfFile('elf_begin.c')
422152SN/AElfFile('elf_cntl.c')
432139SN/AElfFile('elf_data.c')
442139SN/AElfFile('elf_end.c')
452139SN/AElfFile('elf_errmsg.c')
464781Snate@binkert.orgElfFile('elf_errno.c')
474781Snate@binkert.orgElfFile('elf_fill.c')
487799Sgblack@eecs.umich.eduElfFile('elf_flag.c')
494781Snate@binkert.orgElfFile('elf_getarhdr.c')
504781Snate@binkert.orgElfFile('elf_getarsym.c')
513170Sstever@eecs.umich.eduElfFile('elf_getbase.c')
525664Sgblack@eecs.umich.eduElfFile('elf_getident.c')
538105Sgblack@eecs.umich.eduElfFile('elf_hash.c')
546179Sksewell@umich.eduElfFile('elf_kind.c')
554781Snate@binkert.orgElfFile('elf_memory.c')
564781Snate@binkert.orgElfFile('elf_next.c')
576329Sgblack@eecs.umich.eduElfFile('elf_phnum.c')
584781Snate@binkert.orgElfFile('elf_rand.c')
594781Snate@binkert.orgElfFile('elf_rawfile.c')
604781Snate@binkert.orgElfFile('elf_scn.c')
614781Snate@binkert.orgElfFile('elf_shnum.c')
624781Snate@binkert.orgElfFile('elf_shstrndx.c')
634781Snate@binkert.orgElfFile('elf_strptr.c')
642139SN/AElfFile('elf_update.c')
652139SN/AElfFile('elf_version.c')
663546Sgblack@eecs.umich.eduElfFile('gelf_checksum.c')
674202Sbinkertn@umich.eduElfFile('gelf_dyn.c')
682152SN/AElfFile('gelf_ehdr.c')
692152SN/AElfFile('gelf_fsize.c')
702152SN/AElfFile('gelf_getclass.c')
712152SN/AElfFile('gelf_phdr.c')
722152SN/AElfFile('gelf_rel.c')
732152SN/AElfFile('gelf_rela.c')
742152SN/AElfFile('gelf_shdr.c')
752152SN/AElfFile('gelf_sym.c')
762152SN/AElfFile('gelf_symshndx.c')
772152SN/AElfFile('gelf_xlate.c')
782152SN/AElfFile('libelf.c')
792152SN/AElfFile('libelf_align.c')
802504SN/AElfFile('libelf_allocate.c')
812504SN/AElfFile('libelf_ar.c')
822504SN/AElfFile('libelf_checksum.c')
832504SN/AElfFile('libelf_data.c')
842152SN/AElfFile('libelf_ehdr.c')
852504SN/AElfFile('libelf_extended.c')
862152SN/AElfFile('libelf_phdr.c')
872152SN/AElfFile('libelf_shdr.c')
882152SN/AElfFile('libelf_xlate.c')
892152SN/A
902152SN/AElfFile('libelf_convert.c')
912152SN/AElfFile('libelf_fsize.c')
928584Sgblack@eecs.umich.eduElfFile('libelf_msize.c')
938584Sgblack@eecs.umich.edu
946993Snate@binkert.orgm4env = main.Clone()
956993Snate@binkert.orgif m4env['GCC']:
966993Snate@binkert.org    m4env.Append(CCFLAGS=['-Wno-pointer-sign'])
976993Snate@binkert.org    if compareVersions(m4env['GCC_VERSION'], '4.6') >= 0:
986993Snate@binkert.org        m4env.Append(CCFLAGS=['-Wno-unused-but-set-variable',
996993Snate@binkert.org                              '-Wno-implicit-function-declaration'])
1006993Snate@binkert.orgif m4env['CLANG']:
1016993Snate@binkert.org    m4env.Append(CCFLAGS=['-Wno-initializer-overrides', '-Wno-pointer-sign'])
1026993Snate@binkert.org    # clang defaults to c99 (while gcc defaults to gnu89) and there is a
1036993Snate@binkert.org    # difference in the handling of inlining functions which causes
1046993Snate@binkert.org    # linking problems with multiple definitions of the symbols in
1056993Snate@binkert.org    # sysmacros.h for older versions of glibc
1066993Snate@binkert.org    m4env.Append(CCFLAGS=['-std=gnu89'])
1078584Sgblack@eecs.umich.edum4env.Append(CCFLAGS=['-Wno-implicit'])
1088584Sgblack@eecs.umich.edudel m4env['CPPPATH']
1098584Sgblack@eecs.umich.edu
1108584Sgblack@eecs.umich.edu# If we have gm4 use it
1118584Sgblack@eecs.umich.eduif m4env.Detect('gm4'):
1128584Sgblack@eecs.umich.edu    m4env['M4'] = 'gm4'
1136993Snate@binkert.org
1146993Snate@binkert.org# Check that m4 is available
1156993Snate@binkert.orgimport SCons.Tool.m4
1166998Snate@binkert.orgif not SCons.Tool.m4.exists(m4env):
1176998Snate@binkert.org   print "Error: Can't find version of M4 macro processor.  " + \
1186998Snate@binkert.org         "Please install M4 and try again."
1197756SAli.Saidi@ARM.com   Exit(1)
1206993Snate@binkert.org
1216993Snate@binkert.orgm4env.Append(M4FLAGS=['-DSRCDIR=%s' % Dir('.').path])
1226993Snate@binkert.orgm4env['M4COM'] = '$M4 $M4FLAGS $SOURCES > $TARGET'
1236993Snate@binkert.orgm4env.M4(target=File('libelf_convert.c'),
1248585Sgblack@eecs.umich.edu         source=[File('elf_types.m4'), File('libelf_convert.m4')])
1258584Sgblack@eecs.umich.edum4env.M4(target=File('libelf_fsize.c'),
1266993Snate@binkert.org         source=[File('elf_types.m4'), File('libelf_fsize.m4')])
1276993Snate@binkert.orgm4env.M4(target=File('libelf_msize.c'),
1286993Snate@binkert.org         source=[File('elf_types.m4'), File('libelf_msize.m4')])
1297816Ssteve.reinhardt@amd.com
1302152SN/A# Build libelf as a static library with PIC code so it can be linked
1312766Sktlim@umich.edu# into either m5 or the library
1322766Sktlim@umich.edum4env.Library('elf', [m4env.SharedObject(f) for f in elf_files])
1336993Snate@binkert.org
1342152SN/Amain.Prepend(CPPPATH=Dir('.'))
1352152SN/Amain.Append(LIBS=['elf'])
1365944Sgblack@eecs.umich.edumain.Prepend(LIBPATH=[Dir('.')])
1378335Snate@binkert.org
1388335Snate@binkert.org