diff --git a/.gitattributes b/.gitattributes
index 58ccb763338989cb75b1957b37902277cb56279f..52b9d51d91ba70c9af45200b9c85a07d737014cb 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -317,7 +317,6 @@ testfont binary
 /src/main.c foreign_ident
 /src/main.h foreign_ident
 /src/make_banner.pike foreign_ident
-/src/make_variables.in foreign_ident
 /src/mapping.c foreign_ident
 /src/mapping.h foreign_ident
 /src/mklibpike.pike foreign_ident
diff --git a/src/Makefile.in b/src/Makefile.in
index 0324eea56d5124eb9037ba4fac13f675d3199e76..efe73aab0c92b108ec9ec6d8a1678fd80cf9b57d 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -103,6 +103,7 @@ CFLAGS=$(PREFLAGS) $(OTHERFLAGS)
 SMARTLINK=@SMARTLINK@
 REALCC=@REALCC@
 CC=@CC@
+CXX=@CXX@
 CPP=@CPP@
 GDB=gdb
 
diff --git a/src/configure.in b/src/configure.in
index 60171d44839d7ba1b27baa3c7a9329d0ebc99a7f..f8d6ae77f9cce75283f2b9804443e5c2eed4f67d 100644
--- a/src/configure.in
+++ b/src/configure.in
@@ -931,9 +931,17 @@ fi # force_smartlink_script_only
 CC="$SMARTLINK $REALCC"
 pike_cv_prog_CC="$CC"
 
+# Check if there's a C++ compiler.
+AC_PROG_CXX
+# Strip smartlink from $CXX
+REALCXX="`echo $CXX|sed -e 's/.*smartlink //'`"
+CXX="$SMARTLINK $REALCXX"
+pike_cv_prog_CXX="$CXX"
+
 AC_SUBST(SMARTLINK)
 AC_SUBST(REALCC)
-export REALCC SMARTLINK
+AC_SUBST(REALCXX)
+export REALCC REALCXX SMARTLINK
 
 AC_MSG_CHECKING([for a fallback compiler])
 # Strip smartlink from $FALLBACK_CC
diff --git a/src/make_variables.in b/src/make_variables.in
index 41baa09e79fd8cb9990207d2de92651a10333a14..ec65a40e6788fca25d2d6a73f480fa44b10ccf7f 100644
--- a/src/make_variables.in
+++ b/src/make_variables.in
@@ -1,6 +1,8 @@
 # -*- Makefile -*-
 #
-# $Id: make_variables.in,v 1.30 2008/03/05 21:32:14 grubba Exp $
+# $Id$
+#
+# Start of make_variables.in
 #
 # Note: This template is actually used only for make_variables in the
 # subdirectories; the one created in the build base dir is just an
@@ -21,7 +23,7 @@
 # core configure script (e.g. through "make force_configure" in the
 # top directory).
 @propagated_variables@
-#propagated_variables: CC CPP MOD_LDSHARED AR INSTALL
+#propagated_variables: CC CXX CPP MOD_LDSHARED AR INSTALL
 #propagated_variables: BASE_CFLAGS BASE_CPPFLAGS CCSHARED BASE_LDFLAGS
 #propagated_variables: OPTIMIZE WARN PROFIL
 #propagated_variables: LDSHARED_MODULE_REQS
diff --git a/src/modules/common_module_makefile.in b/src/modules/common_module_makefile.in
index 6832b3a1ccc268036f042290c0c1b5763a1c1b80..27912fc35d1b7a988bb946bcb90ef314f7ac7ba8 100644
--- a/src/modules/common_module_makefile.in
+++ b/src/modules/common_module_makefile.in
@@ -116,7 +116,7 @@ $(MODULE_ARCHIVES) ThisIsAPhonyTargetBlaBlaBla: force
 	  if test x"@noopt_retry@" = xyes ; then \
 	    echo "WARNING: Compiler failure! Trying without optimization!" >&2;\
 	    echo "$(CXX) $(PREFLAGS) $(CFLAGS) -c $< -o $@" >$@.fail ;\
-	    if NO_ULIMIT=yes $(CC) $(PREFLAGS) $(NOOPT_CFLAGS) -c $< -o $@ ; then : ; else \
+	    if NO_ULIMIT=yes $(CXX) $(PREFLAGS) $(NOOPT_CFLAGS) -c $< -o $@ ; then : ; else \
 	      status=$$?; \
 	      echo "Compilation command was:" >&2;\
 	      echo "$(CXX) $(PREFLAGS) $(NOOPT_CFLAGS) -c $< -o $@" >&2 ;\