1 | #!/usr/bin/env python
|
---|
2 | #
|
---|
3 | # Copyright (c) 2010 Martin Decky
|
---|
4 | # 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 | #
|
---|
10 | # - Redistributions of source code must retain the above copyright
|
---|
11 | # notice, this list of conditions and the following disclaimer.
|
---|
12 | # - Redistributions in binary form must reproduce the above copyright
|
---|
13 | # notice, this list of conditions and the following disclaimer in the
|
---|
14 | # documentation and/or other materials provided with the distribution.
|
---|
15 | # - The name of the author may not be used to endorse or promote products
|
---|
16 | # derived from this software without specific prior written permission.
|
---|
17 | #
|
---|
18 | # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
19 | # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
20 | # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
21 | # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
22 | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
23 | # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
24 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
25 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
26 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
27 | # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
28 | #
|
---|
29 |
|
---|
30 | """
|
---|
31 | Detect important prerequisites and parameters for building HelenOS
|
---|
32 | """
|
---|
33 |
|
---|
34 | import sys
|
---|
35 | import os
|
---|
36 | import shutil
|
---|
37 | import re
|
---|
38 | import time
|
---|
39 | import subprocess
|
---|
40 |
|
---|
41 | SANDBOX = 'autotool'
|
---|
42 | CONFIG = 'Makefile.config'
|
---|
43 | MAKEFILE = 'Makefile.common'
|
---|
44 | HEADER = 'common.h'
|
---|
45 | GUARD = 'AUTOTOOL_COMMON_H_'
|
---|
46 |
|
---|
47 | PROBE_SOURCE = 'probe.c'
|
---|
48 | PROBE_OUTPUT = 'probe.s'
|
---|
49 |
|
---|
50 | PROBE_INT128_SOURCE = 'probe_int128.c'
|
---|
51 | PROBE_INT128_OUTPUT = 'probe_int128.s'
|
---|
52 |
|
---|
53 | PACKAGE_BINUTILS = "usually part of binutils"
|
---|
54 | PACKAGE_GCC = "preferably version 4.7.0 or newer"
|
---|
55 | PACKAGE_CROSS = "use tools/toolchain.sh to build the cross-compiler toolchain"
|
---|
56 | PACKAGE_CLANG = "reasonably recent version of clang needs to be installed"
|
---|
57 |
|
---|
58 | COMPILER_FAIL = "The compiler is probably not capable to compile HelenOS."
|
---|
59 | COMPILER_WARNING = "The compilation of HelenOS might fail."
|
---|
60 |
|
---|
61 | PROBE_HEAD = """#define AUTOTOOL_DECLARE(category, subcategory, tag, name, strc, conc, value) \\
|
---|
62 | asm volatile ( \\
|
---|
63 | "AUTOTOOL_DECLARE\\t" category "\\t" subcategory "\\t" tag "\\t" name "\\t" strc "\\t" conc "\\t%[val]\\n" \\
|
---|
64 | : \\
|
---|
65 | : [val] "n" (value) \\
|
---|
66 | )
|
---|
67 |
|
---|
68 | #define STRING(arg) STRING_ARG(arg)
|
---|
69 | #define STRING_ARG(arg) #arg
|
---|
70 |
|
---|
71 | #define DECLARE_BUILTIN_TYPE(tag, type) \\
|
---|
72 | AUTOTOOL_DECLARE("builtin_size", "", tag, STRING(type), "", "", sizeof(type)); \\
|
---|
73 | AUTOTOOL_DECLARE("builtin_sign", "unsigned long long int", tag, STRING(type), "unsigned", "", __builtin_types_compatible_p(type, unsigned long long int)); \\
|
---|
74 | AUTOTOOL_DECLARE("builtin_sign", "unsigned long int", tag, STRING(type), "unsigned", "", __builtin_types_compatible_p(type, unsigned long int)); \\
|
---|
75 | AUTOTOOL_DECLARE("builtin_sign", "unsigned int", tag, STRING(type), "unsigned", "", __builtin_types_compatible_p(type, unsigned int)); \\
|
---|
76 | AUTOTOOL_DECLARE("builtin_sign", "unsigned short int", tag, STRING(type), "unsigned", "", __builtin_types_compatible_p(type, unsigned short int)); \\
|
---|
77 | AUTOTOOL_DECLARE("builtin_sign", "unsigned char", tag, STRING(type), "unsigned", "", __builtin_types_compatible_p(type, unsigned char)); \\
|
---|
78 | AUTOTOOL_DECLARE("builtin_sign", "signed long long int", tag, STRING(type), "signed", "", __builtin_types_compatible_p(type, signed long long int)); \\
|
---|
79 | AUTOTOOL_DECLARE("builtin_sign", "signed long int", tag, STRING(type), "signed", "", __builtin_types_compatible_p(type, signed long int)); \\
|
---|
80 | AUTOTOOL_DECLARE("builtin_sign", "signed int", tag, STRING(type), "signed", "", __builtin_types_compatible_p(type, signed int)); \\
|
---|
81 | AUTOTOOL_DECLARE("builtin_sign", "signed short int", tag, STRING(type), "signed", "", __builtin_types_compatible_p(type, signed short int)); \\
|
---|
82 | AUTOTOOL_DECLARE("builtin_sign", "signed char", tag, STRING(type), "signed", "", __builtin_types_compatible_p(type, signed char));
|
---|
83 |
|
---|
84 | #define DECLARE_INTSIZE(tag, type, strc, conc) \\
|
---|
85 | AUTOTOOL_DECLARE("intsize", "unsigned", tag, #type, strc, conc, sizeof(unsigned type)); \\
|
---|
86 | AUTOTOOL_DECLARE("intsize", "signed", tag, #type, strc, conc, sizeof(signed type));
|
---|
87 |
|
---|
88 | #define DECLARE_FLOATSIZE(tag, type) \\
|
---|
89 | AUTOTOOL_DECLARE("floatsize", "", tag, #type, "", "", sizeof(type));
|
---|
90 |
|
---|
91 | extern int main(int, char *[]);
|
---|
92 |
|
---|
93 | int main(int argc, char *argv[])
|
---|
94 | {
|
---|
95 | #ifdef __SIZE_TYPE__
|
---|
96 | DECLARE_BUILTIN_TYPE("size", __SIZE_TYPE__);
|
---|
97 | #endif
|
---|
98 | #ifdef __WCHAR_TYPE__
|
---|
99 | DECLARE_BUILTIN_TYPE("wchar", __WCHAR_TYPE__);
|
---|
100 | #endif
|
---|
101 | #ifdef __WINT_TYPE__
|
---|
102 | DECLARE_BUILTIN_TYPE("wint", __WINT_TYPE__);
|
---|
103 | #endif
|
---|
104 | """
|
---|
105 |
|
---|
106 | PROBE_TAIL = """}
|
---|
107 | """
|
---|
108 |
|
---|
109 | PROBE_INT128_HEAD = """#define AUTOTOOL_DECLARE(category, subcategory, tag, name, strc, conc, value) \\
|
---|
110 | asm volatile ( \\
|
---|
111 | "AUTOTOOL_DECLARE\\t" category "\\t" subcategory "\\t" tag "\\t" name "\\t" strc "\\t" conc "\\t%[val]\\n" \\
|
---|
112 | : \\
|
---|
113 | : [val] "n" (value) \\
|
---|
114 | )
|
---|
115 |
|
---|
116 | #define DECLARE_INTSIZE(tag, type) \\
|
---|
117 | AUTOTOOL_DECLARE("intsize", "unsigned", tag, #type, "", "", sizeof(unsigned type)); \\
|
---|
118 | AUTOTOOL_DECLARE("intsize", "signed", tag, #type, "", "", sizeof(signed type));
|
---|
119 |
|
---|
120 | extern int main(int, char *[]);
|
---|
121 |
|
---|
122 | int main(int argc, char *argv[])
|
---|
123 | {
|
---|
124 | """
|
---|
125 |
|
---|
126 | PROBE_INT128_TAIL = """}
|
---|
127 | """
|
---|
128 |
|
---|
129 | def read_config(fname, config):
|
---|
130 | "Read HelenOS build configuration"
|
---|
131 |
|
---|
132 | inf = open(fname, 'r')
|
---|
133 |
|
---|
134 | for line in inf:
|
---|
135 | res = re.match(r'^(?:#!# )?([^#]\w*)\s*=\s*(.*?)\s*$', line)
|
---|
136 | if (res):
|
---|
137 | config[res.group(1)] = res.group(2)
|
---|
138 |
|
---|
139 | inf.close()
|
---|
140 |
|
---|
141 | def print_error(msg):
|
---|
142 | "Print a bold error message"
|
---|
143 |
|
---|
144 | sys.stderr.write("\n")
|
---|
145 | sys.stderr.write("######################################################################\n")
|
---|
146 | sys.stderr.write("HelenOS build sanity check error:\n")
|
---|
147 | sys.stderr.write("\n")
|
---|
148 | sys.stderr.write("%s\n" % "\n".join(msg))
|
---|
149 | sys.stderr.write("######################################################################\n")
|
---|
150 | sys.stderr.write("\n")
|
---|
151 |
|
---|
152 | sys.exit(1)
|
---|
153 |
|
---|
154 | def print_warning(msg):
|
---|
155 | "Print a bold error message"
|
---|
156 |
|
---|
157 | sys.stderr.write("\n")
|
---|
158 | sys.stderr.write("######################################################################\n")
|
---|
159 | sys.stderr.write("HelenOS build sanity check warning:\n")
|
---|
160 | sys.stderr.write("\n")
|
---|
161 | sys.stderr.write("%s\n" % "\n".join(msg))
|
---|
162 | sys.stderr.write("######################################################################\n")
|
---|
163 | sys.stderr.write("\n")
|
---|
164 |
|
---|
165 | time.sleep(5)
|
---|
166 |
|
---|
167 | def sandbox_enter():
|
---|
168 | "Create a temporal sandbox directory for running tests"
|
---|
169 |
|
---|
170 | if (os.path.exists(SANDBOX)):
|
---|
171 | if (os.path.isdir(SANDBOX)):
|
---|
172 | try:
|
---|
173 | shutil.rmtree(SANDBOX)
|
---|
174 | except:
|
---|
175 | print_error(["Unable to cleanup the directory \"%s\"." % SANDBOX])
|
---|
176 | else:
|
---|
177 | print_error(["Please inspect and remove unexpected directory,",
|
---|
178 | "entry \"%s\"." % SANDBOX])
|
---|
179 |
|
---|
180 | try:
|
---|
181 | os.mkdir(SANDBOX)
|
---|
182 | except:
|
---|
183 | print_error(["Unable to create sandbox directory \"%s\"." % SANDBOX])
|
---|
184 |
|
---|
185 | owd = os.getcwd()
|
---|
186 | os.chdir(SANDBOX)
|
---|
187 |
|
---|
188 | return owd
|
---|
189 |
|
---|
190 | def sandbox_leave(owd):
|
---|
191 | "Leave the temporal sandbox directory"
|
---|
192 |
|
---|
193 | os.chdir(owd)
|
---|
194 |
|
---|
195 | def check_config(config, key):
|
---|
196 | "Check whether the configuration key exists"
|
---|
197 |
|
---|
198 | if (not key in config):
|
---|
199 | print_error(["Build configuration of HelenOS does not contain %s." % key,
|
---|
200 | "Try running \"make config\" again.",
|
---|
201 | "If the problem persists, please contact the developers of HelenOS."])
|
---|
202 |
|
---|
203 | def check_common(common, key):
|
---|
204 | "Check whether the common key exists"
|
---|
205 |
|
---|
206 | if (not key in common):
|
---|
207 | print_error(["Failed to determine the value %s." % key,
|
---|
208 | "Please contact the developers of HelenOS."])
|
---|
209 |
|
---|
210 | def get_target(config):
|
---|
211 | target = None
|
---|
212 | gnu_target = None
|
---|
213 | helenos_target = None
|
---|
214 | cc_args = []
|
---|
215 |
|
---|
216 | if (config['PLATFORM'] == "abs32le"):
|
---|
217 | check_config(config, "CROSS_TARGET")
|
---|
218 | target = config['CROSS_TARGET']
|
---|
219 |
|
---|
220 | if (config['CROSS_TARGET'] == "arm32"):
|
---|
221 | gnu_target = "arm-linux-gnueabi"
|
---|
222 | helenos_target = "arm-helenos-gnueabi"
|
---|
223 |
|
---|
224 | if (config['CROSS_TARGET'] == "ia32"):
|
---|
225 | gnu_target = "i686-pc-linux-gnu"
|
---|
226 | helenos_target = "i686-pc-helenos"
|
---|
227 |
|
---|
228 | if (config['CROSS_TARGET'] == "mips32"):
|
---|
229 | cc_args.append("-mabi=32")
|
---|
230 | gnu_target = "mipsel-linux-gnu"
|
---|
231 | helenos_target = "mipsel-helenos"
|
---|
232 |
|
---|
233 | if (config['PLATFORM'] == "amd64"):
|
---|
234 | target = config['PLATFORM']
|
---|
235 | gnu_target = "amd64-linux-gnu"
|
---|
236 | helenos_target = "amd64-helenos"
|
---|
237 |
|
---|
238 | if (config['PLATFORM'] == "arm32"):
|
---|
239 | target = config['PLATFORM']
|
---|
240 | gnu_target = "arm-linux-gnueabi"
|
---|
241 | helenos_target = "arm-helenos-gnueabi"
|
---|
242 |
|
---|
243 | if (config['PLATFORM'] == "ia32"):
|
---|
244 | target = config['PLATFORM']
|
---|
245 | gnu_target = "i686-pc-linux-gnu"
|
---|
246 | helenos_target = "i686-pc-helenos"
|
---|
247 |
|
---|
248 | if (config['PLATFORM'] == "ia64"):
|
---|
249 | target = config['PLATFORM']
|
---|
250 | gnu_target = "ia64-pc-linux-gnu"
|
---|
251 | helenos_target = "ia64-pc-helenos"
|
---|
252 |
|
---|
253 | if (config['PLATFORM'] == "mips32"):
|
---|
254 | check_config(config, "MACHINE")
|
---|
255 | cc_args.append("-mabi=32")
|
---|
256 |
|
---|
257 | if ((config['MACHINE'] == "msim") or (config['MACHINE'] == "lmalta")):
|
---|
258 | target = config['PLATFORM']
|
---|
259 | gnu_target = "mipsel-linux-gnu"
|
---|
260 | helenos_target = "mipsel-helenos"
|
---|
261 |
|
---|
262 | if ((config['MACHINE'] == "bmalta")):
|
---|
263 | target = "mips32eb"
|
---|
264 | gnu_target = "mips-linux-gnu"
|
---|
265 | helenos_target = "mips-helenos"
|
---|
266 |
|
---|
267 | if (config['PLATFORM'] == "mips64"):
|
---|
268 | check_config(config, "MACHINE")
|
---|
269 | cc_args.append("-mabi=64")
|
---|
270 |
|
---|
271 | if (config['MACHINE'] == "msim"):
|
---|
272 | target = config['PLATFORM']
|
---|
273 | gnu_target = "mips64el-linux-gnu"
|
---|
274 | helenos_target = "mips64el-helenos"
|
---|
275 |
|
---|
276 | if (config['PLATFORM'] == "ppc32"):
|
---|
277 | target = config['PLATFORM']
|
---|
278 | gnu_target = "ppc-linux-gnu"
|
---|
279 | helenos_target = "ppc-helenos"
|
---|
280 |
|
---|
281 | if (config['PLATFORM'] == "riscv64"):
|
---|
282 | target = config['PLATFORM']
|
---|
283 | gnu_target = "riscv64-unknown-linux-gnu"
|
---|
284 | helenos_target = "riscv64-helenos"
|
---|
285 |
|
---|
286 | if (config['PLATFORM'] == "sparc64"):
|
---|
287 | target = config['PLATFORM']
|
---|
288 | gnu_target = "sparc64-linux-gnu"
|
---|
289 | helenos_target = "sparc64-helenos"
|
---|
290 |
|
---|
291 | return (target, cc_args, gnu_target, helenos_target)
|
---|
292 |
|
---|
293 | def check_app(args, name, details):
|
---|
294 | "Check whether an application can be executed"
|
---|
295 |
|
---|
296 | try:
|
---|
297 | sys.stderr.write("Checking for %s ... " % args[0])
|
---|
298 | subprocess.Popen(args, stdout = subprocess.PIPE, stderr = subprocess.PIPE).wait()
|
---|
299 | except:
|
---|
300 | sys.stderr.write("failed\n")
|
---|
301 | print_error(["%s is missing." % name,
|
---|
302 | "",
|
---|
303 | "Execution of \"%s\" has failed. Please make sure that it" % " ".join(args),
|
---|
304 | "is installed in your system (%s)." % details])
|
---|
305 |
|
---|
306 | sys.stderr.write("ok\n")
|
---|
307 |
|
---|
308 | def check_app_alternatives(alts, args, name, details):
|
---|
309 | "Check whether an application can be executed (use several alternatives)"
|
---|
310 |
|
---|
311 | tried = []
|
---|
312 | found = None
|
---|
313 |
|
---|
314 | for alt in alts:
|
---|
315 | working = True
|
---|
316 | cmdline = [alt] + args
|
---|
317 | tried.append(" ".join(cmdline))
|
---|
318 |
|
---|
319 | try:
|
---|
320 | sys.stderr.write("Checking for %s ... " % alt)
|
---|
321 | subprocess.Popen(cmdline, stdout = subprocess.PIPE, stderr = subprocess.PIPE).wait()
|
---|
322 | except:
|
---|
323 | sys.stderr.write("failed\n")
|
---|
324 | working = False
|
---|
325 |
|
---|
326 | if (working):
|
---|
327 | sys.stderr.write("ok\n")
|
---|
328 | found = alt
|
---|
329 | break
|
---|
330 |
|
---|
331 | if (found is None):
|
---|
332 | print_error(["%s is missing." % name,
|
---|
333 | "",
|
---|
334 | "Please make sure that it is installed in your",
|
---|
335 | "system (%s)." % details,
|
---|
336 | "",
|
---|
337 | "The following alternatives were tried:"] + tried)
|
---|
338 |
|
---|
339 | return found
|
---|
340 |
|
---|
341 | def check_clang(path, prefix, common, details):
|
---|
342 | "Check for clang"
|
---|
343 |
|
---|
344 | common['CLANG'] = "%sclang" % prefix
|
---|
345 |
|
---|
346 | if (not path is None):
|
---|
347 | common['CLANG'] = "%s/%s" % (path, common['CLANG'])
|
---|
348 |
|
---|
349 | check_app([common['CLANG'], "--version"], "clang", details)
|
---|
350 |
|
---|
351 | def check_gcc(path, prefix, common, details):
|
---|
352 | "Check for GCC"
|
---|
353 |
|
---|
354 | common['GCC'] = "%sgcc" % prefix
|
---|
355 |
|
---|
356 | if (not path is None):
|
---|
357 | common['GCC'] = "%s/%s" % (path, common['GCC'])
|
---|
358 |
|
---|
359 | check_app([common['GCC'], "--version"], "GNU GCC", details)
|
---|
360 |
|
---|
361 | def check_binutils(path, prefix, common, details):
|
---|
362 | "Check for binutils toolchain"
|
---|
363 |
|
---|
364 | common['AS'] = "%sas" % prefix
|
---|
365 | common['LD'] = "%sld" % prefix
|
---|
366 | common['AR'] = "%sar" % prefix
|
---|
367 | common['OBJCOPY'] = "%sobjcopy" % prefix
|
---|
368 | common['OBJDUMP'] = "%sobjdump" % prefix
|
---|
369 | common['STRIP'] = "%sstrip" % prefix
|
---|
370 |
|
---|
371 | if (not path is None):
|
---|
372 | for key in ["AS", "LD", "AR", "OBJCOPY", "OBJDUMP", "STRIP"]:
|
---|
373 | common[key] = "%s/%s" % (path, common[key])
|
---|
374 |
|
---|
375 | check_app([common['AS'], "--version"], "GNU Assembler", details)
|
---|
376 | check_app([common['LD'], "--version"], "GNU Linker", details)
|
---|
377 | check_app([common['AR'], "--version"], "GNU Archiver", details)
|
---|
378 | check_app([common['OBJCOPY'], "--version"], "GNU Objcopy utility", details)
|
---|
379 | check_app([common['OBJDUMP'], "--version"], "GNU Objdump utility", details)
|
---|
380 | check_app([common['STRIP'], "--version"], "GNU strip", details)
|
---|
381 |
|
---|
382 | def check_python():
|
---|
383 | "Check for Python dependencies"
|
---|
384 |
|
---|
385 | try:
|
---|
386 | sys.stderr.write("Checking for PyYAML ... ")
|
---|
387 | import yaml
|
---|
388 | except ImportError:
|
---|
389 | print_error(["PyYAML is missing.",
|
---|
390 | "",
|
---|
391 | "Please make sure that it is installed in your",
|
---|
392 | "system (usually part of PyYAML package)."])
|
---|
393 |
|
---|
394 | sys.stderr.write("ok\n")
|
---|
395 |
|
---|
396 | def decode_value(value):
|
---|
397 | "Decode integer value"
|
---|
398 |
|
---|
399 | base = 10
|
---|
400 |
|
---|
401 | if ((value.startswith('$')) or (value.startswith('#'))):
|
---|
402 | value = value[1:]
|
---|
403 |
|
---|
404 | if (value.startswith('0x')):
|
---|
405 | value = value[2:]
|
---|
406 | base = 16
|
---|
407 |
|
---|
408 | return int(value, base)
|
---|
409 |
|
---|
410 | def probe_compiler(common, intsizes, floatsizes):
|
---|
411 | "Generate, compile and parse probing source"
|
---|
412 |
|
---|
413 | check_common(common, "CC")
|
---|
414 |
|
---|
415 | outf = open(PROBE_SOURCE, 'w')
|
---|
416 | outf.write(PROBE_HEAD)
|
---|
417 |
|
---|
418 | for typedef in intsizes:
|
---|
419 | outf.write("\tDECLARE_INTSIZE(\"%s\", %s, %s, %s);\n" % (typedef['tag'], typedef['type'], typedef['strc'], typedef['conc']))
|
---|
420 |
|
---|
421 | for typedef in floatsizes:
|
---|
422 | outf.write("\tDECLARE_FLOATSIZE(\"%s\", %s);\n" % (typedef['tag'], typedef['type']))
|
---|
423 |
|
---|
424 | outf.write(PROBE_TAIL)
|
---|
425 | outf.close()
|
---|
426 |
|
---|
427 | args = common['CC_AUTOGEN'].split(' ')
|
---|
428 | args.extend(["-S", "-o", PROBE_OUTPUT, PROBE_SOURCE])
|
---|
429 |
|
---|
430 | try:
|
---|
431 | sys.stderr.write("Checking compiler properties ... ")
|
---|
432 | output = subprocess.Popen(args, stdout = subprocess.PIPE, stderr = subprocess.PIPE).communicate()
|
---|
433 | except:
|
---|
434 | sys.stderr.write("failed\n")
|
---|
435 | print_error(["Error executing \"%s\"." % " ".join(args),
|
---|
436 | "Make sure that the compiler works properly."])
|
---|
437 |
|
---|
438 | if (not os.path.isfile(PROBE_OUTPUT)):
|
---|
439 | sys.stderr.write("failed\n")
|
---|
440 | print(output[1])
|
---|
441 | print_error(["Error executing \"%s\"." % " ".join(args),
|
---|
442 | "The compiler did not produce the output file \"%s\"." % PROBE_OUTPUT,
|
---|
443 | "",
|
---|
444 | output[0],
|
---|
445 | output[1]])
|
---|
446 |
|
---|
447 | sys.stderr.write("ok\n")
|
---|
448 |
|
---|
449 | inf = open(PROBE_OUTPUT, 'r')
|
---|
450 | lines = inf.readlines()
|
---|
451 | inf.close()
|
---|
452 |
|
---|
453 | unsigned_sizes = {}
|
---|
454 | signed_sizes = {}
|
---|
455 |
|
---|
456 | unsigned_tags = {}
|
---|
457 | signed_tags = {}
|
---|
458 |
|
---|
459 | unsigned_strcs = {}
|
---|
460 | signed_strcs = {}
|
---|
461 |
|
---|
462 | unsigned_concs = {}
|
---|
463 | signed_concs = {}
|
---|
464 |
|
---|
465 | float_tags = {}
|
---|
466 |
|
---|
467 | builtin_sizes = {}
|
---|
468 | builtin_signs = {}
|
---|
469 |
|
---|
470 | for j in range(len(lines)):
|
---|
471 | tokens = lines[j].strip().split("\t")
|
---|
472 |
|
---|
473 | if (len(tokens) > 0):
|
---|
474 | if (tokens[0] == "AUTOTOOL_DECLARE"):
|
---|
475 | if (len(tokens) < 7):
|
---|
476 | print_error(["Malformed declaration in \"%s\" on line %s." % (PROBE_OUTPUT, j), COMPILER_FAIL])
|
---|
477 |
|
---|
478 | category = tokens[1]
|
---|
479 | subcategory = tokens[2]
|
---|
480 | tag = tokens[3]
|
---|
481 | name = tokens[4]
|
---|
482 | strc = tokens[5]
|
---|
483 | conc = tokens[6]
|
---|
484 | value = tokens[7]
|
---|
485 |
|
---|
486 | if (category == "intsize"):
|
---|
487 | try:
|
---|
488 | value_int = decode_value(value)
|
---|
489 | except:
|
---|
490 | print_error(["Integer value expected in \"%s\" on line %s." % (PROBE_OUTPUT, j), COMPILER_FAIL])
|
---|
491 |
|
---|
492 | if (subcategory == "unsigned"):
|
---|
493 | unsigned_sizes[value_int] = name
|
---|
494 | unsigned_tags[tag] = value_int
|
---|
495 | unsigned_strcs[value_int] = strc
|
---|
496 | unsigned_concs[value_int] = conc
|
---|
497 | elif (subcategory == "signed"):
|
---|
498 | signed_sizes[value_int] = name
|
---|
499 | signed_tags[tag] = value_int
|
---|
500 | signed_strcs[value_int] = strc
|
---|
501 | signed_concs[value_int] = conc
|
---|
502 | else:
|
---|
503 | print_error(["Unexpected keyword \"%s\" in \"%s\" on line %s." % (subcategory, PROBE_OUTPUT, j), COMPILER_FAIL])
|
---|
504 |
|
---|
505 | if (category == "floatsize"):
|
---|
506 | try:
|
---|
507 | value_int = decode_value(value)
|
---|
508 | except:
|
---|
509 | print_error(["Integer value expected in \"%s\" on line %s." % (PROBE_OUTPUT, j), COMPILER_FAIL])
|
---|
510 |
|
---|
511 | float_tags[tag] = value_int
|
---|
512 |
|
---|
513 | if (category == "builtin_size"):
|
---|
514 | try:
|
---|
515 | value_int = decode_value(value)
|
---|
516 | except:
|
---|
517 | print_error(["Integer value expected in \"%s\" on line %s." % (PROBE_OUTPUT, j), COMPILER_FAIL])
|
---|
518 |
|
---|
519 | builtin_sizes[tag] = {'name': name, 'value': value_int}
|
---|
520 |
|
---|
521 | if (category == "builtin_sign"):
|
---|
522 | try:
|
---|
523 | value_int = decode_value(value)
|
---|
524 | except:
|
---|
525 | print_error(["Integer value expected in \"%s\" on line %s." % (PROBE_OUTPUT, j), COMPILER_FAIL])
|
---|
526 |
|
---|
527 | if (value_int == 1):
|
---|
528 | if (not tag in builtin_signs):
|
---|
529 | builtin_signs[tag] = strc;
|
---|
530 | elif (builtin_signs[tag] != strc):
|
---|
531 | print_error(["Inconsistent builtin type detection in \"%s\" on line %s." % (PROBE_OUTPUT, j), COMPILER_FAIL])
|
---|
532 |
|
---|
533 | return {'unsigned_sizes': unsigned_sizes, 'signed_sizes': signed_sizes, 'unsigned_tags': unsigned_tags, 'signed_tags': signed_tags, 'unsigned_strcs': unsigned_strcs, 'signed_strcs': signed_strcs, 'unsigned_concs': unsigned_concs, 'signed_concs': signed_concs, 'float_tags': float_tags, 'builtin_sizes': builtin_sizes, 'builtin_signs': builtin_signs}
|
---|
534 |
|
---|
535 | def probe_int128(common):
|
---|
536 | "Generate, compile and parse probing source for 128-bit integers"
|
---|
537 |
|
---|
538 | check_common(common, "CC")
|
---|
539 |
|
---|
540 | outf = open(PROBE_INT128_SOURCE, 'w')
|
---|
541 | outf.write(PROBE_INT128_HEAD)
|
---|
542 | outf.write("\tDECLARE_INTSIZE(\"INT128\", int __attribute((mode(TI))));\n")
|
---|
543 | outf.write(PROBE_INT128_TAIL)
|
---|
544 | outf.close()
|
---|
545 |
|
---|
546 | args = common['CC_AUTOGEN'].split(' ')
|
---|
547 | args.extend(["-S", "-o", PROBE_INT128_OUTPUT, PROBE_INT128_SOURCE])
|
---|
548 |
|
---|
549 | try:
|
---|
550 | sys.stderr.write("Checking whether the compiler has intrinsic support for 128-bit integers ... ")
|
---|
551 | output = subprocess.Popen(args, stdout = subprocess.PIPE, stderr = subprocess.PIPE).communicate()
|
---|
552 | except:
|
---|
553 | sys.stderr.write("no\n")
|
---|
554 | return False
|
---|
555 |
|
---|
556 | if (not os.path.isfile(PROBE_INT128_OUTPUT)):
|
---|
557 | sys.stderr.write("no\n")
|
---|
558 | return False
|
---|
559 |
|
---|
560 | inf = open(PROBE_INT128_OUTPUT, 'r')
|
---|
561 | lines = inf.readlines()
|
---|
562 | inf.close()
|
---|
563 |
|
---|
564 | for j in range(len(lines)):
|
---|
565 | tokens = lines[j].strip().split("\t")
|
---|
566 |
|
---|
567 | if (len(tokens) > 0):
|
---|
568 | if (tokens[0] == "AUTOTOOL_DECLARE"):
|
---|
569 | if (len(tokens) < 7):
|
---|
570 | print_error(["Malformed declaration in \"%s\" on line %s." % (PROBE_INT128_OUTPUT, j), COMPILER_FAIL])
|
---|
571 |
|
---|
572 | category = tokens[1]
|
---|
573 | subcategory = tokens[2]
|
---|
574 | tag = tokens[3]
|
---|
575 | name = tokens[4]
|
---|
576 | strc = tokens[5]
|
---|
577 | conc = tokens[6]
|
---|
578 | value = tokens[7]
|
---|
579 |
|
---|
580 | if (category == "intsize"):
|
---|
581 | try:
|
---|
582 | value_int = decode_value(value)
|
---|
583 | except:
|
---|
584 | print_error(["Integer value expected in \"%s\" on line %s." % (PROBE_INT128_OUTPUT, j), COMPILER_FAIL])
|
---|
585 |
|
---|
586 | if (subcategory == "unsigned"):
|
---|
587 | if (value_int != 16):
|
---|
588 | sys.stderr.write("no\n")
|
---|
589 | return False
|
---|
590 | elif (subcategory == "signed"):
|
---|
591 | if (value_int != 16):
|
---|
592 | sys.stderr.write("no\n")
|
---|
593 | return False
|
---|
594 | else:
|
---|
595 | print_error(["Unexpected keyword \"%s\" in \"%s\" on line %s." % (subcategory, PROBE_INT128_OUTPUT, j), COMPILER_FAIL])
|
---|
596 |
|
---|
597 | sys.stderr.write("yes\n")
|
---|
598 | return True
|
---|
599 |
|
---|
600 | def detect_sizes(probe, bytes, inttags, floattags):
|
---|
601 | "Detect correct types for fixed-size types"
|
---|
602 |
|
---|
603 | macros = []
|
---|
604 | typedefs = []
|
---|
605 |
|
---|
606 | for b in bytes:
|
---|
607 | if (not b in probe['unsigned_sizes']):
|
---|
608 | print_error(['Unable to find appropriate unsigned integer type for %u bytes.' % b,
|
---|
609 | COMPILER_FAIL])
|
---|
610 |
|
---|
611 | if (not b in probe['signed_sizes']):
|
---|
612 | print_error(['Unable to find appropriate signed integer type for %u bytes.' % b,
|
---|
613 | COMPILER_FAIL])
|
---|
614 |
|
---|
615 | if (not b in probe['unsigned_strcs']):
|
---|
616 | print_error(['Unable to find appropriate unsigned printf formatter for %u bytes.' % b,
|
---|
617 | COMPILER_FAIL])
|
---|
618 |
|
---|
619 | if (not b in probe['signed_strcs']):
|
---|
620 | print_error(['Unable to find appropriate signed printf formatter for %u bytes.' % b,
|
---|
621 | COMPILER_FAIL])
|
---|
622 |
|
---|
623 | if (not b in probe['unsigned_concs']):
|
---|
624 | print_error(['Unable to find appropriate unsigned literal macro for %u bytes.' % b,
|
---|
625 | COMPILER_FAIL])
|
---|
626 |
|
---|
627 | if (not b in probe['signed_concs']):
|
---|
628 | print_error(['Unable to find appropriate signed literal macro for %u bytes.' % b,
|
---|
629 | COMPILER_FAIL])
|
---|
630 |
|
---|
631 | typedefs.append({'oldtype': "unsigned %s" % probe['unsigned_sizes'][b], 'newtype': "uint%u_t" % (b * 8)})
|
---|
632 | typedefs.append({'oldtype': "signed %s" % probe['signed_sizes'][b], 'newtype': "int%u_t" % (b * 8)})
|
---|
633 |
|
---|
634 | macros.append({'oldmacro': "unsigned %s" % probe['unsigned_sizes'][b], 'newmacro': "UINT%u_T" % (b * 8)})
|
---|
635 | macros.append({'oldmacro': "signed %s" % probe['signed_sizes'][b], 'newmacro': "INT%u_T" % (b * 8)})
|
---|
636 |
|
---|
637 | macros.append({'oldmacro': "\"%so\"" % probe['unsigned_strcs'][b], 'newmacro': "PRIo%u" % (b * 8)})
|
---|
638 | macros.append({'oldmacro': "\"%su\"" % probe['unsigned_strcs'][b], 'newmacro': "PRIu%u" % (b * 8)})
|
---|
639 | macros.append({'oldmacro': "\"%sx\"" % probe['unsigned_strcs'][b], 'newmacro': "PRIx%u" % (b * 8)})
|
---|
640 | macros.append({'oldmacro': "\"%sX\"" % probe['unsigned_strcs'][b], 'newmacro': "PRIX%u" % (b * 8)})
|
---|
641 | macros.append({'oldmacro': "\"%sd\"" % probe['signed_strcs'][b], 'newmacro': "PRId%u" % (b * 8)})
|
---|
642 |
|
---|
643 | name = probe['unsigned_concs'][b]
|
---|
644 | if ((name.startswith('@')) or (name == "")):
|
---|
645 | macros.append({'oldmacro': "c ## U", 'newmacro': "UINT%u_C(c)" % (b * 8)})
|
---|
646 | else:
|
---|
647 | macros.append({'oldmacro': "c ## U%s" % name, 'newmacro': "UINT%u_C(c)" % (b * 8)})
|
---|
648 |
|
---|
649 | name = probe['unsigned_concs'][b]
|
---|
650 | if ((name.startswith('@')) or (name == "")):
|
---|
651 | macros.append({'oldmacro': "c", 'newmacro': "INT%u_C(c)" % (b * 8)})
|
---|
652 | else:
|
---|
653 | macros.append({'oldmacro': "c ## %s" % name, 'newmacro': "INT%u_C(c)" % (b * 8)})
|
---|
654 |
|
---|
655 | for tag in inttags:
|
---|
656 | newmacro = "U%s" % tag
|
---|
657 | if (not tag in probe['unsigned_tags']):
|
---|
658 | print_error(['Unable to find appropriate size macro for %s.' % newmacro,
|
---|
659 | COMPILER_FAIL])
|
---|
660 |
|
---|
661 | oldmacro = "UINT%s" % (probe['unsigned_tags'][tag] * 8)
|
---|
662 | macros.append({'oldmacro': "%s_MIN" % oldmacro, 'newmacro': "%s_MIN" % newmacro})
|
---|
663 | macros.append({'oldmacro': "%s_MAX" % oldmacro, 'newmacro': "%s_MAX" % newmacro})
|
---|
664 | macros.append({'oldmacro': "1", 'newmacro': 'U%s_SIZE_%s' % (tag, probe['unsigned_tags'][tag] * 8)})
|
---|
665 |
|
---|
666 | newmacro = tag
|
---|
667 | if (not tag in probe['signed_tags']):
|
---|
668 | print_error(['Unable to find appropriate size macro for %s' % newmacro,
|
---|
669 | COMPILER_FAIL])
|
---|
670 |
|
---|
671 | oldmacro = "INT%s" % (probe['signed_tags'][tag] * 8)
|
---|
672 | macros.append({'oldmacro': "%s_MIN" % oldmacro, 'newmacro': "%s_MIN" % newmacro})
|
---|
673 | macros.append({'oldmacro': "%s_MAX" % oldmacro, 'newmacro': "%s_MAX" % newmacro})
|
---|
674 | macros.append({'oldmacro': "1", 'newmacro': '%s_SIZE_%s' % (tag, probe['signed_tags'][tag] * 8)})
|
---|
675 |
|
---|
676 | for tag in floattags:
|
---|
677 | if (not tag in probe['float_tags']):
|
---|
678 | print_error(['Unable to find appropriate size macro for %s' % tag,
|
---|
679 | COMPILER_FAIL])
|
---|
680 |
|
---|
681 | macros.append({'oldmacro': "1", 'newmacro': '%s_SIZE_%s' % (tag, probe['float_tags'][tag] * 8)})
|
---|
682 |
|
---|
683 | if (not 'size' in probe['builtin_signs']):
|
---|
684 | print_error(['Unable to determine whether size_t is signed or unsigned.',
|
---|
685 | COMPILER_FAIL])
|
---|
686 |
|
---|
687 | if (probe['builtin_signs']['size'] != 'unsigned'):
|
---|
688 | print_error(['The type size_t is not unsigned.',
|
---|
689 | COMPILER_FAIL])
|
---|
690 |
|
---|
691 | fnd = True
|
---|
692 |
|
---|
693 | if (not 'wchar' in probe['builtin_sizes']):
|
---|
694 | print_warning(['The compiler does not provide the macro __WCHAR_TYPE__',
|
---|
695 | 'for defining the compiler-native type wchar_t. We are',
|
---|
696 | 'forced to define wchar_t as a hardwired type int32_t.',
|
---|
697 | COMPILER_WARNING])
|
---|
698 | fnd = False
|
---|
699 |
|
---|
700 | if (probe['builtin_sizes']['wchar']['value'] != 4):
|
---|
701 | print_warning(['The compiler provided macro __WCHAR_TYPE__ for defining',
|
---|
702 | 'the compiler-native type wchar_t is not compliant with',
|
---|
703 | 'HelenOS. We are forced to define wchar_t as a hardwired',
|
---|
704 | 'type int32_t.',
|
---|
705 | COMPILER_WARNING])
|
---|
706 | fnd = False
|
---|
707 |
|
---|
708 | if (not fnd):
|
---|
709 | macros.append({'oldmacro': "int32_t", 'newmacro': "wchar_t"})
|
---|
710 | else:
|
---|
711 | macros.append({'oldmacro': "__WCHAR_TYPE__", 'newmacro': "wchar_t"})
|
---|
712 |
|
---|
713 | if (not 'wchar' in probe['builtin_signs']):
|
---|
714 | print_error(['Unable to determine whether wchar_t is signed or unsigned.',
|
---|
715 | COMPILER_FAIL])
|
---|
716 |
|
---|
717 | if (probe['builtin_signs']['wchar'] == 'unsigned'):
|
---|
718 | macros.append({'oldmacro': "1", 'newmacro': 'WCHAR_IS_UNSIGNED'})
|
---|
719 | if (probe['builtin_signs']['wchar'] == 'signed'):
|
---|
720 | macros.append({'oldmacro': "1", 'newmacro': 'WCHAR_IS_SIGNED'})
|
---|
721 |
|
---|
722 | fnd = True
|
---|
723 |
|
---|
724 | if (not 'wint' in probe['builtin_sizes']):
|
---|
725 | print_warning(['The compiler does not provide the macro __WINT_TYPE__',
|
---|
726 | 'for defining the compiler-native type wint_t. We are',
|
---|
727 | 'forced to define wint_t as a hardwired type int32_t.',
|
---|
728 | COMPILER_WARNING])
|
---|
729 | fnd = False
|
---|
730 |
|
---|
731 | if (probe['builtin_sizes']['wint']['value'] != 4):
|
---|
732 | print_warning(['The compiler provided macro __WINT_TYPE__ for defining',
|
---|
733 | 'the compiler-native type wint_t is not compliant with',
|
---|
734 | 'HelenOS. We are forced to define wint_t as a hardwired',
|
---|
735 | 'type int32_t.',
|
---|
736 | COMPILER_WARNING])
|
---|
737 | fnd = False
|
---|
738 |
|
---|
739 | if (not fnd):
|
---|
740 | macros.append({'oldmacro': "int32_t", 'newmacro': "wint_t"})
|
---|
741 | else:
|
---|
742 | macros.append({'oldmacro': "__WINT_TYPE__", 'newmacro': "wint_t"})
|
---|
743 |
|
---|
744 | if (not 'wint' in probe['builtin_signs']):
|
---|
745 | print_error(['Unable to determine whether wint_t is signed or unsigned.',
|
---|
746 | COMPILER_FAIL])
|
---|
747 |
|
---|
748 | if (probe['builtin_signs']['wint'] == 'unsigned'):
|
---|
749 | macros.append({'oldmacro': "1", 'newmacro': 'WINT_IS_UNSIGNED'})
|
---|
750 | if (probe['builtin_signs']['wint'] == 'signed'):
|
---|
751 | macros.append({'oldmacro': "1", 'newmacro': 'WINT_IS_SIGNED'})
|
---|
752 |
|
---|
753 | return {'macros': macros, 'typedefs': typedefs}
|
---|
754 |
|
---|
755 | def create_makefile(mkname, common):
|
---|
756 | "Create makefile output"
|
---|
757 |
|
---|
758 | outmk = open(mkname, 'w')
|
---|
759 |
|
---|
760 | outmk.write('#########################################\n')
|
---|
761 | outmk.write('## AUTO-GENERATED FILE, DO NOT EDIT!!! ##\n')
|
---|
762 | outmk.write('## Generated by: tools/autotool.py ##\n')
|
---|
763 | outmk.write('#########################################\n\n')
|
---|
764 |
|
---|
765 | for key, value in common.items():
|
---|
766 | if (type(value) is list):
|
---|
767 | outmk.write('%s = %s\n' % (key, " ".join(value)))
|
---|
768 | else:
|
---|
769 | outmk.write('%s = %s\n' % (key, value))
|
---|
770 |
|
---|
771 | outmk.close()
|
---|
772 |
|
---|
773 | def create_header(hdname, maps, int128):
|
---|
774 | "Create header output"
|
---|
775 |
|
---|
776 | outhd = open(hdname, 'w')
|
---|
777 |
|
---|
778 | outhd.write('/***************************************\n')
|
---|
779 | outhd.write(' * AUTO-GENERATED FILE, DO NOT EDIT!!! *\n')
|
---|
780 | outhd.write(' * Generated by: tools/autotool.py *\n')
|
---|
781 | outhd.write(' ***************************************/\n\n')
|
---|
782 |
|
---|
783 | outhd.write('#ifndef %s\n' % GUARD)
|
---|
784 | outhd.write('#define %s\n\n' % GUARD)
|
---|
785 |
|
---|
786 | for macro in maps['macros']:
|
---|
787 | outhd.write('#define %s %s\n' % (macro['newmacro'], macro['oldmacro']))
|
---|
788 |
|
---|
789 | outhd.write('\n')
|
---|
790 |
|
---|
791 | for typedef in maps['typedefs']:
|
---|
792 | outhd.write('typedef %s %s;\n' % (typedef['oldtype'], typedef['newtype']))
|
---|
793 |
|
---|
794 | if (int128):
|
---|
795 | outhd.write('typedef unsigned int __attribute((mode(TI))) uint128_t;\n')
|
---|
796 | outhd.write('typedef signed int __attribute((mode(TI))) int128_t;\n')
|
---|
797 |
|
---|
798 | outhd.write('\n#endif\n')
|
---|
799 | outhd.close()
|
---|
800 |
|
---|
801 | def main():
|
---|
802 | config = {}
|
---|
803 | common = {}
|
---|
804 |
|
---|
805 | # Read and check configuration
|
---|
806 | if os.path.exists(CONFIG):
|
---|
807 | read_config(CONFIG, config)
|
---|
808 | else:
|
---|
809 | print_error(["Configuration file %s not found! Make sure that the" % CONFIG,
|
---|
810 | "configuration phase of HelenOS build went OK. Try running",
|
---|
811 | "\"make config\" again."])
|
---|
812 |
|
---|
813 | check_config(config, "PLATFORM")
|
---|
814 | check_config(config, "COMPILER")
|
---|
815 | check_config(config, "BARCH")
|
---|
816 |
|
---|
817 | # Cross-compiler prefix
|
---|
818 | if ('CROSS_PREFIX' in os.environ):
|
---|
819 | cross_prefix = os.environ['CROSS_PREFIX']
|
---|
820 | else:
|
---|
821 | cross_prefix = "/usr/local/cross"
|
---|
822 |
|
---|
823 | # HelenOS cross-compiler prefix
|
---|
824 | if ('CROSS_HELENOS_PREFIX' in os.environ):
|
---|
825 | cross_helenos_prefix = os.environ['CROSS_HELENOS_PREFIX']
|
---|
826 | else:
|
---|
827 | cross_helenos_prefix = "/usr/local/cross-helenos"
|
---|
828 |
|
---|
829 | # Prefix binutils tools on Solaris
|
---|
830 | if (os.uname()[0] == "SunOS"):
|
---|
831 | binutils_prefix = "g"
|
---|
832 | else:
|
---|
833 | binutils_prefix = ""
|
---|
834 |
|
---|
835 | owd = sandbox_enter()
|
---|
836 |
|
---|
837 | try:
|
---|
838 | # Common utilities
|
---|
839 | check_app(["ln", "--version"], "Symlink utility", "usually part of coreutils")
|
---|
840 | check_app(["rm", "--version"], "File remove utility", "usually part of coreutils")
|
---|
841 | check_app(["mkdir", "--version"], "Directory creation utility", "usually part of coreutils")
|
---|
842 | check_app(["cp", "--version"], "Copy utility", "usually part of coreutils")
|
---|
843 | check_app(["find", "--version"], "Find utility", "usually part of findutils")
|
---|
844 | check_app(["diff", "--version"], "Diff utility", "usually part of diffutils")
|
---|
845 | check_app(["make", "--version"], "Make utility", "preferably GNU Make")
|
---|
846 | check_app(["makedepend", "-f", "-"], "Makedepend utility", "usually part of imake or xutils")
|
---|
847 | check_app(["unzip"], "unzip utility", "usually part of zip/unzip utilities")
|
---|
848 |
|
---|
849 | # Compiler
|
---|
850 | if (config['COMPILER'] == "gcc_cross"):
|
---|
851 | target, cc_args, gnu_target, helenos_target = get_target(config)
|
---|
852 |
|
---|
853 | if (target is None) or (gnu_target is None):
|
---|
854 | print_error(["Unsupported compiler target for GNU GCC.",
|
---|
855 | "Please contact the developers of HelenOS."])
|
---|
856 |
|
---|
857 | path = "%s/%s/bin" % (cross_prefix, target)
|
---|
858 | prefix = "%s-" % gnu_target
|
---|
859 |
|
---|
860 | check_gcc(path, prefix, common, PACKAGE_CROSS)
|
---|
861 | check_binutils(path, prefix, common, PACKAGE_CROSS)
|
---|
862 |
|
---|
863 | check_common(common, "GCC")
|
---|
864 | common['CC'] = " ".join([common['GCC']] + cc_args)
|
---|
865 | common['CC_AUTOGEN'] = common['CC']
|
---|
866 |
|
---|
867 | if (config['COMPILER'] == "gcc_helenos"):
|
---|
868 | target, cc_args, gnu_target, helenos_target = get_target(config)
|
---|
869 |
|
---|
870 | if (target is None) or (helenos_target is None):
|
---|
871 | print_error(["Unsupported compiler target for GNU GCC.",
|
---|
872 | "Please contact the developers of HelenOS."])
|
---|
873 |
|
---|
874 | path = "%s/%s/bin" % (cross_helenos_prefix, target)
|
---|
875 | prefix = "%s-" % helenos_target
|
---|
876 |
|
---|
877 | check_gcc(path, prefix, common, PACKAGE_CROSS)
|
---|
878 | check_binutils(path, prefix, common, PACKAGE_CROSS)
|
---|
879 |
|
---|
880 | check_common(common, "GCC")
|
---|
881 | common['CC'] = " ".join([common['GCC']] + cc_args)
|
---|
882 | common['CC_AUTOGEN'] = common['CC']
|
---|
883 |
|
---|
884 | if (config['COMPILER'] == "gcc_native"):
|
---|
885 | check_gcc(None, "", common, PACKAGE_GCC)
|
---|
886 | check_binutils(None, binutils_prefix, common, PACKAGE_BINUTILS)
|
---|
887 |
|
---|
888 | check_common(common, "GCC")
|
---|
889 | common['CC'] = common['GCC']
|
---|
890 | common['CC_AUTOGEN'] = common['CC']
|
---|
891 |
|
---|
892 | if (config['COMPILER'] == "icc"):
|
---|
893 | check_app([common['CC'], "-V"], "Intel C++ Compiler", "support is experimental")
|
---|
894 | check_gcc(None, "", common, PACKAGE_GCC)
|
---|
895 | check_binutils(None, binutils_prefix, common, PACKAGE_BINUTILS)
|
---|
896 |
|
---|
897 | common['CC'] = "icc"
|
---|
898 | common['CC_AUTOGEN'] = common['CC']
|
---|
899 |
|
---|
900 | if (config['COMPILER'] == "clang"):
|
---|
901 | target, cc_args, gnu_target, helenos_target = get_target(config)
|
---|
902 |
|
---|
903 | if (target is None) or (gnu_target is None):
|
---|
904 | print_error(["Unsupported compiler target.",
|
---|
905 | "Please contact the developers of HelenOS."])
|
---|
906 |
|
---|
907 | path = "%s/%s/bin" % (cross_prefix, target)
|
---|
908 | prefix = "%s-" % gnu_target
|
---|
909 |
|
---|
910 | check_binutils(path, prefix, common, PACKAGE_CROSS)
|
---|
911 | check_clang(path, prefix, common, PACKAGE_CLANG)
|
---|
912 |
|
---|
913 | check_common(common, "CLANG")
|
---|
914 | common['CC'] = " ".join([common['CLANG']] + cc_args)
|
---|
915 | common['CC_AUTOGEN'] = common['CC'] + " -no-integrated-as"
|
---|
916 |
|
---|
917 | if (config['INTEGRATED_AS'] == "yes"):
|
---|
918 | common['CC'] += " -integrated-as"
|
---|
919 |
|
---|
920 | if (config['INTEGRATED_AS'] == "no"):
|
---|
921 | common['CC'] += " -no-integrated-as"
|
---|
922 |
|
---|
923 | check_python()
|
---|
924 |
|
---|
925 | # Platform-specific utilities
|
---|
926 | if ((config['BARCH'] == "amd64") or (config['BARCH'] == "ia32") or (config['BARCH'] == "ppc32") or (config['BARCH'] == "sparc64")):
|
---|
927 | common['GENISOIMAGE'] = check_app_alternatives(["genisoimage", "mkisofs", "xorriso"], ["--version"], "ISO 9660 creation utility", "usually part of genisoimage")
|
---|
928 | if common['GENISOIMAGE'] == 'xorriso':
|
---|
929 | common['GENISOIMAGE'] += ' -as genisoimage'
|
---|
930 |
|
---|
931 | probe = probe_compiler(common,
|
---|
932 | [
|
---|
933 | {'type': 'long long int', 'tag': 'LLONG', 'strc': '"ll"', 'conc': '"LL"'},
|
---|
934 | {'type': 'long int', 'tag': 'LONG', 'strc': '"l"', 'conc': '"L"'},
|
---|
935 | {'type': 'int', 'tag': 'INT', 'strc': '""', 'conc': '""'},
|
---|
936 | {'type': 'short int', 'tag': 'SHRT', 'strc': '"h"', 'conc': '"@"'},
|
---|
937 | {'type': 'char', 'tag': 'CHAR', 'strc': '"hh"', 'conc': '"@@"'}
|
---|
938 | ],
|
---|
939 | [
|
---|
940 | {'type': 'long double', 'tag': 'LONG_DOUBLE'},
|
---|
941 | {'type': 'double', 'tag': 'DOUBLE'},
|
---|
942 | {'type': 'float', 'tag': 'FLOAT'}
|
---|
943 | ]
|
---|
944 | )
|
---|
945 |
|
---|
946 | int128 = probe_int128(common)
|
---|
947 |
|
---|
948 | maps = detect_sizes(probe, [1, 2, 4, 8], ['CHAR', 'SHRT', 'INT', 'LONG', 'LLONG'], ['LONG_DOUBLE', 'DOUBLE', 'FLOAT'])
|
---|
949 |
|
---|
950 | finally:
|
---|
951 | sandbox_leave(owd)
|
---|
952 |
|
---|
953 | common['AUTOGEN'] = "%s/autogen.py" % os.path.dirname(os.path.abspath(sys.argv[0]))
|
---|
954 |
|
---|
955 | create_makefile(MAKEFILE, common)
|
---|
956 | create_header(HEADER, maps, int128)
|
---|
957 |
|
---|
958 | return 0
|
---|
959 |
|
---|
960 | if __name__ == '__main__':
|
---|
961 | sys.exit(main())
|
---|