source: rtems-tools/rtemstoolkit/wscript @ e0a52a4

5
Last change on this file since e0a52a4 was 4bb3996, checked in by Chris Johns <chrisj@…>, on 04/30/18 at 05:34:48

rtemstoolkit: Add libdwarf from elftoolchain.

The code is taken from:

https://svn.code.sf.net/p/elftoolchain/code/trunk

Update #3417

  • Property mode set to 100644
File size: 14.7 KB
Line 
1#
2# RTEMS Tools Project (http://www.rtems.org/)
3# Copyright 2014-2018 Chris Johns (chrisj@rtems.org)
4# All rights reserved.
5#
6# This file is part of the RTEMS Tools package in 'rtems-tools'.
7#
8# Permission to use, copy, modify, and/or distribute this software for any
9# purpose with or without fee is hereby granted, provided that the above
10# copyright notice and this permission notice appear in all copies.
11#
12# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
15# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19#
20
21#
22# RTEMS Toolkit build script.
23#
24import sys
25
26#
27# Waf system setup. Allow more than one build in the same tree.
28#
29top = '.'
30out = 'build-' + sys.platform
31
32def init(ctx):
33    pass
34
35def options(opt):
36    opt.load('compiler_c')
37    opt.load('compiler_cxx')
38
39def configure(conf):
40    conf.load('compiler_c')
41    conf.load('compiler_cxx')
42    conf_libiberty(conf)
43    conf_elftoolchain(conf)
44
45    conf.find_program('m4')
46
47    conf.check(header_name = 'sys/wait.h',  features = 'c', mandatory = False)
48    conf.check_cc(function_name = 'kill', header_name="signal.h",
49                  features = 'c', mandatory = False)
50    conf.write_config_header('config.h')
51
52def build(bld):
53    #
54    # The local configuration.
55    #
56    conf = {}
57
58    #
59    # The include paths.
60    #
61    conf['includes'] = ['elftoolchain/libelf',
62                        'elftoolchain/libdwarf',
63                        'elftoolchain/common',
64                        'libiberty']
65    if bld.env.DEST_OS == 'win32':
66        conf['includes'] += ['win32']
67
68    #
69    # Build flags.
70    #
71    conf['warningflags'] = ['-Wall', '-Wextra', '-pedantic']
72    conf['optflags'] = bld.env.C_OPTS
73    conf['cflags'] = ['-pipe', '-g'] + conf['optflags']
74    conf['cxxflags'] = ['-pipe', '-g'] + conf['optflags']
75    conf['linkflags'] = ['-g']
76
77    #
78    # Create each of the modules as object files each with their own
79    # configurations.
80    #
81    bld_elftoolchain(bld, conf)
82    bld_libiberty(bld, conf)
83
84    #
85    # RLD source.
86    #
87    rld_source = ['ConvertUTF.c',
88                  'pkgconfig.cpp',
89                  'rld-buffer.cpp',
90                  'rld-cc.cpp',
91                  'rld-compression.cpp',
92                  'rld-config.cpp',
93                  'rld-elf.cpp',
94                  'rld-files.cpp',
95                  'rld-outputter.cpp',
96                  'rld-path.cpp',
97                  'rld-process.cpp',
98                  'rld-rap.cpp',
99                  'rld-resolver.cpp',
100                  'rld-rtems.cpp',
101                  'rld-symbols.cpp',
102                  'rld.cpp']
103
104    #
105    # RTEMS Utilities.
106    #
107    rtems_utils = ['rtems-utils.cpp']
108
109    #
110    # Compression.
111    #
112    compression = ['fastlz.c']
113
114    #
115    # RTL static library
116    #
117    bld.stlib(target = 'rld',
118              install_path = None,
119              source = rld_source + rtems_utils + compression,
120              defines = ['HAVE_CONFIG_H=1',
121                         'RTEMS_VERSION=\"%s\"' % (bld.env.RTEMS_VERSION),
122                         'RTEMS_RELEASE=\"%s\"' % (bld.env.RTEMS_RELEASE),
123                         'FASTLZ_LEVEL=1'],
124              includes = ['.'] + conf['includes'],
125              cflags = conf['cflags'] + conf['warningflags'],
126              cxxflags = conf['cxxflags'] + conf['warningflags'],
127              linkflags = conf['linkflags'])
128
129    #
130    # The Python toolkit.
131    #
132    bld(features = 'py',
133        source = ['__init__.py',
134                  'check.py',
135                  'config.py',
136                  'configuration.py',
137                  'darwin.py',
138                  'error.py',
139                  'execute.py',
140                  'freebsd.py',
141                  'git.py',
142                  'host.py',
143                  'linux.py',
144                  'log.py',
145                  'macros.py',
146                  'mailer.py',
147                  'options.py',
148                  'path.py',
149                  'reraise.py',
150                  'stacktraces.py',
151                  'textbox.py',
152                  'version.py',
153                  'windows.py'],
154        install_from = '.',
155        install_path = '${PREFIX}/share/rtems/rtemstoolkit')
156
157def rebuild(ctx):
158    import waflib.Options
159    waflib.Options.commands.extend(['clean', 'build'])
160
161def tags(ctx):
162    ctx.exec_command('etags $(find . -name \*.[sSch])', shell = True)
163
164#
165# Libelf module.
166#
167def conf_elftoolchain(conf):
168    pass
169
170def bld_elftoolchain(bld, conf):
171    libelf = 'elftoolchain/libelf/'
172    libdwarf = 'elftoolchain/libdwarf/'
173    libelf_m4_rule = '${M4} -D SRCDIR=../rtemstoolkit/' + libelf[:-1] + ' ${SRC} > ${TGT}'
174    libdwarf_m4_rule = '${M4} -D SRCDIR=../rtemstoolkit/' + libdwarf[:-1] + ' ${SRC} > ${TGT}'
175    if bld.env.DEST_OS == 'win32':
176        includes = ['win32']
177    else:
178        includes = []
179
180    libelf_m4_source = ['libelf_convert.c',
181                        'libelf_fsize.c',
182                        'libelf_msize.c']
183    for s in libelf_m4_source:
184        bld(target = s, source = libelf + s[:-2] + '.m4', rule = libelf_m4_rule)
185
186    host_source = []
187
188    if bld.env.DEST_OS == 'linux':
189        common = 'elftoolchain/common/'
190        bld(target = common + 'native-elf-format.h',
191            source = common + 'native-elf-format',
192            name = 'native-elf-format',
193            rule   = './${SRC} > ${TGT}')
194        bld.add_group ()
195    elif bld.env.DEST_OS == 'win32':
196        host_source += [libelf + 'mmap_win32.c']
197
198    bld.stlib(target = 'elf',
199              features = 'c',
200              install_path = None,
201              uses = ['native-elf-format'],
202              includes = [bld.bldnode.abspath(),
203                          'elftoolchain/libelf', 'elftoolchain/common'] + includes,
204              cflags = conf['cflags'],
205              source =[libelf + 'elf.c',
206                       libelf + 'elf_begin.c',
207                       libelf + 'elf_cntl.c',
208                       libelf + 'elf_end.c',
209                       libelf + 'elf_errmsg.c',
210                       libelf + 'elf_errno.c',
211                       libelf + 'elf_data.c',
212                       libelf + 'elf_fill.c',
213                       libelf + 'elf_flag.c',
214                       libelf + 'elf_getarhdr.c',
215                       libelf + 'elf_getarsym.c',
216                       libelf + 'elf_getbase.c',
217                       libelf + 'elf_getident.c',
218                       libelf + 'elf_hash.c',
219                       libelf + 'elf_kind.c',
220                       libelf + 'elf_memory.c',
221                       libelf + 'elf_next.c',
222                       libelf + 'elf_open.c',
223                       libelf + 'elf_rand.c',
224                       libelf + 'elf_rawfile.c',
225                       libelf + 'elf_phnum.c',
226                       libelf + 'elf_shnum.c',
227                       libelf + 'elf_shstrndx.c',
228                       libelf + 'elf_scn.c',
229                       libelf + 'elf_strptr.c',
230                       libelf + 'elf_update.c',
231                       libelf + 'elf_version.c',
232                       libelf + 'gelf_cap.c',
233                       libelf + 'gelf_checksum.c',
234                       libelf + 'gelf_dyn.c',
235                       libelf + 'gelf_ehdr.c',
236                       libelf + 'gelf_getclass.c',
237                       libelf + 'gelf_fsize.c',
238                       libelf + 'gelf_move.c',
239                       libelf + 'gelf_phdr.c',
240                       libelf + 'gelf_rel.c',
241                       libelf + 'gelf_rela.c',
242                       libelf + 'gelf_shdr.c',
243                       libelf + 'gelf_sym.c',
244                       libelf + 'gelf_syminfo.c',
245                       libelf + 'gelf_symshndx.c',
246                       libelf + 'gelf_xlate.c',
247                       libelf + 'libelf_align.c',
248                       libelf + 'libelf_allocate.c',
249                       libelf + 'libelf_ar.c',
250                       libelf + 'libelf_ar_util.c',
251                       libelf + 'libelf_checksum.c',
252                       libelf + 'libelf_data.c',
253                       libelf + 'libelf_ehdr.c',
254                       libelf + 'libelf_extended.c',
255                       libelf + 'libelf_memory.c',
256                       libelf + 'libelf_open.c',
257                       libelf + 'libelf_phdr.c',
258                       libelf + 'libelf_shdr.c',
259                       libelf + 'libelf_xlate.c'] + libelf_m4_source + host_source)
260
261    libdwarf_m4_source = ['dwarf_funcs.c',
262                          'dwarf_pro_funcs.c',
263                          'dwarf_pro_pubnames.c',
264                          'dwarf_pro_types.c',
265                          'dwarf_pro_vars.c',
266                          'dwarf_pro_weaks.c',
267                          'dwarf_pubnames.c',
268                          'dwarf_pubtypes.c',
269                          'dwarf_types.c',
270                          'dwarf_vars.c',
271                          'dwarf_weaks.c']
272    for s in libdwarf_m4_source:
273        bld(target = s, source = libdwarf + s[:-2] + '.m4', rule = libdwarf_m4_rule)
274
275    bld.stlib(target = 'dwarf',
276              features = 'c',
277              install_path = None,
278              includes = [bld.bldnode.abspath(),
279                          'elftoolchain/libelf',
280                          'elftoolchain/libdwarf',
281                          'elftoolchain/common'] + includes,
282              cflags = conf['cflags'],
283              source =[libdwarf + 'dwarf_abbrev.c',
284                       libdwarf + 'dwarf_arange.c',
285                       libdwarf + 'dwarf_attr.c',
286                       libdwarf + 'dwarf_attrval.c',
287                       libdwarf + 'dwarf_cu.c',
288                       libdwarf + 'dwarf_dealloc.c',
289                       libdwarf + 'dwarf_die.c',
290                       libdwarf + 'dwarf_dump.c',
291                       libdwarf + 'dwarf_errmsg.c',
292                       libdwarf + 'dwarf_finish.c',
293                       libdwarf + 'dwarf_form.c',
294                       libdwarf + 'dwarf_frame.c',
295                       libdwarf + 'dwarf_init.c',
296                       libdwarf + 'dwarf_lineno.c',
297                       libdwarf + 'dwarf_loclist.c',
298                       libdwarf + 'dwarf_macinfo.c',
299                       libdwarf + 'dwarf_pro_arange.c',
300                       libdwarf + 'dwarf_pro_attr.c',
301                       libdwarf + 'dwarf_pro_die.c',
302                       libdwarf + 'dwarf_pro_expr.c',
303                       libdwarf + 'dwarf_pro_finish.c',
304                       libdwarf + 'dwarf_pro_frame.c',
305                       libdwarf + 'dwarf_pro_init.c',
306                       libdwarf + 'dwarf_pro_lineno.c',
307                       libdwarf + 'dwarf_pro_macinfo.c',
308                       libdwarf + 'dwarf_pro_reloc.c',
309                       libdwarf + 'dwarf_pro_sections.c',
310                       libdwarf + 'dwarf_ranges.c',
311                       libdwarf + 'dwarf_reloc.c',
312                       libdwarf + 'dwarf_seterror.c',
313                       libdwarf + 'dwarf_str.c',
314                       libdwarf + 'libdwarf.c',
315                       libdwarf + 'libdwarf_abbrev.c',
316                       libdwarf + 'libdwarf_arange.c',
317                       libdwarf + 'libdwarf_attr.c',
318                       libdwarf + 'libdwarf_die.c',
319                       libdwarf + 'libdwarf_error.c',
320                       libdwarf + 'libdwarf_elf_access.c',
321                       libdwarf + 'libdwarf_elf_init.c',
322                       libdwarf + 'libdwarf_frame.c',
323                       libdwarf + 'libdwarf_info.c',
324                       libdwarf + 'libdwarf_init.c',
325                       libdwarf + 'libdwarf_lineno.c',
326                       libdwarf + 'libdwarf_loc.c',
327                       libdwarf + 'libdwarf_loclist.c',
328                       libdwarf + 'libdwarf_macinfo.c',
329                       libdwarf + 'libdwarf_nametbl.c',
330                       libdwarf + 'libdwarf_ranges.c',
331                       libdwarf + 'libdwarf_reloc.c',
332                       libdwarf + 'libdwarf_rw.c',
333                       libdwarf + 'libdwarf_sections.c',
334                       libdwarf + 'libdwarf_str.c'] + libdwarf_m4_source)
335
336#
337# Libiberty module.
338#
339def conf_libiberty(conf):
340    conf.check(header_name='alloca.h',    features = 'c', mandatory = False)
341    conf.check(header_name='fcntl.h',     features = 'c', mandatory = False)
342    conf.check(header_name='process.h',   features = 'c', mandatory = False)
343    conf.check(header_name='stdlib.h',    features = 'c')
344    conf.check(header_name='string.h',    features = 'c')
345    conf.check(header_name='strings.h',   features = 'c', mandatory = False)
346    conf.check(header_name='sys/file.h',  features = 'c', mandatory = False)
347    conf.check(header_name='sys/stat.h',  features = 'c', mandatory = False)
348    conf.check(header_name='sys/time.h',  features = 'c', mandatory = False)
349    conf.check(header_name='sys/types.h', features = 'c', mandatory = False)
350    conf.check(header_name='sys/wait.h',  features = 'c', mandatory = False)
351    conf.check(header_name='unistd.h',    features = 'c', mandatory = False)
352    conf.check(header_name='vfork.h',     features = 'c', mandatory = False)
353
354    conf.check_cc(function_name='getrusage',
355                  header_name="sys/time.h sys/resource.h",
356                  features = 'c', mandatory = False)
357
358    conf.write_config_header('libiberty/config.h')
359
360def bld_libiberty(bld, conf):
361    if bld.env.DEST_OS == 'win32':
362        pex_host = 'libiberty/pex-win32.c'
363    else:
364        pex_host = 'libiberty/pex-unix.c'
365    bld.stlib(target = 'iberty',
366              features = 'c',
367              install_path = None,
368              includes = ['libiberty'],
369              cflags = conf['cflags'],
370              defines = ['HAVE_CONFIG_H=1'],
371              source =['libiberty/concat.c',
372                       'libiberty/cplus-dem.c',
373                       'libiberty/cp-demangle.c',
374                       'libiberty/d-demangle.c',
375                       'libiberty/rust-demangle.c',
376                       'libiberty/make-temp-file.c',
377                       'libiberty/mkstemps.c',
378                       'libiberty/safe-ctype.c',
379                       'libiberty/stpcpy.c',
380                       'libiberty/pex-common.c',
381                       'libiberty/pex-one.c',
382                       'libiberty/xmalloc.c',
383                       'libiberty/xmemdup.c',
384                       'libiberty/xstrdup.c',
385                       'libiberty/xstrerror.c',
386                       pex_host])
387
388#
389# The doxy command.
390#
391from waflib import Build
392class doxy(Build.BuildContext):
393    fun = 'build'
394    cmd = 'doxy'
Note: See TracBrowser for help on using the repository browser.