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 | # |
---|
24 | import sys |
---|
25 | |
---|
26 | # |
---|
27 | # Waf system setup. Allow more than one build in the same tree. |
---|
28 | # |
---|
29 | top = '.' |
---|
30 | out = 'build-' + sys.platform |
---|
31 | |
---|
32 | def init(ctx): |
---|
33 | pass |
---|
34 | |
---|
35 | def options(opt): |
---|
36 | opt.load('compiler_c') |
---|
37 | opt.load('compiler_cxx') |
---|
38 | |
---|
39 | def 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 | |
---|
52 | def 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 | 'rtems.py', |
---|
152 | 'stacktraces.py', |
---|
153 | 'textbox.py', |
---|
154 | 'version.py', |
---|
155 | 'windows.py'], |
---|
156 | install_from = '.', |
---|
157 | install_path = '${PREFIX}/share/rtems/rtemstoolkit') |
---|
158 | bld.install_files('${PREFIX}/share/rtems/rtemstoolkit', |
---|
159 | 'python-wrapper.sh', |
---|
160 | relative_trick = True) |
---|
161 | |
---|
162 | def rebuild(ctx): |
---|
163 | import waflib.Options |
---|
164 | waflib.Options.commands.extend(['clean', 'build']) |
---|
165 | |
---|
166 | def tags(ctx): |
---|
167 | ctx.exec_command('etags $(find . -name \*.[sSch])', shell = True) |
---|
168 | |
---|
169 | # |
---|
170 | # Libelf module. |
---|
171 | # |
---|
172 | def conf_elftoolchain(conf): |
---|
173 | pass |
---|
174 | |
---|
175 | def bld_elftoolchain(bld, conf): |
---|
176 | libelf = 'elftoolchain/libelf/' |
---|
177 | libelftc = 'elftoolchain/libelftc/' |
---|
178 | libdwarf = 'elftoolchain/libdwarf/' |
---|
179 | libelf_m4_rule = '${M4} -D SRCDIR=../rtemstoolkit/' + libelf[:-1] + ' ${SRC} > ${TGT}' |
---|
180 | libdwarf_m4_rule = '${M4} -D SRCDIR=../rtemstoolkit/' + libdwarf[:-1] + ' ${SRC} > ${TGT}' |
---|
181 | if bld.env.DEST_OS == 'win32': |
---|
182 | includes = ['win32'] |
---|
183 | else: |
---|
184 | includes = [] |
---|
185 | |
---|
186 | libelf_m4_source = ['libelf_convert.c', |
---|
187 | 'libelf_fsize.c', |
---|
188 | 'libelf_msize.c'] |
---|
189 | for s in libelf_m4_source: |
---|
190 | bld(target = s, source = libelf + s[:-2] + '.m4', rule = libelf_m4_rule) |
---|
191 | |
---|
192 | host_source = [] |
---|
193 | |
---|
194 | if bld.env.DEST_OS == 'linux': |
---|
195 | common = 'elftoolchain/common/' |
---|
196 | bld(target = common + 'native-elf-format.h', |
---|
197 | source = common + 'native-elf-format', |
---|
198 | name = 'native-elf-format', |
---|
199 | rule = './${SRC} > ${TGT}') |
---|
200 | bld.add_group () |
---|
201 | elif bld.env.DEST_OS == 'win32': |
---|
202 | host_source += [libelf + 'mmap_win32.c'] |
---|
203 | |
---|
204 | bld.stlib(target = 'elf', |
---|
205 | features = 'c', |
---|
206 | install_path = None, |
---|
207 | uses = ['native-elf-format'], |
---|
208 | includes = [bld.bldnode.abspath(), |
---|
209 | 'elftoolchain/libelf', 'elftoolchain/common'] + includes, |
---|
210 | cflags = conf['cflags'], |
---|
211 | source =[libelf + 'elf.c', |
---|
212 | libelf + 'elf_begin.c', |
---|
213 | libelf + 'elf_cntl.c', |
---|
214 | libelf + 'elf_end.c', |
---|
215 | libelf + 'elf_errmsg.c', |
---|
216 | libelf + 'elf_errno.c', |
---|
217 | libelf + 'elf_data.c', |
---|
218 | libelf + 'elf_fill.c', |
---|
219 | libelf + 'elf_flag.c', |
---|
220 | libelf + 'elf_getarhdr.c', |
---|
221 | libelf + 'elf_getarsym.c', |
---|
222 | libelf + 'elf_getbase.c', |
---|
223 | libelf + 'elf_getident.c', |
---|
224 | libelf + 'elf_hash.c', |
---|
225 | libelf + 'elf_kind.c', |
---|
226 | libelf + 'elf_memory.c', |
---|
227 | libelf + 'elf_next.c', |
---|
228 | libelf + 'elf_open.c', |
---|
229 | libelf + 'elf_rand.c', |
---|
230 | libelf + 'elf_rawfile.c', |
---|
231 | libelf + 'elf_phnum.c', |
---|
232 | libelf + 'elf_shnum.c', |
---|
233 | libelf + 'elf_shstrndx.c', |
---|
234 | libelf + 'elf_scn.c', |
---|
235 | libelf + 'elf_strptr.c', |
---|
236 | libelf + 'elf_update.c', |
---|
237 | libelf + 'elf_version.c', |
---|
238 | libelf + 'gelf_cap.c', |
---|
239 | libelf + 'gelf_checksum.c', |
---|
240 | libelf + 'gelf_dyn.c', |
---|
241 | libelf + 'gelf_ehdr.c', |
---|
242 | libelf + 'gelf_getclass.c', |
---|
243 | libelf + 'gelf_fsize.c', |
---|
244 | libelf + 'gelf_move.c', |
---|
245 | libelf + 'gelf_phdr.c', |
---|
246 | libelf + 'gelf_rel.c', |
---|
247 | libelf + 'gelf_rela.c', |
---|
248 | libelf + 'gelf_shdr.c', |
---|
249 | libelf + 'gelf_sym.c', |
---|
250 | libelf + 'gelf_syminfo.c', |
---|
251 | libelf + 'gelf_symshndx.c', |
---|
252 | libelf + 'gelf_xlate.c', |
---|
253 | libelf + 'libelf_align.c', |
---|
254 | libelf + 'libelf_allocate.c', |
---|
255 | libelf + 'libelf_ar.c', |
---|
256 | libelf + 'libelf_ar_util.c', |
---|
257 | libelf + 'libelf_checksum.c', |
---|
258 | libelf + 'libelf_data.c', |
---|
259 | libelf + 'libelf_ehdr.c', |
---|
260 | libelf + 'libelf_extended.c', |
---|
261 | libelf + 'libelf_memory.c', |
---|
262 | libelf + 'libelf_open.c', |
---|
263 | libelf + 'libelf_phdr.c', |
---|
264 | libelf + 'libelf_shdr.c', |
---|
265 | libelf + 'libelf_xlate.c'] + libelf_m4_source + host_source) |
---|
266 | |
---|
267 | libdwarf_m4_source = ['dwarf_funcs.c', |
---|
268 | 'dwarf_pro_funcs.c', |
---|
269 | 'dwarf_pro_pubnames.c', |
---|
270 | 'dwarf_pro_types.c', |
---|
271 | 'dwarf_pro_vars.c', |
---|
272 | 'dwarf_pro_weaks.c', |
---|
273 | 'dwarf_pubnames.c', |
---|
274 | 'dwarf_pubtypes.c', |
---|
275 | 'dwarf_types.c', |
---|
276 | 'dwarf_vars.c', |
---|
277 | 'dwarf_weaks.c'] |
---|
278 | for s in libdwarf_m4_source: |
---|
279 | bld(target = s, source = libdwarf + s[:-2] + '.m4', rule = libdwarf_m4_rule) |
---|
280 | |
---|
281 | bld.stlib(target = 'dwarf', |
---|
282 | features = 'c', |
---|
283 | install_path = None, |
---|
284 | includes = [bld.bldnode.abspath(), |
---|
285 | 'elftoolchain/libelf', |
---|
286 | 'elftoolchain/libdwarf', |
---|
287 | 'elftoolchain/common'] + includes, |
---|
288 | cflags = conf['cflags'], |
---|
289 | source =[libdwarf + 'dwarf_abbrev.c', |
---|
290 | libdwarf + 'dwarf_arange.c', |
---|
291 | libdwarf + 'dwarf_attr.c', |
---|
292 | libdwarf + 'dwarf_attrval.c', |
---|
293 | libdwarf + 'dwarf_cu.c', |
---|
294 | libdwarf + 'dwarf_dealloc.c', |
---|
295 | libdwarf + 'dwarf_die.c', |
---|
296 | libdwarf + 'dwarf_dump.c', |
---|
297 | libdwarf + 'dwarf_errmsg.c', |
---|
298 | libdwarf + 'dwarf_finish.c', |
---|
299 | libdwarf + 'dwarf_form.c', |
---|
300 | libdwarf + 'dwarf_frame.c', |
---|
301 | libdwarf + 'dwarf_init.c', |
---|
302 | libdwarf + 'dwarf_lineno.c', |
---|
303 | libdwarf + 'dwarf_loclist.c', |
---|
304 | libdwarf + 'dwarf_macinfo.c', |
---|
305 | libdwarf + 'dwarf_pro_arange.c', |
---|
306 | libdwarf + 'dwarf_pro_attr.c', |
---|
307 | libdwarf + 'dwarf_pro_die.c', |
---|
308 | libdwarf + 'dwarf_pro_expr.c', |
---|
309 | libdwarf + 'dwarf_pro_finish.c', |
---|
310 | libdwarf + 'dwarf_pro_frame.c', |
---|
311 | libdwarf + 'dwarf_pro_init.c', |
---|
312 | libdwarf + 'dwarf_pro_lineno.c', |
---|
313 | libdwarf + 'dwarf_pro_macinfo.c', |
---|
314 | libdwarf + 'dwarf_pro_reloc.c', |
---|
315 | libdwarf + 'dwarf_pro_sections.c', |
---|
316 | libdwarf + 'dwarf_ranges.c', |
---|
317 | libdwarf + 'dwarf_reloc.c', |
---|
318 | libdwarf + 'dwarf_seterror.c', |
---|
319 | libdwarf + 'dwarf_str.c', |
---|
320 | libdwarf + 'libdwarf.c', |
---|
321 | libdwarf + 'libdwarf_abbrev.c', |
---|
322 | libdwarf + 'libdwarf_arange.c', |
---|
323 | libdwarf + 'libdwarf_attr.c', |
---|
324 | libdwarf + 'libdwarf_die.c', |
---|
325 | libdwarf + 'libdwarf_error.c', |
---|
326 | libdwarf + 'libdwarf_elf_access.c', |
---|
327 | libdwarf + 'libdwarf_elf_init.c', |
---|
328 | libdwarf + 'libdwarf_frame.c', |
---|
329 | libdwarf + 'libdwarf_info.c', |
---|
330 | libdwarf + 'libdwarf_init.c', |
---|
331 | libdwarf + 'libdwarf_lineno.c', |
---|
332 | libdwarf + 'libdwarf_loc.c', |
---|
333 | libdwarf + 'libdwarf_loclist.c', |
---|
334 | libdwarf + 'libdwarf_macinfo.c', |
---|
335 | libdwarf + 'libdwarf_nametbl.c', |
---|
336 | libdwarf + 'libdwarf_ranges.c', |
---|
337 | libdwarf + 'libdwarf_reloc.c', |
---|
338 | libdwarf + 'libdwarf_rw.c', |
---|
339 | libdwarf + 'libdwarf_sections.c', |
---|
340 | libdwarf + 'libdwarf_str.c'] + libdwarf_m4_source) |
---|
341 | |
---|
342 | bld.stlib(target = 'elftc', |
---|
343 | features = 'c', |
---|
344 | install_path = None, |
---|
345 | includes = [bld.bldnode.abspath(), |
---|
346 | 'elftoolchain/libelf', |
---|
347 | 'elftoolchain/libelftc', |
---|
348 | 'elftoolchain/common'] + includes, |
---|
349 | cflags = conf['cflags'], |
---|
350 | source =[libelftc + 'elftc_bfdtarget.c', |
---|
351 | libelftc + 'elftc_copyfile.c', |
---|
352 | libelftc + 'elftc_demangle.c', |
---|
353 | libelftc + 'elftc_reloc_type_str.c', |
---|
354 | libelftc + 'elftc_set_timestamps.c', |
---|
355 | libelftc + 'elftc_string_table.c', |
---|
356 | libelftc + 'elftc_timestamp.c', |
---|
357 | libelftc + 'elftc_version.c', |
---|
358 | libelftc + 'libelftc_bfdtarget.c', |
---|
359 | libelftc + 'libelftc_dem_arm.c', |
---|
360 | libelftc + 'libelftc_dem_gnu2.c', |
---|
361 | libelftc + 'libelftc_dem_gnu3.c', |
---|
362 | libelftc + 'libelftc_hash.c', |
---|
363 | libelftc + 'libelftc_vstr.c']) |
---|
364 | |
---|
365 | # |
---|
366 | # Libiberty module. |
---|
367 | # |
---|
368 | def conf_libiberty(conf): |
---|
369 | conf.check(header_name='alloca.h', features = 'c', mandatory = False) |
---|
370 | conf.check(header_name='fcntl.h', features = 'c', mandatory = False) |
---|
371 | conf.check(header_name='process.h', features = 'c', mandatory = False) |
---|
372 | conf.check(header_name='stdlib.h', features = 'c') |
---|
373 | conf.check(header_name='string.h', features = 'c') |
---|
374 | conf.check(header_name='strings.h', features = 'c', mandatory = False) |
---|
375 | conf.check(header_name='sys/file.h', features = 'c', mandatory = False) |
---|
376 | conf.check(header_name='sys/stat.h', features = 'c', mandatory = False) |
---|
377 | conf.check(header_name='sys/time.h', features = 'c', mandatory = False) |
---|
378 | conf.check(header_name='sys/types.h', features = 'c', mandatory = False) |
---|
379 | conf.check(header_name='sys/wait.h', features = 'c', mandatory = False) |
---|
380 | conf.check(header_name='unistd.h', features = 'c', mandatory = False) |
---|
381 | conf.check(header_name='vfork.h', features = 'c', mandatory = False) |
---|
382 | |
---|
383 | conf.check_cc(function_name='getrusage', |
---|
384 | header_name="sys/time.h sys/resource.h", |
---|
385 | features = 'c', mandatory = False) |
---|
386 | |
---|
387 | conf.write_config_header('libiberty/config.h') |
---|
388 | |
---|
389 | def bld_libiberty(bld, conf): |
---|
390 | if bld.env.DEST_OS == 'win32': |
---|
391 | pex_host = 'libiberty/pex-win32.c' |
---|
392 | else: |
---|
393 | pex_host = 'libiberty/pex-unix.c' |
---|
394 | bld.stlib(target = 'iberty', |
---|
395 | features = 'c', |
---|
396 | install_path = None, |
---|
397 | includes = ['libiberty'], |
---|
398 | cflags = conf['cflags'], |
---|
399 | defines = ['HAVE_CONFIG_H=1'], |
---|
400 | source =['libiberty/concat.c', |
---|
401 | 'libiberty/cplus-dem.c', |
---|
402 | 'libiberty/cp-demangle.c', |
---|
403 | 'libiberty/d-demangle.c', |
---|
404 | 'libiberty/rust-demangle.c', |
---|
405 | 'libiberty/make-temp-file.c', |
---|
406 | 'libiberty/mkstemps.c', |
---|
407 | 'libiberty/safe-ctype.c', |
---|
408 | 'libiberty/stpcpy.c', |
---|
409 | 'libiberty/pex-common.c', |
---|
410 | 'libiberty/pex-one.c', |
---|
411 | 'libiberty/xmalloc.c', |
---|
412 | 'libiberty/xmemdup.c', |
---|
413 | 'libiberty/xstrdup.c', |
---|
414 | 'libiberty/xstrerror.c', |
---|
415 | pex_host]) |
---|
416 | |
---|
417 | # |
---|
418 | # The doxy command. |
---|
419 | # |
---|
420 | from waflib import Build |
---|
421 | class doxy(Build.BuildContext): |
---|
422 | fun = 'build' |
---|
423 | cmd = 'doxy' |
---|