| 1 | #!/usr/bin/env python | 
|---|
| 2 | # | 
|---|
| 3 | # Copyright (c) 2010 Martin Decky | 
|---|
| 4 | # All rights reserved. | 
|---|
| 5 | # | 
|---|
| 6 | # Redistribution and use in source and binary forms, with or without | 
|---|
| 7 | # modification, are permitted provided that the following conditions | 
|---|
| 8 | # are met: | 
|---|
| 9 | # | 
|---|
| 10 | # - Redistributions of source code must retain the above copyright | 
|---|
| 11 | #   notice, this list of conditions and the following disclaimer. | 
|---|
| 12 | # - Redistributions in binary form must reproduce the above copyright | 
|---|
| 13 | #   notice, this list of conditions and the following disclaimer in the | 
|---|
| 14 | #   documentation and/or other materials provided with the distribution. | 
|---|
| 15 | # - The name of the author may not be used to endorse or promote products | 
|---|
| 16 | #   derived from this software without specific prior written permission. | 
|---|
| 17 | # | 
|---|
| 18 | # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | 
|---|
| 19 | # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | 
|---|
| 20 | # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | 
|---|
| 21 | # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | 
|---|
| 22 | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | 
|---|
| 23 | # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 
|---|
| 24 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 
|---|
| 25 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 
|---|
| 26 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 
|---|
| 27 | # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 
|---|
| 28 | # | 
|---|
| 29 |  | 
|---|
| 30 | """ | 
|---|
| 31 | Detect important prerequisites and parameters for building HelenOS | 
|---|
| 32 | """ | 
|---|
| 33 |  | 
|---|
| 34 | import sys | 
|---|
| 35 | import os | 
|---|
| 36 | import shutil | 
|---|
| 37 | import re | 
|---|
| 38 | import time | 
|---|
| 39 | import subprocess | 
|---|
| 40 |  | 
|---|
| 41 | SANDBOX = 'autotool' | 
|---|
| 42 | CONFIG = 'Makefile.config' | 
|---|
| 43 | MAKEFILE = 'Makefile.common' | 
|---|
| 44 | HEADER = 'common.h' | 
|---|
| 45 | GUARD = 'AUTOTOOL_COMMON_H_' | 
|---|
| 46 |  | 
|---|
| 47 | PROBE_SOURCE = 'probe.c' | 
|---|
| 48 | PROBE_OUTPUT = 'probe.s' | 
|---|
| 49 |  | 
|---|
| 50 | PACKAGE_BINUTILS = "usually part of binutils" | 
|---|
| 51 | PACKAGE_GCC = "preferably version 4.7.0 or newer" | 
|---|
| 52 | PACKAGE_CROSS = "use tools/toolchain.sh to build the cross-compiler toolchain" | 
|---|
| 53 |  | 
|---|
| 54 | COMPILER_FAIL = "The compiler is probably not capable to compile HelenOS." | 
|---|
| 55 | COMPILER_WARNING = "The compilation of HelenOS might fail." | 
|---|
| 56 |  | 
|---|
| 57 | PROBE_HEAD = """#define AUTOTOOL_DECLARE(category, subcategory, tag, name, strc, conc, value) \\ | 
|---|
| 58 | asm volatile ( \\ | 
|---|
| 59 | "AUTOTOOL_DECLARE\\t" category "\\t" subcategory "\\t" tag "\\t" name "\\t" strc "\\t" conc "\\t%[val]\\n" \\ | 
|---|
| 60 | : \\ | 
|---|
| 61 | : [val] "n" (value) \\ | 
|---|
| 62 | ) | 
|---|
| 63 |  | 
|---|
| 64 | #define STRING(arg)      STRING_ARG(arg) | 
|---|
| 65 | #define STRING_ARG(arg)  #arg | 
|---|
| 66 |  | 
|---|
| 67 | #define DECLARE_BUILTIN_TYPE(tag, 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)); | 
|---|
| 79 |  | 
|---|
| 80 | #define DECLARE_INTSIZE(tag, type, strc, conc) \\ | 
|---|
| 81 | AUTOTOOL_DECLARE("intsize", "unsigned", tag, #type, strc, conc, sizeof(unsigned type)); \\ | 
|---|
| 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)); | 
|---|
| 86 |  | 
|---|
| 87 | int main(int argc, char *argv[]) | 
|---|
| 88 | { | 
|---|
| 89 | #ifdef __SIZE_TYPE__ | 
|---|
| 90 | DECLARE_BUILTIN_TYPE("size", __SIZE_TYPE__); | 
|---|
| 91 | #endif | 
|---|
| 92 | #ifdef __WCHAR_TYPE__ | 
|---|
| 93 | DECLARE_BUILTIN_TYPE("wchar", __WCHAR_TYPE__); | 
|---|
| 94 | #endif | 
|---|
| 95 | #ifdef __WINT_TYPE__ | 
|---|
| 96 | DECLARE_BUILTIN_TYPE("wint", __WINT_TYPE__); | 
|---|
| 97 | #endif | 
|---|
| 98 | """ | 
|---|
| 99 |  | 
|---|
| 100 | PROBE_TAIL = """} | 
|---|
| 101 | """ | 
|---|
| 102 |  | 
|---|
| 103 | def read_config(fname, config): | 
|---|
| 104 | "Read HelenOS build configuration" | 
|---|
| 105 |  | 
|---|
| 106 | inf = open(fname, 'r') | 
|---|
| 107 |  | 
|---|
| 108 | for line in inf: | 
|---|
| 109 | res = re.match(r'^(?:#!# )?([^#]\w*)\s*=\s*(.*?)\s*$', line) | 
|---|
| 110 | if (res): | 
|---|
| 111 | config[res.group(1)] = res.group(2) | 
|---|
| 112 |  | 
|---|
| 113 | inf.close() | 
|---|
| 114 |  | 
|---|
| 115 | def print_error(msg): | 
|---|
| 116 | "Print a bold error message" | 
|---|
| 117 |  | 
|---|
| 118 | sys.stderr.write("\n") | 
|---|
| 119 | sys.stderr.write("######################################################################\n") | 
|---|
| 120 | sys.stderr.write("HelenOS build sanity check error:\n") | 
|---|
| 121 | sys.stderr.write("\n") | 
|---|
| 122 | sys.stderr.write("%s\n" % "\n".join(msg)) | 
|---|
| 123 | sys.stderr.write("######################################################################\n") | 
|---|
| 124 | sys.stderr.write("\n") | 
|---|
| 125 |  | 
|---|
| 126 | sys.exit(1) | 
|---|
| 127 |  | 
|---|
| 128 | def print_warning(msg): | 
|---|
| 129 | "Print a bold error message" | 
|---|
| 130 |  | 
|---|
| 131 | sys.stderr.write("\n") | 
|---|
| 132 | sys.stderr.write("######################################################################\n") | 
|---|
| 133 | sys.stderr.write("HelenOS build sanity check warning:\n") | 
|---|
| 134 | sys.stderr.write("\n") | 
|---|
| 135 | sys.stderr.write("%s\n" % "\n".join(msg)) | 
|---|
| 136 | sys.stderr.write("######################################################################\n") | 
|---|
| 137 | sys.stderr.write("\n") | 
|---|
| 138 |  | 
|---|
| 139 | time.sleep(5) | 
|---|
| 140 |  | 
|---|
| 141 | def sandbox_enter(): | 
|---|
| 142 | "Create a temporal sandbox directory for running tests" | 
|---|
| 143 |  | 
|---|
| 144 | if (os.path.exists(SANDBOX)): | 
|---|
| 145 | if (os.path.isdir(SANDBOX)): | 
|---|
| 146 | try: | 
|---|
| 147 | shutil.rmtree(SANDBOX) | 
|---|
| 148 | except: | 
|---|
| 149 | print_error(["Unable to cleanup the directory \"%s\"." % SANDBOX]) | 
|---|
| 150 | else: | 
|---|
| 151 | print_error(["Please inspect and remove unexpected directory,", | 
|---|
| 152 | "entry \"%s\"." % SANDBOX]) | 
|---|
| 153 |  | 
|---|
| 154 | try: | 
|---|
| 155 | os.mkdir(SANDBOX) | 
|---|
| 156 | except: | 
|---|
| 157 | print_error(["Unable to create sandbox directory \"%s\"." % SANDBOX]) | 
|---|
| 158 |  | 
|---|
| 159 | owd = os.getcwd() | 
|---|
| 160 | os.chdir(SANDBOX) | 
|---|
| 161 |  | 
|---|
| 162 | return owd | 
|---|
| 163 |  | 
|---|
| 164 | def sandbox_leave(owd): | 
|---|
| 165 | "Leave the temporal sandbox directory" | 
|---|
| 166 |  | 
|---|
| 167 | os.chdir(owd) | 
|---|
| 168 |  | 
|---|
| 169 | def check_config(config, key): | 
|---|
| 170 | "Check whether the configuration key exists" | 
|---|
| 171 |  | 
|---|
| 172 | if (not key in config): | 
|---|
| 173 | print_error(["Build configuration of HelenOS does not contain %s." % key, | 
|---|
| 174 | "Try running \"make config\" again.", | 
|---|
| 175 | "If the problem persists, please contact the developers of HelenOS."]) | 
|---|
| 176 |  | 
|---|
| 177 | def check_common(common, key): | 
|---|
| 178 | "Check whether the common key exists" | 
|---|
| 179 |  | 
|---|
| 180 | if (not key in common): | 
|---|
| 181 | print_error(["Failed to determine the value %s." % key, | 
|---|
| 182 | "Please contact the developers of HelenOS."]) | 
|---|
| 183 |  | 
|---|
| 184 | def check_app(args, name, details): | 
|---|
| 185 | "Check whether an application can be executed" | 
|---|
| 186 |  | 
|---|
| 187 | try: | 
|---|
| 188 | sys.stderr.write("Checking for %s ... " % args[0]) | 
|---|
| 189 | subprocess.Popen(args, stdout = subprocess.PIPE, stderr = subprocess.PIPE).wait() | 
|---|
| 190 | except: | 
|---|
| 191 | sys.stderr.write("failed\n") | 
|---|
| 192 | print_error(["%s is missing." % name, | 
|---|
| 193 | "", | 
|---|
| 194 | "Execution of \"%s\" has failed. Please make sure that it" % " ".join(args), | 
|---|
| 195 | "is installed in your system (%s)." % details]) | 
|---|
| 196 |  | 
|---|
| 197 | sys.stderr.write("ok\n") | 
|---|
| 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 |  | 
|---|
| 232 | def check_gcc(path, prefix, common, details): | 
|---|
| 233 | "Check for GCC" | 
|---|
| 234 |  | 
|---|
| 235 | common['GCC'] = "%sgcc" % prefix | 
|---|
| 236 |  | 
|---|
| 237 | if (not path is None): | 
|---|
| 238 | common['GCC'] = "%s/%s" % (path, common['GCC']) | 
|---|
| 239 |  | 
|---|
| 240 | check_app([common['GCC'], "--version"], "GNU GCC", details) | 
|---|
| 241 |  | 
|---|
| 242 | def check_binutils(path, prefix, common, details): | 
|---|
| 243 | "Check for binutils toolchain" | 
|---|
| 244 |  | 
|---|
| 245 | common['AS'] = "%sas" % prefix | 
|---|
| 246 | common['LD'] = "%sld" % prefix | 
|---|
| 247 | common['AR'] = "%sar" % prefix | 
|---|
| 248 | common['OBJCOPY'] = "%sobjcopy" % prefix | 
|---|
| 249 | common['OBJDUMP'] = "%sobjdump" % prefix | 
|---|
| 250 | common['STRIP'] = "%sstrip" % prefix | 
|---|
| 251 |  | 
|---|
| 252 | if (not path is None): | 
|---|
| 253 | for key in ["AS", "LD", "AR", "OBJCOPY", "OBJDUMP", "STRIP"]: | 
|---|
| 254 | common[key] = "%s/%s" % (path, common[key]) | 
|---|
| 255 |  | 
|---|
| 256 | check_app([common['AS'], "--version"], "GNU Assembler", details) | 
|---|
| 257 | check_app([common['LD'], "--version"], "GNU Linker", details) | 
|---|
| 258 | check_app([common['AR'], "--version"], "GNU Archiver", details) | 
|---|
| 259 | check_app([common['OBJCOPY'], "--version"], "GNU Objcopy utility", details) | 
|---|
| 260 | check_app([common['OBJDUMP'], "--version"], "GNU Objdump utility", details) | 
|---|
| 261 | check_app([common['STRIP'], "--version"], "GNU strip", details) | 
|---|
| 262 |  | 
|---|
| 263 | def decode_value(value): | 
|---|
| 264 | "Decode integer value" | 
|---|
| 265 |  | 
|---|
| 266 | base = 10 | 
|---|
| 267 |  | 
|---|
| 268 | if ((value.startswith('$')) or (value.startswith('#'))): | 
|---|
| 269 | value = value[1:] | 
|---|
| 270 |  | 
|---|
| 271 | if (value.startswith('0x')): | 
|---|
| 272 | value = value[2:] | 
|---|
| 273 | base = 16 | 
|---|
| 274 |  | 
|---|
| 275 | return int(value, base) | 
|---|
| 276 |  | 
|---|
| 277 | def probe_compiler(common, intsizes, floatsizes): | 
|---|
| 278 | "Generate, compile and parse probing source" | 
|---|
| 279 |  | 
|---|
| 280 | check_common(common, "CC") | 
|---|
| 281 |  | 
|---|
| 282 | outf = open(PROBE_SOURCE, 'w') | 
|---|
| 283 | outf.write(PROBE_HEAD) | 
|---|
| 284 |  | 
|---|
| 285 | for typedef in intsizes: | 
|---|
| 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'])) | 
|---|
| 290 |  | 
|---|
| 291 | outf.write(PROBE_TAIL) | 
|---|
| 292 | outf.close() | 
|---|
| 293 |  | 
|---|
| 294 | args = [common['CC']] | 
|---|
| 295 | args.extend(common['CC_ARGS']) | 
|---|
| 296 | args.extend(["-S", "-o", PROBE_OUTPUT, PROBE_SOURCE]) | 
|---|
| 297 |  | 
|---|
| 298 | try: | 
|---|
| 299 | sys.stderr.write("Checking compiler properties ... ") | 
|---|
| 300 | output = subprocess.Popen(args, stdout = subprocess.PIPE, stderr = subprocess.PIPE).communicate() | 
|---|
| 301 | except: | 
|---|
| 302 | sys.stderr.write("failed\n") | 
|---|
| 303 | print_error(["Error executing \"%s\"." % " ".join(args), | 
|---|
| 304 | "Make sure that the compiler works properly."]) | 
|---|
| 305 |  | 
|---|
| 306 | if (not os.path.isfile(PROBE_OUTPUT)): | 
|---|
| 307 | sys.stderr.write("failed\n") | 
|---|
| 308 | print(output[1]) | 
|---|
| 309 | print_error(["Error executing \"%s\"." % " ".join(args), | 
|---|
| 310 | "The compiler did not produce the output file \"%s\"." % PROBE_OUTPUT, | 
|---|
| 311 | "", | 
|---|
| 312 | output[0], | 
|---|
| 313 | output[1]]) | 
|---|
| 314 |  | 
|---|
| 315 | sys.stderr.write("ok\n") | 
|---|
| 316 |  | 
|---|
| 317 | inf = open(PROBE_OUTPUT, 'r') | 
|---|
| 318 | lines = inf.readlines() | 
|---|
| 319 | inf.close() | 
|---|
| 320 |  | 
|---|
| 321 | unsigned_sizes = {} | 
|---|
| 322 | signed_sizes = {} | 
|---|
| 323 |  | 
|---|
| 324 | unsigned_tags = {} | 
|---|
| 325 | signed_tags = {} | 
|---|
| 326 |  | 
|---|
| 327 | unsigned_strcs = {} | 
|---|
| 328 | signed_strcs = {} | 
|---|
| 329 |  | 
|---|
| 330 | unsigned_concs = {} | 
|---|
| 331 | signed_concs = {} | 
|---|
| 332 |  | 
|---|
| 333 | float_tags = {} | 
|---|
| 334 |  | 
|---|
| 335 | builtin_sizes = {} | 
|---|
| 336 | builtin_signs = {} | 
|---|
| 337 |  | 
|---|
| 338 | for j in range(len(lines)): | 
|---|
| 339 | tokens = lines[j].strip().split("\t") | 
|---|
| 340 |  | 
|---|
| 341 | if (len(tokens) > 0): | 
|---|
| 342 | if (tokens[0] == "AUTOTOOL_DECLARE"): | 
|---|
| 343 | if (len(tokens) < 7): | 
|---|
| 344 | print_error(["Malformed declaration in \"%s\" on line %s." % (PROBE_OUTPUT, j), COMPILER_FAIL]) | 
|---|
| 345 |  | 
|---|
| 346 | category = tokens[1] | 
|---|
| 347 | subcategory = tokens[2] | 
|---|
| 348 | tag = tokens[3] | 
|---|
| 349 | name = tokens[4] | 
|---|
| 350 | strc = tokens[5] | 
|---|
| 351 | conc = tokens[6] | 
|---|
| 352 | value = tokens[7] | 
|---|
| 353 |  | 
|---|
| 354 | if (category == "intsize"): | 
|---|
| 355 | try: | 
|---|
| 356 | value_int = decode_value(value) | 
|---|
| 357 | except: | 
|---|
| 358 | print_error(["Integer value expected in \"%s\" on line %s." % (PROBE_OUTPUT, j), COMPILER_FAIL]) | 
|---|
| 359 |  | 
|---|
| 360 | if (subcategory == "unsigned"): | 
|---|
| 361 | unsigned_sizes[value_int] = name | 
|---|
| 362 | unsigned_tags[tag] = value_int | 
|---|
| 363 | unsigned_strcs[value_int] = strc | 
|---|
| 364 | unsigned_concs[value_int] = conc | 
|---|
| 365 | elif (subcategory == "signed"): | 
|---|
| 366 | signed_sizes[value_int] = name | 
|---|
| 367 | signed_tags[tag] = value_int | 
|---|
| 368 | signed_strcs[value_int] = strc | 
|---|
| 369 | signed_concs[value_int] = conc | 
|---|
| 370 | else: | 
|---|
| 371 | print_error(["Unexpected keyword \"%s\" in \"%s\" on line %s." % (subcategory, PROBE_OUTPUT, j), COMPILER_FAIL]) | 
|---|
| 372 |  | 
|---|
| 373 | if (category == "floatsize"): | 
|---|
| 374 | try: | 
|---|
| 375 | value_int = decode_value(value) | 
|---|
| 376 | except: | 
|---|
| 377 | print_error(["Integer value expected in \"%s\" on line %s." % (PROBE_OUTPUT, j), COMPILER_FAIL]) | 
|---|
| 378 |  | 
|---|
| 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" | 
|---|
| 405 |  | 
|---|
| 406 | macros = [] | 
|---|
| 407 | typedefs = [] | 
|---|
| 408 |  | 
|---|
| 409 | for b in bytes: | 
|---|
| 410 | if (not b in probe['unsigned_sizes']): | 
|---|
| 411 | print_error(['Unable to find appropriate unsigned integer type for %u bytes.' % b, | 
|---|
| 412 | COMPILER_FAIL]) | 
|---|
| 413 |  | 
|---|
| 414 | if (not b in probe['signed_sizes']): | 
|---|
| 415 | print_error(['Unable to find appropriate signed integer type for %u bytes.' % b, | 
|---|
| 416 | COMPILER_FAIL]) | 
|---|
| 417 |  | 
|---|
| 418 | if (not b in probe['unsigned_strcs']): | 
|---|
| 419 | print_error(['Unable to find appropriate unsigned printf formatter for %u bytes.' % b, | 
|---|
| 420 | COMPILER_FAIL]) | 
|---|
| 421 |  | 
|---|
| 422 | if (not b in probe['signed_strcs']): | 
|---|
| 423 | print_error(['Unable to find appropriate signed printf formatter for %u bytes.' % b, | 
|---|
| 424 | COMPILER_FAIL]) | 
|---|
| 425 |  | 
|---|
| 426 | if (not b in probe['unsigned_concs']): | 
|---|
| 427 | print_error(['Unable to find appropriate unsigned literal macro for %u bytes.' % b, | 
|---|
| 428 | COMPILER_FAIL]) | 
|---|
| 429 |  | 
|---|
| 430 | if (not b in probe['signed_concs']): | 
|---|
| 431 | print_error(['Unable to find appropriate signed literal macro for %u bytes.' % b, | 
|---|
| 432 | COMPILER_FAIL]) | 
|---|
| 433 |  | 
|---|
| 434 | typedefs.append({'oldtype': "unsigned %s" % probe['unsigned_sizes'][b], 'newtype': "uint%u_t" % (b * 8)}) | 
|---|
| 435 | typedefs.append({'oldtype': "signed %s" % probe['signed_sizes'][b], 'newtype': "int%u_t" % (b * 8)}) | 
|---|
| 436 |  | 
|---|
| 437 | macros.append({'oldmacro': "unsigned %s" % probe['unsigned_sizes'][b], 'newmacro': "UINT%u_T" % (b * 8)}) | 
|---|
| 438 | macros.append({'oldmacro': "signed %s" % probe['signed_sizes'][b], 'newmacro': "INT%u_T" % (b * 8)}) | 
|---|
| 439 |  | 
|---|
| 440 | macros.append({'oldmacro': "\"%so\"" % probe['unsigned_strcs'][b], 'newmacro': "PRIo%u" % (b * 8)}) | 
|---|
| 441 | macros.append({'oldmacro': "\"%su\"" % probe['unsigned_strcs'][b], 'newmacro': "PRIu%u" % (b * 8)}) | 
|---|
| 442 | macros.append({'oldmacro': "\"%sx\"" % probe['unsigned_strcs'][b], 'newmacro': "PRIx%u" % (b * 8)}) | 
|---|
| 443 | macros.append({'oldmacro': "\"%sX\"" % probe['unsigned_strcs'][b], 'newmacro': "PRIX%u" % (b * 8)}) | 
|---|
| 444 | macros.append({'oldmacro': "\"%sd\"" % probe['signed_strcs'][b], 'newmacro': "PRId%u" % (b * 8)}) | 
|---|
| 445 |  | 
|---|
| 446 | name = probe['unsigned_concs'][b] | 
|---|
| 447 | if ((name.startswith('@')) or (name == "")): | 
|---|
| 448 | macros.append({'oldmacro': "c ## U", 'newmacro': "UINT%u_C(c)" % (b * 8)}) | 
|---|
| 449 | else: | 
|---|
| 450 | macros.append({'oldmacro': "c ## U%s" % name, 'newmacro': "UINT%u_C(c)" % (b * 8)}) | 
|---|
| 451 |  | 
|---|
| 452 | name = probe['unsigned_concs'][b] | 
|---|
| 453 | if ((name.startswith('@')) or (name == "")): | 
|---|
| 454 | macros.append({'oldmacro': "c", 'newmacro': "INT%u_C(c)" % (b * 8)}) | 
|---|
| 455 | else: | 
|---|
| 456 | macros.append({'oldmacro': "c ## %s" % name, 'newmacro': "INT%u_C(c)" % (b * 8)}) | 
|---|
| 457 |  | 
|---|
| 458 | for tag in inttags: | 
|---|
| 459 | newmacro = "U%s" % tag | 
|---|
| 460 | if (not tag in probe['unsigned_tags']): | 
|---|
| 461 | print_error(['Unable to find appropriate size macro for %s.' % newmacro, | 
|---|
| 462 | COMPILER_FAIL]) | 
|---|
| 463 |  | 
|---|
| 464 | oldmacro = "UINT%s" % (probe['unsigned_tags'][tag] * 8) | 
|---|
| 465 | macros.append({'oldmacro': "%s_MIN" % oldmacro, 'newmacro': "%s_MIN" % newmacro}) | 
|---|
| 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)}) | 
|---|
| 468 |  | 
|---|
| 469 | newmacro = tag | 
|---|
| 470 | if (not tag in probe['signed_tags']): | 
|---|
| 471 | print_error(['Unable to find appropriate size macro for %s' % newmacro, | 
|---|
| 472 | COMPILER_FAIL]) | 
|---|
| 473 |  | 
|---|
| 474 | oldmacro = "INT%s" % (probe['signed_tags'][tag] * 8) | 
|---|
| 475 | macros.append({'oldmacro': "%s_MIN" % oldmacro, 'newmacro': "%s_MIN" % newmacro}) | 
|---|
| 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]) | 
|---|
| 493 |  | 
|---|
| 494 | fnd = True | 
|---|
| 495 |  | 
|---|
| 496 | if (not 'wchar' in probe['builtin_sizes']): | 
|---|
| 497 | print_warning(['The compiler does not provide the macro __WCHAR_TYPE__', | 
|---|
| 498 | 'for defining the compiler-native type wchar_t. We are', | 
|---|
| 499 | 'forced to define wchar_t as a hardwired type int32_t.', | 
|---|
| 500 | COMPILER_WARNING]) | 
|---|
| 501 | fnd = False | 
|---|
| 502 |  | 
|---|
| 503 | if (probe['builtin_sizes']['wchar']['value'] != 4): | 
|---|
| 504 | print_warning(['The compiler provided macro __WCHAR_TYPE__ for defining', | 
|---|
| 505 | 'the compiler-native type wchar_t is not compliant with', | 
|---|
| 506 | 'HelenOS. We are forced to define wchar_t as a hardwired', | 
|---|
| 507 | 'type int32_t.', | 
|---|
| 508 | COMPILER_WARNING]) | 
|---|
| 509 | fnd = False | 
|---|
| 510 |  | 
|---|
| 511 | if (not fnd): | 
|---|
| 512 | macros.append({'oldmacro': "int32_t", 'newmacro': "wchar_t"}) | 
|---|
| 513 | else: | 
|---|
| 514 | macros.append({'oldmacro': "__WCHAR_TYPE__", 'newmacro': "wchar_t"}) | 
|---|
| 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 |  | 
|---|
| 525 | fnd = True | 
|---|
| 526 |  | 
|---|
| 527 | if (not 'wint' in probe['builtin_sizes']): | 
|---|
| 528 | print_warning(['The compiler does not provide the macro __WINT_TYPE__', | 
|---|
| 529 | 'for defining the compiler-native type wint_t. We are', | 
|---|
| 530 | 'forced to define wint_t as a hardwired type int32_t.', | 
|---|
| 531 | COMPILER_WARNING]) | 
|---|
| 532 | fnd = False | 
|---|
| 533 |  | 
|---|
| 534 | if (probe['builtin_sizes']['wint']['value'] != 4): | 
|---|
| 535 | print_warning(['The compiler provided macro __WINT_TYPE__ for defining', | 
|---|
| 536 | 'the compiler-native type wint_t is not compliant with', | 
|---|
| 537 | 'HelenOS. We are forced to define wint_t as a hardwired', | 
|---|
| 538 | 'type int32_t.', | 
|---|
| 539 | COMPILER_WARNING]) | 
|---|
| 540 | fnd = False | 
|---|
| 541 |  | 
|---|
| 542 | if (not fnd): | 
|---|
| 543 | macros.append({'oldmacro': "int32_t", 'newmacro': "wint_t"}) | 
|---|
| 544 | else: | 
|---|
| 545 | 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'}) | 
|---|
| 555 |  | 
|---|
| 556 | return {'macros': macros, 'typedefs': typedefs} | 
|---|
| 557 |  | 
|---|
| 558 | def create_makefile(mkname, common): | 
|---|
| 559 | "Create makefile output" | 
|---|
| 560 |  | 
|---|
| 561 | outmk = open(mkname, 'w') | 
|---|
| 562 |  | 
|---|
| 563 | outmk.write('#########################################\n') | 
|---|
| 564 | outmk.write('## AUTO-GENERATED FILE, DO NOT EDIT!!! ##\n') | 
|---|
| 565 | outmk.write('## Generated by: tools/autotool.py     ##\n') | 
|---|
| 566 | outmk.write('#########################################\n\n') | 
|---|
| 567 |  | 
|---|
| 568 | for key, value in common.items(): | 
|---|
| 569 | if (type(value) is list): | 
|---|
| 570 | outmk.write('%s = %s\n' % (key, " ".join(value))) | 
|---|
| 571 | else: | 
|---|
| 572 | outmk.write('%s = %s\n' % (key, value)) | 
|---|
| 573 |  | 
|---|
| 574 | outmk.close() | 
|---|
| 575 |  | 
|---|
| 576 | def create_header(hdname, maps): | 
|---|
| 577 | "Create header output" | 
|---|
| 578 |  | 
|---|
| 579 | outhd = open(hdname, 'w') | 
|---|
| 580 |  | 
|---|
| 581 | outhd.write('/***************************************\n') | 
|---|
| 582 | outhd.write(' * AUTO-GENERATED FILE, DO NOT EDIT!!! *\n') | 
|---|
| 583 | outhd.write(' * Generated by: tools/autotool.py     *\n') | 
|---|
| 584 | outhd.write(' ***************************************/\n\n') | 
|---|
| 585 |  | 
|---|
| 586 | outhd.write('#ifndef %s\n' % GUARD) | 
|---|
| 587 | outhd.write('#define %s\n\n' % GUARD) | 
|---|
| 588 |  | 
|---|
| 589 | for macro in maps['macros']: | 
|---|
| 590 | outhd.write('#define %s  %s\n' % (macro['newmacro'], macro['oldmacro'])) | 
|---|
| 591 |  | 
|---|
| 592 | outhd.write('\n') | 
|---|
| 593 |  | 
|---|
| 594 | for typedef in maps['typedefs']: | 
|---|
| 595 | outhd.write('typedef %s %s;\n' % (typedef['oldtype'], typedef['newtype'])) | 
|---|
| 596 |  | 
|---|
| 597 | outhd.write('\n#endif\n') | 
|---|
| 598 | outhd.close() | 
|---|
| 599 |  | 
|---|
| 600 | def main(): | 
|---|
| 601 | config = {} | 
|---|
| 602 | common = {} | 
|---|
| 603 |  | 
|---|
| 604 | # Read and check configuration | 
|---|
| 605 | if os.path.exists(CONFIG): | 
|---|
| 606 | read_config(CONFIG, config) | 
|---|
| 607 | else: | 
|---|
| 608 | print_error(["Configuration file %s not found! Make sure that the" % CONFIG, | 
|---|
| 609 | "configuration phase of HelenOS build went OK. Try running", | 
|---|
| 610 | "\"make config\" again."]) | 
|---|
| 611 |  | 
|---|
| 612 | check_config(config, "PLATFORM") | 
|---|
| 613 | check_config(config, "COMPILER") | 
|---|
| 614 | check_config(config, "BARCH") | 
|---|
| 615 |  | 
|---|
| 616 | # Cross-compiler prefix | 
|---|
| 617 | if ('CROSS_PREFIX' in os.environ): | 
|---|
| 618 | cross_prefix = os.environ['CROSS_PREFIX'] | 
|---|
| 619 | else: | 
|---|
| 620 | cross_prefix = "/usr/local/cross" | 
|---|
| 621 |  | 
|---|
| 622 | # Prefix binutils tools on Solaris | 
|---|
| 623 | if (os.uname()[0] == "SunOS"): | 
|---|
| 624 | binutils_prefix = "g" | 
|---|
| 625 | else: | 
|---|
| 626 | binutils_prefix = "" | 
|---|
| 627 |  | 
|---|
| 628 | owd = sandbox_enter() | 
|---|
| 629 |  | 
|---|
| 630 | try: | 
|---|
| 631 | # Common utilities | 
|---|
| 632 | check_app(["ln", "--version"], "Symlink utility", "usually part of coreutils") | 
|---|
| 633 | check_app(["rm", "--version"], "File remove utility", "usually part of coreutils") | 
|---|
| 634 | check_app(["mkdir", "--version"], "Directory creation utility", "usually part of coreutils") | 
|---|
| 635 | check_app(["cp", "--version"], "Copy utility", "usually part of coreutils") | 
|---|
| 636 | check_app(["find", "--version"], "Find utility", "usually part of findutils") | 
|---|
| 637 | check_app(["diff", "--version"], "Diff utility", "usually part of diffutils") | 
|---|
| 638 | check_app(["make", "--version"], "Make utility", "preferably GNU Make") | 
|---|
| 639 | check_app(["makedepend", "-f", "-"], "Makedepend utility", "usually part of imake or xutils") | 
|---|
| 640 |  | 
|---|
| 641 | # Compiler | 
|---|
| 642 | common['CC_ARGS'] = [] | 
|---|
| 643 | if (config['COMPILER'] == "gcc_cross"): | 
|---|
| 644 | if (config['PLATFORM'] == "abs32le"): | 
|---|
| 645 | check_config(config, "CROSS_TARGET") | 
|---|
| 646 | target = config['CROSS_TARGET'] | 
|---|
| 647 |  | 
|---|
| 648 | if (config['CROSS_TARGET'] == "arm32"): | 
|---|
| 649 | gnu_target = "arm-linux-gnueabi" | 
|---|
| 650 |  | 
|---|
| 651 | if (config['CROSS_TARGET'] == "ia32"): | 
|---|
| 652 | gnu_target = "i686-pc-linux-gnu" | 
|---|
| 653 |  | 
|---|
| 654 | if (config['CROSS_TARGET'] == "mips32"): | 
|---|
| 655 | gnu_target = "mipsel-linux-gnu" | 
|---|
| 656 | common['CC_ARGS'].append("-mabi=32") | 
|---|
| 657 |  | 
|---|
| 658 | if (config['PLATFORM'] == "amd64"): | 
|---|
| 659 | target = config['PLATFORM'] | 
|---|
| 660 | gnu_target = "amd64-linux-gnu" | 
|---|
| 661 |  | 
|---|
| 662 | if (config['PLATFORM'] == "arm32"): | 
|---|
| 663 | target = config['PLATFORM'] | 
|---|
| 664 | gnu_target = "arm-linux-gnueabi" | 
|---|
| 665 |  | 
|---|
| 666 | if (config['PLATFORM'] == "ia32"): | 
|---|
| 667 | target = config['PLATFORM'] | 
|---|
| 668 | gnu_target = "i686-pc-linux-gnu" | 
|---|
| 669 |  | 
|---|
| 670 | if (config['PLATFORM'] == "ia64"): | 
|---|
| 671 | target = config['PLATFORM'] | 
|---|
| 672 | gnu_target = "ia64-pc-linux-gnu" | 
|---|
| 673 |  | 
|---|
| 674 | if (config['PLATFORM'] == "mips32"): | 
|---|
| 675 | check_config(config, "MACHINE") | 
|---|
| 676 | common['CC_ARGS'].append("-mabi=32") | 
|---|
| 677 |  | 
|---|
| 678 | if ((config['MACHINE'] == "msim") or (config['MACHINE'] == "lmalta")): | 
|---|
| 679 | target = config['PLATFORM'] | 
|---|
| 680 | gnu_target = "mipsel-linux-gnu" | 
|---|
| 681 |  | 
|---|
| 682 | if ((config['MACHINE'] == "bmalta")): | 
|---|
| 683 | target = "mips32eb" | 
|---|
| 684 | gnu_target = "mips-linux-gnu" | 
|---|
| 685 |  | 
|---|
| 686 | if (config['PLATFORM'] == "mips64"): | 
|---|
| 687 | check_config(config, "MACHINE") | 
|---|
| 688 | common['CC_ARGS'].append("-mabi=64") | 
|---|
| 689 |  | 
|---|
| 690 | if (config['MACHINE'] == "msim"): | 
|---|
| 691 | target = config['PLATFORM'] | 
|---|
| 692 | gnu_target = "mips64el-linux-gnu" | 
|---|
| 693 |  | 
|---|
| 694 | if (config['PLATFORM'] == "ppc32"): | 
|---|
| 695 | target = config['PLATFORM'] | 
|---|
| 696 | gnu_target = "ppc-linux-gnu" | 
|---|
| 697 |  | 
|---|
| 698 | if (config['PLATFORM'] == "sparc64"): | 
|---|
| 699 | target = config['PLATFORM'] | 
|---|
| 700 | gnu_target = "sparc64-linux-gnu" | 
|---|
| 701 |  | 
|---|
| 702 | path = "%s/%s/bin" % (cross_prefix, target) | 
|---|
| 703 | prefix = "%s-" % gnu_target | 
|---|
| 704 |  | 
|---|
| 705 | check_gcc(path, prefix, common, PACKAGE_CROSS) | 
|---|
| 706 | check_binutils(path, prefix, common, PACKAGE_CROSS) | 
|---|
| 707 |  | 
|---|
| 708 | check_common(common, "GCC") | 
|---|
| 709 | common['CC'] = common['GCC'] | 
|---|
| 710 |  | 
|---|
| 711 | if (config['COMPILER'] == "gcc_native"): | 
|---|
| 712 | check_gcc(None, "", common, PACKAGE_GCC) | 
|---|
| 713 | check_binutils(None, binutils_prefix, common, PACKAGE_BINUTILS) | 
|---|
| 714 |  | 
|---|
| 715 | check_common(common, "GCC") | 
|---|
| 716 | common['CC'] = common['GCC'] | 
|---|
| 717 |  | 
|---|
| 718 | if (config['COMPILER'] == "icc"): | 
|---|
| 719 | common['CC'] = "icc" | 
|---|
| 720 | check_app([common['CC'], "-V"], "Intel C++ Compiler", "support is experimental") | 
|---|
| 721 | check_gcc(None, "", common, PACKAGE_GCC) | 
|---|
| 722 | check_binutils(None, binutils_prefix, common, PACKAGE_BINUTILS) | 
|---|
| 723 |  | 
|---|
| 724 | if (config['COMPILER'] == "clang"): | 
|---|
| 725 | common['CC'] = "clang" | 
|---|
| 726 | check_app([common['CC'], "--version"], "Clang compiler", "preferably version 1.0 or newer") | 
|---|
| 727 | check_gcc(None, "", common, PACKAGE_GCC) | 
|---|
| 728 | check_binutils(None, binutils_prefix, common, PACKAGE_BINUTILS) | 
|---|
| 729 |  | 
|---|
| 730 | # Platform-specific utilities | 
|---|
| 731 | if ((config['BARCH'] == "amd64") or (config['BARCH'] == "ia32") or (config['BARCH'] == "ppc32") or (config['BARCH'] == "sparc64")): | 
|---|
| 732 | common['GENISOIMAGE'] = check_app_alternatives(["mkisofs", "genisoimage"], ["--version"], "ISO 9660 creation utility", "usually part of genisoimage") | 
|---|
| 733 |  | 
|---|
| 734 | probe = probe_compiler(common, | 
|---|
| 735 | [ | 
|---|
| 736 | {'type': 'long long int', 'tag': 'LLONG', 'strc': '"ll"', 'conc': '"LL"'}, | 
|---|
| 737 | {'type': 'long int', 'tag': 'LONG', 'strc': '"l"', 'conc': '"L"'}, | 
|---|
| 738 | {'type': 'int', 'tag': 'INT', 'strc': '""', 'conc': '""'}, | 
|---|
| 739 | {'type': 'short int', 'tag': 'SHORT', 'strc': '"h"', 'conc': '"@"'}, | 
|---|
| 740 | {'type': 'char', 'tag': 'CHAR', 'strc': '"hh"', 'conc': '"@@"'} | 
|---|
| 741 | ], | 
|---|
| 742 | [ | 
|---|
| 743 | {'type': 'long double', 'tag': 'LONG_DOUBLE'}, | 
|---|
| 744 | {'type': 'double', 'tag': 'DOUBLE'}, | 
|---|
| 745 | {'type': 'float', 'tag': 'FLOAT'} | 
|---|
| 746 | ] | 
|---|
| 747 | ) | 
|---|
| 748 |  | 
|---|
| 749 | maps = detect_sizes(probe, [1, 2, 4, 8], ['CHAR', 'SHORT', 'INT', 'LONG', 'LLONG'], ['LONG_DOUBLE', 'DOUBLE', 'FLOAT']) | 
|---|
| 750 |  | 
|---|
| 751 | finally: | 
|---|
| 752 | sandbox_leave(owd) | 
|---|
| 753 |  | 
|---|
| 754 | create_makefile(MAKEFILE, common) | 
|---|
| 755 | create_header(HEADER, maps) | 
|---|
| 756 |  | 
|---|
| 757 | return 0 | 
|---|
| 758 |  | 
|---|
| 759 | if __name__ == '__main__': | 
|---|
| 760 | sys.exit(main()) | 
|---|