source: rtems-tools/rtemstoolkit/wscript @ 5075e8e

5
Last change on this file since 5075e8e was 1f1a10f, checked in by Chris Johns <chrisj@…>, on 05/23/18 at 08:39:54

elftoolchain: Add libelftc.

  • Property mode set to 100644
File size: 15.9 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'] = list(set(['-pipe', '-g'] + conf['optflags']))
74    conf['cxxflags'] = list(set(['-pipe', '-g', '-std=c++11'] + 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-dwarf.cpp',
94                  'rld-elf.cpp',
95                  'rld-files.cpp',
96                  'rld-outputter.cpp',
97                  'rld-path.cpp',
98                  'rld-process.cpp',
99                  'rld-rap.cpp',
100                  'rld-resolver.cpp',
101                  'rld-rtems.cpp',
102                  'rld-symbols.cpp',
103                  'rld.cpp']
104
105    #
106    # RTEMS Utilities.
107    #
108    rtems_utils = ['rtems-utils.cpp']
109
110    #
111    # Compression.
112    #
113    compression = ['fastlz.c']
114
115    #
116    # RTL static library
117    #
118    bld.stlib(target = 'rld',
119              install_path = None,
120              source = rld_source + rtems_utils + compression,
121              defines = ['HAVE_CONFIG_H=1',
122                         'RTEMS_VERSION=\"%s\"' % (bld.env.RTEMS_VERSION),
123                         'RTEMS_RELEASE=\"%s\"' % (bld.env.RTEMS_RELEASE),
124                         'FASTLZ_LEVEL=1'],
125              includes = ['.'] + conf['includes'],
126              cflags = conf['cflags'] + conf['warningflags'],
127              cxxflags = conf['cxxflags'] + conf['warningflags'],
128              linkflags = conf['linkflags'])
129
130    #
131    # The Python toolkit.
132    #
133    bld(features = 'py',
134        source = ['__init__.py',
135                  'check.py',
136                  'config.py',
137                  'configuration.py',
138                  'darwin.py',
139                  'error.py',
140                  'execute.py',
141                  'freebsd.py',
142                  'git.py',
143                  'host.py',
144                  'linux.py',
145                  'log.py',
146                  'macros.py',
147                  'mailer.py',
148                  'options.py',
149                  'path.py',
150                  'reraise.py',
151                  'stacktraces.py',
152                  'textbox.py',
153                  'version.py',
154                  'windows.py'],
155        install_from = '.',
156        install_path = '${PREFIX}/share/rtems/rtemstoolkit')
157
158def rebuild(ctx):
159    import waflib.Options
160    waflib.Options.commands.extend(['clean', 'build'])
161
162def tags(ctx):
163    ctx.exec_command('etags $(find . -name \*.[sSch])', shell = True)
164
165#
166# Libelf module.
167#
168def conf_elftoolchain(conf):
169    pass
170
171def bld_elftoolchain(bld, conf):
172    libelf = 'elftoolchain/libelf/'
173    libelftc = 'elftoolchain/libelftc/'
174    libdwarf = 'elftoolchain/libdwarf/'
175    libelf_m4_rule = '${M4} -D SRCDIR=../rtemstoolkit/' + libelf[:-1] + ' ${SRC} > ${TGT}'
176    libdwarf_m4_rule = '${M4} -D SRCDIR=../rtemstoolkit/' + libdwarf[:-1] + ' ${SRC} > ${TGT}'
177    if bld.env.DEST_OS == 'win32':
178        includes = ['win32']
179    else:
180        includes = []
181
182    libelf_m4_source = ['libelf_convert.c',
183                        'libelf_fsize.c',
184                        'libelf_msize.c']
185    for s in libelf_m4_source:
186        bld(target = s, source = libelf + s[:-2] + '.m4', rule = libelf_m4_rule)
187
188    host_source = []
189
190    if bld.env.DEST_OS == 'linux':
191        common = 'elftoolchain/common/'
192        bld(target = common + 'native-elf-format.h',
193            source = common + 'native-elf-format',
194            name = 'native-elf-format',
195            rule   = './${SRC} > ${TGT}')
196        bld.add_group ()
197    elif bld.env.DEST_OS == 'win32':
198        host_source += [libelf + 'mmap_win32.c']
199
200    bld.stlib(target = 'elf',
201              features = 'c',
202              install_path = None,
203              uses = ['native-elf-format'],
204              includes = [bld.bldnode.abspath(),
205                          'elftoolchain/libelf', 'elftoolchain/common'] + includes,
206              cflags = conf['cflags'],
207              source =[libelf + 'elf.c',
208                       libelf + 'elf_begin.c',
209                       libelf + 'elf_cntl.c',
210                       libelf + 'elf_end.c',
211                       libelf + 'elf_errmsg.c',
212                       libelf + 'elf_errno.c',
213                       libelf + 'elf_data.c',
214                       libelf + 'elf_fill.c',
215                       libelf + 'elf_flag.c',
216                       libelf + 'elf_getarhdr.c',
217                       libelf + 'elf_getarsym.c',
218                       libelf + 'elf_getbase.c',
219                       libelf + 'elf_getident.c',
220                       libelf + 'elf_hash.c',
221                       libelf + 'elf_kind.c',
222                       libelf + 'elf_memory.c',
223                       libelf + 'elf_next.c',
224                       libelf + 'elf_open.c',
225                       libelf + 'elf_rand.c',
226                       libelf + 'elf_rawfile.c',
227                       libelf + 'elf_phnum.c',
228                       libelf + 'elf_shnum.c',
229                       libelf + 'elf_shstrndx.c',
230                       libelf + 'elf_scn.c',
231                       libelf + 'elf_strptr.c',
232                       libelf + 'elf_update.c',
233                       libelf + 'elf_version.c',
234                       libelf + 'gelf_cap.c',
235                       libelf + 'gelf_checksum.c',
236                       libelf + 'gelf_dyn.c',
237                       libelf + 'gelf_ehdr.c',
238                       libelf + 'gelf_getclass.c',
239                       libelf + 'gelf_fsize.c',
240                       libelf + 'gelf_move.c',
241                       libelf + 'gelf_phdr.c',
242                       libelf + 'gelf_rel.c',
243                       libelf + 'gelf_rela.c',
244                       libelf + 'gelf_shdr.c',
245                       libelf + 'gelf_sym.c',
246                       libelf + 'gelf_syminfo.c',
247                       libelf + 'gelf_symshndx.c',
248                       libelf + 'gelf_xlate.c',
249                       libelf + 'libelf_align.c',
250                       libelf + 'libelf_allocate.c',
251                       libelf + 'libelf_ar.c',
252                       libelf + 'libelf_ar_util.c',
253                       libelf + 'libelf_checksum.c',
254                       libelf + 'libelf_data.c',
255                       libelf + 'libelf_ehdr.c',
256                       libelf + 'libelf_extended.c',
257                       libelf + 'libelf_memory.c',
258                       libelf + 'libelf_open.c',
259                       libelf + 'libelf_phdr.c',
260                       libelf + 'libelf_shdr.c',
261                       libelf + 'libelf_xlate.c'] + libelf_m4_source + host_source)
262
263    libdwarf_m4_source = ['dwarf_funcs.c',
264                          'dwarf_pro_funcs.c',
265                          'dwarf_pro_pubnames.c',
266                          'dwarf_pro_types.c',
267                          'dwarf_pro_vars.c',
268                          'dwarf_pro_weaks.c',
269                          'dwarf_pubnames.c',
270                          'dwarf_pubtypes.c',
271                          'dwarf_types.c',
272                          'dwarf_vars.c',
273                          'dwarf_weaks.c']
274    for s in libdwarf_m4_source:
275        bld(target = s, source = libdwarf + s[:-2] + '.m4', rule = libdwarf_m4_rule)
276
277    bld.stlib(target = 'dwarf',
278              features = 'c',
279              install_path = None,
280              includes = [bld.bldnode.abspath(),
281                          'elftoolchain/libelf',
282                          'elftoolchain/libdwarf',
283                          'elftoolchain/common'] + includes,
284              cflags = conf['cflags'],
285              source =[libdwarf + 'dwarf_abbrev.c',
286                       libdwarf + 'dwarf_arange.c',
287                       libdwarf + 'dwarf_attr.c',
288                       libdwarf + 'dwarf_attrval.c',
289                       libdwarf + 'dwarf_cu.c',
290                       libdwarf + 'dwarf_dealloc.c',
291                       libdwarf + 'dwarf_die.c',
292                       libdwarf + 'dwarf_dump.c',
293                       libdwarf + 'dwarf_errmsg.c',
294                       libdwarf + 'dwarf_finish.c',
295                       libdwarf + 'dwarf_form.c',
296                       libdwarf + 'dwarf_frame.c',
297                       libdwarf + 'dwarf_init.c',
298                       libdwarf + 'dwarf_lineno.c',
299                       libdwarf + 'dwarf_loclist.c',
300                       libdwarf + 'dwarf_macinfo.c',
301                       libdwarf + 'dwarf_pro_arange.c',
302                       libdwarf + 'dwarf_pro_attr.c',
303                       libdwarf + 'dwarf_pro_die.c',
304                       libdwarf + 'dwarf_pro_expr.c',
305                       libdwarf + 'dwarf_pro_finish.c',
306                       libdwarf + 'dwarf_pro_frame.c',
307                       libdwarf + 'dwarf_pro_init.c',
308                       libdwarf + 'dwarf_pro_lineno.c',
309                       libdwarf + 'dwarf_pro_macinfo.c',
310                       libdwarf + 'dwarf_pro_reloc.c',
311                       libdwarf + 'dwarf_pro_sections.c',
312                       libdwarf + 'dwarf_ranges.c',
313                       libdwarf + 'dwarf_reloc.c',
314                       libdwarf + 'dwarf_seterror.c',
315                       libdwarf + 'dwarf_str.c',
316                       libdwarf + 'libdwarf.c',
317                       libdwarf + 'libdwarf_abbrev.c',
318                       libdwarf + 'libdwarf_arange.c',
319                       libdwarf + 'libdwarf_attr.c',
320                       libdwarf + 'libdwarf_die.c',
321                       libdwarf + 'libdwarf_error.c',
322                       libdwarf + 'libdwarf_elf_access.c',
323                       libdwarf + 'libdwarf_elf_init.c',
324                       libdwarf + 'libdwarf_frame.c',
325                       libdwarf + 'libdwarf_info.c',
326                       libdwarf + 'libdwarf_init.c',
327                       libdwarf + 'libdwarf_lineno.c',
328                       libdwarf + 'libdwarf_loc.c',
329                       libdwarf + 'libdwarf_loclist.c',
330                       libdwarf + 'libdwarf_macinfo.c',
331                       libdwarf + 'libdwarf_nametbl.c',
332                       libdwarf + 'libdwarf_ranges.c',
333                       libdwarf + 'libdwarf_reloc.c',
334                       libdwarf + 'libdwarf_rw.c',
335                       libdwarf + 'libdwarf_sections.c',
336                       libdwarf + 'libdwarf_str.c'] + libdwarf_m4_source)
337
338    bld.stlib(target = 'elftc',
339              features = 'c',
340              install_path = None,
341              includes = [bld.bldnode.abspath(),
342                          'elftoolchain/libelf',
343                          'elftoolchain/libelftc',
344                          'elftoolchain/common'] + includes,
345              cflags = conf['cflags'],
346              source =[libelftc + 'elftc_bfdtarget.c',
347                       libelftc + 'elftc_copyfile.c',
348                       libelftc + 'elftc_demangle.c',
349                       libelftc + 'elftc_reloc_type_str.c',
350                       libelftc + 'elftc_set_timestamps.c',
351                       libelftc + 'elftc_string_table.c',
352                       libelftc + 'elftc_timestamp.c',
353                       libelftc + 'elftc_version.c',
354                       libelftc + 'libelftc_bfdtarget.c',
355                       libelftc + 'libelftc_dem_arm.c',
356                       libelftc + 'libelftc_dem_gnu2.c',
357                       libelftc + 'libelftc_dem_gnu3.c',
358                       libelftc + 'libelftc_hash.c',
359                       libelftc + 'libelftc_vstr.c'])
360
361#
362# Libiberty module.
363#
364def conf_libiberty(conf):
365    conf.check(header_name='alloca.h',    features = 'c', mandatory = False)
366    conf.check(header_name='fcntl.h',     features = 'c', mandatory = False)
367    conf.check(header_name='process.h',   features = 'c', mandatory = False)
368    conf.check(header_name='stdlib.h',    features = 'c')
369    conf.check(header_name='string.h',    features = 'c')
370    conf.check(header_name='strings.h',   features = 'c', mandatory = False)
371    conf.check(header_name='sys/file.h',  features = 'c', mandatory = False)
372    conf.check(header_name='sys/stat.h',  features = 'c', mandatory = False)
373    conf.check(header_name='sys/time.h',  features = 'c', mandatory = False)
374    conf.check(header_name='sys/types.h', features = 'c', mandatory = False)
375    conf.check(header_name='sys/wait.h',  features = 'c', mandatory = False)
376    conf.check(header_name='unistd.h',    features = 'c', mandatory = False)
377    conf.check(header_name='vfork.h',     features = 'c', mandatory = False)
378
379    conf.check_cc(function_name='getrusage',
380                  header_name="sys/time.h sys/resource.h",
381                  features = 'c', mandatory = False)
382
383    conf.write_config_header('libiberty/config.h')
384
385def bld_libiberty(bld, conf):
386    if bld.env.DEST_OS == 'win32':
387        pex_host = 'libiberty/pex-win32.c'
388    else:
389        pex_host = 'libiberty/pex-unix.c'
390    bld.stlib(target = 'iberty',
391              features = 'c',
392              install_path = None,
393              includes = ['libiberty'],
394              cflags = conf['cflags'],
395              defines = ['HAVE_CONFIG_H=1'],
396              source =['libiberty/concat.c',
397                       'libiberty/cplus-dem.c',
398                       'libiberty/cp-demangle.c',
399                       'libiberty/d-demangle.c',
400                       'libiberty/rust-demangle.c',
401                       'libiberty/make-temp-file.c',
402                       'libiberty/mkstemps.c',
403                       'libiberty/safe-ctype.c',
404                       'libiberty/stpcpy.c',
405                       'libiberty/pex-common.c',
406                       'libiberty/pex-one.c',
407                       'libiberty/xmalloc.c',
408                       'libiberty/xmemdup.c',
409                       'libiberty/xstrdup.c',
410                       'libiberty/xstrerror.c',
411                       pex_host])
412
413#
414# The doxy command.
415#
416from waflib import Build
417class doxy(Build.BuildContext):
418    fun = 'build'
419    cmd = 'doxy'
Note: See TracBrowser for help on using the repository browser.