source: rtems-tools/rtemstoolkit/wscript @ b7b19f4

5
Last change on this file since b7b19f4 was d7979de, checked in by Chris Johns <chrisj@…>, on 05/27/19 at 00:08:27

waf: Update the check_cc tests to a newer method supported by waf.

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