From: cournape Date: Wed, 3 Sep 2008 08:28:57 +0000 (+0000) Subject: Add a CheckCC check. X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=3fab1f39681194e94b4517f5c73408cde26d3062;p=scons.git Add a CheckCC check. git-svn-id: http://scons.tigris.org/svn/scons/trunk@3328 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- diff --git a/src/engine/SCons/Conftest.py b/src/engine/SCons/Conftest.py index d3111686..34fd5e8b 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): """