3
# Copyright (c) 2010 Martin Decky
6
# Redistribution and use in source and binary forms, with or without
7
# modification, are permitted provided that the following conditions
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.
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.
30
Check whether several important prerequisites for building HelenOS
31
are present in the system
38
MAKEFILE = 'Makefile.config'
40
def read_config(fname, config):
41
"Read HelenOS build configuration"
43
inf = file(fname, 'r')
46
res = re.match(r'^(?:#!# )?([^#]\w*)\s*=\s*(.*?)\s*$', line)
48
config[res.group(1)] = res.group(2)
53
"Print a bold error message"
55
sys.stderr.write("\n")
56
sys.stderr.write("######################################################################\n")
57
sys.stderr.write("HelenOS build sanity check error:\n")
58
sys.stderr.write("\n")
59
sys.stderr.write("%s\n" % "\n".join(msg))
60
sys.stderr.write("######################################################################\n")
61
sys.stderr.write("\n")
65
def check_app(args, name, details):
66
"Check whether an application can be executed"
69
sys.stderr.write("Checking for %s ... " % args[0])
70
subprocess.Popen(args, stdout = subprocess.PIPE, stderr = subprocess.PIPE).wait()
72
sys.stderr.write("failed\n")
73
print_error(["%s is missing." % name,
75
"Execution of \"%s\" has failed. Please make sure that it" % " ".join(args),
76
"is installed in your system (%s)." % details])
78
sys.stderr.write("ok\n")
81
"Check for binutils toolchain"
83
check_app(["as", "--version"], "GNU Assembler", "usually part of binutils")
84
check_app(["ld", "--version"], "GNU Linker", "usually part of binutils")
85
check_app(["ar", "--version"], "GNU Archiver", "usually part of binutils")
86
check_app(["objcopy", "--version"], "Objcopy utility", "usually part of binutils")
87
check_app(["objdump", "--version"], "Objdump utility", "usually part of binutils")
93
if os.path.exists(MAKEFILE):
94
read_config(MAKEFILE, config)
96
print_error(["Configuration file %s not found! Make sure that the" % MAKEFILE,
97
"configuration phase of HelenOS build went OK. Try running",
98
"\"make config\" again."])
100
if ('CROSS_PREFIX' in os.environ):
101
cross_prefix = os.environ['CROSS_PREFIX']
103
cross_prefix = "/usr/local"
106
check_app(["ln", "--version"], "Symlink utility", "usually part of coreutils")
107
check_app(["rm", "--version"], "File remove utility", "usually part of coreutils")
108
check_app(["mkdir", "--version"], "Directory creation utility", "usually part of coreutils")
109
check_app(["cp", "--version"], "Copy utility", "usually part of coreutils")
110
check_app(["uname", "--version"], "System information utility", "usually part of coreutils")
111
check_app(["find", "--version"], "Find utility", "usually part of findutils")
112
check_app(["diff", "--version"], "Diff utility", "usually part of diffutils")
113
check_app(["make", "--version"], "Make utility", "preferably GNU Make")
114
check_app(["makedepend", "-f", "-"], "Makedepend utility", "usually part of imake or xutils")
117
if (config['COMPILER'] == "gcc_native"):
118
check_app(["gcc", "--version"], "GNU GCC", "preferably version 4.4 or newer")
121
if (config['COMPILER'] == "icc"):
122
check_app(["icc", "-V"], "Intel C++ Compiler", "support is experimental")
125
if (config['COMPILER'] == "suncc"):
126
check_app(["suncc", "-V"], "Sun Studio Compiler", "support is experimental")
129
if (config['COMPILER'] == "clang"):
130
check_app(["clang", "--version"], "Clang compiler", "preferably version 1.0 or newer")
133
if ((config['UARCH'] == "amd64") or (config['UARCH'] == "ia32") or (config['UARCH'] == "ppc32") or (config['UARCH'] == "sparc64")):
134
check_app(["mkisofs", "--version"], "ISO 9660 creation utility", "usually part of genisoimage")
137
print_error(["Build configuration of HelenOS is corrupted or the sanity checks",
138
"are out-of-sync. Try running \"make config\" again. ",
139
"If the problem persists, please contact the developers of HelenOS."])
143
if __name__ == '__main__':