Changeset 81716eb in mainline for tools/autotool.py


Ignore:
Timestamp:
2012-04-08T17:53:15Z (12 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
c5bff3c
Parents:
1b90e90 (diff), f3378ba (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Mainline changes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tools/autotool.py

    r1b90e90 r81716eb  
    4949
    5050PACKAGE_BINUTILS = "usually part of binutils"
    51 PACKAGE_GCC = "preferably version 4.5.1 or newer"
     51PACKAGE_GCC = "preferably version 4.7.0 or newer"
    5252PACKAGE_CROSS = "use tools/toolchain.sh to build the cross-compiler toolchain"
    5353
     
    6666
    6767#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));
    6979
    7080#define DECLARE_INTSIZE(tag, type, strc, conc) \\
    7181        AUTOTOOL_DECLARE("intsize", "unsigned", tag, #type, strc, conc, sizeof(unsigned type)); \\
    7282        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));
    7386
    7487int main(int argc, char *argv[])
     
    262275        return int(value, base)
    263276
    264 def probe_compiler(common, sizes):
     277def probe_compiler(common, intsizes, floatsizes):
    265278        "Generate, compile and parse probing source"
    266279       
     
    270283        outf.write(PROBE_HEAD)
    271284       
    272         for typedef in sizes:
     285        for typedef in intsizes:
    273286                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']))
    274290       
    275291        outf.write(PROBE_TAIL)
     
    315331        signed_concs = {}
    316332       
    317         builtins = {}
     333        float_tags = {}
     334       
     335        builtin_sizes = {}
     336        builtin_signs = {}
    318337       
    319338        for j in range(len(lines)):
     
    352371                                                print_error(["Unexpected keyword \"%s\" in \"%s\" on line %s." % (subcategory, PROBE_OUTPUT, j), COMPILER_FAIL])
    353372                               
    354                                 if (category == "builtin"):
     373                                if (category == "floatsize"):
    355374                                        try:
    356375                                                value_int = decode_value(value)
     
    358377                                                print_error(["Integer value expected in \"%s\" on line %s." % (PROBE_OUTPUT, j), COMPILER_FAIL])
    359378                                       
    360                                         builtins[tag] = {'name': name, 'value': value_int}
    361        
    362         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}
    363 
    364 def detect_uints(probe, bytes, tags):
    365         "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
     403def detect_sizes(probe, bytes, inttags, floattags):
     404        "Detect correct types for fixed-size types"
    366405       
    367406        macros = []
     
    370409        for b in bytes:
    371410                if (not b in probe['unsigned_sizes']):
    372                         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,
    373412                                     COMPILER_FAIL])
    374413               
    375414                if (not b in probe['signed_sizes']):
    376                         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,
    377416                                     COMPILER_FAIL])
    378417               
    379418                if (not b in probe['unsigned_strcs']):
    380                         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,
    381420                                     COMPILER_FAIL])
    382421               
    383422                if (not b in probe['signed_strcs']):
    384                         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,
    385424                                     COMPILER_FAIL])
    386425               
    387426                if (not b in probe['unsigned_concs']):
    388                         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,
    389428                                     COMPILER_FAIL])
    390429               
    391430                if (not b in probe['signed_concs']):
    392                         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,
    393432                                     COMPILER_FAIL])
    394433               
     
    417456                        macros.append({'oldmacro': "c ## %s" % name, 'newmacro': "INT%u_C(c)" % (b * 8)})
    418457       
    419         for tag in tags:
     458        for tag in inttags:
    420459                newmacro = "U%s" % tag
    421460                if (not tag in probe['unsigned_tags']):
    422                         print_error(['Unable to find appropriate size macro for %s' % newmacro,
     461                        print_error(['Unable to find appropriate size macro for %s.' % newmacro,
    423462                                     COMPILER_FAIL])
    424463               
     
    426465                macros.append({'oldmacro': "%s_MIN" % oldmacro, 'newmacro': "%s_MIN" % newmacro})
    427466                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)})
    428468               
    429469                newmacro = tag
    430                 if (not tag in probe['unsigned_tags']):
     470                if (not tag in probe['signed_tags']):
    431471                        print_error(['Unable to find appropriate size macro for %s' % newmacro,
    432472                                     COMPILER_FAIL])
     
    435475                macros.append({'oldmacro': "%s_MIN" % oldmacro, 'newmacro': "%s_MIN" % newmacro})
    436476                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])
    437493       
    438494        fnd = True
    439495       
    440         if (not 'wchar' in probe['builtins']):
     496        if (not 'wchar' in probe['builtin_sizes']):
    441497                print_warning(['The compiler does not provide the macro __WCHAR_TYPE__',
    442498                               'for defining the compiler-native type wchar_t. We are',
     
    445501                fnd = False
    446502       
    447         if (probe['builtins']['wchar']['value'] != 4):
     503        if (probe['builtin_sizes']['wchar']['value'] != 4):
    448504                print_warning(['The compiler provided macro __WCHAR_TYPE__ for defining',
    449505                               'the compiler-native type wchar_t is not compliant with',
     
    458514                macros.append({'oldmacro': "__WCHAR_TYPE__", 'newmacro': "wchar_t"})
    459515       
     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       
    460525        fnd = True
    461526       
    462         if (not 'wint' in probe['builtins']):
     527        if (not 'wint' in probe['builtin_sizes']):
    463528                print_warning(['The compiler does not provide the macro __WINT_TYPE__',
    464529                               'for defining the compiler-native type wint_t. We are',
     
    467532                fnd = False
    468533       
    469         if (probe['builtins']['wint']['value'] != 4):
     534        if (probe['builtin_sizes']['wint']['value'] != 4):
    470535                print_warning(['The compiler provided macro __WINT_TYPE__ for defining',
    471536                               'the compiler-native type wint_t is not compliant with',
     
    479544        else:
    480545                macros.append({'oldmacro': "__WINT_TYPE__", 'newmacro': "wint_t"})
     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'})
    481555       
    482556        return {'macros': macros, 'typedefs': typedefs}
     
    571645                               
    572646                                if (config['CROSS_TARGET'] == "arm32"):
    573                                         gnu_target = "arm-linux-gnu"
     647                                        gnu_target = "arm-linux-gnueabi"
    574648                               
    575649                                if (config['CROSS_TARGET'] == "ia32"):
     
    586660                        if (config['PLATFORM'] == "arm32"):
    587661                                target = config['PLATFORM']
    588                                 gnu_target = "arm-linux-gnu"
     662                                gnu_target = "arm-linux-gnueabi"
    589663                       
    590664                        if (config['PLATFORM'] == "ia32"):
     
    669743                                {'type': 'short int', 'tag': 'SHORT', 'strc': '"h"', 'conc': '"@"'},
    670744                                {'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'}
    671750                        ]
    672751                )
    673752               
    674                 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'])
    675754               
    676755        finally:
Note: See TracChangeset for help on using the changeset viewer.