source: mainline/tools/autotool.py@ d2f75eb

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since d2f75eb was d2f75eb, checked in by GitHub <noreply@…>, 7 years ago

Replace autogen.py with something simpler. (#30)

Instead of generating headers for certain structures, the headers are written manually and we automate checking correctness instead. Checking is performed by generating a C source with a bunch of static asserts, using a simple awk script. This is then treated as a normal source file.

The primary motivation for this change is to reduce the complexity of the build process. Also, the .ag files we used previously are more difficult to understand than regular C code, and at least one IDE (GNOME Builder) completely refuses to open them.

  • Property mode set to 100755
File size: 21.9 KB
Line 
1#!/usr/bin/env python2
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"""
31Detect important prerequisites and parameters for building HelenOS
32"""
33
34import sys
35import os
36import shutil
37import re
38import time
39import subprocess
40
41SANDBOX = 'autotool'
42CONFIG = 'Makefile.config'
43MAKEFILE = 'Makefile.common'
44HEADER = 'common.h.new'
45GUARD = '_AUTOTOOL_COMMON_H_'
46
47PROBE_SOURCE = 'probe.c'
48PROBE_OUTPUT = 'probe.s'
49
50PACKAGE_BINUTILS = "usually part of binutils"
51PACKAGE_GCC = "preferably version 4.7.0 or newer"
52PACKAGE_CROSS = "use tools/toolchain.sh to build the cross-compiler toolchain"
53PACKAGE_CLANG = "reasonably recent version of clang needs to be installed"
54
55COMPILER_FAIL = "The compiler is probably not capable to compile HelenOS."
56COMPILER_WARNING = "The compilation of HelenOS might fail."
57
58PROBE_HEAD = """#define AUTOTOOL_DECLARE(category, tag, name, signedness, base, size, compatible) \\
59 asm volatile ( \\
60 "AUTOTOOL_DECLARE\\t" category "\\t" tag "\\t" name "\\t" signedness "\\t" base "\\t%[size_val]\\t%[cmp_val]\\n" \\
61 : \\
62 : [size_val] "n" (size), [cmp_val] "n" (compatible) \\
63 )
64
65#define STRING(arg) STRING_ARG(arg)
66#define STRING_ARG(arg) #arg
67
68#define DECLARE_BUILTIN_TYPE(tag, type) \\
69 AUTOTOOL_DECLARE("unsigned long long int", tag, STRING(type), "unsigned", "long long", sizeof(type), __builtin_types_compatible_p(type, unsigned long long int)); \\
70 AUTOTOOL_DECLARE("unsigned long int", tag, STRING(type), "unsigned", "long", sizeof(type), __builtin_types_compatible_p(type, unsigned long int)); \\
71 AUTOTOOL_DECLARE("unsigned int", tag, STRING(type), "unsigned", "int", sizeof(type), __builtin_types_compatible_p(type, unsigned int)); \\
72 AUTOTOOL_DECLARE("unsigned short int", tag, STRING(type), "unsigned", "short", sizeof(type), __builtin_types_compatible_p(type, unsigned short int)); \\
73 AUTOTOOL_DECLARE("unsigned char", tag, STRING(type), "unsigned", "char", sizeof(type), __builtin_types_compatible_p(type, unsigned char)); \\
74 AUTOTOOL_DECLARE("signed long long int", tag, STRING(type), "signed", "long long", sizeof(type), __builtin_types_compatible_p(type, signed long long int)); \\
75 AUTOTOOL_DECLARE("signed long int", tag, STRING(type), "signed", "long", sizeof(type), __builtin_types_compatible_p(type, signed long int)); \\
76 AUTOTOOL_DECLARE("signed int", tag, STRING(type), "signed", "int", sizeof(type), __builtin_types_compatible_p(type, signed int)); \\
77 AUTOTOOL_DECLARE("signed short int", tag, STRING(type), "signed", "short", sizeof(type), __builtin_types_compatible_p(type, signed short int)); \\
78 AUTOTOOL_DECLARE("signed char", tag, STRING(type), "signed", "char", sizeof(type), __builtin_types_compatible_p(type, signed char)); \\
79 AUTOTOOL_DECLARE("pointer", tag, STRING(type), "N/A", "pointer", sizeof(type), __builtin_types_compatible_p(type, void*)); \\
80 AUTOTOOL_DECLARE("long double", tag, STRING(type), "signed", "long double", sizeof(type), __builtin_types_compatible_p(type, long double)); \\
81 AUTOTOOL_DECLARE("double", tag, STRING(type), "signed", "double", sizeof(type), __builtin_types_compatible_p(type, double)); \\
82 AUTOTOOL_DECLARE("float", tag, STRING(type), "signed", "float", sizeof(type), __builtin_types_compatible_p(type, float));
83
84extern int main(int, char *[]);
85
86int main(int argc, char *argv[])
87{
88"""
89
90PROBE_TAIL = """}
91"""
92
93def read_config(fname, config):
94 "Read HelenOS build configuration"
95
96 inf = open(fname, 'r')
97
98 for line in inf:
99 res = re.match(r'^(?:#!# )?([^#]\w*)\s*=\s*(.*?)\s*$', line)
100 if (res):
101 config[res.group(1)] = res.group(2)
102
103 inf.close()
104
105def print_error(msg):
106 "Print a bold error message"
107
108 sys.stderr.write("\n")
109 sys.stderr.write("######################################################################\n")
110 sys.stderr.write("HelenOS build sanity check error:\n")
111 sys.stderr.write("\n")
112 sys.stderr.write("%s\n" % "\n".join(msg))
113 sys.stderr.write("######################################################################\n")
114 sys.stderr.write("\n")
115
116 sys.exit(1)
117
118def print_warning(msg):
119 "Print a bold error message"
120
121 sys.stderr.write("\n")
122 sys.stderr.write("######################################################################\n")
123 sys.stderr.write("HelenOS build sanity check warning:\n")
124 sys.stderr.write("\n")
125 sys.stderr.write("%s\n" % "\n".join(msg))
126 sys.stderr.write("######################################################################\n")
127 sys.stderr.write("\n")
128
129 time.sleep(5)
130
131def sandbox_enter():
132 "Create a temporal sandbox directory for running tests"
133
134 if (os.path.exists(SANDBOX)):
135 if (os.path.isdir(SANDBOX)):
136 try:
137 shutil.rmtree(SANDBOX)
138 except:
139 print_error(["Unable to cleanup the directory \"%s\"." % SANDBOX])
140 else:
141 print_error(["Please inspect and remove unexpected directory,",
142 "entry \"%s\"." % SANDBOX])
143
144 try:
145 os.mkdir(SANDBOX)
146 except:
147 print_error(["Unable to create sandbox directory \"%s\"." % SANDBOX])
148
149 owd = os.getcwd()
150 os.chdir(SANDBOX)
151
152 return owd
153
154def sandbox_leave(owd):
155 "Leave the temporal sandbox directory"
156
157 os.chdir(owd)
158
159def check_config(config, key):
160 "Check whether the configuration key exists"
161
162 if (not key in config):
163 print_error(["Build configuration of HelenOS does not contain %s." % key,
164 "Try running \"make config\" again.",
165 "If the problem persists, please contact the developers of HelenOS."])
166
167def check_common(common, key):
168 "Check whether the common key exists"
169
170 if (not key in common):
171 print_error(["Failed to determine the value %s." % key,
172 "Please contact the developers of HelenOS."])
173
174def get_target(config):
175 platform = None
176 gnu_target = None
177 helenos_target = None
178 target = None
179 cc_args = []
180
181 if (config['PLATFORM'] == "abs32le"):
182 check_config(config, "CROSS_TARGET")
183 platform = config['CROSS_TARGET']
184
185 if (config['CROSS_TARGET'] == "arm32"):
186 gnu_target = "arm-linux-gnueabi"
187 helenos_target = "arm-helenos-gnueabi"
188
189 if (config['CROSS_TARGET'] == "ia32"):
190 gnu_target = "i686-pc-linux-gnu"
191 helenos_target = "i686-pc-helenos"
192
193 if (config['CROSS_TARGET'] == "mips32"):
194 cc_args.append("-mabi=32")
195 gnu_target = "mipsel-linux-gnu"
196 helenos_target = "mipsel-helenos"
197
198 if (config['PLATFORM'] == "amd64"):
199 platform = config['PLATFORM']
200 gnu_target = "amd64-unknown-elf"
201 helenos_target = "amd64-helenos"
202
203 if (config['PLATFORM'] == "arm32"):
204 platform = config['PLATFORM']
205 gnu_target = "arm-linux-gnueabi"
206 helenos_target = "arm-helenos-gnueabi"
207
208 if (config['PLATFORM'] == "ia32"):
209 platform = config['PLATFORM']
210 gnu_target = "i686-pc-linux-gnu"
211 helenos_target = "i686-pc-helenos"
212
213 if (config['PLATFORM'] == "ia64"):
214 platform = config['PLATFORM']
215 gnu_target = "ia64-pc-linux-gnu"
216 helenos_target = "ia64-pc-helenos"
217
218 if (config['PLATFORM'] == "mips32"):
219 check_config(config, "MACHINE")
220 cc_args.append("-mabi=32")
221
222 if ((config['MACHINE'] == "msim") or (config['MACHINE'] == "lmalta")):
223 platform = config['PLATFORM']
224 gnu_target = "mipsel-linux-gnu"
225 helenos_target = "mipsel-helenos"
226
227 if ((config['MACHINE'] == "bmalta")):
228 platform = "mips32eb"
229 gnu_target = "mips-linux-gnu"
230 helenos_target = "mips-helenos"
231
232 if (config['PLATFORM'] == "mips64"):
233 check_config(config, "MACHINE")
234 cc_args.append("-mabi=64")
235
236 if (config['MACHINE'] == "msim"):
237 platform = config['PLATFORM']
238 gnu_target = "mips64el-linux-gnu"
239 helenos_target = "mips64el-helenos"
240
241 if (config['PLATFORM'] == "ppc32"):
242 platform = config['PLATFORM']
243 gnu_target = "ppc-linux-gnu"
244 helenos_target = "ppc-helenos"
245
246 if (config['PLATFORM'] == "riscv64"):
247 platform = config['PLATFORM']
248 gnu_target = "riscv64-unknown-linux-gnu"
249 helenos_target = "riscv64-helenos"
250
251 if (config['PLATFORM'] == "sparc64"):
252 platform = config['PLATFORM']
253 gnu_target = "sparc64-linux-gnu"
254 helenos_target = "sparc64-helenos"
255
256 if (config['COMPILER'] == "gcc_helenos"):
257 target = helenos_target
258 else:
259 target = gnu_target
260
261 return (platform, cc_args, target)
262
263def check_app(args, name, details):
264 "Check whether an application can be executed"
265
266 try:
267 sys.stderr.write("Checking for %s ... " % args[0])
268 subprocess.Popen(args, stdout = subprocess.PIPE, stderr = subprocess.PIPE).wait()
269 except:
270 sys.stderr.write("failed\n")
271 print_error(["%s is missing." % name,
272 "",
273 "Execution of \"%s\" has failed. Please make sure that it" % " ".join(args),
274 "is installed in your system (%s)." % details])
275
276 sys.stderr.write("ok\n")
277
278def check_app_alternatives(alts, args, name, details):
279 "Check whether an application can be executed (use several alternatives)"
280
281 tried = []
282 found = None
283
284 for alt in alts:
285 working = True
286 cmdline = [alt] + args
287 tried.append(" ".join(cmdline))
288
289 try:
290 sys.stderr.write("Checking for %s ... " % alt)
291 subprocess.Popen(cmdline, stdout = subprocess.PIPE, stderr = subprocess.PIPE).wait()
292 except:
293 sys.stderr.write("failed\n")
294 working = False
295
296 if (working):
297 sys.stderr.write("ok\n")
298 found = alt
299 break
300
301 if (found is None):
302 print_error(["%s is missing." % name,
303 "",
304 "Please make sure that it is installed in your",
305 "system (%s)." % details,
306 "",
307 "The following alternatives were tried:"] + tried)
308
309 return found
310
311def check_clang(path, prefix, common, details):
312 "Check for clang"
313
314 common['CLANG'] = "%sclang" % prefix
315
316 if (not path is None):
317 common['CLANG'] = "%s/%s" % (path, common['CLANG'])
318
319 check_app([common['CLANG'], "--version"], "clang", details)
320
321def check_gcc(path, prefix, common, details):
322 "Check for GCC"
323
324 common['GCC'] = "%sgcc" % prefix
325
326 if (not path is None):
327 common['GCC'] = "%s/%s" % (path, common['GCC'])
328
329 check_app([common['GCC'], "--version"], "GNU GCC", details)
330
331def check_binutils(path, prefix, common, details):
332 "Check for binutils toolchain"
333
334 common['AS'] = "%sas" % prefix
335 common['LD'] = "%sld" % prefix
336 common['AR'] = "%sar" % prefix
337 common['OBJCOPY'] = "%sobjcopy" % prefix
338 common['OBJDUMP'] = "%sobjdump" % prefix
339 common['STRIP'] = "%sstrip" % prefix
340
341 if (not path is None):
342 for key in ["AS", "LD", "AR", "OBJCOPY", "OBJDUMP", "STRIP"]:
343 common[key] = "%s/%s" % (path, common[key])
344
345 check_app([common['AS'], "--version"], "GNU Assembler", details)
346 check_app([common['LD'], "--version"], "GNU Linker", details)
347 check_app([common['AR'], "--version"], "GNU Archiver", details)
348 check_app([common['OBJCOPY'], "--version"], "GNU Objcopy utility", details)
349 check_app([common['OBJDUMP'], "--version"], "GNU Objdump utility", details)
350 check_app([common['STRIP'], "--version"], "GNU strip", details)
351
352def check_python():
353 "Check for Python dependencies"
354
355 try:
356 sys.stderr.write("Checking for PyYAML ... ")
357 import yaml
358 except ImportError:
359 print_error(["PyYAML is missing.",
360 "",
361 "Please make sure that it is installed in your",
362 "system (usually part of PyYAML package)."])
363
364 sys.stderr.write("ok\n")
365
366def decode_value(value):
367 "Decode integer value"
368
369 base = 10
370
371 if ((value.startswith('$')) or (value.startswith('#'))):
372 value = value[1:]
373
374 if (value.startswith('0x')):
375 value = value[2:]
376 base = 16
377
378 return int(value, base)
379
380def probe_compiler(common, typesizes):
381 "Generate, compile and parse probing source"
382
383 check_common(common, "CC")
384
385 outf = open(PROBE_SOURCE, 'w')
386 outf.write(PROBE_HEAD)
387
388 for typedef in typesizes:
389 if 'def' in typedef:
390 outf.write("#ifdef %s\n" % typedef['def'])
391 outf.write("\tDECLARE_BUILTIN_TYPE(\"%s\", %s);\n" % (typedef['tag'], typedef['type']))
392 if 'def' in typedef:
393 outf.write("#endif\n")
394
395 outf.write(PROBE_TAIL)
396 outf.close()
397
398 args = common['CC_AUTOGEN'].split(' ')
399 args.extend(["-S", "-o", PROBE_OUTPUT, PROBE_SOURCE])
400
401 try:
402 sys.stderr.write("Checking compiler properties ... ")
403 output = subprocess.Popen(args, stdout = subprocess.PIPE, stderr = subprocess.PIPE).communicate()
404 except:
405 sys.stderr.write("failed\n")
406 print_error(["Error executing \"%s\"." % " ".join(args),
407 "Make sure that the compiler works properly."])
408
409 if (not os.path.isfile(PROBE_OUTPUT)):
410 sys.stderr.write("failed\n")
411 print(output[1])
412 print_error(["Error executing \"%s\"." % " ".join(args),
413 "The compiler did not produce the output file \"%s\"." % PROBE_OUTPUT,
414 "",
415 output[0],
416 output[1]])
417
418 sys.stderr.write("ok\n")
419
420 inf = open(PROBE_OUTPUT, 'r')
421 lines = inf.readlines()
422 inf.close()
423
424 builtins = {}
425
426 for j in range(len(lines)):
427 tokens = lines[j].strip().split("\t")
428
429 if (len(tokens) > 0):
430 if (tokens[0] == "AUTOTOOL_DECLARE"):
431 if (len(tokens) < 8):
432 print_error(["Malformed declaration in \"%s\" on line %s." % (PROBE_OUTPUT, j), COMPILER_FAIL])
433
434 category = tokens[1]
435 tag = tokens[2]
436 name = tokens[3]
437 signedness = tokens[4]
438 base = tokens[5]
439 size = tokens[6]
440 compatible = tokens[7]
441
442 try:
443 compatible_int = decode_value(compatible)
444 size_int = decode_value(size)
445 except:
446 print_error(["Integer value expected in \"%s\" on line %s." % (PROBE_OUTPUT, j), COMPILER_FAIL])
447
448 if (compatible_int == 1):
449 builtins[tag] = {
450 'tag': tag,
451 'name': name,
452 'sign': signedness,
453 'base': base,
454 'size': size_int,
455 }
456
457 for typedef in typesizes:
458 if not typedef['tag'] in builtins:
459 print_error(['Unable to determine the properties of type %s.' % typedef['tag'],
460 COMPILER_FAIL])
461 if 'sname' in typedef:
462 builtins[typedef['tag']]['sname'] = typedef['sname']
463
464 return builtins
465
466def get_suffix(type):
467 if type['sign'] == 'unsigned':
468 return {
469 "char": "",
470 "short": "",
471 "int": "U",
472 "long": "UL",
473 "long long": "ULL",
474 }[type['base']]
475 else:
476 return {
477 "char": "",
478 "short": "",
479 "int": "",
480 "long": "L",
481 "long long": "LL",
482 }[type['base']]
483
484def get_max(type):
485 val = (1 << (type['size']*8 - 1))
486 if type['sign'] == 'unsigned':
487 val *= 2
488 return val - 1
489
490def detect_sizes(probe):
491 "Detect properties of builtin types"
492
493 macros = {}
494
495 for type in probe.values():
496 macros['__SIZEOF_%s__' % type['tag']] = type['size']
497
498 if ('sname' in type):
499 macros['__%s_TYPE__' % type['sname']] = type['name']
500 macros['__%s_WIDTH__' % type['sname']] = type['size']*8
501 macros['__%s_%s__' % (type['sname'], type['sign'].upper())] = "1"
502 macros['__%s_C_SUFFIX__' % type['sname']] = get_suffix(type)
503 macros['__%s_MAX__' % type['sname']] = "%d%s" % (get_max(type), get_suffix(type))
504
505 if (probe['SIZE_T']['sign'] != 'unsigned'):
506 print_error(['The type size_t is not unsigned.', COMPILER_FAIL])
507
508 return macros
509
510def create_makefile(mkname, common):
511 "Create makefile output"
512
513 outmk = open(mkname, 'w')
514
515 outmk.write('#########################################\n')
516 outmk.write('## AUTO-GENERATED FILE, DO NOT EDIT!!! ##\n')
517 outmk.write('## Generated by: tools/autotool.py ##\n')
518 outmk.write('#########################################\n\n')
519
520 for key, value in common.items():
521 if (type(value) is list):
522 outmk.write('%s = %s\n' % (key, " ".join(value)))
523 else:
524 outmk.write('%s = %s\n' % (key, value))
525
526 outmk.close()
527
528def create_header(hdname, macros):
529 "Create header output"
530
531 outhd = open(hdname, 'w')
532
533 outhd.write('/***************************************\n')
534 outhd.write(' * AUTO-GENERATED FILE, DO NOT EDIT!!! *\n')
535 outhd.write(' * Generated by: tools/autotool.py *\n')
536 outhd.write(' ***************************************/\n\n')
537
538 outhd.write('#ifndef %s\n' % GUARD)
539 outhd.write('#define %s\n\n' % GUARD)
540
541 for macro in sorted(macros):
542 outhd.write('#ifndef %s\n' % macro)
543 outhd.write('#define %s %s\n' % (macro, macros[macro]))
544 outhd.write('#endif\n\n')
545
546 outhd.write('\n#endif\n')
547 outhd.close()
548
549def main():
550 config = {}
551 common = {}
552
553 # Read and check configuration
554 if os.path.exists(CONFIG):
555 read_config(CONFIG, config)
556 else:
557 print_error(["Configuration file %s not found! Make sure that the" % CONFIG,
558 "configuration phase of HelenOS build went OK. Try running",
559 "\"make config\" again."])
560
561 check_config(config, "PLATFORM")
562 check_config(config, "COMPILER")
563 check_config(config, "BARCH")
564
565 # Cross-compiler prefix
566 if ('CROSS_PREFIX' in os.environ):
567 cross_prefix = os.environ['CROSS_PREFIX']
568 else:
569 cross_prefix = "/usr/local/cross"
570
571 # HelenOS cross-compiler prefix
572 if ('CROSS_HELENOS_PREFIX' in os.environ):
573 cross_helenos_prefix = os.environ['CROSS_HELENOS_PREFIX']
574 else:
575 cross_helenos_prefix = "/usr/local/cross-helenos"
576
577 # Prefix binutils tools on Solaris
578 if (os.uname()[0] == "SunOS"):
579 binutils_prefix = "g"
580 else:
581 binutils_prefix = ""
582
583 owd = sandbox_enter()
584
585 try:
586 # Common utilities
587 check_app(["ln", "--version"], "Symlink utility", "usually part of coreutils")
588 check_app(["rm", "--version"], "File remove utility", "usually part of coreutils")
589 check_app(["mkdir", "--version"], "Directory creation utility", "usually part of coreutils")
590 check_app(["cp", "--version"], "Copy utility", "usually part of coreutils")
591 check_app(["find", "--version"], "Find utility", "usually part of findutils")
592 check_app(["diff", "--version"], "Diff utility", "usually part of diffutils")
593 check_app(["make", "--version"], "Make utility", "preferably GNU Make")
594 check_app(["unzip"], "unzip utility", "usually part of zip/unzip utilities")
595
596 platform, cc_args, target = get_target(config)
597
598 if (platform is None) or (target is None):
599 print_error(["Unsupported compiler target.",
600 "Please contact the developers of HelenOS."])
601
602 path = "%s/%s/bin" % (cross_prefix, target)
603
604 # Compatibility with earlier toolchain paths.
605 if not os.path.exists(path):
606 if (config['COMPILER'] == "gcc_helenos"):
607 check_path = "%s/%s/%s" % (cross_helenos_prefix, platform, target)
608 if not os.path.exists(check_path):
609 print_error(["Toolchain for target is not installed, or CROSS_PREFIX is not set correctly."])
610 path = "%s/%s/bin" % (cross_helenos_prefix, platform)
611 else:
612 check_path = "%s/%s/%s" % (cross_prefix, platform, target)
613 if not os.path.exists(check_path):
614 print_error(["Toolchain for target is not installed, or CROSS_PREFIX is not set correctly."])
615 path = "%s/%s/bin" % (cross_prefix, platform)
616
617 common['TARGET'] = target
618 prefix = "%s-" % target
619
620 # Compiler
621 if (config['COMPILER'] == "gcc_cross" or config['COMPILER'] == "gcc_helenos"):
622 check_gcc(path, prefix, common, PACKAGE_CROSS)
623 check_binutils(path, prefix, common, PACKAGE_CROSS)
624
625 check_common(common, "GCC")
626 common['CC'] = " ".join([common['GCC']] + cc_args)
627 common['CC_AUTOGEN'] = common['CC']
628
629 if (config['COMPILER'] == "gcc_native"):
630 check_gcc(None, "", common, PACKAGE_GCC)
631 check_binutils(None, binutils_prefix, common, PACKAGE_BINUTILS)
632
633 check_common(common, "GCC")
634 common['CC'] = common['GCC']
635 common['CC_AUTOGEN'] = common['CC']
636
637 if (config['COMPILER'] == "clang"):
638 check_binutils(path, prefix, common, PACKAGE_CROSS)
639 check_clang(path, prefix, common, PACKAGE_CLANG)
640
641 check_common(common, "CLANG")
642 common['CC'] = " ".join([common['CLANG']] + cc_args)
643 common['CC_AUTOGEN'] = common['CC'] + " -no-integrated-as"
644
645 if (config['INTEGRATED_AS'] == "yes"):
646 common['CC'] += " -integrated-as"
647
648 if (config['INTEGRATED_AS'] == "no"):
649 common['CC'] += " -no-integrated-as"
650
651 check_python()
652
653 # Platform-specific utilities
654 if ((config['BARCH'] == "amd64") or (config['BARCH'] == "ia32") or (config['BARCH'] == "ppc32") or (config['BARCH'] == "sparc64")):
655 common['GENISOIMAGE'] = check_app_alternatives(["genisoimage", "mkisofs", "xorriso"], ["--version"], "ISO 9660 creation utility", "usually part of genisoimage")
656 if common['GENISOIMAGE'] == 'xorriso':
657 common['GENISOIMAGE'] += ' -as genisoimage'
658
659 probe = probe_compiler(common,
660 [
661 {'type': 'long long int', 'tag': 'LONG_LONG', 'sname': 'LLONG' },
662 {'type': 'long int', 'tag': 'LONG', 'sname': 'LONG' },
663 {'type': 'int', 'tag': 'INT', 'sname': 'INT' },
664 {'type': 'short int', 'tag': 'SHORT', 'sname': 'SHRT'},
665 {'type': 'void*', 'tag': 'POINTER'},
666 {'type': 'long double', 'tag': 'LONG_DOUBLE'},
667 {'type': 'double', 'tag': 'DOUBLE'},
668 {'type': 'float', 'tag': 'FLOAT'},
669 {'type': '__SIZE_TYPE__', 'tag': 'SIZE_T', 'def': '__SIZE_TYPE__', 'sname': 'SIZE' },
670 {'type': '__PTRDIFF_TYPE__', 'tag': 'PTRDIFF_T', 'def': '__PTRDIFF_TYPE__', 'sname': 'PTRDIFF' },
671 {'type': '__WINT_TYPE__', 'tag': 'WINT_T', 'def': '__WINT_TYPE__', 'sname': 'WINT' },
672 {'type': '__WCHAR_TYPE__', 'tag': 'WCHAR_T', 'def': '__WCHAR_TYPE__', 'sname': 'WCHAR' },
673 {'type': '__INTMAX_TYPE__', 'tag': 'INTMAX_T', 'def': '__INTMAX_TYPE__', 'sname': 'INTMAX' },
674 {'type': 'unsigned __INTMAX_TYPE__', 'tag': 'UINTMAX_T', 'def': '__INTMAX_TYPE__', 'sname': 'UINTMAX' },
675 ]
676 )
677
678 macros = detect_sizes(probe)
679
680 finally:
681 sandbox_leave(owd)
682
683 create_makefile(MAKEFILE, common)
684 create_header(HEADER, macros)
685
686 return 0
687
688if __name__ == '__main__':
689 sys.exit(main())
Note: See TracBrowser for help on using the repository browser.