SConscript revision 9534
16019Shines@cs.fsu.edu# -*- mode:python -*-
26019Shines@cs.fsu.edu
37100Sgblack@eecs.umich.edu# Copyright (c) 2004-2005 The Regents of The University of Michigan
47100Sgblack@eecs.umich.edu# All rights reserved.
57100Sgblack@eecs.umich.edu#
67100Sgblack@eecs.umich.edu# Redistribution and use in source and binary forms, with or without
77100Sgblack@eecs.umich.edu# modification, are permitted provided that the following conditions are
87100Sgblack@eecs.umich.edu# met: redistributions of source code must retain the above copyright
97100Sgblack@eecs.umich.edu# notice, this list of conditions and the following disclaimer;
107100Sgblack@eecs.umich.edu# redistributions in binary form must reproduce the above copyright
117100Sgblack@eecs.umich.edu# notice, this list of conditions and the following disclaimer in the
127100Sgblack@eecs.umich.edu# documentation and/or other materials provided with the distribution;
137100Sgblack@eecs.umich.edu# neither the name of the copyright holders nor the names of its
147100Sgblack@eecs.umich.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('main')
346019Shines@cs.fsu.edu
356019Shines@cs.fsu.edufrom m5.util import compareVersions
366019Shines@cs.fsu.edu
376019Shines@cs.fsu.eduelf_files = []
386019Shines@cs.fsu.edudef ElfFile(filename):
396019Shines@cs.fsu.edu    elf_files.append(File(filename))
406019Shines@cs.fsu.edu
416019Shines@cs.fsu.eduElfFile('elf_begin.c')
426757SAli.Saidi@ARM.comElfFile('elf_cntl.c')
436019Shines@cs.fsu.eduElfFile('elf_data.c')
446019Shines@cs.fsu.eduElfFile('elf_end.c')
456019Shines@cs.fsu.eduElfFile('elf_errmsg.c')
466019Shines@cs.fsu.eduElfFile('elf_errno.c')
476019Shines@cs.fsu.eduElfFile('elf_fill.c')
486019Shines@cs.fsu.eduElfFile('elf_flag.c')
496019Shines@cs.fsu.eduElfFile('elf_getarhdr.c')
506019Shines@cs.fsu.eduElfFile('elf_getarsym.c')
517170Sgblack@eecs.umich.eduElfFile('elf_getbase.c')
526253Sgblack@eecs.umich.eduElfFile('elf_getident.c')
537202Sgblack@eecs.umich.eduElfFile('elf_hash.c')
546253Sgblack@eecs.umich.eduElfFile('elf_kind.c')
556253Sgblack@eecs.umich.eduElfFile('elf_memory.c')
567396Sgblack@eecs.umich.eduElfFile('elf_next.c')
578745Sgblack@eecs.umich.eduElfFile('elf_phnum.c')
587405SAli.Saidi@ARM.comElfFile('elf_rand.c')
597259Sgblack@eecs.umich.eduElfFile('elf_rawfile.c')
607423Sgblack@eecs.umich.eduElfFile('elf_scn.c')
616397Sgblack@eecs.umich.eduElfFile('elf_shnum.c')
626019Shines@cs.fsu.eduElfFile('elf_shstrndx.c')
636757SAli.Saidi@ARM.comElfFile('elf_strptr.c')
647752SWilliam.Wang@arm.comElfFile('elf_update.c')
656019Shines@cs.fsu.eduElfFile('elf_version.c')
668745Sgblack@eecs.umich.eduElfFile('gelf_checksum.c')
676397Sgblack@eecs.umich.eduElfFile('gelf_dyn.c')
686019Shines@cs.fsu.eduElfFile('gelf_ehdr.c')
696397Sgblack@eecs.umich.eduElfFile('gelf_fsize.c')
708335Snate@binkert.orgElfFile('gelf_getclass.c')
718335Snate@binkert.orgElfFile('gelf_phdr.c')
728335Snate@binkert.orgElfFile('gelf_rel.c')
738335Snate@binkert.orgElfFile('gelf_rela.c')
746019Shines@cs.fsu.eduElfFile('gelf_shdr.c')
756757SAli.Saidi@ARM.comElfFile('gelf_sym.c')
766757SAli.Saidi@ARM.comElfFile('gelf_symshndx.c')
777694SAli.Saidi@ARM.comElfFile('gelf_xlate.c')
787585SAli.Saidi@arm.comElfFile('libelf.c')
797404SAli.Saidi@ARM.comElfFile('libelf_align.c')
806757SAli.Saidi@ARM.comElfFile('libelf_allocate.c')
816757SAli.Saidi@ARM.comElfFile('libelf_ar.c')
826019Shines@cs.fsu.eduElfFile('libelf_checksum.c')
836019Shines@cs.fsu.eduElfFile('libelf_data.c')
846019Shines@cs.fsu.eduElfFile('libelf_ehdr.c')
856019Shines@cs.fsu.eduElfFile('libelf_extended.c')
866019Shines@cs.fsu.eduElfFile('libelf_phdr.c')
876019Shines@cs.fsu.eduElfFile('libelf_shdr.c')
886019Shines@cs.fsu.eduElfFile('libelf_xlate.c')
896019Shines@cs.fsu.edu
906019Shines@cs.fsu.eduElfFile('libelf_convert.c')
916019Shines@cs.fsu.eduElfFile('libelf_fsize.c')
926019Shines@cs.fsu.eduElfFile('libelf_msize.c')
936019Shines@cs.fsu.edu
94m4env = main.Clone()
95if m4env['GCC']:
96    m4env.Append(CCFLAGS=['-Wno-pointer-sign'])
97    if compareVersions(m4env['GCC_VERSION'], '4.6') >= 0:
98        m4env.Append(CCFLAGS=['-Wno-unused-but-set-variable',
99                              '-Wno-implicit-function-declaration'])
100if m4env['CLANG']:
101    m4env.Append(CCFLAGS=['-Wno-initializer-overrides', '-Wno-pointer-sign'])
102    # clang defaults to c99 (while gcc defaults to gnu89) and there is a
103    # difference in the handling of inlining functions which causes
104    # linking problems with multiple definitions of the symbols in
105    # sysmacros.h for older versions of glibc
106    m4env.Append(CCFLAGS=['-std=gnu89'])
107m4env.Append(CCFLAGS=['-Wno-implicit'])
108del m4env['CPPPATH']
109
110# If we have gm4 use it
111if m4env.Detect('gm4'):
112    m4env['M4'] = 'gm4'
113
114# Check that m4 is available
115import SCons.Tool.m4
116if not SCons.Tool.m4.exists(m4env):
117   print "Error: Can't find version of M4 macro processor.  " + \
118         "Please install M4 and try again."
119   Exit(1)
120
121m4env.Append(M4FLAGS=['-DSRCDIR=%s' % Dir('.').path])
122m4env['M4COM'] = '$M4 $M4FLAGS $SOURCES > $TARGET'
123m4env.M4(target=File('libelf_convert.c'),
124         source=[File('elf_types.m4'), File('libelf_convert.m4')])
125m4env.M4(target=File('libelf_fsize.c'),
126         source=[File('elf_types.m4'), File('libelf_fsize.m4')])
127m4env.M4(target=File('libelf_msize.c'),
128         source=[File('elf_types.m4'), File('libelf_msize.m4')])
129
130# Build libelf as a static library with PIC code so it can be linked
131# into either m5 or the library
132m4env.Library('elf', [m4env.SharedObject(f) for f in elf_files])
133
134main.Prepend(CPPPATH=Dir('.'))
135main.Append(LIBS=['elf'])
136main.Prepend(LIBPATH=[Dir('.')])
137
138