Index: tools/autotool.py
===================================================================
--- tools/autotool.py	(revision 2660ee33905b12512a15891b19f47af71a4770f1)
+++ tools/autotool.py	(revision 1cac8753dba1dcd1e470087cba35d1d4f93975a2)
@@ -93,17 +93,17 @@
 def read_config(fname, config):
 	"Read HelenOS build configuration"
-	
+
 	inf = open(fname, 'r')
-	
+
 	for line in inf:
 		res = re.match(r'^(?:#!# )?([^#]\w*)\s*=\s*(.*?)\s*$', line)
 		if (res):
 			config[res.group(1)] = res.group(2)
-	
+
 	inf.close()
 
 def print_error(msg):
 	"Print a bold error message"
-	
+
 	sys.stderr.write("\n")
 	sys.stderr.write("######################################################################\n")
@@ -113,10 +113,10 @@
 	sys.stderr.write("######################################################################\n")
 	sys.stderr.write("\n")
-	
+
 	sys.exit(1)
 
 def print_warning(msg):
 	"Print a bold error message"
-	
+
 	sys.stderr.write("\n")
 	sys.stderr.write("######################################################################\n")
@@ -126,10 +126,10 @@
 	sys.stderr.write("######################################################################\n")
 	sys.stderr.write("\n")
-	
+
 	time.sleep(5)
 
 def sandbox_enter():
 	"Create a temporal sandbox directory for running tests"
-	
+
 	if (os.path.exists(SANDBOX)):
 		if (os.path.isdir(SANDBOX)):
@@ -141,23 +141,23 @@
 			print_error(["Please inspect and remove unexpected directory,",
 			             "entry \"%s\"." % SANDBOX])
-	
+
 	try:
 		os.mkdir(SANDBOX)
 	except:
 		print_error(["Unable to create sandbox directory \"%s\"." % SANDBOX])
-	
+
 	owd = os.getcwd()
 	os.chdir(SANDBOX)
-	
+
 	return owd
 
 def sandbox_leave(owd):
 	"Leave the temporal sandbox directory"
-	
+
 	os.chdir(owd)
 
 def check_config(config, key):
 	"Check whether the configuration key exists"
-	
+
 	if (not key in config):
 		print_error(["Build configuration of HelenOS does not contain %s." % key,
@@ -167,5 +167,5 @@
 def check_common(common, key):
 	"Check whether the common key exists"
-	
+
 	if (not key in common):
 		print_error(["Failed to determine the value %s." % key,
@@ -178,90 +178,90 @@
 	target = None
 	cc_args = []
-	
+
 	if (config['PLATFORM'] == "abs32le"):
 		check_config(config, "CROSS_TARGET")
 		platform = config['CROSS_TARGET']
-		
+
 		if (config['CROSS_TARGET'] == "arm32"):
 			gnu_target = "arm-linux-gnueabi"
 			helenos_target = "arm-helenos-gnueabi"
-		
+
 		if (config['CROSS_TARGET'] == "ia32"):
 			gnu_target = "i686-pc-linux-gnu"
 			helenos_target = "i686-pc-helenos"
-		
+
 		if (config['CROSS_TARGET'] == "mips32"):
 			cc_args.append("-mabi=32")
 			gnu_target = "mipsel-linux-gnu"
 			helenos_target = "mipsel-helenos"
-	
+
 	if (config['PLATFORM'] == "amd64"):
 		platform = config['PLATFORM']
 		gnu_target = "amd64-unknown-elf"
 		helenos_target = "amd64-helenos"
-	
+
 	if (config['PLATFORM'] == "arm32"):
 		platform = config['PLATFORM']
 		gnu_target = "arm-linux-gnueabi"
 		helenos_target = "arm-helenos-gnueabi"
-	
+
 	if (config['PLATFORM'] == "ia32"):
 		platform = config['PLATFORM']
 		gnu_target = "i686-pc-linux-gnu"
 		helenos_target = "i686-pc-helenos"
-	
+
 	if (config['PLATFORM'] == "ia64"):
 		platform = config['PLATFORM']
 		gnu_target = "ia64-pc-linux-gnu"
 		helenos_target = "ia64-pc-helenos"
-	
+
 	if (config['PLATFORM'] == "mips32"):
 		check_config(config, "MACHINE")
 		cc_args.append("-mabi=32")
-		
+
 		if ((config['MACHINE'] == "msim") or (config['MACHINE'] == "lmalta")):
 			platform = config['PLATFORM']
 			gnu_target = "mipsel-linux-gnu"
 			helenos_target = "mipsel-helenos"
-		
+
 		if ((config['MACHINE'] == "bmalta")):
 			platform = "mips32eb"
 			gnu_target = "mips-linux-gnu"
 			helenos_target = "mips-helenos"
-	
+
 	if (config['PLATFORM'] == "mips64"):
 		check_config(config, "MACHINE")
 		cc_args.append("-mabi=64")
-		
+
 		if (config['MACHINE'] == "msim"):
 			platform = config['PLATFORM']
 			gnu_target = "mips64el-linux-gnu"
 			helenos_target = "mips64el-helenos"
-	
+
 	if (config['PLATFORM'] == "ppc32"):
 		platform = config['PLATFORM']
 		gnu_target = "ppc-linux-gnu"
 		helenos_target = "ppc-helenos"
-	
+
 	if (config['PLATFORM'] == "riscv64"):
 		platform = config['PLATFORM']
 		gnu_target = "riscv64-unknown-linux-gnu"
 		helenos_target = "riscv64-helenos"
-	
+
 	if (config['PLATFORM'] == "sparc64"):
 		platform = config['PLATFORM']
 		gnu_target = "sparc64-linux-gnu"
 		helenos_target = "sparc64-helenos"
-	
+
 	if (config['COMPILER'] == "gcc_helenos"):
 		target = helenos_target
 	else:
 		target = gnu_target
-	
+
 	return (platform, cc_args, target)
 
 def check_app(args, name, details):
 	"Check whether an application can be executed"
-	
+
 	try:
 		sys.stderr.write("Checking for %s ... " % args[0])
@@ -273,18 +273,18 @@
 		             "Execution of \"%s\" has failed. Please make sure that it" % " ".join(args),
 		             "is installed in your system (%s)." % details])
-	
+
 	sys.stderr.write("ok\n")
 
 def check_app_alternatives(alts, args, name, details):
 	"Check whether an application can be executed (use several alternatives)"
-	
+
 	tried = []
 	found = None
-	
+
 	for alt in alts:
 		working = True
 		cmdline = [alt] + args
 		tried.append(" ".join(cmdline))
-		
+
 		try:
 			sys.stderr.write("Checking for %s ... " % alt)
@@ -293,10 +293,10 @@
 			sys.stderr.write("failed\n")
 			working = False
-		
+
 		if (working):
 			sys.stderr.write("ok\n")
 			found = alt
 			break
-	
+
 	if (found is None):
 		print_error(["%s is missing." % name,
@@ -306,30 +306,30 @@
 		             "",
 		             "The following alternatives were tried:"] + tried)
-	
+
 	return found
 
 def check_clang(path, prefix, common, details):
 	"Check for clang"
-	
+
 	common['CLANG'] = "%sclang" % prefix
-	
+
 	if (not path is None):
 		common['CLANG'] = "%s/%s" % (path, common['CLANG'])
-	
+
 	check_app([common['CLANG'], "--version"], "clang", details)
 
 def check_gcc(path, prefix, common, details):
 	"Check for GCC"
-	
+
 	common['GCC'] = "%sgcc" % prefix
-	
+
 	if (not path is None):
 		common['GCC'] = "%s/%s" % (path, common['GCC'])
-	
+
 	check_app([common['GCC'], "--version"], "GNU GCC", details)
 
 def check_binutils(path, prefix, common, details):
 	"Check for binutils toolchain"
-	
+
 	common['AS'] = "%sas" % prefix
 	common['LD'] = "%sld" % prefix
@@ -338,9 +338,9 @@
 	common['OBJDUMP'] = "%sobjdump" % prefix
 	common['STRIP'] = "%sstrip" % prefix
-	
+
 	if (not path is None):
 		for key in ["AS", "LD", "AR", "OBJCOPY", "OBJDUMP", "STRIP"]:
 			common[key] = "%s/%s" % (path, common[key])
-	
+
 	check_app([common['AS'], "--version"], "GNU Assembler", details)
 	check_app([common['LD'], "--version"], "GNU Linker", details)
@@ -352,5 +352,5 @@
 def check_python():
 	"Check for Python dependencies"
-	
+
 	try:
 		sys.stderr.write("Checking for PyYAML ... ")
@@ -361,29 +361,29 @@
 		             "Please make sure that it is installed in your",
 		             "system (usually part of PyYAML package)."])
-	
+
 	sys.stderr.write("ok\n")
 
 def decode_value(value):
 	"Decode integer value"
-	
+
 	base = 10
-	
+
 	if ((value.startswith('$')) or (value.startswith('#'))):
 		value = value[1:]
-	
+
 	if (value.startswith('0x')):
 		value = value[2:]
 		base = 16
-	
+
 	return int(value, base)
 
 def probe_compiler(common, typesizes):
 	"Generate, compile and parse probing source"
-	
+
 	check_common(common, "CC")
-	
+
 	outf = open(PROBE_SOURCE, 'w')
 	outf.write(PROBE_HEAD)
-	
+
 	for typedef in typesizes:
 		if 'def' in typedef:
@@ -392,11 +392,11 @@
 		if 'def' in typedef:
 			outf.write("#endif\n")
-	
+
 	outf.write(PROBE_TAIL)
 	outf.close()
-	
+
 	args = common['CC_AUTOGEN'].split(' ')
 	args.extend(["-S", "-o", PROBE_OUTPUT, PROBE_SOURCE])
-	
+
 	try:
 		sys.stderr.write("Checking compiler properties ... ")
@@ -406,5 +406,5 @@
 		print_error(["Error executing \"%s\"." % " ".join(args),
 		             "Make sure that the compiler works properly."])
-	
+
 	if (not os.path.isfile(PROBE_OUTPUT)):
 		sys.stderr.write("failed\n")
@@ -415,21 +415,21 @@
 		             output[0],
 		             output[1]])
-	
+
 	sys.stderr.write("ok\n")
-	
+
 	inf = open(PROBE_OUTPUT, 'r')
 	lines = inf.readlines()
 	inf.close()
-	
+
 	builtins = {}
-	
+
 	for j in range(len(lines)):
 		tokens = lines[j].strip().split("\t")
-		
+
 		if (len(tokens) > 0):
 			if (tokens[0] == "AUTOTOOL_DECLARE"):
 				if (len(tokens) < 8):
 					print_error(["Malformed declaration in \"%s\" on line %s." % (PROBE_OUTPUT, j), COMPILER_FAIL])
-				
+
 				category = tokens[1]
 				tag = tokens[2]
@@ -439,5 +439,5 @@
 				size = tokens[6]
 				compatible = tokens[7]
-				
+
 				try:
 					compatible_int = decode_value(compatible)
@@ -445,5 +445,5 @@
 				except:
 					print_error(["Integer value expected in \"%s\" on line %s." % (PROBE_OUTPUT, j), COMPILER_FAIL])
-				
+
 				if (compatible_int == 1):
 					builtins[tag] = {
@@ -454,5 +454,5 @@
 						'size': size_int,
 					}
-	
+
 	for typedef in typesizes:
 		if not typedef['tag'] in builtins:
@@ -461,5 +461,5 @@
 		if 'sname' in typedef:
 			builtins[typedef['tag']]['sname'] = typedef['sname']
-	
+
 	return builtins
 
@@ -490,10 +490,10 @@
 def detect_sizes(probe):
 	"Detect properties of builtin types"
-	
+
 	macros = {}
-	
+
 	for type in probe.values():
 		macros['__SIZEOF_%s__' % type['tag']] = type['size']
-		
+
 		if ('sname' in type):
 			macros['__%s_TYPE__'  % type['sname']] = type['name']
@@ -502,20 +502,20 @@
 			macros['__%s_C_SUFFIX__' % type['sname']] = get_suffix(type)
 			macros['__%s_MAX__' % type['sname']] = "%d%s" % (get_max(type), get_suffix(type))
-	
+
 	if (probe['SIZE_T']['sign'] != 'unsigned'):
 		print_error(['The type size_t is not unsigned.', COMPILER_FAIL])
-	
+
 	return macros
 
 def create_makefile(mkname, common):
 	"Create makefile output"
-	
+
 	outmk = open(mkname, 'w')
-	
+
 	outmk.write('#########################################\n')
 	outmk.write('## AUTO-GENERATED FILE, DO NOT EDIT!!! ##\n')
 	outmk.write('## Generated by: tools/autotool.py     ##\n')
 	outmk.write('#########################################\n\n')
-	
+
 	for key, value in common.items():
 		if (type(value) is list):
@@ -523,25 +523,25 @@
 		else:
 			outmk.write('%s = %s\n' % (key, value))
-	
+
 	outmk.close()
 
 def create_header(hdname, macros):
 	"Create header output"
-	
+
 	outhd = open(hdname, 'w')
-	
+
 	outhd.write('/***************************************\n')
 	outhd.write(' * AUTO-GENERATED FILE, DO NOT EDIT!!! *\n')
 	outhd.write(' * Generated by: tools/autotool.py     *\n')
 	outhd.write(' ***************************************/\n\n')
-	
+
 	outhd.write('#ifndef %s\n' % GUARD)
 	outhd.write('#define %s\n\n' % GUARD)
-	
+
 	for macro in sorted(macros):
 		outhd.write('#ifndef %s\n' % macro)
 		outhd.write('#define %s  %s\n' % (macro, macros[macro]))
 		outhd.write('#endif\n\n')
-	
+
 	outhd.write('\n#endif\n')
 	outhd.close()
@@ -550,5 +550,5 @@
 	config = {}
 	common = {}
-	
+
 	# Read and check configuration
 	if os.path.exists(CONFIG):
@@ -558,9 +558,9 @@
 		             "configuration phase of HelenOS build went OK. Try running",
 		             "\"make config\" again."])
-	
+
 	check_config(config, "PLATFORM")
 	check_config(config, "COMPILER")
 	check_config(config, "BARCH")
-	
+
 	# Cross-compiler prefix
 	if ('CROSS_PREFIX' in os.environ):
@@ -568,5 +568,5 @@
 	else:
 		cross_prefix = "/usr/local/cross"
-	
+
 	# HelenOS cross-compiler prefix
 	if ('CROSS_HELENOS_PREFIX' in os.environ):
@@ -574,5 +574,5 @@
 	else:
 		cross_helenos_prefix = "/usr/local/cross-helenos"
-	
+
 	# Prefix binutils tools on Solaris
 	if (os.uname()[0] == "SunOS"):
@@ -580,7 +580,7 @@
 	else:
 		binutils_prefix = ""
-	
+
 	owd = sandbox_enter()
-	
+
 	try:
 		# Common utilities
@@ -593,13 +593,13 @@
 		check_app(["make", "--version"], "Make utility", "preferably GNU Make")
 		check_app(["unzip"], "unzip utility", "usually part of zip/unzip utilities")
-		
+
 		platform, cc_args, target = get_target(config)
-		
+
 		if (platform is None) or (target is None):
 			print_error(["Unsupported compiler target.",
 				     "Please contact the developers of HelenOS."])
-		
+
 		path = "%s/%s/bin" % (cross_prefix, target)
-		
+
 		# Compatibility with earlier toolchain paths.
 		if not os.path.exists(path):
@@ -614,41 +614,41 @@
 					print_error(["Toolchain for target is not installed, or CROSS_PREFIX is not set correctly."])
 				path = "%s/%s/bin" % (cross_prefix, platform)
-		
+
 		common['TARGET'] = target
 		prefix = "%s-" % target
-		
+
 		# Compiler
 		if (config['COMPILER'] == "gcc_cross" or config['COMPILER'] == "gcc_helenos"):
 			check_gcc(path, prefix, common, PACKAGE_CROSS)
 			check_binutils(path, prefix, common, PACKAGE_CROSS)
-			
+
 			check_common(common, "GCC")
 			common['CC'] = " ".join([common['GCC']] + cc_args)
 			common['CC_AUTOGEN'] = common['CC']
-		
+
 		if (config['COMPILER'] == "gcc_native"):
 			check_gcc(None, "", common, PACKAGE_GCC)
 			check_binutils(None, binutils_prefix, common, PACKAGE_BINUTILS)
-			
+
 			check_common(common, "GCC")
 			common['CC'] = common['GCC']
 			common['CC_AUTOGEN'] = common['CC']
-		
+
 		if (config['COMPILER'] == "clang"):
 			check_binutils(path, prefix, common, PACKAGE_CROSS)
 			check_clang(path, prefix, common, PACKAGE_CLANG)
-			
+
 			check_common(common, "CLANG")
 			common['CC'] = " ".join([common['CLANG']] + cc_args)
 			common['CC_AUTOGEN'] = common['CC'] + " -no-integrated-as"
-			
+
 			if (config['INTEGRATED_AS'] == "yes"):
 				common['CC'] += " -integrated-as"
-			
+
 			if (config['INTEGRATED_AS'] == "no"):
 				common['CC'] += " -no-integrated-as"
-		
+
 		check_python()
-		
+
 		# Platform-specific utilities
 		if ((config['BARCH'] == "amd64") or (config['BARCH'] == "ia32") or (config['BARCH'] == "ppc32") or (config['BARCH'] == "sparc64")):
@@ -656,5 +656,5 @@
 			if common['GENISOIMAGE'] == 'xorriso':
 				common['GENISOIMAGE'] += ' -as genisoimage'
-		
+
 		probe = probe_compiler(common,
 			[
@@ -675,15 +675,15 @@
 			]
 		)
-		
+
 		macros = detect_sizes(probe)
-		
+
 	finally:
 		sandbox_leave(owd)
-	
+
 	common['AUTOGEN'] = "%s/autogen.py" % os.path.dirname(os.path.abspath(sys.argv[0]))
-	
+
 	create_makefile(MAKEFILE, common)
 	create_header(HEADER, macros)
-	
+
 	return 0
 
