Changeset 32355bc in mainline
- Timestamp:
- 2019-08-17T12:49:42Z (5 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 5fd05862
- Parents:
- fa70134
- git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2019-06-15 12:58:56)
- git-committer:
- Jiří Zárevúcky <zarevucky.jiri@…> (2019-08-17 12:49:42)
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
Makefile
rfa70134 r32355bc 41 41 42 42 COMMON_MAKEFILE = Makefile.common 43 COMMON_HEADER = common.h44 43 45 44 CONFIG_MAKEFILE = Makefile.config … … 53 52 $(MAKE) -r -C boot PRECHECK=$(PRECHECK) 54 53 55 common: $(COMMON_MAKEFILE) $(CO MMON_HEADER) $(CONFIG_MAKEFILE) $(CONFIG_HEADER) $(ERRNO_HEADER)54 common: $(COMMON_MAKEFILE) $(CONFIG_MAKEFILE) $(CONFIG_HEADER) $(ERRNO_HEADER) 56 55 57 56 kernel: common … … 123 122 # Autotool (detects compiler features) 124 123 125 autotool $(COMMON_MAKEFILE) $(COMMON_HEADER): $(CONFIG_MAKEFILE) $(AUTOTOOL)124 autotool $(COMMON_MAKEFILE): $(CONFIG_MAKEFILE) $(AUTOTOOL) 126 125 $(AUTOTOOL) 127 diff -q $(COMMON_HEADER).new $(COMMON_HEADER) 2> /dev/null; if [ $$? -ne 0 ]; then mv -f $(COMMON_HEADER).new $(COMMON_HEADER); fi128 126 129 127 # Build-time configuration … … 153 151 154 152 distclean: clean 155 rm -f $(CSCOPE).out $(COMMON_MAKEFILE) $(CO MMON_HEADER) $(CONFIG_MAKEFILE) $(CONFIG_HEADER) tools/*.pyc tools/checkers/*.pyc release/HelenOS-*153 rm -f $(CSCOPE).out $(COMMON_MAKEFILE) $(CONFIG_MAKEFILE) $(CONFIG_HEADER) tools/*.pyc tools/checkers/*.pyc release/HelenOS-* 156 154 157 155 clean: -
boot/Makefile
rfa70134 r32355bc 31 31 include Makefile.common 32 32 33 all: $(VERSION_DEF) $(COMMON_MAKEFILE) $(CO MMON_HEADER) $(CONFIG_MAKEFILE) $(CONFIG_HEADER) $(PREBUILD) build_dist33 all: $(VERSION_DEF) $(COMMON_MAKEFILE) $(CONFIG_MAKEFILE) $(CONFIG_HEADER) $(PREBUILD) build_dist 34 34 $(MAKE) -r -f $(BUILD) PRECHECK=$(PRECHECK) 35 35 ifneq ($(POSTBUILD),) -
boot/Makefile.build
rfa70134 r32355bc 73 73 endif 74 74 75 all: $(VERSION_DEF) $(COMMON_MAKEFILE) $(CO MMON_HEADER) $(CONFIG_MAKEFILE) $(CONFIG_HEADER) $(BOOT_OUTPUT)75 all: $(VERSION_DEF) $(COMMON_MAKEFILE) $(CONFIG_MAKEFILE) $(CONFIG_HEADER) $(BOOT_OUTPUT) 76 76 77 77 clean: -
boot/Makefile.common
rfa70134 r32355bc 35 35 36 36 COMMON_MAKEFILE = $(ROOT_PATH)/Makefile.common 37 COMMON_HEADER = $(ROOT_PATH)/common.h38 37 39 38 CONFIG_MAKEFILE = $(ROOT_PATH)/Makefile.config -
kernel/Makefile
rfa70134 r32355bc 35 35 36 36 COMMON_MAKEFILE = $(ROOT_PATH)/Makefile.common 37 COMMON_HEADER = $(ROOT_PATH)/common.h38 37 COMMON_HEADER_ARCH = arch/$(KARCH)/include/arch/common.h 39 38 … … 74 73 .DELETE_ON_ERROR: 75 74 76 all: $(VERSION_DEF) $(COMMON_MAKEFILE) $(CO MMON_HEADER) $(CONFIG_MAKEFILE) $(CONFIG_HEADER) $(KERNEL) $(DISASM)75 all: $(VERSION_DEF) $(COMMON_MAKEFILE) $(CONFIG_MAKEFILE) $(CONFIG_HEADER) $(KERNEL) $(DISASM) 77 76 78 77 clean: autogen_clean -
tools/autotool.py
rfa70134 r32355bc 42 42 CONFIG = 'Makefile.config' 43 43 MAKEFILE = 'Makefile.common' 44 HEADER = 'common.h.new' 45 GUARD = '_AUTOTOOL_COMMON_H_' 46 47 PROBE_SOURCE = 'probe.c' 48 PROBE_OUTPUT = 'probe.s' 49 50 PACKAGE_BINUTILS = "usually part of binutils" 51 PACKAGE_GCC = "preferably version 4.7.0 or newer" 44 52 45 PACKAGE_CROSS = "use tools/toolchain.sh to build the cross-compiler toolchain" 53 46 PACKAGE_CLANG = "reasonably recent version of clang needs to be installed" 54 55 TOOLCHAIN_FAIL = [56 "Compiler toolchain for target is not installed, or CROSS_PREFIX",57 "environment variable is not set correctly. Use tools/toolchain.sh",58 "to (re)build the cross-compiler toolchain."]59 COMPILER_FAIL = "The compiler is probably not capable to compile HelenOS."60 COMPILER_WARNING = "The compilation of HelenOS might fail."61 62 PROBE_HEAD = """#define AUTOTOOL_DECLARE(category, tag, name, signedness, base, size, compatible) \\63 asm volatile ( \\64 "AUTOTOOL_DECLARE\\t" category "\\t" tag "\\t" name "\\t" signedness "\\t" base "\\t%[size_val]\\t%[cmp_val]\\n" \\65 : \\66 : [size_val] "n" (size), [cmp_val] "n" (compatible) \\67 )68 69 #define STRING(arg) STRING_ARG(arg)70 #define STRING_ARG(arg) #arg71 72 #define DECLARE_BUILTIN_TYPE(tag, type) \\73 AUTOTOOL_DECLARE("unsigned long long int", tag, STRING(type), "unsigned", "long long", sizeof(type), __builtin_types_compatible_p(type, unsigned long long int)); \\74 AUTOTOOL_DECLARE("unsigned long int", tag, STRING(type), "unsigned", "long", sizeof(type), __builtin_types_compatible_p(type, unsigned long int)); \\75 AUTOTOOL_DECLARE("unsigned int", tag, STRING(type), "unsigned", "int", sizeof(type), __builtin_types_compatible_p(type, unsigned int)); \\76 AUTOTOOL_DECLARE("unsigned short int", tag, STRING(type), "unsigned", "short", sizeof(type), __builtin_types_compatible_p(type, unsigned short int)); \\77 AUTOTOOL_DECLARE("unsigned char", tag, STRING(type), "unsigned", "char", sizeof(type), __builtin_types_compatible_p(type, unsigned char)); \\78 AUTOTOOL_DECLARE("signed long long int", tag, STRING(type), "signed", "long long", sizeof(type), __builtin_types_compatible_p(type, signed long long int)); \\79 AUTOTOOL_DECLARE("signed long int", tag, STRING(type), "signed", "long", sizeof(type), __builtin_types_compatible_p(type, signed long int)); \\80 AUTOTOOL_DECLARE("signed int", tag, STRING(type), "signed", "int", sizeof(type), __builtin_types_compatible_p(type, signed int)); \\81 AUTOTOOL_DECLARE("signed short int", tag, STRING(type), "signed", "short", sizeof(type), __builtin_types_compatible_p(type, signed short int)); \\82 AUTOTOOL_DECLARE("signed char", tag, STRING(type), "signed", "char", sizeof(type), __builtin_types_compatible_p(type, signed char)); \\83 AUTOTOOL_DECLARE("pointer", tag, STRING(type), "N/A", "pointer", sizeof(type), __builtin_types_compatible_p(type, void*)); \\84 AUTOTOOL_DECLARE("long double", tag, STRING(type), "signed", "long double", sizeof(type), __builtin_types_compatible_p(type, long double)); \\85 AUTOTOOL_DECLARE("double", tag, STRING(type), "signed", "double", sizeof(type), __builtin_types_compatible_p(type, double)); \\86 AUTOTOOL_DECLARE("float", tag, STRING(type), "signed", "float", sizeof(type), __builtin_types_compatible_p(type, float));87 88 extern int main(int, char *[]);89 90 int main(int argc, char *argv[])91 {92 """93 94 PROBE_TAIL = """}95 """96 47 97 48 def read_config(fname, config): … … 119 70 120 71 sys.exit(1) 121 122 def print_warning(msg):123 "Print a bold error message"124 125 sys.stderr.write("\n")126 sys.stderr.write("######################################################################\n")127 sys.stderr.write("HelenOS build sanity check warning:\n")128 sys.stderr.write("\n")129 sys.stderr.write("%s\n" % "\n".join(msg))130 sys.stderr.write("######################################################################\n")131 sys.stderr.write("\n")132 133 time.sleep(5)134 72 135 73 def sandbox_enter(): … … 371 309 check_app([common['STRIP'], "--version"], "GNU strip", details) 372 310 373 def decode_value(value):374 "Decode integer value"375 376 base = 10377 378 if ((value.startswith('$')) or (value.startswith('#'))):379 value = value[1:]380 381 if (value.startswith('0x')):382 value = value[2:]383 base = 16384 385 return int(value, base)386 387 def probe_compiler(cc, common, typesizes):388 "Generate, compile and parse probing source"389 390 check_common(common, "CC")391 392 outf = open(PROBE_SOURCE, 'w')393 outf.write(PROBE_HEAD)394 395 for typedef in typesizes:396 if 'def' in typedef:397 outf.write("#ifdef %s\n" % typedef['def'])398 outf.write("\tDECLARE_BUILTIN_TYPE(\"%s\", %s);\n" % (typedef['tag'], typedef['type']))399 if 'def' in typedef:400 outf.write("#endif\n")401 402 outf.write(PROBE_TAIL)403 outf.close()404 405 args = cc.split(' ')406 args.extend(["-S", "-o", PROBE_OUTPUT, PROBE_SOURCE])407 408 try:409 sys.stderr.write("Checking compiler properties ... ")410 output = subprocess.Popen(args, stdout = subprocess.PIPE, stderr = subprocess.PIPE).communicate()411 except:412 sys.stderr.write("failed\n")413 print_error(["Error executing \"%s\"." % " ".join(args),414 "Make sure that the compiler works properly."])415 416 if (not os.path.isfile(PROBE_OUTPUT)):417 sys.stderr.write("failed\n")418 print(output[1])419 print_error(["Error executing \"%s\"." % " ".join(args),420 "The compiler did not produce the output file \"%s\"." % PROBE_OUTPUT,421 "",422 output[0],423 output[1]])424 425 sys.stderr.write("ok\n")426 427 inf = open(PROBE_OUTPUT, 'r')428 lines = inf.readlines()429 inf.close()430 431 builtins = {}432 433 for j in range(len(lines)):434 tokens = lines[j].strip().split("\t")435 436 if (len(tokens) > 0):437 if (tokens[0] == "AUTOTOOL_DECLARE"):438 if (len(tokens) < 8):439 print_error(["Malformed declaration in \"%s\" on line %s." % (PROBE_OUTPUT, j), COMPILER_FAIL])440 441 category = tokens[1]442 tag = tokens[2]443 name = tokens[3]444 signedness = tokens[4]445 base = tokens[5]446 size = tokens[6]447 compatible = tokens[7]448 449 try:450 compatible_int = decode_value(compatible)451 size_int = decode_value(size)452 except:453 print_error(["Integer value expected in \"%s\" on line %s." % (PROBE_OUTPUT, j), COMPILER_FAIL])454 455 if (compatible_int == 1):456 builtins[tag] = {457 'tag': tag,458 'name': name,459 'sign': signedness,460 'base': base,461 'size': size_int,462 }463 464 for typedef in typesizes:465 if not typedef['tag'] in builtins:466 print_error(['Unable to determine the properties of type %s.' % typedef['tag'],467 COMPILER_FAIL])468 if 'sname' in typedef:469 builtins[typedef['tag']]['sname'] = typedef['sname']470 471 return builtins472 473 def get_suffix(type):474 if type['sign'] == 'unsigned':475 return {476 "char": "",477 "short": "",478 "int": "U",479 "long": "UL",480 "long long": "ULL",481 }[type['base']]482 else:483 return {484 "char": "",485 "short": "",486 "int": "",487 "long": "L",488 "long long": "LL",489 }[type['base']]490 491 def get_max(type):492 val = (1 << (type['size']*8 - 1))493 if type['sign'] == 'unsigned':494 val *= 2495 return val - 1496 497 def detect_sizes(probe):498 "Detect properties of builtin types"499 500 macros = {}501 502 for type in probe.values():503 macros['__SIZEOF_%s__' % type['tag']] = type['size']504 505 if ('sname' in type):506 macros['__%s_TYPE__' % type['sname']] = type['name']507 macros['__%s_WIDTH__' % type['sname']] = type['size']*8508 macros['__%s_%s__' % (type['sname'], type['sign'].upper())] = "1"509 macros['__%s_C_SUFFIX__' % type['sname']] = get_suffix(type)510 macros['__%s_MAX__' % type['sname']] = "%d%s" % (get_max(type), get_suffix(type))511 512 if (probe['SIZE_T']['sign'] != 'unsigned'):513 print_error(['The type size_t is not unsigned.', COMPILER_FAIL])514 515 return macros516 517 311 def create_makefile(mkname, common): 518 312 "Create makefile output" … … 647 441 common['GENISOIMAGE'] += ' -as genisoimage' 648 442 649 probe = probe_compiler(cc_autogen, common,650 [651 {'type': 'long long int', 'tag': 'LONG_LONG', 'sname': 'LLONG' },652 {'type': 'long int', 'tag': 'LONG', 'sname': 'LONG' },653 {'type': 'int', 'tag': 'INT', 'sname': 'INT' },654 {'type': 'short int', 'tag': 'SHORT', 'sname': 'SHRT'},655 {'type': 'void*', 'tag': 'POINTER'},656 {'type': 'long double', 'tag': 'LONG_DOUBLE'},657 {'type': 'double', 'tag': 'DOUBLE'},658 {'type': 'float', 'tag': 'FLOAT'},659 {'type': '__SIZE_TYPE__', 'tag': 'SIZE_T', 'def': '__SIZE_TYPE__', 'sname': 'SIZE' },660 {'type': '__PTRDIFF_TYPE__', 'tag': 'PTRDIFF_T', 'def': '__PTRDIFF_TYPE__', 'sname': 'PTRDIFF' },661 {'type': '__WINT_TYPE__', 'tag': 'WINT_T', 'def': '__WINT_TYPE__', 'sname': 'WINT' },662 {'type': '__WCHAR_TYPE__', 'tag': 'WCHAR_T', 'def': '__WCHAR_TYPE__', 'sname': 'WCHAR' },663 {'type': '__INTMAX_TYPE__', 'tag': 'INTMAX_T', 'def': '__INTMAX_TYPE__', 'sname': 'INTMAX' },664 {'type': 'unsigned __INTMAX_TYPE__', 'tag': 'UINTMAX_T', 'def': '__INTMAX_TYPE__', 'sname': 'UINTMAX' },665 ]666 )667 668 macros = detect_sizes(probe)669 670 443 finally: 671 444 sandbox_leave(owd) 672 445 673 446 create_makefile(MAKEFILE, common) 674 create_header(HEADER, macros)675 447 676 448 return 0 -
uspace/Makefile.common
rfa70134 r32355bc 60 60 61 61 COMMON_MAKEFILE = $(ROOT_PATH)/Makefile.common 62 COMMON_HEADER = $(ROOT_PATH)/common.h63 62 64 63 CONFIG_MAKEFILE = $(ROOT_PATH)/Makefile.config
Note:
See TracChangeset
for help on using the changeset viewer.