1 | # |
---|
2 | # RTEMS Project (https://www.rtems.org/) |
---|
3 | # |
---|
4 | # Copyright (c) 2015-2016 Chris Johns <chrisj@rtems.org>. All rights reserved. |
---|
5 | # |
---|
6 | # Redistribution and use in source and binary forms, with or without |
---|
7 | # modification, are permitted provided that the following conditions |
---|
8 | # are met: |
---|
9 | # 1. Redistributions of source code must retain the above copyright |
---|
10 | # notice, this list of conditions and the following disclaimer. |
---|
11 | # 2. Redistributions in binary form must reproduce the above copyright |
---|
12 | # notice, this list of conditions and the following disclaimer in the |
---|
13 | # documentation and/or other materials provided with the distribution. |
---|
14 | # |
---|
15 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
---|
16 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
---|
17 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
---|
18 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
---|
19 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
---|
20 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
---|
21 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
---|
22 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
---|
23 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
---|
24 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
---|
25 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
---|
26 | |
---|
27 | # |
---|
28 | # RTEMS LibBSD is a transparent source build of the FreeBSD kernel source for RTEMS. |
---|
29 | # |
---|
30 | # To use see README.waf shipped with this file. |
---|
31 | # |
---|
32 | |
---|
33 | from __future__ import print_function |
---|
34 | |
---|
35 | rtems_version = "5" |
---|
36 | |
---|
37 | try: |
---|
38 | import rtems_waf.rtems as rtems |
---|
39 | except: |
---|
40 | print("error: no rtems_waf git submodule; see README.waf") |
---|
41 | import sys |
---|
42 | sys.exit(1) |
---|
43 | |
---|
44 | import libbsd_waf |
---|
45 | |
---|
46 | def init(ctx): |
---|
47 | rtems.init(ctx, version = rtems_version, long_commands = True) |
---|
48 | libbsd_waf.init(ctx) |
---|
49 | |
---|
50 | def options(opt): |
---|
51 | rtems.options(opt) |
---|
52 | opt.add_option("--enable-auto-regen", |
---|
53 | action = "store_true", |
---|
54 | default = False, |
---|
55 | dest = "auto_regen", |
---|
56 | help = "Enable auto-regeneration of LEX, RPC and YACC files.") |
---|
57 | opt.add_option("--enable-warnings", |
---|
58 | action = "store_true", |
---|
59 | default = False, |
---|
60 | dest = "warnings", |
---|
61 | help = "Enable all warnings. The default is quiet builds.") |
---|
62 | opt.add_option("--net-test-config", |
---|
63 | default = "config.inc", |
---|
64 | dest = "net_config", |
---|
65 | help = "Network test configuration.") |
---|
66 | opt.add_option("--freebsd-options", |
---|
67 | action = "store", |
---|
68 | default = "", |
---|
69 | dest = "freebsd_options", |
---|
70 | help = "Set FreeBSD options (developer option).") |
---|
71 | opt.add_option("--optimization", |
---|
72 | action = "store", |
---|
73 | default = "2", |
---|
74 | dest = "optimization", |
---|
75 | help = "Set optimization level to OPTIMIZATION (-On compiler flag). Default is 2 (-O2).") |
---|
76 | libbsd_waf.options(opt) |
---|
77 | |
---|
78 | def bsp_configure(conf, arch_bsp): |
---|
79 | conf.check(header_name = "dlfcn.h", features = "c") |
---|
80 | conf.check(header_name = "rtems/pci.h", features = "c", mandatory = False) |
---|
81 | if not rtems.check_posix(conf): |
---|
82 | conf.fatal("RTEMS kernel POSIX support is disabled; configure RTEMS with --enable-posix") |
---|
83 | if rtems.check_networking(conf): |
---|
84 | conf.fatal("RTEMS kernel contains the old network support; configure RTEMS with --disable-networking") |
---|
85 | libbsd_waf.bsp_configure(conf, arch_bsp) |
---|
86 | |
---|
87 | def configure(conf): |
---|
88 | if conf.options.auto_regen: |
---|
89 | conf.find_program("lex", mandatory = True) |
---|
90 | conf.find_program("rpcgen", mandatory = True) |
---|
91 | conf.find_program("yacc", mandatory = True) |
---|
92 | conf.env.AUTO_REGEN = conf.options.auto_regen |
---|
93 | conf.env.WARNINGS = conf.options.warnings |
---|
94 | conf.env.NET_CONFIG = conf.options.net_config |
---|
95 | conf.env.FREEBSD_OPTIONS =conf.options.freebsd_options |
---|
96 | conf.env.OPTIMIZATION = conf.options.optimization |
---|
97 | rtems.configure(conf, bsp_configure) |
---|
98 | libbsd_waf.configure(conf) |
---|
99 | |
---|
100 | def build(bld): |
---|
101 | rtems.build(bld) |
---|
102 | libbsd_waf.build(bld) |
---|