Index: Lib/distutils/tests/test_sysconfig.py =================================================================== --- Lib/distutils/tests/test_sysconfig.py (revision 70611) +++ Lib/distutils/tests/test_sysconfig.py (working copy) @@ -50,17 +50,22 @@ return os.environ['AR'] = 'xxx' + os.environ['LIBS'] = 'gcov -lyyy zzz' - # make sure AR gets caught + # make sure certain environment variables get caught class compiler: compiler_type = 'unix' + def __init__(self): + self.libraries = [] + def set_executables(self, **kw): self.exes = kw comp = compiler() sysconfig.customize_compiler(comp) self.assertEquals(comp.exes['archiver'], 'xxx') + self.assertEquals(comp.libraries, ['gcov', 'yyy', 'zzz']) def test_suite(): Index: Lib/distutils/command/build_ext.py =================================================================== --- Lib/distutils/command/build_ext.py (revision 70611) +++ Lib/distutils/command/build_ext.py (working copy) @@ -341,7 +341,8 @@ for macro in self.undef: self.compiler.undefine_macro(macro) if self.libraries is not None: - self.compiler.set_libraries(self.libraries) + for lib in self.libraries: + self.compiler.add_library(lib) if self.library_dirs is not None: self.compiler.set_library_dirs(self.library_dirs) if self.rpath is not None: Index: Lib/distutils/sysconfig.py =================================================================== --- Lib/distutils/sysconfig.py (revision 70611) +++ Lib/distutils/sysconfig.py (working copy) @@ -165,9 +165,9 @@ varies across Unices and is stored in Python's Makefile. """ if compiler.compiler_type == "unix": - (cc, cxx, opt, cflags, ccshared, ldshared, so_ext, ar) = \ + (cc, cxx, opt, cflags, ccshared, ldshared, so_ext, ar, libs) = \ get_config_vars('CC', 'CXX', 'OPT', 'CFLAGS', - 'CCSHARED', 'LDSHARED', 'SO', 'AR') + 'CCSHARED', 'LDSHARED', 'SO', 'AR', 'LIBS') if 'CC' in os.environ: cc = os.environ['CC'] @@ -190,6 +190,8 @@ ldshared = ldshared + ' ' + os.environ['CPPFLAGS'] if 'AR' in os.environ: ar = os.environ['AR'] + if 'LIBS' in os.environ: + libs = os.environ['LIBS'] cc_cmd = cc + ' ' + cflags compiler.set_executables( @@ -202,6 +204,12 @@ archiver=ar) compiler.shared_lib_extension = so_ext + for chunk in libs.split(" "): + if not chunk: + continue + if chunk.startswith("-l"): + chunk = chunk[2:] + compiler.libraries.append(chunk) def get_config_h_filename():