1 | # |
---|
2 | # RTEMS Toolkit build script. |
---|
3 | # |
---|
4 | import sys |
---|
5 | |
---|
6 | version_major = 1 |
---|
7 | version_minor = 0 |
---|
8 | version_revision = 0 |
---|
9 | |
---|
10 | # |
---|
11 | # Waf system setup. Allow more than one build in the same tree. |
---|
12 | # |
---|
13 | top = '.' |
---|
14 | out = 'build-' + sys.platform |
---|
15 | |
---|
16 | def options(opt): |
---|
17 | opt.load("g++") |
---|
18 | opt.load("gcc") |
---|
19 | |
---|
20 | def configure(conf): |
---|
21 | conf.load("g++") |
---|
22 | conf.load("gcc") |
---|
23 | conf_libiberty(conf) |
---|
24 | conf_libelf(conf) |
---|
25 | |
---|
26 | conf.check(header_name='sys/wait.h', features = 'c', mandatory = False) |
---|
27 | conf.check_cc(function_name='kill', header_name="signal.h", |
---|
28 | features = 'c', mandatory = False) |
---|
29 | conf.write_config_header('config.h') |
---|
30 | |
---|
31 | def build(bld): |
---|
32 | # |
---|
33 | # The local configuration. |
---|
34 | # |
---|
35 | conf = {} |
---|
36 | |
---|
37 | # |
---|
38 | # The include paths. |
---|
39 | # |
---|
40 | conf['includes'] = ['elftoolchain/libelf', 'elftoolchain/common', 'libiberty'] |
---|
41 | if sys.platform == 'win32': |
---|
42 | conf['includes'] += ['win32'] |
---|
43 | |
---|
44 | # |
---|
45 | # Build flags. |
---|
46 | # |
---|
47 | conf['warningflags'] = ['-Wall', '-Wextra', '-pedantic'] |
---|
48 | conf['optflags'] = bld.env.C_OPTS |
---|
49 | conf['cflags'] = ['-pipe', '-g'] + conf['optflags'] |
---|
50 | conf['cxxflags'] = ['-pipe', '-g'] + conf['optflags'] |
---|
51 | conf['linkflags'] = ['-g'] |
---|
52 | |
---|
53 | # |
---|
54 | # Create each of the modules as object files each with their own |
---|
55 | # configurations. |
---|
56 | # |
---|
57 | bld_fastlz(bld, conf) |
---|
58 | bld_libelf(bld, conf) |
---|
59 | bld_libiberty(bld, conf) |
---|
60 | |
---|
61 | # |
---|
62 | # RLD source. |
---|
63 | # |
---|
64 | rld_source = ['ConvertUTF.c', |
---|
65 | 'pkgconfig.cpp', |
---|
66 | 'rld-config.cpp', |
---|
67 | 'rld-elf.cpp', |
---|
68 | 'rld-files.cpp', |
---|
69 | 'rld-cc.cpp', |
---|
70 | 'rld-compression.cpp', |
---|
71 | 'rld-outputter.cpp', |
---|
72 | 'rld-path.cpp', |
---|
73 | 'rld-process.cpp', |
---|
74 | 'rld-resolver.cpp', |
---|
75 | 'rld-rtems.cpp', |
---|
76 | 'rld-symbols.cpp', |
---|
77 | 'rld-rap.cpp', |
---|
78 | 'rld.cpp'] |
---|
79 | |
---|
80 | # |
---|
81 | # RTEMS Utilities. |
---|
82 | # |
---|
83 | rtems_utils = ['rtems-utils.cpp'] |
---|
84 | |
---|
85 | # |
---|
86 | # RTL static library |
---|
87 | # |
---|
88 | bld.stlib(target = 'rld', |
---|
89 | install_path = None, |
---|
90 | source = rld_source + rtems_utils, |
---|
91 | defines = ['HAVE_CONFIG_H=1', 'RTEMS_VERSION=' + bld.env.RTEMS_VERSION], |
---|
92 | includes = ['.'] + conf['includes'], |
---|
93 | cflags = conf['cflags'] + conf['warningflags'], |
---|
94 | cxxflags = conf['cxxflags'] + conf['warningflags'], |
---|
95 | linkflags = conf['linkflags']) |
---|
96 | |
---|
97 | def rebuild(ctx): |
---|
98 | import waflib.Options |
---|
99 | waflib.Options.commands.extend(['clean', 'build']) |
---|
100 | |
---|
101 | def tags(ctx): |
---|
102 | ctx.exec_command('etags $(find . -name \*.[sSch])', shell = True) |
---|
103 | |
---|
104 | # |
---|
105 | # Libelf module. |
---|
106 | # |
---|
107 | def conf_libelf(conf): |
---|
108 | pass |
---|
109 | |
---|
110 | def bld_fastlz(bld, conf): |
---|
111 | bld(target = 'fastlz', |
---|
112 | features = 'c', |
---|
113 | source = 'fastlz.c', |
---|
114 | cflags = conf['cflags'], |
---|
115 | defines = ['FASTLZ_LEVEL=1']) |
---|
116 | |
---|
117 | def bld_libelf(bld, conf): |
---|
118 | libelf = 'elftoolchain/libelf/' |
---|
119 | |
---|
120 | # |
---|
121 | # Work around the ${SRC} having Windows slashes which the MSYS m4 does not |
---|
122 | # understand. |
---|
123 | # |
---|
124 | if sys.platform == 'win32': |
---|
125 | m4_rule = 'type ${SRC} | m4 -D SRCDIR=../rtemstoolkit/' + libelf[:-1] + '> ${TGT}"' |
---|
126 | includes = ['win32'] |
---|
127 | else: |
---|
128 | m4_rule = 'm4 -D SRCDIR=../rtemstoolkit/' + libelf[:-1] + ' ${SRC} > ${TGT}' |
---|
129 | includes = [] |
---|
130 | |
---|
131 | bld(target = 'libelf_convert.c', source = libelf + 'libelf_convert.m4', rule = m4_rule) |
---|
132 | bld(target = 'libelf_fsize.c', source = libelf + 'libelf_fsize.m4', rule = m4_rule) |
---|
133 | bld(target = 'libelf_msize.c', source = libelf + 'libelf_msize.m4', rule = m4_rule) |
---|
134 | |
---|
135 | host_source = [] |
---|
136 | |
---|
137 | if sys.platform == 'linux2': |
---|
138 | common = 'elftoolchain/common/' |
---|
139 | bld(target = common + 'native-elf-format.h', |
---|
140 | source = common + 'native-elf-format', |
---|
141 | name = 'native-elf-format', |
---|
142 | rule = './${SRC} > ${TGT}') |
---|
143 | bld.add_group () |
---|
144 | elif sys.platform == 'win32': |
---|
145 | host_source += [libelf + 'mmap_win32.c'] |
---|
146 | |
---|
147 | bld.stlib(target = 'elf', |
---|
148 | features = 'c', |
---|
149 | install_path = None, |
---|
150 | uses = ['native-elf-format'], |
---|
151 | includes = [bld.bldnode.abspath(), 'elftoolchain/libelf', 'elftoolchain/common'] + includes, |
---|
152 | cflags = conf['cflags'], |
---|
153 | source =[libelf + 'elf.c', |
---|
154 | libelf + 'elf_begin.c', |
---|
155 | libelf + 'elf_cntl.c', |
---|
156 | libelf + 'elf_end.c', |
---|
157 | libelf + 'elf_errmsg.c', |
---|
158 | libelf + 'elf_errno.c', |
---|
159 | libelf + 'elf_data.c', |
---|
160 | libelf + 'elf_fill.c', |
---|
161 | libelf + 'elf_flag.c', |
---|
162 | libelf + 'elf_getarhdr.c', |
---|
163 | libelf + 'elf_getarsym.c', |
---|
164 | libelf + 'elf_getbase.c', |
---|
165 | libelf + 'elf_getident.c', |
---|
166 | libelf + 'elf_hash.c', |
---|
167 | libelf + 'elf_kind.c', |
---|
168 | libelf + 'elf_memory.c', |
---|
169 | libelf + 'elf_next.c', |
---|
170 | libelf + 'elf_rand.c', |
---|
171 | libelf + 'elf_rawfile.c', |
---|
172 | libelf + 'elf_phnum.c', |
---|
173 | libelf + 'elf_shnum.c', |
---|
174 | libelf + 'elf_shstrndx.c', |
---|
175 | libelf + 'elf_scn.c', |
---|
176 | libelf + 'elf_strptr.c', |
---|
177 | libelf + 'elf_update.c', |
---|
178 | libelf + 'elf_version.c', |
---|
179 | libelf + 'gelf_cap.c', |
---|
180 | libelf + 'gelf_checksum.c', |
---|
181 | libelf + 'gelf_dyn.c', |
---|
182 | libelf + 'gelf_ehdr.c', |
---|
183 | libelf + 'gelf_getclass.c', |
---|
184 | libelf + 'gelf_fsize.c', |
---|
185 | libelf + 'gelf_move.c', |
---|
186 | libelf + 'gelf_phdr.c', |
---|
187 | libelf + 'gelf_rel.c', |
---|
188 | libelf + 'gelf_rela.c', |
---|
189 | libelf + 'gelf_shdr.c', |
---|
190 | libelf + 'gelf_sym.c', |
---|
191 | libelf + 'gelf_syminfo.c', |
---|
192 | libelf + 'gelf_symshndx.c', |
---|
193 | libelf + 'gelf_xlate.c', |
---|
194 | libelf + 'libelf_align.c', |
---|
195 | libelf + 'libelf_allocate.c', |
---|
196 | libelf + 'libelf_ar.c', |
---|
197 | libelf + 'libelf_ar_util.c', |
---|
198 | libelf + 'libelf_checksum.c', |
---|
199 | libelf + 'libelf_data.c', |
---|
200 | libelf + 'libelf_ehdr.c', |
---|
201 | libelf + 'libelf_extended.c', |
---|
202 | libelf + 'libelf_phdr.c', |
---|
203 | libelf + 'libelf_shdr.c', |
---|
204 | libelf + 'libelf_xlate.c', |
---|
205 | 'libelf_convert.c', |
---|
206 | 'libelf_fsize.c', |
---|
207 | 'libelf_msize.c'] + host_source) |
---|
208 | |
---|
209 | # |
---|
210 | # Libiberty module. |
---|
211 | # |
---|
212 | def conf_libiberty(conf): |
---|
213 | conf.check(header_name='alloca.h', features = 'c', mandatory = False) |
---|
214 | conf.check(header_name='fcntl.h', features = 'c', mandatory = False) |
---|
215 | conf.check(header_name='process.h', features = 'c', mandatory = False) |
---|
216 | conf.check(header_name='stdlib.h', features = 'c') |
---|
217 | conf.check(header_name='string.h', features = 'c') |
---|
218 | conf.check(header_name='strings.h', features = 'c', mandatory = False) |
---|
219 | conf.check(header_name='sys/file.h', features = 'c', mandatory = False) |
---|
220 | conf.check(header_name='sys/stat.h', features = 'c', mandatory = False) |
---|
221 | conf.check(header_name='sys/time.h', features = 'c', mandatory = False) |
---|
222 | conf.check(header_name='sys/types.h', features = 'c', mandatory = False) |
---|
223 | conf.check(header_name='sys/wait.h', features = 'c', mandatory = False) |
---|
224 | conf.check(header_name='unistd.h', features = 'c', mandatory = False) |
---|
225 | conf.check(header_name='vfork.h', features = 'c', mandatory = False) |
---|
226 | |
---|
227 | conf.check_cc(function_name='getrusage', |
---|
228 | header_name="sys/time.h sys/resource.h", |
---|
229 | features = 'c', mandatory = False) |
---|
230 | |
---|
231 | conf.write_config_header('libiberty/config.h') |
---|
232 | |
---|
233 | def bld_libiberty(bld, conf): |
---|
234 | if sys.platform == 'win32': |
---|
235 | pex_host = 'libiberty/pex-win32.c' |
---|
236 | else: |
---|
237 | pex_host = 'libiberty/pex-unix.c' |
---|
238 | bld.stlib(target = 'iberty', |
---|
239 | features = 'c', |
---|
240 | install_path = None, |
---|
241 | includes = ['libiberty'], |
---|
242 | cflags = conf['cflags'], |
---|
243 | defines = ['HAVE_CONFIG_H=1'], |
---|
244 | source =['libiberty/concat.c', |
---|
245 | 'libiberty/cplus-dem.c', |
---|
246 | 'libiberty/cp-demangle.c', |
---|
247 | 'libiberty/make-temp-file.c', |
---|
248 | 'libiberty/mkstemps.c', |
---|
249 | 'libiberty/safe-ctype.c', |
---|
250 | 'libiberty/stpcpy.c', |
---|
251 | 'libiberty/pex-common.c', |
---|
252 | 'libiberty/pex-one.c', |
---|
253 | pex_host]) |
---|
254 | |
---|
255 | # |
---|
256 | # The doxy command. |
---|
257 | # |
---|
258 | from waflib import Build |
---|
259 | class doxy(Build.BuildContext): |
---|
260 | fun = 'build' |
---|
261 | cmd = 'doxy' |
---|