Changes in tools/autotool.py [d776329:6db5d4b] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tools/autotool.py
rd776329 r6db5d4b 48 48 PROBE_OUTPUT = 'probe.s' 49 49 50 PROBE_INT128_SOURCE = 'probe_int128.c'51 PROBE_INT128_OUTPUT = 'probe_int128.s'52 53 50 PACKAGE_BINUTILS = "usually part of binutils" 54 51 PACKAGE_GCC = "preferably version 4.7.0 or newer" … … 88 85 AUTOTOOL_DECLARE("floatsize", "", tag, #type, "", "", sizeof(type)); 89 86 90 extern int main(int, char *[]);91 92 87 int main(int argc, char *argv[]) 93 88 { … … 106 101 """ 107 102 108 PROBE_INT128_HEAD = """#define AUTOTOOL_DECLARE(category, subcategory, tag, name, strc, conc, value) \\109 asm volatile ( \\110 "AUTOTOOL_DECLARE\\t" category "\\t" subcategory "\\t" tag "\\t" name "\\t" strc "\\t" conc "\\t%[val]\\n" \\111 : \\112 : [val] "n" (value) \\113 )114 115 #define DECLARE_INTSIZE(tag, type) \\116 AUTOTOOL_DECLARE("intsize", "unsigned", tag, #type, "", "", sizeof(unsigned type)); \\117 AUTOTOOL_DECLARE("intsize", "signed", tag, #type, "", "", sizeof(signed type));118 119 extern int main(int, char *[]);120 121 int main(int argc, char *argv[])122 {123 """124 125 PROBE_INT128_TAIL = """}126 """127 128 103 def read_config(fname, config): 129 104 "Read HelenOS build configuration" … … 211 186 gnu_target = None 212 187 clang_target = None 213 helenos_target = None214 188 cc_args = [] 215 189 … … 220 194 if (config['CROSS_TARGET'] == "arm32"): 221 195 gnu_target = "arm-linux-gnueabi" 222 clang_target = "arm-unknown-none" 223 helenos_target = "arm-helenos-gnueabi" 196 clang_target = "arm-unknown-linux" 224 197 225 198 if (config['CROSS_TARGET'] == "ia32"): 226 199 gnu_target = "i686-pc-linux-gnu" 227 clang_target = "i686-unknown-none" 228 helenos_target = "i686-pc-helenos" 200 clang_target = "i386-unknown-linux" 229 201 230 202 if (config['CROSS_TARGET'] == "mips32"): 231 cc_args.append("-mabi=32")232 203 gnu_target = "mipsel-linux-gnu" 233 clang_target = "mipsel-unknown- none"234 helenos_target = "mipsel-helenos"204 clang_target = "mipsel-unknown-linux" 205 common['CC_ARGS'].append("-mabi=32") 235 206 236 207 if (config['PLATFORM'] == "amd64"): 237 208 target = config['PLATFORM'] 238 209 gnu_target = "amd64-linux-gnu" 239 clang_target = "x86_64-unknown-none" 240 helenos_target = "amd64-helenos" 210 clang_target = "x86_64-unknown-linux" 241 211 242 212 if (config['PLATFORM'] == "arm32"): 243 213 target = config['PLATFORM'] 244 214 gnu_target = "arm-linux-gnueabi" 245 clang_target = "arm-unknown-none-eabi" 246 helenos_target = "arm-helenos-gnueabi" 215 clang_target = "arm-unknown-linux" 247 216 248 217 if (config['PLATFORM'] == "ia32"): 249 218 target = config['PLATFORM'] 250 219 gnu_target = "i686-pc-linux-gnu" 251 clang_target = "i686-unknown-none" 252 helenos_target = "i686-pc-helenos" 220 clang_target = "i386-unknown-linux" 253 221 254 222 if (config['PLATFORM'] == "ia64"): 255 223 target = config['PLATFORM'] 256 224 gnu_target = "ia64-pc-linux-gnu" 257 helenos_target = "ia64-pc-helenos"258 225 259 226 if (config['PLATFORM'] == "mips32"): … … 264 231 target = config['PLATFORM'] 265 232 gnu_target = "mipsel-linux-gnu" 266 clang_target = "mipsel-unknown-none" 267 helenos_target = "mipsel-helenos" 233 clang_target = "mipsel-unknown-linux" 268 234 269 235 if ((config['MACHINE'] == "bmalta")): 270 236 target = "mips32eb" 271 237 gnu_target = "mips-linux-gnu" 272 clang_target = "mips-unknown-none" 273 helenos_target = "mips-helenos" 238 clang_target = "mips-unknown-linux" 274 239 275 240 if (config['PLATFORM'] == "mips64"): … … 280 245 target = config['PLATFORM'] 281 246 gnu_target = "mips64el-linux-gnu" 282 clang_target = "mips64el-unknown-none" 283 helenos_target = "mips64el-helenos" 247 clang_target = "mips64el-unknown-linux" 284 248 285 249 if (config['PLATFORM'] == "ppc32"): 286 250 target = config['PLATFORM'] 287 251 gnu_target = "ppc-linux-gnu" 288 clang_target = "ppc-unknown-none" 289 helenos_target = "ppc-helenos" 290 291 if (config['PLATFORM'] == "riscv64"): 292 target = config['PLATFORM'] 293 gnu_target = "riscv64-unknown-linux-gnu" 294 clang_target = "riscv-unknown-none" 295 helenos_target = "riscv64-helenos" 252 clang_target = "powerpc-unknown-linux" 296 253 297 254 if (config['PLATFORM'] == "sparc64"): 298 255 target = config['PLATFORM'] 299 256 gnu_target = "sparc64-linux-gnu" 300 clang_target = "sparc-unknown-none" 301 helenos_target = "sparc64-helenos" 302 303 return (target, cc_args, gnu_target, clang_target, helenos_target) 257 clang_target = "sparc-unknown-linux" 258 259 return (target, cc_args, gnu_target, clang_target) 304 260 305 261 def check_app(args, name, details): … … 382 338 check_app([common['STRIP'], "--version"], "GNU strip", details) 383 339 384 def check_python():385 "Check for Python dependencies"386 387 try:388 sys.stderr.write("Checking for PyYAML ... ")389 import yaml390 except ImportError:391 print_error(["PyYAML is missing.",392 "",393 "Please make sure that it is installed in your",394 "system (usually part of PyYAML package)."])395 396 sys.stderr.write("ok\n")397 398 340 def decode_value(value): 399 341 "Decode integer value" … … 422 364 423 365 for typedef in floatsizes: 424 outf.write("\ tDECLARE_FLOATSIZE(\"%s\", %s);\n" % (typedef['tag'], typedef['type']))366 outf.write("\nDECLARE_FLOATSIZE(\"%s\", %s);\n" % (typedef['tag'], typedef['type'])) 425 367 426 368 outf.write(PROBE_TAIL) … … 536 478 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} 537 479 538 def probe_int128(common):539 "Generate, compile and parse probing source for 128-bit integers"540 541 check_common(common, "CC")542 543 outf = open(PROBE_INT128_SOURCE, 'w')544 outf.write(PROBE_INT128_HEAD)545 outf.write("\tDECLARE_INTSIZE(\"INT128\", int __attribute((mode(TI))));\n")546 outf.write(PROBE_INT128_TAIL)547 outf.close()548 549 args = [common['CC']]550 args.extend(common['CC_ARGS'])551 args.extend(["-S", "-o", PROBE_INT128_OUTPUT, PROBE_INT128_SOURCE])552 553 try:554 sys.stderr.write("Checking whether the compiler has intrinsic support for 128-bit integers ... ")555 output = subprocess.Popen(args, stdout = subprocess.PIPE, stderr = subprocess.PIPE).communicate()556 except:557 sys.stderr.write("no\n")558 return False559 560 if (not os.path.isfile(PROBE_INT128_OUTPUT)):561 sys.stderr.write("no\n")562 return False563 564 inf = open(PROBE_INT128_OUTPUT, 'r')565 lines = inf.readlines()566 inf.close()567 568 for j in range(len(lines)):569 tokens = lines[j].strip().split("\t")570 571 if (len(tokens) > 0):572 if (tokens[0] == "AUTOTOOL_DECLARE"):573 if (len(tokens) < 7):574 print_error(["Malformed declaration in \"%s\" on line %s." % (PROBE_INT128_OUTPUT, j), COMPILER_FAIL])575 576 category = tokens[1]577 subcategory = tokens[2]578 tag = tokens[3]579 name = tokens[4]580 strc = tokens[5]581 conc = tokens[6]582 value = tokens[7]583 584 if (category == "intsize"):585 try:586 value_int = decode_value(value)587 except:588 print_error(["Integer value expected in \"%s\" on line %s." % (PROBE_INT128_OUTPUT, j), COMPILER_FAIL])589 590 if (subcategory == "unsigned"):591 if (value_int != 16):592 sys.stderr.write("no\n")593 return False594 elif (subcategory == "signed"):595 if (value_int != 16):596 sys.stderr.write("no\n")597 return False598 else:599 print_error(["Unexpected keyword \"%s\" in \"%s\" on line %s." % (subcategory, PROBE_INT128_OUTPUT, j), COMPILER_FAIL])600 601 sys.stderr.write("yes\n")602 return True603 604 480 def detect_sizes(probe, bytes, inttags, floattags): 605 481 "Detect correct types for fixed-size types" … … 775 651 outmk.close() 776 652 777 def create_header(hdname, maps , int128):653 def create_header(hdname, maps): 778 654 "Create header output" 779 655 … … 795 671 for typedef in maps['typedefs']: 796 672 outhd.write('typedef %s %s;\n' % (typedef['oldtype'], typedef['newtype'])) 797 798 if (int128):799 outhd.write('typedef unsigned int __attribute((mode(TI))) uint128_t;\n')800 outhd.write('typedef signed int __attribute((mode(TI))) int128_t;\n')801 673 802 674 outhd.write('\n#endif\n') … … 824 696 else: 825 697 cross_prefix = "/usr/local/cross" 826 827 # HelenOS cross-compiler prefix828 if ('CROSS_HELENOS_PREFIX' in os.environ):829 cross_helenos_prefix = os.environ['CROSS_HELENOS_PREFIX']830 else:831 cross_helenos_prefix = "/usr/local/cross-helenos"832 698 833 699 # Prefix binutils tools on Solaris … … 853 719 common['CC_ARGS'] = [] 854 720 if (config['COMPILER'] == "gcc_cross"): 855 target, cc_args, gnu_target, clang_target , helenos_target= get_target(config)721 target, cc_args, gnu_target, clang_target = get_target(config) 856 722 857 723 if (target is None) or (gnu_target is None): … … 869 735 common['CC_ARGS'].extend(cc_args) 870 736 871 if (config['COMPILER'] == "gcc_helenos"):872 target, cc_args, gnu_target, clang_target, helenos_target = get_target(config)873 874 if (target is None) or (helenos_target is None):875 print_error(["Unsupported compiler target for GNU GCC.",876 "Please contact the developers of HelenOS."])877 878 path = "%s/%s/bin" % (cross_helenos_prefix, target)879 prefix = "%s-" % helenos_target880 881 check_gcc(path, prefix, common, PACKAGE_CROSS)882 check_binutils(path, prefix, common, PACKAGE_CROSS)883 884 check_common(common, "GCC")885 common['CC'] = common['GCC']886 common['CC_ARGS'].extend(cc_args)887 888 737 if (config['COMPILER'] == "gcc_native"): 889 738 check_gcc(None, "", common, PACKAGE_GCC) … … 894 743 895 744 if (config['COMPILER'] == "icc"): 745 common['CC'] = "icc" 896 746 check_app([common['CC'], "-V"], "Intel C++ Compiler", "support is experimental") 897 747 check_gcc(None, "", common, PACKAGE_GCC) 898 748 check_binutils(None, binutils_prefix, common, PACKAGE_BINUTILS) 899 900 common['CC'] = "icc"901 749 902 750 if (config['COMPILER'] == "clang"): 903 target, cc_args, gnu_target, clang_target , helenos_target= get_target(config)751 target, cc_args, gnu_target, clang_target = get_target(config) 904 752 905 753 if (target is None) or (gnu_target is None) or (clang_target is None): … … 921 769 common['CLANG_TARGET'] = clang_target 922 770 923 check_python()924 925 771 # Platform-specific utilities 926 772 if ((config['BARCH'] == "amd64") or (config['BARCH'] == "ia32") or (config['BARCH'] == "ppc32") or (config['BARCH'] == "sparc64")): 927 common['GENISOIMAGE'] = check_app_alternatives(["mkisofs", "genisoimage", "xorriso"], ["--version"], "ISO 9660 creation utility", "usually part of genisoimage") 928 if common['GENISOIMAGE'] == 'xorriso': 929 common['GENISOIMAGE'] += ' -as genisoimage' 773 common['GENISOIMAGE'] = check_app_alternatives(["mkisofs", "genisoimage"], ["--version"], "ISO 9660 creation utility", "usually part of genisoimage") 930 774 931 775 probe = probe_compiler(common, … … 944 788 ) 945 789 946 int128 = probe_int128(common)947 948 790 maps = detect_sizes(probe, [1, 2, 4, 8], ['CHAR', 'SHORT', 'INT', 'LONG', 'LLONG'], ['LONG_DOUBLE', 'DOUBLE', 'FLOAT']) 949 791 … … 951 793 sandbox_leave(owd) 952 794 953 common['AUTOGEN'] = "%s/autogen.py" % os.path.dirname(os.path.abspath(sys.argv[0]))954 955 795 create_makefile(MAKEFILE, common) 956 create_header(HEADER, maps , int128)796 create_header(HEADER, maps) 957 797 958 798 return 0
Note:
See TracChangeset
for help on using the changeset viewer.