SConscript revision 11294
14484Sbinkertn@umich.edu# -*- mode:python -*-
24484Sbinkertn@umich.edu
34484Sbinkertn@umich.edu# Copyright (c) 2004-2005 The Regents of The University of Michigan
44484Sbinkertn@umich.edu# All rights reserved.
54484Sbinkertn@umich.edu#
64484Sbinkertn@umich.edu# Redistribution and use in source and binary forms, with or without
74484Sbinkertn@umich.edu# modification, are permitted provided that the following conditions are
84484Sbinkertn@umich.edu# met: redistributions of source code must retain the above copyright
94484Sbinkertn@umich.edu# notice, this list of conditions and the following disclaimer;
104484Sbinkertn@umich.edu# redistributions in binary form must reproduce the above copyright
114484Sbinkertn@umich.edu# notice, this list of conditions and the following disclaimer in the
124484Sbinkertn@umich.edu# documentation and/or other materials provided with the distribution;
134484Sbinkertn@umich.edu# neither the name of the copyright holders nor the names of its
144484Sbinkertn@umich.edu# contributors may be used to endorse or promote products derived from
154484Sbinkertn@umich.edu# this software without specific prior written permission.
164484Sbinkertn@umich.edu#
174484Sbinkertn@umich.edu# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
184484Sbinkertn@umich.edu# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
194484Sbinkertn@umich.edu# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
204484Sbinkertn@umich.edu# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
214484Sbinkertn@umich.edu# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
224484Sbinkertn@umich.edu# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
234484Sbinkertn@umich.edu# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
244484Sbinkertn@umich.edu# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
254484Sbinkertn@umich.edu# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
264484Sbinkertn@umich.edu# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
274484Sbinkertn@umich.edu# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
284484Sbinkertn@umich.edu#
294484Sbinkertn@umich.edu# Authors: Nathan Binkert
304484Sbinkertn@umich.edu
314494Ssaidi@eecs.umich.eduimport os, subprocess
324484Sbinkertn@umich.edu
336121Snate@binkert.orgImport('main')
344484Sbinkertn@umich.edu
358946Sandreas.hansson@arm.comfrom m5.util import compareVersions
368946Sandreas.hansson@arm.com
374484Sbinkertn@umich.eduelf_files = []
384484Sbinkertn@umich.edudef ElfFile(filename):
394484Sbinkertn@umich.edu    elf_files.append(File(filename))
404781Snate@binkert.org
414484Sbinkertn@umich.eduElfFile('elf_begin.c')
424484Sbinkertn@umich.eduElfFile('elf_cntl.c')
434484Sbinkertn@umich.eduElfFile('elf_data.c')
444484Sbinkertn@umich.eduElfFile('elf_end.c')
458349Sgblack@eecs.umich.eduElfFile('elf_errmsg.c')
468349Sgblack@eecs.umich.eduElfFile('elf_errno.c')
474484Sbinkertn@umich.eduElfFile('elf_fill.c')
484484Sbinkertn@umich.eduElfFile('elf_flag.c')
494484Sbinkertn@umich.eduElfFile('elf_getarhdr.c')
504484Sbinkertn@umich.eduElfFile('elf_getarsym.c')
514484Sbinkertn@umich.eduElfFile('elf_getbase.c')
524484Sbinkertn@umich.eduElfFile('elf_getident.c')
534484Sbinkertn@umich.eduElfFile('elf_hash.c')
544484Sbinkertn@umich.eduElfFile('elf_kind.c')
554484Sbinkertn@umich.eduElfFile('elf_memory.c')
564484Sbinkertn@umich.eduElfFile('elf_next.c')
574484Sbinkertn@umich.eduElfFile('elf_phnum.c')
584484Sbinkertn@umich.eduElfFile('elf_rand.c')
594484Sbinkertn@umich.eduElfFile('elf_rawfile.c')
604484Sbinkertn@umich.eduElfFile('elf_scn.c')
614484Sbinkertn@umich.eduElfFile('elf_shnum.c')
624484Sbinkertn@umich.eduElfFile('elf_shstrndx.c')
634484Sbinkertn@umich.eduElfFile('elf_strptr.c')
644484Sbinkertn@umich.eduElfFile('elf_update.c')
654484Sbinkertn@umich.eduElfFile('elf_version.c')
664484Sbinkertn@umich.eduElfFile('gelf_checksum.c')
674484Sbinkertn@umich.eduElfFile('gelf_dyn.c')
684484Sbinkertn@umich.eduElfFile('gelf_ehdr.c')
694484Sbinkertn@umich.eduElfFile('gelf_fsize.c')
704484Sbinkertn@umich.eduElfFile('gelf_getclass.c')
714484Sbinkertn@umich.eduElfFile('gelf_phdr.c')
724484Sbinkertn@umich.eduElfFile('gelf_rel.c')
734484Sbinkertn@umich.eduElfFile('gelf_rela.c')
744484Sbinkertn@umich.eduElfFile('gelf_shdr.c')
754484Sbinkertn@umich.eduElfFile('gelf_sym.c')
764484Sbinkertn@umich.eduElfFile('gelf_symshndx.c')
774484Sbinkertn@umich.eduElfFile('gelf_xlate.c')
784484Sbinkertn@umich.eduElfFile('libelf.c')
794484Sbinkertn@umich.eduElfFile('libelf_align.c')
804484Sbinkertn@umich.eduElfFile('libelf_allocate.c')
814484Sbinkertn@umich.eduElfFile('libelf_ar.c')
824484Sbinkertn@umich.eduElfFile('libelf_checksum.c')
834484Sbinkertn@umich.eduElfFile('libelf_data.c')
844484Sbinkertn@umich.eduElfFile('libelf_ehdr.c')
854484Sbinkertn@umich.eduElfFile('libelf_extended.c')
864484Sbinkertn@umich.eduElfFile('libelf_phdr.c')
874484Sbinkertn@umich.eduElfFile('libelf_shdr.c')
884484Sbinkertn@umich.eduElfFile('libelf_xlate.c')
894484Sbinkertn@umich.edu
904484Sbinkertn@umich.eduElfFile('libelf_convert.c')
914484Sbinkertn@umich.eduElfFile('libelf_fsize.c')
924484Sbinkertn@umich.eduElfFile('libelf_msize.c')
934484Sbinkertn@umich.edu
946121Snate@binkert.orgm4env = main.Clone()
956121Snate@binkert.orgif m4env['GCC']:
9611294Sandreas.hansson@arm.com    m4env.Append(CCFLAGS=['-Wno-pointer-sign',
9711294Sandreas.hansson@arm.com                          '-Wno-unused-but-set-variable',
9811294Sandreas.hansson@arm.com                          '-Wno-implicit-function-declaration',
9911294Sandreas.hansson@arm.com                          '-Wno-override-init'])
1008737Skoansin.tan@gmail.comif m4env['CLANG']:
1018737Skoansin.tan@gmail.com    m4env.Append(CCFLAGS=['-Wno-initializer-overrides', '-Wno-pointer-sign'])
1029388Sandreas.hansson@arm.com    # clang defaults to c99 (while gcc defaults to gnu89) and there is a
1039388Sandreas.hansson@arm.com    # difference in the handling of inlining functions which causes
1049388Sandreas.hansson@arm.com    # linking problems with multiple definitions of the symbols in
1059388Sandreas.hansson@arm.com    # sysmacros.h for older versions of glibc
1069388Sandreas.hansson@arm.com    m4env.Append(CCFLAGS=['-std=gnu89'])
1075765Snate@binkert.orgm4env.Append(CCFLAGS=['-Wno-implicit'])
1085397Ssaidi@eecs.umich.edudel m4env['CPPPATH']
1095274Ssaidi@eecs.umich.edu
1104494Ssaidi@eecs.umich.edu# If we have gm4 use it
1114504Ssaidi@eecs.umich.eduif m4env.Detect('gm4'):
1124494Ssaidi@eecs.umich.edu    m4env['M4'] = 'gm4'
1134494Ssaidi@eecs.umich.edu
1144496Ssaidi@eecs.umich.edu# Check that m4 is available
1154504Ssaidi@eecs.umich.eduimport SCons.Tool.m4
1164504Ssaidi@eecs.umich.eduif not SCons.Tool.m4.exists(m4env):
1174500Sbinkertn@umich.edu   print "Error: Can't find version of M4 macro processor.  " + \
1184500Sbinkertn@umich.edu         "Please install M4 and try again."
1194496Ssaidi@eecs.umich.edu   Exit(1)
1204496Ssaidi@eecs.umich.edu
1217739Sgblack@eecs.umich.edum4env.Append(M4FLAGS=['-DSRCDIR=%s' % Dir('.').path])
1224487Sstever@eecs.umich.edum4env['M4COM'] = '$M4 $M4FLAGS $SOURCES > $TARGET'
1234484Sbinkertn@umich.edum4env.M4(target=File('libelf_convert.c'),
1244484Sbinkertn@umich.edu         source=[File('elf_types.m4'), File('libelf_convert.m4')])
1254484Sbinkertn@umich.edum4env.M4(target=File('libelf_fsize.c'),
1264484Sbinkertn@umich.edu         source=[File('elf_types.m4'), File('libelf_fsize.m4')])
1274484Sbinkertn@umich.edum4env.M4(target=File('libelf_msize.c'),
1284484Sbinkertn@umich.edu         source=[File('elf_types.m4'), File('libelf_msize.m4')])
1295601Snate@binkert.org
1305601Snate@binkert.org# Build libelf as a static library with PIC code so it can be linked
1315601Snate@binkert.org# into either m5 or the library
1325601Snate@binkert.orgm4env.Library('elf', [m4env.SharedObject(f) for f in elf_files])
1334484Sbinkertn@umich.edu
1346121Snate@binkert.orgmain.Prepend(CPPPATH=Dir('.'))
1356121Snate@binkert.orgmain.Append(LIBS=['elf'])
1366121Snate@binkert.orgmain.Prepend(LIBPATH=[Dir('.')])
1374494Ssaidi@eecs.umich.edu
138