X-Git-Url: http://git.tremily.us/?a=blobdiff_plain;f=src%2Fengine%2FSCons%2FConftest.py;h=e995e77a8678955bf4583ee6067e6b1ab6370dd4;hb=3278be138bc860dd641d1d65d92fc30647a83347;hp=34fd5e8b69605872ce9491e5cd795f024033919e;hpb=3fab1f39681194e94b4517f5c73408cde26d3062;p=scons.git diff --git a/src/engine/SCons/Conftest.py b/src/engine/SCons/Conftest.py index 34fd5e8b..e995e77a 100644 --- a/src/engine/SCons/Conftest.py +++ b/src/engine/SCons/Conftest.py @@ -64,13 +64,19 @@ Autoconf-like configuration support; low level implementation of tests. # Append "lib_name_list" to the value of LIBS. # "lib_namelist" is a list of strings. # Return the value of LIBS before changing it (any type -# can be used, it is passed to SetLIBS() later. +# can be used, it is passed to SetLIBS() later.) +# +# context.PrependLIBS(lib_name_list) +# Prepend "lib_name_list" to the value of LIBS. +# "lib_namelist" is a list of strings. +# Return the value of LIBS before changing it (any type +# can be used, it is passed to SetLIBS() later.) # # context.SetLIBS(value) # Set LIBS to "value". The type of "value" is what # AppendLIBS() returned. # Return the value of LIBS before changing it (any type -# can be used, it is passed to SetLIBS() later. +# can be used, it is passed to SetLIBS() later.) # # context.headerfilename # Name of file to append configure results to, usually @@ -162,7 +168,67 @@ int main() _YesNoResult(context, ret, None, text) return ret -def _check_empty_program(context, comp, text, language): +def CheckSHCC(context): + """ + Configure check for a working shared C compiler. + + This checks whether the C compiler, as defined in the $SHCC construction + variable, can compile a C source file. It uses the current $SHCCCOM value + too, so that it can test against non working flags. + + """ + context.Display("Checking whether the (shared) C compiler works") + text = """ +int foo() +{ + return 0; +} +""" + ret = _check_empty_program(context, 'SHCC', text, 'C', use_shared = True) + _YesNoResult(context, ret, None, text) + return ret + +def CheckCXX(context): + """ + Configure check for a working CXX compiler. + + This checks whether the CXX compiler, as defined in the $CXX construction + variable, can compile a CXX source file. It uses the current $CXXCOM 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, 'CXX', text, 'C++') + _YesNoResult(context, ret, None, text) + return ret + +def CheckSHCXX(context): + """ + Configure check for a working shared CXX compiler. + + This checks whether the CXX compiler, as defined in the $SHCXX construction + variable, can compile a CXX source file. It uses the current $SHCXXCOM value + too, so that it can test against non working flags. + + """ + context.Display("Checking whether the (shared) C++ compiler works") + text = """ +int main() +{ + return 0; +} +""" + ret = _check_empty_program(context, 'SHCXX', text, 'C++', use_shared = True) + _YesNoResult(context, ret, None, text) + return ret + +def _check_empty_program(context, comp, text, language, use_shared = False): """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 @@ -172,7 +238,10 @@ def _check_empty_program(context, comp, text, language): if msg: return 1 - return context.CompileProg(text, suffix) + if use_shared: + return context.CompileSharedObject(text, suffix) + else: + return context.CompileProg(text, suffix) def CheckFunc(context, function_name, header = None, language = None): @@ -509,7 +578,8 @@ int main() return st def CheckLib(context, libs, func_name = None, header = None, - extra_libs = None, call = None, language = None, autoadd = 1): + extra_libs = None, call = None, language = None, autoadd = 1, + append = True): """ Configure check for a C or C++ libraries "libs". Searches through the list of libraries, until one is found where the test succeeds. @@ -594,7 +664,10 @@ return 0; l = [ lib_name ] if extra_libs: l.extend(extra_libs) - oldLIBS = context.AppendLIBS(l) + if append: + oldLIBS = context.AppendLIBS(l) + else: + oldLIBS = context.PrependLIBS(l) sym = "HAVE_LIB" + lib_name else: oldLIBS = -1 @@ -713,3 +786,9 @@ def _lang2suffix(lang): # vim: set sw=4 et sts=4 tw=79 fo+=l: + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: