[177e4ea] | 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 | #
|
---|
[3c80f2b] | 29 |
|
---|
[177e4ea] | 30 | """
|
---|
| 31 | Detect important prerequisites and parameters for building HelenOS
|
---|
| 32 | """
|
---|
| 33 |
|
---|
| 34 | import sys
|
---|
| 35 | import os
|
---|
[4e9aaf5] | 36 | import shutil
|
---|
[177e4ea] | 37 | import re
|
---|
| 38 | import time
|
---|
| 39 | import subprocess
|
---|
| 40 |
|
---|
[4e9aaf5] | 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'
|
---|
[177e4ea] | 49 |
|
---|
| 50 | PACKAGE_BINUTILS = "usually part of binutils"
|
---|
[a4a0f1d] | 51 | PACKAGE_GCC = "preferably version 4.7.0 or newer"
|
---|
[177e4ea] | 52 | PACKAGE_CROSS = "use tools/toolchain.sh to build the cross-compiler toolchain"
|
---|
| 53 |
|
---|
[4e9aaf5] | 54 | COMPILER_FAIL = "The compiler is probably not capable to compile HelenOS."
|
---|
[96b89acb] | 55 | COMPILER_WARNING = "The compilation of HelenOS might fail."
|
---|
[4e9aaf5] | 56 |
|
---|
[dc0b964] | 57 | PROBE_HEAD = """#define AUTOTOOL_DECLARE(category, subcategory, tag, name, strc, conc, value) \\
|
---|
[4e9aaf5] | 58 | asm volatile ( \\
|
---|
[dc0b964] | 59 | "AUTOTOOL_DECLARE\\t" category "\\t" subcategory "\\t" tag "\\t" name "\\t" strc "\\t" conc "\\t%[val]\\n" \\
|
---|
[4e9aaf5] | 60 | : \\
|
---|
| 61 | : [val] "n" (value) \\
|
---|
| 62 | )
|
---|
| 63 |
|
---|
[96b89acb] | 64 | #define STRING(arg) STRING_ARG(arg)
|
---|
| 65 | #define STRING_ARG(arg) #arg
|
---|
| 66 |
|
---|
| 67 | #define DECLARE_BUILTIN_TYPE(tag, type) \\
|
---|
[a4a0f1d] | 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));
|
---|
[96b89acb] | 79 |
|
---|
[dc0b964] | 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));
|
---|
[4e9aaf5] | 83 |
|
---|
[a4a0f1d] | 84 | #define DECLARE_FLOATSIZE(tag, type) \\
|
---|
| 85 | AUTOTOOL_DECLARE("floatsize", "", tag, #type, "", "", sizeof(type));
|
---|
| 86 |
|
---|
[4e9aaf5] | 87 | int main(int argc, char *argv[])
|
---|
| 88 | {
|
---|
[96b89acb] | 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
|
---|
[4e9aaf5] | 98 | """
|
---|
| 99 |
|
---|
| 100 | PROBE_TAIL = """}
|
---|
| 101 | """
|
---|
| 102 |
|
---|
[177e4ea] | 103 | def read_config(fname, config):
|
---|
| 104 | "Read HelenOS build configuration"
|
---|
| 105 |
|
---|
[28f4adb] | 106 | inf = open(fname, 'r')
|
---|
[177e4ea] | 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 |
|
---|
[96b89acb] | 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 |
|
---|
[4e9aaf5] | 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 |
|
---|
[177e4ea] | 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 |
|
---|
[4e9aaf5] | 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 |
|
---|
[177e4ea] | 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 |
|
---|
[7174403] | 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 |
|
---|
[177e4ea] | 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
|
---|
[a4125fb1] | 250 | common['STRIP'] = "%sstrip" % prefix
|
---|
[177e4ea] | 251 |
|
---|
| 252 | if (not path is None):
|
---|
[a4125fb1] | 253 | for key in ["AS", "LD", "AR", "OBJCOPY", "OBJDUMP", "STRIP"]:
|
---|
[177e4ea] | 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)
|
---|
[a4125fb1] | 261 | check_app([common['STRIP'], "--version"], "GNU strip", details)
|
---|
[177e4ea] | 262 |
|
---|
[96b89acb] | 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 |
|
---|
[a4a0f1d] | 277 | def probe_compiler(common, intsizes, floatsizes):
|
---|
[4e9aaf5] | 278 | "Generate, compile and parse probing source"
|
---|
| 279 |
|
---|
| 280 | check_common(common, "CC")
|
---|
| 281 |
|
---|
[28f4adb] | 282 | outf = open(PROBE_SOURCE, 'w')
|
---|
[4e9aaf5] | 283 | outf.write(PROBE_HEAD)
|
---|
| 284 |
|
---|
[a4a0f1d] | 285 | for typedef in intsizes:
|
---|
[dc0b964] | 286 | outf.write("\tDECLARE_INTSIZE(\"%s\", %s, %s, %s);\n" % (typedef['tag'], typedef['type'], typedef['strc'], typedef['conc']))
|
---|
[4e9aaf5] | 287 |
|
---|
[a4a0f1d] | 288 | for typedef in floatsizes:
|
---|
| 289 | outf.write("\nDECLARE_FLOATSIZE(\"%s\", %s);\n" % (typedef['tag'], typedef['type']))
|
---|
| 290 |
|
---|
[4e9aaf5] | 291 | outf.write(PROBE_TAIL)
|
---|
| 292 | outf.close()
|
---|
| 293 |
|
---|
[2429e4a] | 294 | args = [common['CC']]
|
---|
| 295 | args.extend(common['CC_ARGS'])
|
---|
| 296 | args.extend(["-S", "-o", PROBE_OUTPUT, PROBE_SOURCE])
|
---|
[4e9aaf5] | 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")
|
---|
[28f4adb] | 308 | print(output[1])
|
---|
[4e9aaf5] | 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 |
|
---|
[28f4adb] | 317 | inf = open(PROBE_OUTPUT, 'r')
|
---|
[4e9aaf5] | 318 | lines = inf.readlines()
|
---|
| 319 | inf.close()
|
---|
| 320 |
|
---|
| 321 | unsigned_sizes = {}
|
---|
| 322 | signed_sizes = {}
|
---|
| 323 |
|
---|
[9539be6] | 324 | unsigned_tags = {}
|
---|
| 325 | signed_tags = {}
|
---|
| 326 |
|
---|
[dc0b964] | 327 | unsigned_strcs = {}
|
---|
| 328 | signed_strcs = {}
|
---|
| 329 |
|
---|
| 330 | unsigned_concs = {}
|
---|
| 331 | signed_concs = {}
|
---|
| 332 |
|
---|
[a4a0f1d] | 333 | float_tags = {}
|
---|
| 334 |
|
---|
| 335 | builtin_sizes = {}
|
---|
| 336 | builtin_signs = {}
|
---|
[96b89acb] | 337 |
|
---|
[4e9aaf5] | 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"):
|
---|
[dc0b964] | 343 | if (len(tokens) < 7):
|
---|
[4e9aaf5] | 344 | print_error(["Malformed declaration in \"%s\" on line %s." % (PROBE_OUTPUT, j), COMPILER_FAIL])
|
---|
| 345 |
|
---|
| 346 | category = tokens[1]
|
---|
| 347 | subcategory = tokens[2]
|
---|
[9539be6] | 348 | tag = tokens[3]
|
---|
| 349 | name = tokens[4]
|
---|
[dc0b964] | 350 | strc = tokens[5]
|
---|
| 351 | conc = tokens[6]
|
---|
| 352 | value = tokens[7]
|
---|
[4e9aaf5] | 353 |
|
---|
| 354 | if (category == "intsize"):
|
---|
| 355 | try:
|
---|
[96b89acb] | 356 | value_int = decode_value(value)
|
---|
[4e9aaf5] | 357 | except:
|
---|
| 358 | print_error(["Integer value expected in \"%s\" on line %s." % (PROBE_OUTPUT, j), COMPILER_FAIL])
|
---|
| 359 |
|
---|
| 360 | if (subcategory == "unsigned"):
|
---|
[96b89acb] | 361 | unsigned_sizes[value_int] = name
|
---|
[9539be6] | 362 | unsigned_tags[tag] = value_int
|
---|
[96b89acb] | 363 | unsigned_strcs[value_int] = strc
|
---|
| 364 | unsigned_concs[value_int] = conc
|
---|
[4e9aaf5] | 365 | elif (subcategory == "signed"):
|
---|
[96b89acb] | 366 | signed_sizes[value_int] = name
|
---|
[9539be6] | 367 | signed_tags[tag] = value_int
|
---|
[96b89acb] | 368 | signed_strcs[value_int] = strc
|
---|
| 369 | signed_concs[value_int] = conc
|
---|
[4e9aaf5] | 370 | else:
|
---|
| 371 | print_error(["Unexpected keyword \"%s\" in \"%s\" on line %s." % (subcategory, PROBE_OUTPUT, j), COMPILER_FAIL])
|
---|
[96b89acb] | 372 |
|
---|
[a4a0f1d] | 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"):
|
---|
[96b89acb] | 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 |
|
---|
[a4a0f1d] | 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])
|
---|
[4e9aaf5] | 400 |
|
---|
[a4a0f1d] | 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}
|
---|
[4e9aaf5] | 402 |
|
---|
[a4a0f1d] | 403 | def detect_sizes(probe, bytes, inttags, floattags):
|
---|
| 404 | "Detect correct types for fixed-size types"
|
---|
[4e9aaf5] | 405 |
|
---|
[9539be6] | 406 | macros = []
|
---|
[4e9aaf5] | 407 | typedefs = []
|
---|
| 408 |
|
---|
| 409 | for b in bytes:
|
---|
[96b89acb] | 410 | if (not b in probe['unsigned_sizes']):
|
---|
[a4a0f1d] | 411 | print_error(['Unable to find appropriate unsigned integer type for %u bytes.' % b,
|
---|
[4e9aaf5] | 412 | COMPILER_FAIL])
|
---|
| 413 |
|
---|
[96b89acb] | 414 | if (not b in probe['signed_sizes']):
|
---|
[a4a0f1d] | 415 | print_error(['Unable to find appropriate signed integer type for %u bytes.' % b,
|
---|
[4e9aaf5] | 416 | COMPILER_FAIL])
|
---|
[dc0b964] | 417 |
|
---|
[96b89acb] | 418 | if (not b in probe['unsigned_strcs']):
|
---|
[a4a0f1d] | 419 | print_error(['Unable to find appropriate unsigned printf formatter for %u bytes.' % b,
|
---|
[85369b1] | 420 | COMPILER_FAIL])
|
---|
[dc0b964] | 421 |
|
---|
[96b89acb] | 422 | if (not b in probe['signed_strcs']):
|
---|
[a4a0f1d] | 423 | print_error(['Unable to find appropriate signed printf formatter for %u bytes.' % b,
|
---|
[85369b1] | 424 | COMPILER_FAIL])
|
---|
[dc0b964] | 425 |
|
---|
[96b89acb] | 426 | if (not b in probe['unsigned_concs']):
|
---|
[a4a0f1d] | 427 | print_error(['Unable to find appropriate unsigned literal macro for %u bytes.' % b,
|
---|
[85369b1] | 428 | COMPILER_FAIL])
|
---|
[dc0b964] | 429 |
|
---|
[96b89acb] | 430 | if (not b in probe['signed_concs']):
|
---|
[a4a0f1d] | 431 | print_error(['Unable to find appropriate signed literal macro for %u bytes.' % b,
|
---|
[96b89acb] | 432 | COMPILER_FAIL])
|
---|
[dc0b964] | 433 |
|
---|
[96b89acb] | 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)})
|
---|
[dc0b964] | 436 |
|
---|
[d408ea0] | 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 |
|
---|
[96b89acb] | 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)})
|
---|
[9539be6] | 445 |
|
---|
[96b89acb] | 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)})
|
---|
[9539be6] | 451 |
|
---|
[96b89acb] | 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 |
|
---|
[a4a0f1d] | 458 | for tag in inttags:
|
---|
[96b89acb] | 459 | newmacro = "U%s" % tag
|
---|
| 460 | if (not tag in probe['unsigned_tags']):
|
---|
[a4a0f1d] | 461 | print_error(['Unable to find appropriate size macro for %s.' % newmacro,
|
---|
[9539be6] | 462 | COMPILER_FAIL])
|
---|
| 463 |
|
---|
[96b89acb] | 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})
|
---|
[a4a0f1d] | 467 | macros.append({'oldmacro': "1", 'newmacro': 'U%s_SIZE_%s' % (tag, probe['unsigned_tags'][tag] * 8)})
|
---|
[9539be6] | 468 |
|
---|
[96b89acb] | 469 | newmacro = tag
|
---|
[a4a0f1d] | 470 | if (not tag in probe['signed_tags']):
|
---|
[9539be6] | 471 | print_error(['Unable to find appropriate size macro for %s' % newmacro,
|
---|
| 472 | COMPILER_FAIL])
|
---|
[96b89acb] | 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})
|
---|
[a4a0f1d] | 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])
|
---|
[96b89acb] | 493 |
|
---|
| 494 | fnd = True
|
---|
| 495 |
|
---|
[a4a0f1d] | 496 | if (not 'wchar' in probe['builtin_sizes']):
|
---|
[96b89acb] | 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 |
|
---|
[a4a0f1d] | 503 | if (probe['builtin_sizes']['wchar']['value'] != 4):
|
---|
[96b89acb] | 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 |
|
---|
[a4a0f1d] | 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 |
|
---|
[96b89acb] | 525 | fnd = True
|
---|
| 526 |
|
---|
[a4a0f1d] | 527 | if (not 'wint' in probe['builtin_sizes']):
|
---|
[96b89acb] | 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 |
|
---|
[a4a0f1d] | 534 | if (probe['builtin_sizes']['wint']['value'] != 4):
|
---|
[96b89acb] | 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"})
|
---|
[9539be6] | 546 |
|
---|
[a4a0f1d] | 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 |
|
---|
[9539be6] | 556 | return {'macros': macros, 'typedefs': typedefs}
|
---|
[4e9aaf5] | 557 |
|
---|
| 558 | def create_makefile(mkname, common):
|
---|
| 559 | "Create makefile output"
|
---|
[177e4ea] | 560 |
|
---|
[28f4adb] | 561 | outmk = open(mkname, 'w')
|
---|
[177e4ea] | 562 |
|
---|
[4e9aaf5] | 563 | outmk.write('#########################################\n')
|
---|
| 564 | outmk.write('## AUTO-GENERATED FILE, DO NOT EDIT!!! ##\n')
|
---|
[571239a] | 565 | outmk.write('## Generated by: tools/autotool.py ##\n')
|
---|
[4e9aaf5] | 566 | outmk.write('#########################################\n\n')
|
---|
[177e4ea] | 567 |
|
---|
| 568 | for key, value in common.items():
|
---|
[7174403] | 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))
|
---|
[4e9aaf5] | 573 |
|
---|
| 574 | outmk.close()
|
---|
| 575 |
|
---|
[9539be6] | 576 | def create_header(hdname, maps):
|
---|
[4e9aaf5] | 577 | "Create header output"
|
---|
| 578 |
|
---|
[28f4adb] | 579 | outhd = open(hdname, 'w')
|
---|
[4e9aaf5] | 580 |
|
---|
| 581 | outhd.write('/***************************************\n')
|
---|
| 582 | outhd.write(' * AUTO-GENERATED FILE, DO NOT EDIT!!! *\n')
|
---|
[571239a] | 583 | outhd.write(' * Generated by: tools/autotool.py *\n')
|
---|
[4e9aaf5] | 584 | outhd.write(' ***************************************/\n\n')
|
---|
[177e4ea] | 585 |
|
---|
[4e9aaf5] | 586 | outhd.write('#ifndef %s\n' % GUARD)
|
---|
| 587 | outhd.write('#define %s\n\n' % GUARD)
|
---|
| 588 |
|
---|
[9539be6] | 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']:
|
---|
[4e9aaf5] | 595 | outhd.write('typedef %s %s;\n' % (typedef['oldtype'], typedef['newtype']))
|
---|
| 596 |
|
---|
| 597 | outhd.write('\n#endif\n')
|
---|
| 598 | outhd.close()
|
---|
[177e4ea] | 599 |
|
---|
| 600 | def main():
|
---|
| 601 | config = {}
|
---|
| 602 | common = {}
|
---|
| 603 |
|
---|
| 604 | # Read and check configuration
|
---|
[4e9aaf5] | 605 | if os.path.exists(CONFIG):
|
---|
| 606 | read_config(CONFIG, config)
|
---|
[177e4ea] | 607 | else:
|
---|
[4e9aaf5] | 608 | print_error(["Configuration file %s not found! Make sure that the" % CONFIG,
|
---|
[177e4ea] | 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:
|
---|
[603c8740] | 620 | cross_prefix = "/usr/local/cross"
|
---|
[177e4ea] | 621 |
|
---|
| 622 | # Prefix binutils tools on Solaris
|
---|
| 623 | if (os.uname()[0] == "SunOS"):
|
---|
| 624 | binutils_prefix = "g"
|
---|
| 625 | else:
|
---|
| 626 | binutils_prefix = ""
|
---|
| 627 |
|
---|
[4e9aaf5] | 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
|
---|
[2429e4a] | 642 | common['CC_ARGS'] = []
|
---|
[4e9aaf5] | 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"):
|
---|
[a4a0f1d] | 649 | gnu_target = "arm-linux-gnueabi"
|
---|
[4e9aaf5] | 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"
|
---|
[2429e4a] | 656 | common['CC_ARGS'].append("-mabi=32")
|
---|
[177e4ea] | 657 |
|
---|
[4e9aaf5] | 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']
|
---|
[a4a0f1d] | 664 | gnu_target = "arm-linux-gnueabi"
|
---|
[177e4ea] | 665 |
|
---|
[4e9aaf5] | 666 | if (config['PLATFORM'] == "ia32"):
|
---|
| 667 | target = config['PLATFORM']
|
---|
[177e4ea] | 668 | gnu_target = "i686-pc-linux-gnu"
|
---|
| 669 |
|
---|
[4e9aaf5] | 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")
|
---|
[2429e4a] | 676 | common['CC_ARGS'].append("-mabi=32")
|
---|
[4e9aaf5] | 677 |
|
---|
[232cd4f] | 678 | if ((config['MACHINE'] == "msim") or (config['MACHINE'] == "lmalta")):
|
---|
[4e9aaf5] | 679 | target = config['PLATFORM']
|
---|
| 680 | gnu_target = "mipsel-linux-gnu"
|
---|
| 681 |
|
---|
[232cd4f] | 682 | if ((config['MACHINE'] == "bmalta")):
|
---|
[4e9aaf5] | 683 | target = "mips32eb"
|
---|
| 684 | gnu_target = "mips-linux-gnu"
|
---|
| 685 |
|
---|
[2429e4a] | 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 |
|
---|
[4e9aaf5] | 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']
|
---|
[177e4ea] | 710 |
|
---|
[4e9aaf5] | 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']
|
---|
[177e4ea] | 717 |
|
---|
[4e9aaf5] | 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)
|
---|
[177e4ea] | 723 |
|
---|
[4e9aaf5] | 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)
|
---|
[177e4ea] | 729 |
|
---|
[4e9aaf5] | 730 | # Platform-specific utilities
|
---|
| 731 | if ((config['BARCH'] == "amd64") or (config['BARCH'] == "ia32") or (config['BARCH'] == "ppc32") or (config['BARCH'] == "sparc64")):
|
---|
[7174403] | 732 | common['GENISOIMAGE'] = check_app_alternatives(["mkisofs", "genisoimage"], ["--version"], "ISO 9660 creation utility", "usually part of genisoimage")
|
---|
[177e4ea] | 733 |
|
---|
[4e9aaf5] | 734 | probe = probe_compiler(common,
|
---|
| 735 | [
|
---|
[96b89acb] | 736 | {'type': 'long long int', 'tag': 'LLONG', 'strc': '"ll"', 'conc': '"LL"'},
|
---|
[dc0b964] | 737 | {'type': 'long int', 'tag': 'LONG', 'strc': '"l"', 'conc': '"L"'},
|
---|
[96b89acb] | 738 | {'type': 'int', 'tag': 'INT', 'strc': '""', 'conc': '""'},
|
---|
| 739 | {'type': 'short int', 'tag': 'SHORT', 'strc': '"h"', 'conc': '"@"'},
|
---|
| 740 | {'type': 'char', 'tag': 'CHAR', 'strc': '"hh"', 'conc': '"@@"'}
|
---|
[a4a0f1d] | 741 | ],
|
---|
| 742 | [
|
---|
| 743 | {'type': 'long double', 'tag': 'LONG_DOUBLE'},
|
---|
| 744 | {'type': 'double', 'tag': 'DOUBLE'},
|
---|
| 745 | {'type': 'float', 'tag': 'FLOAT'}
|
---|
[4e9aaf5] | 746 | ]
|
---|
| 747 | )
|
---|
[177e4ea] | 748 |
|
---|
[a4a0f1d] | 749 | maps = detect_sizes(probe, [1, 2, 4, 8], ['CHAR', 'SHORT', 'INT', 'LONG', 'LLONG'], ['LONG_DOUBLE', 'DOUBLE', 'FLOAT'])
|
---|
[177e4ea] | 750 |
|
---|
[4e9aaf5] | 751 | finally:
|
---|
| 752 | sandbox_leave(owd)
|
---|
| 753 |
|
---|
| 754 | create_makefile(MAKEFILE, common)
|
---|
[9539be6] | 755 | create_header(HEADER, maps)
|
---|
[177e4ea] | 756 |
|
---|
| 757 | return 0
|
---|
| 758 |
|
---|
| 759 | if __name__ == '__main__':
|
---|
| 760 | sys.exit(main())
|
---|