From e82cd51fc1e345fd8005dccf6e1ae1862a37455c Mon Sep 17 00:00:00 2001 From: David Cournapeau Date: Wed, 3 Sep 2008 08:28:57 +0000 Subject: Add a CheckCC check. --- src/engine/SCons/Conftest.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) 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): """ -- cgit v0.12