Index: Lib/distutils/ccompiler.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/ccompiler.py,v retrieving revision 1.56 diff -c -r1.56 ccompiler.py *** Lib/distutils/ccompiler.py 26 Feb 2003 18:52:07 -0000 1.56 --- Lib/distutils/ccompiler.py 8 Apr 2003 00:37:41 -0000 *************** *** 883,888 **** --- 883,927 ---- """ raise NotImplementedError + def has_function(self, funcname, + includes=None, + include_dirs=None, + libraries=None, + library_dirs=None): + # this can't be included at module scope because it tries to + # import math + import tempfile + if includes is None: + includes = [] + if include_dirs is None: + include_dirs = [] + if libraries is None: + libraries = [] + if library_dirs is None: + library_dirs = [] + fd, fname = tempfile.mkstemp(".c", funcname, text=True) + f = os.fdopen(fd, "w") + for incl in includes: + f.write("""#include "%s"\n""" % incl) + f.write("""\ + main (int argc, char **argv) { + %s(); + } + """ % funcname) + f.close() + try: + objects = self.compile([fname], include_dirs=include_dirs) + except CompileError: + return False + + try: + self.link_executable(objects, "a.out", + libraries=libraries, + library_dirs=library_dirs) + except (LinkError, TypeError): + return False + return True + def find_library_file (self, dirs, lib, debug=0): """Search the specified list of directories for a static or shared library file 'lib' and return the full path to that file. If