Back out post-2.0 code changes from trunk: r4643, r4642 r4640, r4637.
[scons.git] / src / engine / SCons / Conftest.py
index 34fd5e8b69605872ce9491e5cd795f024033919e..e995e77a8678955bf4583ee6067e6b1ab6370dd4 100644 (file)
@@ -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: