Changes in tools/autotool.py [2429e4a:a4a0f1d] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tools/autotool.py
r2429e4a ra4a0f1d 49 49 50 50 PACKAGE_BINUTILS = "usually part of binutils" 51 PACKAGE_GCC = "preferably version 4. 5.1or newer"51 PACKAGE_GCC = "preferably version 4.7.0 or newer" 52 52 PACKAGE_CROSS = "use tools/toolchain.sh to build the cross-compiler toolchain" 53 53 … … 66 66 67 67 #define DECLARE_BUILTIN_TYPE(tag, type) \\ 68 AUTOTOOL_DECLARE("builtin", "", tag, STRING(type), "", "", sizeof(type)); 68 AUTOTOOL_DECLARE("builtin_size", "", tag, STRING(type), "", "", sizeof(type)); \\ 69 AUTOTOOL_DECLARE("builtin_sign", "unsigned long long int", tag, STRING(type), "unsigned", "", __builtin_types_compatible_p(type, unsigned long long int)); \\ 70 AUTOTOOL_DECLARE("builtin_sign", "unsigned long int", tag, STRING(type), "unsigned", "", __builtin_types_compatible_p(type, unsigned long int)); \\ 71 AUTOTOOL_DECLARE("builtin_sign", "unsigned int", tag, STRING(type), "unsigned", "", __builtin_types_compatible_p(type, unsigned int)); \\ 72 AUTOTOOL_DECLARE("builtin_sign", "unsigned short int", tag, STRING(type), "unsigned", "", __builtin_types_compatible_p(type, unsigned short int)); \\ 73 AUTOTOOL_DECLARE("builtin_sign", "unsigned char", tag, STRING(type), "unsigned", "", __builtin_types_compatible_p(type, unsigned char)); \\ 74 AUTOTOOL_DECLARE("builtin_sign", "signed long long int", tag, STRING(type), "signed", "", __builtin_types_compatible_p(type, signed long long int)); \\ 75 AUTOTOOL_DECLARE("builtin_sign", "signed long int", tag, STRING(type), "signed", "", __builtin_types_compatible_p(type, signed long int)); \\ 76 AUTOTOOL_DECLARE("builtin_sign", "signed int", tag, STRING(type), "signed", "", __builtin_types_compatible_p(type, signed int)); \\ 77 AUTOTOOL_DECLARE("builtin_sign", "signed short int", tag, STRING(type), "signed", "", __builtin_types_compatible_p(type, signed short int)); \\ 78 AUTOTOOL_DECLARE("builtin_sign", "signed char", tag, STRING(type), "signed", "", __builtin_types_compatible_p(type, signed char)); 69 79 70 80 #define DECLARE_INTSIZE(tag, type, strc, conc) \\ 71 81 AUTOTOOL_DECLARE("intsize", "unsigned", tag, #type, strc, conc, sizeof(unsigned type)); \\ 72 82 AUTOTOOL_DECLARE("intsize", "signed", tag, #type, strc, conc, sizeof(signed type)); 83 84 #define DECLARE_FLOATSIZE(tag, type) \\ 85 AUTOTOOL_DECLARE("floatsize", "", tag, #type, "", "", sizeof(type)); 73 86 74 87 int main(int argc, char *argv[]) … … 184 197 sys.stderr.write("ok\n") 185 198 199 def check_app_alternatives(alts, args, name, details): 200 "Check whether an application can be executed (use several alternatives)" 201 202 tried = [] 203 found = None 204 205 for alt in alts: 206 working = True 207 cmdline = [alt] + args 208 tried.append(" ".join(cmdline)) 209 210 try: 211 sys.stderr.write("Checking for %s ... " % alt) 212 subprocess.Popen(cmdline, stdout = subprocess.PIPE, stderr = subprocess.PIPE).wait() 213 except: 214 sys.stderr.write("failed\n") 215 working = False 216 217 if (working): 218 sys.stderr.write("ok\n") 219 found = alt 220 break 221 222 if (found is None): 223 print_error(["%s is missing." % name, 224 "", 225 "Please make sure that it is installed in your", 226 "system (%s)." % details, 227 "", 228 "The following alternatives were tried:"] + tried) 229 230 return found 231 186 232 def check_gcc(path, prefix, common, details): 187 233 "Check for GCC" … … 229 275 return int(value, base) 230 276 231 def probe_compiler(common, sizes):277 def probe_compiler(common, intsizes, floatsizes): 232 278 "Generate, compile and parse probing source" 233 279 … … 237 283 outf.write(PROBE_HEAD) 238 284 239 for typedef in sizes:285 for typedef in intsizes: 240 286 outf.write("\tDECLARE_INTSIZE(\"%s\", %s, %s, %s);\n" % (typedef['tag'], typedef['type'], typedef['strc'], typedef['conc'])) 287 288 for typedef in floatsizes: 289 outf.write("\nDECLARE_FLOATSIZE(\"%s\", %s);\n" % (typedef['tag'], typedef['type'])) 241 290 242 291 outf.write(PROBE_TAIL) … … 282 331 signed_concs = {} 283 332 284 builtins = {} 333 float_tags = {} 334 335 builtin_sizes = {} 336 builtin_signs = {} 285 337 286 338 for j in range(len(lines)): … … 319 371 print_error(["Unexpected keyword \"%s\" in \"%s\" on line %s." % (subcategory, PROBE_OUTPUT, j), COMPILER_FAIL]) 320 372 321 if (category == " builtin"):373 if (category == "floatsize"): 322 374 try: 323 375 value_int = decode_value(value) … … 325 377 print_error(["Integer value expected in \"%s\" on line %s." % (PROBE_OUTPUT, j), COMPILER_FAIL]) 326 378 327 builtins[tag] = {'name': name, 'value': value_int} 328 329 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, 'builtins': builtins} 330 331 def detect_uints(probe, bytes, tags): 332 "Detect correct types for fixed-size integer types" 379 float_tags[tag] = value_int 380 381 if (category == "builtin_size"): 382 try: 383 value_int = decode_value(value) 384 except: 385 print_error(["Integer value expected in \"%s\" on line %s." % (PROBE_OUTPUT, j), COMPILER_FAIL]) 386 387 builtin_sizes[tag] = {'name': name, 'value': value_int} 388 389 if (category == "builtin_sign"): 390 try: 391 value_int = decode_value(value) 392 except: 393 print_error(["Integer value expected in \"%s\" on line %s." % (PROBE_OUTPUT, j), COMPILER_FAIL]) 394 395 if (value_int == 1): 396 if (not tag in builtin_signs): 397 builtin_signs[tag] = strc; 398 elif (builtin_signs[tag] != strc): 399 print_error(["Inconsistent builtin type detection in \"%s\" on line %s." % (PROBE_OUTPUT, j), COMPILER_FAIL]) 400 401 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} 402 403 def detect_sizes(probe, bytes, inttags, floattags): 404 "Detect correct types for fixed-size types" 333 405 334 406 macros = [] … … 337 409 for b in bytes: 338 410 if (not b in probe['unsigned_sizes']): 339 print_error(['Unable to find appropriate unsigned integer type for %u bytes ' % b,411 print_error(['Unable to find appropriate unsigned integer type for %u bytes.' % b, 340 412 COMPILER_FAIL]) 341 413 342 414 if (not b in probe['signed_sizes']): 343 print_error(['Unable to find appropriate signed integer type for %u bytes ' % b,415 print_error(['Unable to find appropriate signed integer type for %u bytes.' % b, 344 416 COMPILER_FAIL]) 345 417 346 418 if (not b in probe['unsigned_strcs']): 347 print_error(['Unable to find appropriate unsigned printf formatter for %u bytes ' % b,419 print_error(['Unable to find appropriate unsigned printf formatter for %u bytes.' % b, 348 420 COMPILER_FAIL]) 349 421 350 422 if (not b in probe['signed_strcs']): 351 print_error(['Unable to find appropriate signed printf formatter for %u bytes ' % b,423 print_error(['Unable to find appropriate signed printf formatter for %u bytes.' % b, 352 424 COMPILER_FAIL]) 353 425 354 426 if (not b in probe['unsigned_concs']): 355 print_error(['Unable to find appropriate unsigned literal macro for %u bytes ' % b,427 print_error(['Unable to find appropriate unsigned literal macro for %u bytes.' % b, 356 428 COMPILER_FAIL]) 357 429 358 430 if (not b in probe['signed_concs']): 359 print_error(['Unable to find appropriate signed literal macro for %u bytes ' % b,431 print_error(['Unable to find appropriate signed literal macro for %u bytes.' % b, 360 432 COMPILER_FAIL]) 361 433 … … 384 456 macros.append({'oldmacro': "c ## %s" % name, 'newmacro': "INT%u_C(c)" % (b * 8)}) 385 457 386 for tag in tags:458 for tag in inttags: 387 459 newmacro = "U%s" % tag 388 460 if (not tag in probe['unsigned_tags']): 389 print_error(['Unable to find appropriate size macro for %s ' % newmacro,461 print_error(['Unable to find appropriate size macro for %s.' % newmacro, 390 462 COMPILER_FAIL]) 391 463 … … 393 465 macros.append({'oldmacro': "%s_MIN" % oldmacro, 'newmacro': "%s_MIN" % newmacro}) 394 466 macros.append({'oldmacro': "%s_MAX" % oldmacro, 'newmacro': "%s_MAX" % newmacro}) 467 macros.append({'oldmacro': "1", 'newmacro': 'U%s_SIZE_%s' % (tag, probe['unsigned_tags'][tag] * 8)}) 395 468 396 469 newmacro = tag 397 if (not tag in probe[' unsigned_tags']):470 if (not tag in probe['signed_tags']): 398 471 print_error(['Unable to find appropriate size macro for %s' % newmacro, 399 472 COMPILER_FAIL]) … … 402 475 macros.append({'oldmacro': "%s_MIN" % oldmacro, 'newmacro': "%s_MIN" % newmacro}) 403 476 macros.append({'oldmacro': "%s_MAX" % oldmacro, 'newmacro': "%s_MAX" % newmacro}) 477 macros.append({'oldmacro': "1", 'newmacro': '%s_SIZE_%s' % (tag, probe['signed_tags'][tag] * 8)}) 478 479 for tag in floattags: 480 if (not tag in probe['float_tags']): 481 print_error(['Unable to find appropriate size macro for %s' % tag, 482 COMPILER_FAIL]) 483 484 macros.append({'oldmacro': "1", 'newmacro': '%s_SIZE_%s' % (tag, probe['float_tags'][tag] * 8)}) 485 486 if (not 'size' in probe['builtin_signs']): 487 print_error(['Unable to determine whether size_t is signed or unsigned.', 488 COMPILER_FAIL]) 489 490 if (probe['builtin_signs']['size'] != 'unsigned'): 491 print_error(['The type size_t is not unsigned.', 492 COMPILER_FAIL]) 404 493 405 494 fnd = True 406 495 407 if (not 'wchar' in probe['builtin s']):496 if (not 'wchar' in probe['builtin_sizes']): 408 497 print_warning(['The compiler does not provide the macro __WCHAR_TYPE__', 409 498 'for defining the compiler-native type wchar_t. We are', … … 412 501 fnd = False 413 502 414 if (probe['builtin s']['wchar']['value'] != 4):503 if (probe['builtin_sizes']['wchar']['value'] != 4): 415 504 print_warning(['The compiler provided macro __WCHAR_TYPE__ for defining', 416 505 'the compiler-native type wchar_t is not compliant with', … … 425 514 macros.append({'oldmacro': "__WCHAR_TYPE__", 'newmacro': "wchar_t"}) 426 515 516 if (not 'wchar' in probe['builtin_signs']): 517 print_error(['Unable to determine whether wchar_t is signed or unsigned.', 518 COMPILER_FAIL]) 519 520 if (probe['builtin_signs']['wchar'] == 'unsigned'): 521 macros.append({'oldmacro': "1", 'newmacro': 'WCHAR_IS_UNSIGNED'}) 522 if (probe['builtin_signs']['wchar'] == 'signed'): 523 macros.append({'oldmacro': "1", 'newmacro': 'WCHAR_IS_SIGNED'}) 524 427 525 fnd = True 428 526 429 if (not 'wint' in probe['builtin s']):527 if (not 'wint' in probe['builtin_sizes']): 430 528 print_warning(['The compiler does not provide the macro __WINT_TYPE__', 431 529 'for defining the compiler-native type wint_t. We are', … … 434 532 fnd = False 435 533 436 if (probe['builtin s']['wint']['value'] != 4):534 if (probe['builtin_sizes']['wint']['value'] != 4): 437 535 print_warning(['The compiler provided macro __WINT_TYPE__ for defining', 438 536 'the compiler-native type wint_t is not compliant with', … … 447 545 macros.append({'oldmacro': "__WINT_TYPE__", 'newmacro': "wint_t"}) 448 546 547 if (not 'wint' in probe['builtin_signs']): 548 print_error(['Unable to determine whether wint_t is signed or unsigned.', 549 COMPILER_FAIL]) 550 551 if (probe['builtin_signs']['wint'] == 'unsigned'): 552 macros.append({'oldmacro': "1", 'newmacro': 'WINT_IS_UNSIGNED'}) 553 if (probe['builtin_signs']['wint'] == 'signed'): 554 macros.append({'oldmacro': "1", 'newmacro': 'WINT_IS_SIGNED'}) 555 449 556 return {'macros': macros, 'typedefs': typedefs} 450 557 … … 459 566 460 567 for key, value in common.items(): 461 outmk.write('%s = %s\n' % (key, value)) 568 if (type(value) is list): 569 outmk.write('%s = %s\n' % (key, " ".join(value))) 570 else: 571 outmk.write('%s = %s\n' % (key, value)) 462 572 463 573 outmk.close() … … 535 645 536 646 if (config['CROSS_TARGET'] == "arm32"): 537 gnu_target = "arm-linux-gnu "647 gnu_target = "arm-linux-gnueabi" 538 648 539 649 if (config['CROSS_TARGET'] == "ia32"): … … 550 660 if (config['PLATFORM'] == "arm32"): 551 661 target = config['PLATFORM'] 552 gnu_target = "arm-linux-gnu "662 gnu_target = "arm-linux-gnueabi" 553 663 554 664 if (config['PLATFORM'] == "ia32"): … … 624 734 # Platform-specific utilities 625 735 if ((config['BARCH'] == "amd64") or (config['BARCH'] == "ia32") or (config['BARCH'] == "ppc32") or (config['BARCH'] == "sparc64")): 626 c heck_app(["mkisofs","--version"], "ISO 9660 creation utility", "usually part of genisoimage")736 common['GENISOIMAGE'] = check_app_alternatives(["mkisofs", "genisoimage"], ["--version"], "ISO 9660 creation utility", "usually part of genisoimage") 627 737 628 738 probe = probe_compiler(common, … … 633 743 {'type': 'short int', 'tag': 'SHORT', 'strc': '"h"', 'conc': '"@"'}, 634 744 {'type': 'char', 'tag': 'CHAR', 'strc': '"hh"', 'conc': '"@@"'} 745 ], 746 [ 747 {'type': 'long double', 'tag': 'LONG_DOUBLE'}, 748 {'type': 'double', 'tag': 'DOUBLE'}, 749 {'type': 'float', 'tag': 'FLOAT'} 635 750 ] 636 751 ) 637 752 638 maps = detect_ uints(probe, [1, 2, 4, 8], ['CHAR', 'SHORT', 'INT', 'LONG', 'LLONG'])753 maps = detect_sizes(probe, [1, 2, 4, 8], ['CHAR', 'SHORT', 'INT', 'LONG', 'LLONG'], ['LONG_DOUBLE', 'DOUBLE', 'FLOAT']) 639 754 640 755 finally:
Note:
See TracChangeset
for help on using the changeset viewer.