Index: configure
===================================================================
--- configure	(Revision 41421)
+++ configure	(Arbeitskopie)
@@ -1,5 +1,5 @@
 #! /bin/sh
-# From configure.in Revision: 1.486 .
+# From configure.in Revision: 39267 .
 # Guess values for system-dependent variables and create Makefiles.
 # Generated by GNU Autoconf 2.59 for python 2.5.
 #
@@ -312,7 +312,7 @@
 # include <unistd.h>
 #endif"
 
-ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS VERSION SOVERSION CONFIG_ARGS PYTHONFRAMEWORK PYTHONFRAMEWORKDIR PYTHONFRAMEWORKPREFIX PYTHONFRAMEWORKINSTALLDIR MACHDEP SGI_ABI EXTRAPLATDIR EXTRAMACHDEPPATH CONFIGURE_MACOSX_DEPLOYMENT_TARGET CXX MAINOBJ EXEEXT CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC OBJEXT CPP EGREP BUILDEXEEXT LIBRARY LDLIBRARY DLLLIBRARY BLDLIBRARY LDLIBRARYDIR INSTSONAME RUNSHARED LINKCC RANLIB ac_ct_RANLIB AR INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA LN OPT BASECFLAGS OTHER_LIBTOOL_OPT LIBTOOL_CRUFT SO LDSHARED BLDSHARED CCSHARED LINKFORSHARED CFLAGSFORSHARED SHLIBS USE_SIGNAL_MODULE SIGNAL_OBJS USE_THREAD_MODULE LDLAST THREADOBJ DLINCLDIR DYNLOADFILE MACHDEP_OBJS TRUE LIBOBJS HAVE_GETHOSTBYNAME_R_6_ARG HAVE_GETHOSTBYNAME_R_5_ARG HAVE_GETHOSTBYNAME_R_3_ARG HAVE_GETHOSTBYNAME_R HAVE_GETHOSTBYNAME LIBM LIBC UNICODE_OBJS THREADHEADERS SRCDIRS LTLIBOBJS'
+ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS VERSION SOVERSION CONFIG_ARGS PYTHONFRAMEWORK PYTHONFRAMEWORKDIR PYTHONFRAMEWORKPREFIX PYTHONFRAMEWORKINSTALLDIR MACHDEP SGI_ABI EXTRAPLATDIR EXTRAMACHDEPPATH CONFIGURE_MACOSX_DEPLOYMENT_TARGET CXX MAINCC EXEEXT CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC OBJEXT CPP EGREP BUILDEXEEXT LIBRARY LDLIBRARY DLLLIBRARY BLDLIBRARY LDLIBRARYDIR INSTSONAME RUNSHARED LINKCC RANLIB ac_ct_RANLIB AR INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA LN OPT BASECFLAGS OTHER_LIBTOOL_OPT LIBTOOL_CRUFT SO LDSHARED BLDSHARED CCSHARED LINKFORSHARED CFLAGSFORSHARED SHLIBS USE_SIGNAL_MODULE SIGNAL_OBJS USE_THREAD_MODULE LDLAST THREADOBJ DLINCLDIR DYNLOADFILE MACHDEP_OBJS TRUE LIBOBJS HAVE_GETHOSTBYNAME_R_6_ARG HAVE_GETHOSTBYNAME_R_5_ARG HAVE_GETHOSTBYNAME_R_3_ARG HAVE_GETHOSTBYNAME_R HAVE_GETHOSTBYNAME LIBM LIBC UNICODE_OBJS THREADHEADERS SRCDIRS LTLIBOBJS'
 ac_subst_files=''
 
 # Initialize some variables set by options.
@@ -859,7 +859,9 @@
   --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
   --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
   --without-gcc           never use gcc
-  --with-cxx=<compiler>   enable C++ support
+  --with-cxx-main=<compiler>
+                          compile main() and link python executable with C++
+                          compiler
   --with-suffix=.exe      set executable suffix
   --with-pydebug          build with Py_DEBUG defined
   --with-libs='lib1 ...'  link against additional libs
@@ -1669,42 +1671,129 @@
 
 
 
-MAINOBJ=python.o
-echo "$as_me:$LINENO: checking for --with-cxx=<compiler>" >&5
-echo $ECHO_N "checking for --with-cxx=<compiler>... $ECHO_C" >&6
+echo "$as_me:$LINENO: checking for --with-cxx-main=<compiler>" >&5
+echo $ECHO_N "checking for --with-cxx-main=<compiler>... $ECHO_C" >&6
 
-# Check whether --with-cxx or --without-cxx was given.
-if test "${with_cxx+set}" = set; then
-  withval="$with_cxx"
+# Check whether --with-cxx_main or --without-cxx_main was given.
+if test "${with_cxx_main+set}" = set; then
+  withval="$with_cxx_main"
 
-	check_cxx=no
+
 	case $withval in
-	no)	CXX=
-		with_cxx=no;;
-	*)	CXX=$withval
-		MAINOBJ=ccpython.o
-		with_cxx=$withval;;
+	no)	with_cxx_main=no
+		MAINCC='$(CC)';;
+	yes)	with_cxx_main=yes
+		MAINCC='$(CXX)';;
+	*)	with_cxx_main=yes
+		MAINCC=$withval
+		if test -z "$CXX"
+		then
+			CXX=$withval
+		fi;;
 	esac
 else
 
-	with_cxx=no
-	check_cxx=yes
+	with_cxx_main=no
+	MAINCC='$(CC)'
 
 fi;
-echo "$as_me:$LINENO: result: $with_cxx" >&5
-echo "${ECHO_T}$with_cxx" >&6
+echo "$as_me:$LINENO: result: $with_cxx_main" >&5
+echo "${ECHO_T}$with_cxx_main" >&6
 
-if test "$with_cxx" = "yes"
+
+
+
+preset_cxx="$CXX"
+if test -z "$CXX"
 then
-	{ { echo "$as_me:$LINENO: error: must supply a compiler when using --with-cxx" >&5
-echo "$as_me: error: must supply a compiler when using --with-cxx" >&2;}
-   { (exit 1); exit 1; }; }
+        case "$CC" in
+        gcc)    # Extract the first word of "g++", so it can be a program name with args.
+set dummy g++; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_path_CXX+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  case $CXX in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_CXX="$CXX" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in notfound
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_path_CXX="$as_dir/$ac_word$ac_exec_ext"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+
+  test -z "$ac_cv_path_CXX" && ac_cv_path_CXX="g++"
+  ;;
+esac
 fi
+CXX=$ac_cv_path_CXX
 
+if test -n "$CXX"; then
+  echo "$as_me:$LINENO: result: $CXX" >&5
+echo "${ECHO_T}$CXX" >&6
+else
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+ ;;
+        cc)     # Extract the first word of "c++", so it can be a program name with args.
+set dummy c++; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_path_CXX+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  case $CXX in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_CXX="$CXX" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in notfound
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_path_CXX="$as_dir/$ac_word$ac_exec_ext"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
 
+  test -z "$ac_cv_path_CXX" && ac_cv_path_CXX="c++"
+  ;;
+esac
+fi
+CXX=$ac_cv_path_CXX
 
-
-if test "$check_cxx" = "yes"
+if test -n "$CXX"; then
+  echo "$as_me:$LINENO: result: $CXX" >&5
+echo "${ECHO_T}$CXX" >&6
+else
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+ ;;
+        esac
+	if test "$CXX" = "notfound"
+	then
+		CXX=""
+	fi
+fi
+if test -z "$CXX"
 then
 	for ac_prog in $CCC c++ g++ gcc CC cxx cc++ cl
 do
@@ -1749,9 +1838,12 @@
 
 	if test "$CXX" = "notfound"
 	then
-		CXX=
-	else
-		ac_ext=cc
+		CXX=""
+	fi
+fi
+if test "$CXX"
+then
+	ac_ext=cc
 ac_cpp='$CXXCPP $CPPFLAGS'
 ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
 ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
@@ -1916,9 +2008,21 @@
 
 
 
-	fi
 fi
+if test "$preset_cxx" != "$CXX"
+then
+        { echo "$as_me:$LINENO: WARNING:
 
+  By default, distutils will build C++ extension modules with \"$CXX\".
+  If this is not intended, then set CXX on the configure command line.
+  " >&5
+echo "$as_me: WARNING:
+
+  By default, distutils will build C++ extension modules with \"$CXX\".
+  If this is not intended, then set CXX on the configure command line.
+  " >&2;}
+fi
+
 # If the user switches compilers, we can't believe the cache
 if test ! -z "$ac_cv_prog_CC" -a ! -z "$CC" -a "$CC" != "$ac_cv_prog_CC"
 then
@@ -3262,22 +3366,7 @@
 echo $ECHO_N "checking LINKCC... $ECHO_C" >&6
 if test -z "$LINKCC"
 then
-        if test -z "$CXX"; then
-              LINKCC="\$(PURIFY) \$(CC)"
-        else
-              echo 'extern "C" void foo();int main(){foo();}' > conftest_a.cc
-              $CXX -c conftest_a.cc # 2>&5
-              echo 'void foo(){}' > conftest_b.$ac_ext
-              $CC -c conftest_b.$ac_ext # 2>&5
-              if $CC -o conftest$ac_exeext conftest_a.$ac_objext conftest_b.$ac_objext 2>&5 \
-                 && test -s conftest$ac_exeext && ./conftest$ac_exeext
-              then
-                 LINKCC="\$(PURIFY) \$(CC)"
-              else
-                 LINKCC="\$(PURIFY) \$(CXX)"
-              fi
-              rm -fr conftest*
-        fi
+	LINKCC='$(PURIFY) $(MAINCC)'
 	case $ac_sys_system in
 	AIX*)
 	   exp_extra="\"\""
@@ -21445,7 +21534,7 @@
 s,@EXTRAMACHDEPPATH@,$EXTRAMACHDEPPATH,;t t
 s,@CONFIGURE_MACOSX_DEPLOYMENT_TARGET@,$CONFIGURE_MACOSX_DEPLOYMENT_TARGET,;t t
 s,@CXX@,$CXX,;t t
-s,@MAINOBJ@,$MAINOBJ,;t t
+s,@MAINCC@,$MAINCC,;t t
 s,@EXEEXT@,$EXEEXT,;t t
 s,@CC@,$CC,;t t
 s,@CFLAGS@,$CFLAGS,;t t
Index: configure.in
===================================================================
--- configure.in	(Revision 41421)
+++ configure.in	(Arbeitskopie)
@@ -302,34 +302,33 @@
 AC_MSG_RESULT($without_gcc)
 
 AC_SUBST(CXX)
-AC_SUBST(MAINOBJ)
-MAINOBJ=python.o
-AC_MSG_CHECKING(for --with-cxx=<compiler>)
-AC_ARG_WITH(cxx,
-            AC_HELP_STRING(--with-cxx=<compiler>, enable C++ support),
+AC_SUBST(MAINCC)
+AC_MSG_CHECKING(for --with-cxx-main=<compiler>)
+AC_ARG_WITH(cxx_main,
+            AC_HELP_STRING([--with-cxx-main=<compiler>],
+                           [compile main() and link python executable with C++ compiler]),
 [
-	check_cxx=no
+	
 	case $withval in
-	no)	CXX=
-		with_cxx=no;;
-	*)	CXX=$withval
-		MAINOBJ=ccpython.o
-		with_cxx=$withval;;
+	no)	with_cxx_main=no
+		MAINCC='$(CC)';;
+	yes)	with_cxx_main=yes
+		MAINCC='$(CXX)';;
+	*)	with_cxx_main=yes
+		MAINCC=$withval
+		if test -z "$CXX"
+		then
+			CXX=$withval
+		fi;;
 	esac], [
-	with_cxx=no
-	check_cxx=yes
+	with_cxx_main=no
+	MAINCC='$(CC)'
 ])
-AC_MSG_RESULT($with_cxx)
+AC_MSG_RESULT($with_cxx_main)
 
-if test "$with_cxx" = "yes"
-then
-	AC_MSG_ERROR([must supply a compiler when using --with-cxx])
-fi
-
 dnl The following fragment works similar to AC_PROG_CXX.
-dnl It does not fail if CXX is not found, and it is not executed if 
-dnl --without-cxx was given.
-dnl Finally, it does not test whether CXX is g++.
+dnl It does not fail if CXX is not found, and it does not 
+dnl test whether CXX is g++.
 
 dnl Autoconf 2.5x does not have AC_PROG_CXX_WORKS anymore
 ifdef([AC_PROG_CXX_WORKS],[],
@@ -340,17 +339,39 @@
       ]
 )])
 
-if test "$check_cxx" = "yes" 
+preset_cxx="$CXX"
+if test -z "$CXX"
 then
+        case "$CC" in
+        gcc)    AC_PATH_PROG(CXX, [g++], [g++], [notfound]) ;;
+        cc)     AC_PATH_PROG(CXX, [c++], [c++], [notfound]) ;;
+        esac
+	if test "$CXX" = "notfound"
+	then
+		CXX=""
+	fi
+fi
+if test -z "$CXX"
+then
 	AC_CHECK_PROGS(CXX, $CCC c++ g++ gcc CC cxx cc++ cl, notfound)
 	if test "$CXX" = "notfound"
 	then
-		CXX=
-	else
-		AC_PROG_CXX_WORKS
+		CXX=""
 	fi
 fi
+if test "$CXX"
+then
+	AC_PROG_CXX_WORKS
+fi
+if test "$preset_cxx" != "$CXX"
+then
+        AC_MSG_WARN([
 
+  By default, distutils will build C++ extension modules with "$CXX".
+  If this is not intended, then set CXX on the configure command line.
+  ])
+fi
+
 # If the user switches compilers, we can't believe the cache
 if test ! -z "$ac_cv_prog_CC" -a ! -z "$CC" -a "$CC" != "$ac_cv_prog_CC"
 then
@@ -468,22 +489,7 @@
 AC_MSG_CHECKING(LINKCC)
 if test -z "$LINKCC"
 then
-        if test -z "$CXX"; then
-              LINKCC="\$(PURIFY) \$(CC)"
-        else
-              echo 'extern "C" void foo();int main(){foo();}' > conftest_a.cc
-              $CXX -c conftest_a.cc # 2>&5
-              echo 'void foo(){}' > conftest_b.$ac_ext
-              $CC -c conftest_b.$ac_ext # 2>&5
-              if $CC -o conftest$ac_exeext conftest_a.$ac_objext conftest_b.$ac_objext 2>&5 \
-                 && test -s conftest$ac_exeext && ./conftest$ac_exeext
-              then
-                 LINKCC="\$(PURIFY) \$(CC)"
-              else
-                 LINKCC="\$(PURIFY) \$(CXX)"
-              fi
-              rm -fr conftest*
-        fi
+	LINKCC='$(PURIFY) $(MAINCC)'
 	case $ac_sys_system in
 	AIX*)
 	   exp_extra="\"\""
Index: Misc/NEWS
===================================================================
--- Misc/NEWS	(Revision 41421)
+++ Misc/NEWS	(Arbeitskopie)
@@ -554,6 +554,11 @@
 Build
 -----
 
+- Remove ccpython.cc; replace --with-cxx with --with-cxx-main. Link with C++
+  compiler only if --with-cxx-main was specified. (Can be overriden by
+  explicitly setting LINKCC.) Decouple CXX from --with-cxx-main, see
+  description in README.
+
 - Bug #1189330: configure did not correctly determine the necessary
   value of LINKCC if python was built with GCC 4.0.
 
Index: README
===================================================================
--- README	(Revision 41421)
+++ README	(Arbeitskopie)
@@ -1028,15 +1028,37 @@
 --with-libs='libs': Add 'libs' to the LIBS that the python interpreter
 	is linked against.
 
---with-cxx=<compiler>: Some C++ compilers require that main() is
-        compiled with the C++ if there is any C++ code in the application.
-        Specifically, g++ on a.out systems may require that to support
-        construction of global objects. With this option, the main() function
-        of Python will be compiled with <compiler>; use that only if you
-        plan to use C++ extension modules, and if your compiler requires
-        compilation of main() as a C++ program.
+--with-cxx-main=<compiler>: If you plan to use C++ extension modules,
+        then -- on some platforms -- you need to compile python's main()
+        function with the C++ compiler. With this option, make will use
+        <compiler> to compile main() *and* to link the python executable.
+        It is likely that the resulting executable depends on the C++
+        runtime library of <compiler>. (The default is --without-cxx-main.)
 
+        There are platforms that do not require you to build Python
+        with a C++ compiler in order to use C++ extension modules.
+        E.g., x86 Linux with ELF shared binaries and GCC 3.x, 4.x is such
+        a platform. We recommend that you configure Python
+        --without-cxx-main on those platforms because a mismatch
+        between the C++ compiler version used to build Python and to
+        build a C++ extension module is likely to cause a crash at
+        runtime.
 
+        The Python installation also stores the variable CXX that
+        determines, e.g., the C++ compiler distutils calls by default
+        to build C++ extensions. If you set CXX on the configure command
+        line to any string of non-zero length, then configure won't
+        change CXX. If you do not preset CXX but pass
+        --with-cxx-main=<compiler>, then configure sets CXX=<compiler>.
+        In all other cases, configure looks for a C++ compiler by
+        some common names (c++, g++, gcc, CC, cxx, cc++, cl) and sets
+        CXX to the first compiler it finds. If it does not find any
+        C++ compiler, then it sets CXX="".
+
+        Similarly, if you want to change the command used to link the
+        python executable, then set LINKCC on the configure command line.
+
+
 --with-pydebug:  Enable additional debugging code to help track down
 	memory management problems.  This allows printing a list of all
 	live objects when the interpreter terminates.
Index: Makefile.pre.in
===================================================================
--- Makefile.pre.in	(Revision 41421)
+++ Makefile.pre.in	(Arbeitskopie)
@@ -30,6 +30,7 @@
 
 CC=		@CC@
 CXX=		@CXX@
+MAINCC=		@MAINCC@
 LINKCC=		@LINKCC@
 AR=		@AR@
 RANLIB=		@RANLIB@
@@ -156,7 +157,6 @@
 SYSLIBS=	$(LIBM) $(LIBC)
 SHLIBS=		@SHLIBS@
 
-MAINOBJ=	@MAINOBJ@
 THREADOBJ=	@THREADOBJ@
 DLINCLDIR=	@DLINCLDIR@
 DYNLOADFILE=	@DYNLOADFILE@
@@ -324,9 +324,9 @@
 all:		$(BUILDPYTHON) oldsharedmods sharedmods
 
 # Build the interpreter
-$(BUILDPYTHON):	Modules/$(MAINOBJ) $(LIBRARY) $(LDLIBRARY)
+$(BUILDPYTHON):	Modules/python.o $(LIBRARY) $(LDLIBRARY)
 		$(LINKCC) $(LDFLAGS) $(LINKFORSHARED) -o $@ \
-			Modules/$(MAINOBJ) \
+			Modules/python.o \
 			$(BLDLIBRARY) $(LIBS) $(MODLIBS) $(SYSLIBS) $(LDLAST)
 
 platform: $(BUILDPYTHON)
@@ -453,8 +453,8 @@
 		-DVPATH='"$(VPATH)"' \
 		-o $@ $(srcdir)/Modules/getpath.c
 
-Modules/ccpython.o: $(srcdir)/Modules/ccpython.cc
-	$(CXX) -c $(PY_CFLAGS) -o $@ $(srcdir)/Modules/ccpython.cc
+Modules/python.o: $(srcdir)/Modules/python.c
+	$(MAINCC) -c $(PY_CFLAGS) -o $@ $(srcdir)/Modules/python.c
 
 
 $(GRAMMAR_H) $(GRAMMAR_C): $(PGEN) $(GRAMMAR_INPUT)
@@ -541,7 +541,7 @@
 		Include/weakrefobject.h \
 		pyconfig.h
 
-$(LIBRARY_OBJS) $(MODOBJS) Modules/$(MAINOBJ): $(PYTHON_HEADERS)
+$(LIBRARY_OBJS) $(MODOBJS) Modules/python.o: $(PYTHON_HEADERS)
 
 
 ######################################################################
@@ -809,7 +809,7 @@
 		fi; \
 	fi
 	$(INSTALL_DATA) Modules/config.c $(DESTDIR)$(LIBPL)/config.c
-	$(INSTALL_DATA) Modules/$(MAINOBJ) $(DESTDIR)$(LIBPL)/$(MAINOBJ)
+	$(INSTALL_DATA) Modules/python.o $(DESTDIR)$(LIBPL)/python.o
 	$(INSTALL_DATA) $(srcdir)/Modules/config.c.in $(DESTDIR)$(LIBPL)/config.c.in
 	$(INSTALL_DATA) Makefile $(DESTDIR)$(LIBPL)/Makefile
 	$(INSTALL_DATA) Modules/Setup $(DESTDIR)$(LIBPL)/Setup

 	  	 
