--- Python-2.5.2/Lib/distutils/ccompiler.py 2008-04-07 01:06:20.000000000 -0500 +++ Python-2.5.2/Lib/distutils/ccompiler.py 2008-04-07 01:10:51.000000000 -0500 @@ -689,12 +689,15 @@ class CCompiler: depends, extra_postargs) cc_args = self._get_cc_args(pp_opts, debug, extra_preargs) + lang = self.detect_language(sources) + for obj in objects: try: src, ext = build[obj] except KeyError: continue - self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts) + self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts, + lang=lang) # Return *all* object filenames, not just the ones we just built. return objects --- Python-2.5.2/Lib/distutils/sysconfig.py 2008-04-07 01:06:20.000000000 -0500 +++ Python-2.5.2/Lib/distutils/sysconfig.py 2008-04-07 00:45:49.000000000 -0500 @@ -146,9 +146,9 @@ def customize_compiler(compiler): varies across Unices and is stored in Python's Makefile. """ if compiler.compiler_type == "unix": - (cc, cxx, opt, cflags, ccshared, ldshared, so_ext) = \ - get_config_vars('CC', 'CXX', 'OPT', 'CFLAGS', - 'CCSHARED', 'LDSHARED', 'SO') + (cc, cxx, opt, cflags, ccshared, ldshared, so_ext, cxxflags) = ( + get_config_vars('CC', 'CXX', 'OPT', 'CFLAGS', 'CCSHARED', + 'LDSHARED', 'SO', 'CXXFLAGS')) if os.environ.has_key('CC'): cc = os.environ['CC'] @@ -169,13 +169,17 @@ def customize_compiler(compiler): cpp = cpp + ' ' + os.environ['CPPFLAGS'] cflags = cflags + ' ' + os.environ['CPPFLAGS'] ldshared = ldshared + ' ' + os.environ['CPPFLAGS'] + if os.environ.has_key('CXXFLAGS'): + cxxflags = opt + ' ' + os.environ['CXXFLAGS'] cc_cmd = cc + ' ' + cflags + cxx_cmd = cxx + ' ' + cxxflags compiler.set_executables( preprocessor=cpp, compiler=cc_cmd, compiler_so=cc_cmd + ' ' + ccshared, - compiler_cxx=cxx, + compiler_cxx=cxx_cmd, + compiler_cxx_so=cxx_cmd + ' ' + ccshared, linker_so=ldshared, linker_exe=cc) @@ -512,6 +516,7 @@ def get_config_vars(*args): for key in ('LDFLAGS', 'BASECFLAGS', # a number of derived variables. These need to be # patched up as well. + 'CXXFLAGS', 'CFLAGS', 'PY_CFLAGS', 'BLDSHARED'): flags = _config_vars[key] --- Python-2.5.2/Lib/distutils/unixccompiler.py 2008-04-07 01:06:20.000000000 -0500 +++ Python-2.5.2/Lib/distutils/unixccompiler.py 2008-04-07 01:10:54.000000000 -0500 @@ -114,6 +114,7 @@ class UnixCCompiler(CCompiler): 'compiler' : ["cc"], 'compiler_so' : ["cc"], 'compiler_cxx' : ["cc"], + 'compiler_cxx_so' : ["cc"], 'linker_so' : ["cc", "-shared"], 'linker_exe' : ["cc"], 'archiver' : ["ar", "-cr"], @@ -165,12 +166,18 @@ class UnixCCompiler(CCompiler): except DistutilsExecError, msg: raise CompileError, msg - def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts): + def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts, + lang='c'): compiler_so = self.compiler_so + compiler_cxx_so = self.compiler_cxx_so if sys.platform == 'darwin': compiler_so = _darwin_compiler_fixup(compiler_so, cc_args + extra_postargs) try: - self.spawn(compiler_so + cc_args + [src, '-o', obj] + + if lang == 'c++': + cc = compiler_cxx_so + cc_args + else: + cc = compiler_so + cc_args + self.spawn(cc + cc_args + [src, '-o', obj] + extra_postargs) except DistutilsExecError, msg: raise CompileError, msg