Added 'include_dirs' parameters all over the place.
Added 'check_lib()', which provides a subset of the functionality of
  'check_func()' with a simpler interface and implementation.
diff --git a/Lib/distutils/command/config.py b/Lib/distutils/command/config.py
index 570f71a..5c3f26a 100644
--- a/Lib/distutils/command/config.py
+++ b/Lib/distutils/command/config.py
@@ -112,24 +112,26 @@
         file.close()
         return filename
 
-    def _preprocess (self, body, headers, lang):
+    def _preprocess (self, body, headers, include_dirs, lang):
         src = self._gen_temp_sourcefile(body, headers, lang)
         out = "_configtest.i"
         self.temp_files.extend([src, out])
-        self.compiler.preprocess(src, out)
+        self.compiler.preprocess(src, out, include_dirs=include_dirs)
         return (src, out)
 
-    def _compile (self, body, headers, lang):
+    def _compile (self, body, headers, include_dirs, lang):
         src = self._gen_temp_sourcefile(body, headers, lang)
         if self.dump_source:
             dump_file(src, "compiling '%s':" % src)
         (obj,) = self.compiler.object_filenames([src])
         self.temp_files.extend([src, obj])
-        self.compiler.compile([src])
+        self.compiler.compile([src], include_dirs=include_dirs)
         return (src, obj)
 
-    def _link (self, body, headers, libraries, library_dirs, lang):
-        (src, obj) = self._compile(body, headers, lang)
+    def _link (self, body,
+               headers, include_dirs,
+               libraries, library_dirs, lang):
+        (src, obj) = self._compile(body, headers, include_dirs, lang)
         prog = os.path.splitext(os.path.basename(src))[0] 
         self.temp_files.append(prog)    # XXX should be prog + exe_ext
         self.compiler.link_executable([obj], prog,
@@ -159,7 +161,7 @@
 
     # XXX need access to the header search path and maybe default macros.
 
-    def try_cpp (self, body=None, headers=None, lang="c"):
+    def try_cpp (self, body=None, headers=None, include_dirs=None, lang="c"):
         """Construct a source file from 'body' (a string containing lines
         of C/C++ code) and 'headers' (a list of header files to include)
         and run it through the preprocessor.  Return true if the
@@ -177,7 +179,8 @@
         self._clean()
         return ok
 
-    def search_cpp (self, pattern, body=None, headers=None, lang="c"):
+    def search_cpp (self, pattern, body=None,
+                    headers=None, include_dirs=None, lang="c"):
         """Construct a source file (just like 'try_cpp()'), run it through
         the preprocessor, and return true if any line of the output matches
         'pattern'.  'pattern' should either be a compiled regex object or a
@@ -206,7 +209,7 @@
         self._clean()
         return match
 
-    def try_compile (self, body, headers=None, lang="c"):
+    def try_compile (self, body, headers=None, include_dirs=None, lang="c"):
         """Try to compile a source file built from 'body' and 'headers'.
         Return true on success, false otherwise.
         """
@@ -222,8 +225,8 @@
         self._clean()
         return ok
 
-    def try_link (self,
-                  body, headers=None,
+    def try_link (self, body,
+                  headers=None, include_dirs=None,
                   libraries=None, library_dirs=None,
                   lang="c"):
         """Try to compile and link a source file, built from 'body' and
@@ -233,7 +236,8 @@
         from distutils.ccompiler import CompileError, LinkError
         self._check_compiler()
         try:
-            self._link(body, headers, libraries, library_dirs, lang)
+            self._link(body, headers, include_dirs,
+                       libraries, library_dirs, lang)
             ok = 1
         except (CompileError, LinkError):
             ok = 0
@@ -242,8 +246,8 @@
         self._clean()
         return ok
             
-    def try_run (self,
-                 body, headers=None, 
+    def try_run (self, body,
+                 headers=None, include_dirs=None,
                  libraries=None, library_dirs=None,
                  lang="c"):
         """Try to compile, link to an executable, and run a program
@@ -253,7 +257,8 @@
         from distutils.ccompiler import CompileError, LinkError
         self._check_compiler()
         try:
-            self._link(body, headers, libraries, library_dirs, lang)
+            self._link(body, headers, include_dirs,
+                       libraries, library_dirs, lang)
             self.spawn([exe])
             ok = 1
         except (CompileError, LinkError, DistutilsExecError):
@@ -268,7 +273,8 @@
     # (these are the ones that are actually likely to be useful
     # when implementing a real-world config command!)
 
-    def check_func (self, func, headers=None,
+    def check_func (self, func,
+                    headers=None, include_dirs=None,
                     libraries=None, library_dirs=None,
                     decl=0, call=0):
 
@@ -298,16 +304,30 @@
         body.append("}")
         body = string.join(body, "\n") + "\n"
 
-        return self.try_link(body, headers, libraries, library_dirs)
+        return self.try_link(body, headers, include_dirs,
+                             libraries, library_dirs)
 
     # check_func ()
 
-    def check_header (self, header, lang="c"):
+    def check_lib (self, library, library_dirs=None,
+                   headers=None, include_dirs=None):
+        """Determine if 'library' is available to be linked against,
+        without actually checking that any particular symbols are provided
+        by it.  'headers' will be used in constructing the source file to
+        be compiled, but the only effect of this is to check if all the
+        header files listed are available.
+        """
+        self._check_compiler()
+        return self.try_link("int main (void) { }",
+                             headers, include_dirs, [library], library_dirs)
+
+    def check_header (self, header, include_dirs=None,
+                      library_dirs=None, lang="c"):
         """Determine if the system header file named by 'header_file'
         exists and can be found by the preprocessor; return true if so,
         false otherwise.
         """
-        return self.try_cpp(headers=[header])
+        return self.try_cpp(headers=[header], include_dirs=include_dirs)
 
 
 # class config