Changes in tools/autotool.py [9539be6:85369b1] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tools/autotool.py
r9539be6 r85369b1 49 49 50 50 PACKAGE_BINUTILS = "usually part of binutils" 51 PACKAGE_GCC = "preferably version 4. 4.3or newer"51 PACKAGE_GCC = "preferably version 4.5.1 or newer" 52 52 PACKAGE_CROSS = "use tools/toolchain.sh to build the cross-compiler toolchain" 53 53 54 54 COMPILER_FAIL = "The compiler is probably not capable to compile HelenOS." 55 55 56 PROBE_HEAD = """#define AUTOTOOL_DECLARE(category, subcategory, tag, name, value) \\56 PROBE_HEAD = """#define AUTOTOOL_DECLARE(category, subcategory, tag, name, strc, conc, value) \\ 57 57 asm volatile ( \\ 58 "AUTOTOOL_DECLARE\\t" category "\\t" subcategory "\\t" tag "\\t" name "\\t %[val]\\n" \\58 "AUTOTOOL_DECLARE\\t" category "\\t" subcategory "\\t" tag "\\t" name "\\t" strc "\\t" conc "\\t%[val]\\n" \\ 59 59 : \\ 60 60 : [val] "n" (value) \\ 61 61 ) 62 62 63 #define DECLARE_INTSIZE(tag, type ) \\64 AUTOTOOL_DECLARE("intsize", "unsigned", tag, #type, s izeof(unsigned type)); \\65 AUTOTOOL_DECLARE("intsize", "signed", tag, #type, s izeof(signed type))63 #define DECLARE_INTSIZE(tag, type, strc, conc) \\ 64 AUTOTOOL_DECLARE("intsize", "unsigned", tag, #type, strc, conc, sizeof(unsigned type)); \\ 65 AUTOTOOL_DECLARE("intsize", "signed", tag, #type, strc, conc, sizeof(signed type)); 66 66 67 67 int main(int argc, char *argv[]) … … 75 75 "Read HelenOS build configuration" 76 76 77 inf = file(fname, 'r')77 inf = open(fname, 'r') 78 78 79 79 for line in inf: … … 191 191 check_common(common, "CC") 192 192 193 outf = file(PROBE_SOURCE, 'w')193 outf = open(PROBE_SOURCE, 'w') 194 194 outf.write(PROBE_HEAD) 195 195 196 196 for typedef in sizes: 197 outf.write("\tDECLARE_INTSIZE(\"%s\", %s );\n" % (typedef['tag'], typedef['type']))197 outf.write("\tDECLARE_INTSIZE(\"%s\", %s, %s, %s);\n" % (typedef['tag'], typedef['type'], typedef['strc'], typedef['conc'])) 198 198 199 199 outf.write(PROBE_TAIL) … … 212 212 if (not os.path.isfile(PROBE_OUTPUT)): 213 213 sys.stderr.write("failed\n") 214 print output[1]214 print(output[1]) 215 215 print_error(["Error executing \"%s\"." % " ".join(args), 216 216 "The compiler did not produce the output file \"%s\"." % PROBE_OUTPUT, … … 221 221 sys.stderr.write("ok\n") 222 222 223 inf = file(PROBE_OUTPUT, 'r')223 inf = open(PROBE_OUTPUT, 'r') 224 224 lines = inf.readlines() 225 225 inf.close() … … 231 231 signed_tags = {} 232 232 233 unsigned_strcs = {} 234 signed_strcs = {} 235 236 unsigned_concs = {} 237 signed_concs = {} 238 233 239 for j in range(len(lines)): 234 240 tokens = lines[j].strip().split("\t") … … 236 242 if (len(tokens) > 0): 237 243 if (tokens[0] == "AUTOTOOL_DECLARE"): 238 if (len(tokens) < 5):244 if (len(tokens) < 7): 239 245 print_error(["Malformed declaration in \"%s\" on line %s." % (PROBE_OUTPUT, j), COMPILER_FAIL]) 240 246 … … 243 249 tag = tokens[3] 244 250 name = tokens[4] 245 value = tokens[5] 251 strc = tokens[5] 252 conc = tokens[6] 253 value = tokens[7] 246 254 247 255 if (category == "intsize"): … … 263 271 unsigned_sizes[name] = value_int 264 272 unsigned_tags[tag] = value_int 273 unsigned_strcs[strc] = value_int 274 unsigned_concs[conc] = value_int 265 275 elif (subcategory == "signed"): 266 276 signed_sizes[name] = value_int 267 277 signed_tags[tag] = value_int 278 signed_strcs[strc] = value_int 279 signed_concs[conc] = value_int 268 280 else: 269 281 print_error(["Unexpected keyword \"%s\" in \"%s\" on line %s." % (subcategory, PROBE_OUTPUT, j), COMPILER_FAIL]) 270 282 271 return {'unsigned_sizes' : unsigned_sizes, 'signed_sizes' : signed_sizes, 'unsigned_tags': unsigned_tags, 'signed_tags': signed_tags}283 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} 272 284 273 285 def detect_uints(probe, bytes): … … 279 291 for b in bytes: 280 292 fnd = False 281 newtype = "uint%s_t" % (b * 8)282 283 293 for name, value in probe['unsigned_sizes'].items(): 284 294 if (value == b): 285 oldtype = "unsigned %s" % name 286 typedefs.append({'oldtype' : oldtype, 'newtype' : newtype}) 287 fnd = True 288 break 289 290 if (not fnd): 291 print_error(['Unable to find appropriate integer type for %s' % newtype, 295 typedefs.append({'oldtype': "unsigned %s" % name, 'newtype': "uint%u_t" % (b * 8)}) 296 fnd = True 297 break 298 299 if (not fnd): 300 print_error(['Unable to find appropriate unsigned integer type for %u bytes' % b, 292 301 COMPILER_FAIL]) 293 302 294 303 295 304 fnd = False 296 newtype = "int%s_t" % (b * 8)297 298 305 for name, value in probe['signed_sizes'].items(): 299 306 if (value == b): 300 oldtype = "signed %s" % name 301 typedefs.append({'oldtype' : oldtype, 'newtype' : newtype}) 302 fnd = True 303 break 304 305 if (not fnd): 306 print_error(['Unable to find appropriate integer type for %s' % newtype, 307 typedefs.append({'oldtype': "signed %s" % name, 'newtype': "int%u_t" % (b * 8)}) 308 fnd = True 309 break 310 311 if (not fnd): 312 print_error(['Unable to find appropriate signed integer type for %u bytes' % b, 313 COMPILER_FAIL]) 314 315 316 fnd = False 317 for name, value in probe['unsigned_strcs'].items(): 318 if (value == b): 319 macros.append({'oldmacro': "\"%so\"" % name, 'newmacro': "PRIo%u" % (b * 8)}) 320 macros.append({'oldmacro': "\"%su\"" % name, 'newmacro': "PRIu%u" % (b * 8)}) 321 macros.append({'oldmacro': "\"%sx\"" % name, 'newmacro': "PRIx%u" % (b * 8)}) 322 macros.append({'oldmacro': "\"%sX\"" % name, 'newmacro': "PRIX%u" % (b * 8)}) 323 fnd = True 324 break 325 326 if (not fnd): 327 print_error(['Unable to find appropriate unsigned printf formatter for %u bytes' % b, 328 COMPILER_FAIL]) 329 330 331 fnd = False 332 for name, value in probe['signed_strcs'].items(): 333 if (value == b): 334 macros.append({'oldmacro': "\"%sd\"" % name, 'newmacro': "PRId%u" % (b * 8)}) 335 fnd = True 336 break 337 338 if (not fnd): 339 print_error(['Unable to find appropriate signed printf formatter for %u bytes' % b, 340 COMPILER_FAIL]) 341 342 343 fnd = False 344 for name, value in probe['unsigned_concs'].items(): 345 if (value == b): 346 if ((name.startswith('@')) or (name == "")): 347 macros.append({'oldmacro': "c ## U", 'newmacro': "UINT%u_C(c)" % (b * 8)}) 348 else: 349 macros.append({'oldmacro': "c ## U%s" % name, 'newmacro': "UINT%u_C(c)" % (b * 8)}) 350 fnd = True 351 break 352 353 if (not fnd): 354 print_error(['Unable to find appropriate unsigned literal macro for %u bytes' % b, 355 COMPILER_FAIL]) 356 357 358 fnd = False 359 for name, value in probe['signed_concs'].items(): 360 if (value == b): 361 if ((name.startswith('@')) or (name == "")): 362 macros.append({'oldmacro': "c", 'newmacro': "INT%u_C(c)" % (b * 8)}) 363 else: 364 macros.append({'oldmacro': "c ## %s" % name, 'newmacro': "INT%u_C(c)" % (b * 8)}) 365 fnd = True 366 break 367 368 if (not fnd): 369 print_error(['Unable to find appropriate unsigned literal macro for %u bytes' % b, 307 370 COMPILER_FAIL]) 308 371 … … 343 406 "Create makefile output" 344 407 345 outmk = file(mkname, 'w')408 outmk = open(mkname, 'w') 346 409 347 410 outmk.write('#########################################\n') … … 357 420 "Create header output" 358 421 359 outhd = file(hdname, 'w')422 outhd = open(hdname, 'w') 360 423 361 424 outhd.write('/***************************************\n') … … 508 571 probe = probe_compiler(common, 509 572 [ 510 {'type': 'char', 'tag': 'CHAR' },511 {'type': 'short int', 'tag': 'SHORT' },512 {'type': 'int', 'tag': 'INT' },513 {'type': 'long int', 'tag': 'LONG' },514 {'type': 'long long int', 'tag': 'LLONG' }573 {'type': 'char', 'tag': 'CHAR', 'strc': '"hh"', 'conc': '"@@"'}, 574 {'type': 'short int', 'tag': 'SHORT', 'strc': '"h"', 'conc': '"@"'}, 575 {'type': 'int', 'tag': 'INT', 'strc': '""', 'conc': '""'}, 576 {'type': 'long int', 'tag': 'LONG', 'strc': '"l"', 'conc': '"L"'}, 577 {'type': 'long long int', 'tag': 'LLONG', 'strc': '"ll"', 'conc': '"LL"'} 515 578 ] 516 579 )
Note:
See TracChangeset
for help on using the changeset viewer.