summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Cournapeau <cournape@gmail.com>2008-09-03 08:28:57 (GMT)
committerDavid Cournapeau <cournape@gmail.com>2008-09-03 08:28:57 (GMT)
commite82cd51fc1e345fd8005dccf6e1ae1862a37455c (patch)
treeeb0a3a0d89ca827f9e9a6404a3714217cdfc6ded /src
parentf026c1e0de57accedf8046325cf4efa529cf8e50 (diff)
downloadSCons-e82cd51fc1e345fd8005dccf6e1ae1862a37455c.zip
SCons-e82cd51fc1e345fd8005dccf6e1ae1862a37455c.tar.gz
SCons-e82cd51fc1e345fd8005dccf6e1ae1862a37455c.tar.bz2
Add a CheckCC check.
Diffstat (limited to 'src')
-rw-r--r--src/engine/SCons/Conftest.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/engine/SCons/Conftest.py b/src/engine/SCons/Conftest.py
index d311168..34fd5e8 100644
--- a/src/engine/SCons/Conftest.py
+++ b/src/engine/SCons/Conftest.py
@@ -142,6 +142,38 @@ int main() {
_YesNoResult(context, ret, None, text)
return ret
+def CheckCC(context):
+ """
+ Configure check for a working C compiler.
+
+ This checks whether the C compiler, as defined in the $CC construction
+ variable, can compile a C source file. It uses the current $CCCOM value
+ too, so that it can test against non working flags.
+
+ """
+ context.Display("Checking whether the C compiler works")
+ text = """
+int main()
+{
+ return 0;
+}
+"""
+ ret = _check_empty_program(context, 'CC', text, 'C')
+ _YesNoResult(context, ret, None, text)
+ return ret
+
+def _check_empty_program(context, comp, text, language):
+ """Return 0 on success, 1 otherwise."""
+ if not context.env.has_key(comp) or not context.env[comp]:
+ # The compiler construction variable is not set or empty
+ return 1
+
+ lang, suffix, msg = _lang2suffix(language)
+ if msg:
+ return 1
+
+ return context.CompileProg(text, suffix)
+
def CheckFunc(context, function_name, header = None, language = None):
"""