Changes in tools/autotool.py [85369b1:9539be6] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tools/autotool.py
r85369b1 r9539be6 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.4.3 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, strc, conc,value) \\56 PROBE_HEAD = """#define AUTOTOOL_DECLARE(category, subcategory, tag, name, value) \\ 57 57 asm volatile ( \\ 58 "AUTOTOOL_DECLARE\\t" category "\\t" subcategory "\\t" tag "\\t" name "\\t " strc "\\t" conc "\\t%[val]\\n" \\58 "AUTOTOOL_DECLARE\\t" category "\\t" subcategory "\\t" tag "\\t" name "\\t%[val]\\n" \\ 59 59 : \\ 60 60 : [val] "n" (value) \\ 61 61 ) 62 62 63 #define DECLARE_INTSIZE(tag, type , strc, conc) \\64 AUTOTOOL_DECLARE("intsize", "unsigned", tag, #type, s trc, conc, sizeof(unsigned type)); \\65 AUTOTOOL_DECLARE("intsize", "signed", tag, #type, s trc, conc, sizeof(signed type));63 #define DECLARE_INTSIZE(tag, type) \\ 64 AUTOTOOL_DECLARE("intsize", "unsigned", tag, #type, sizeof(unsigned type)); \\ 65 AUTOTOOL_DECLARE("intsize", "signed", tag, #type, sizeof(signed type)) 66 66 67 67 int main(int argc, char *argv[]) … … 75 75 "Read HelenOS build configuration" 76 76 77 inf = open(fname, 'r')77 inf = file(fname, 'r') 78 78 79 79 for line in inf: … … 191 191 check_common(common, "CC") 192 192 193 outf = open(PROBE_SOURCE, 'w')193 outf = file(PROBE_SOURCE, 'w') 194 194 outf.write(PROBE_HEAD) 195 195 196 196 for typedef in sizes: 197 outf.write("\tDECLARE_INTSIZE(\"%s\", %s , %s, %s);\n" % (typedef['tag'], typedef['type'], typedef['strc'], typedef['conc']))197 outf.write("\tDECLARE_INTSIZE(\"%s\", %s);\n" % (typedef['tag'], typedef['type'])) 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 = open(PROBE_OUTPUT, 'r')223 inf = file(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 239 233 for j in range(len(lines)): 240 234 tokens = lines[j].strip().split("\t") … … 242 236 if (len(tokens) > 0): 243 237 if (tokens[0] == "AUTOTOOL_DECLARE"): 244 if (len(tokens) < 7):238 if (len(tokens) < 5): 245 239 print_error(["Malformed declaration in \"%s\" on line %s." % (PROBE_OUTPUT, j), COMPILER_FAIL]) 246 240 … … 249 243 tag = tokens[3] 250 244 name = tokens[4] 251 strc = tokens[5] 252 conc = tokens[6] 253 value = tokens[7] 245 value = tokens[5] 254 246 255 247 if (category == "intsize"): … … 271 263 unsigned_sizes[name] = value_int 272 264 unsigned_tags[tag] = value_int 273 unsigned_strcs[strc] = value_int274 unsigned_concs[conc] = value_int275 265 elif (subcategory == "signed"): 276 266 signed_sizes[name] = value_int 277 267 signed_tags[tag] = value_int 278 signed_strcs[strc] = value_int279 signed_concs[conc] = value_int280 268 else: 281 269 print_error(["Unexpected keyword \"%s\" in \"%s\" on line %s." % (subcategory, PROBE_OUTPUT, j), COMPILER_FAIL]) 282 270 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}271 return {'unsigned_sizes' : unsigned_sizes, 'signed_sizes' : signed_sizes, 'unsigned_tags': unsigned_tags, 'signed_tags': signed_tags} 284 272 285 273 def detect_uints(probe, bytes): … … 291 279 for b in bytes: 292 280 fnd = False 281 newtype = "uint%s_t" % (b * 8) 282 293 283 for name, value in probe['unsigned_sizes'].items(): 294 284 if (value == b): 295 typedefs.append({'oldtype': "unsigned %s" % name, 'newtype': "uint%u_t" % (b * 8)}) 285 oldtype = "unsigned %s" % name 286 typedefs.append({'oldtype' : oldtype, 'newtype' : newtype}) 296 287 fnd = True 297 288 break 298 289 299 290 if (not fnd): 300 print_error(['Unable to find appropriate unsigned integer type for %u bytes' % b,291 print_error(['Unable to find appropriate integer type for %s' % newtype, 301 292 COMPILER_FAIL]) 302 293 303 294 304 295 fnd = False 296 newtype = "int%s_t" % (b * 8) 297 305 298 for name, value in probe['signed_sizes'].items(): 306 299 if (value == b): 307 typedefs.append({'oldtype': "signed %s" % name, 'newtype': "int%u_t" % (b * 8)}) 300 oldtype = "signed %s" % name 301 typedefs.append({'oldtype' : oldtype, 'newtype' : newtype}) 308 302 fnd = True 309 303 break 310 304 311 305 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, 306 print_error(['Unable to find appropriate integer type for %s' % newtype, 370 307 COMPILER_FAIL]) 371 308 … … 406 343 "Create makefile output" 407 344 408 outmk = open(mkname, 'w')345 outmk = file(mkname, 'w') 409 346 410 347 outmk.write('#########################################\n') … … 420 357 "Create header output" 421 358 422 outhd = open(hdname, 'w')359 outhd = file(hdname, 'w') 423 360 424 361 outhd.write('/***************************************\n') … … 571 508 probe = probe_compiler(common, 572 509 [ 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"'}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'} 578 515 ] 579 516 )
Note:
See TracChangeset
for help on using the changeset viewer.