summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Smith <psmith@gnu.org>2023-02-05 10:22:13 -0500
committerPaul Smith <psmith@gnu.org>2023-02-05 10:22:13 -0500
commitffa28f3914ff402b3915f75e4fed86ac6fb1449d (patch)
tree18be9779b3dc4cf14f5af89c07c0d471429ab5e9
parent8f03e69af009253d919a866110a28d78c61c3c26 (diff)
downloadmake-git-ffa28f3914ff402b3915f75e4fed86ac6fb1449d.tar.gz
[SV 63668] Use autoconf to detect the default C++ compiler
* configure.ac: Add AC_PROG_CXX to search for a C++ compiler. (MAKE_CXX): Add the discovered compiler to config.h. * src/default.c (default_variables): Use MAKE_CXX as the C++ compiler.
-rw-r--r--configure.ac2
-rw-r--r--src/default.c20
2 files changed, 15 insertions, 7 deletions
diff --git a/configure.ac b/configure.ac
index 67793e6e..8326c010 100644
--- a/configure.ac
+++ b/configure.ac
@@ -37,6 +37,8 @@ AM_INIT_AUTOMAKE([1.16.1 foreign -Werror -Wall])
# Checks for programs.
AC_USE_SYSTEM_EXTENSIONS
AC_PROG_CC
+AC_PROG_CXX
+AC_DEFINE_UNQUOTED(MAKE_CXX, ["$CXX"], [Default C++ compiler.])
# Configure gnulib
gl_EARLY
diff --git a/src/default.c b/src/default.c
index 1082b41d..ffb5f98c 100644
--- a/src/default.c
+++ b/src/default.c
@@ -527,18 +527,24 @@ static const char *default_variables[] =
"AS", "as",
#ifdef GCC_IS_NATIVE
"CC", "gcc",
-# ifdef __MSDOS__
- "CXX", "gpp", /* g++ is an invalid name on MSDOS */
-# else
- "CXX", "gcc",
-# endif /* __MSDOS__ */
"OBJC", "gcc",
#else
"CC", "cc",
- "CXX", "g++",
"OBJC", "cc",
#endif
-
+#ifdef MAKE_CXX
+ "CXX", MAKE_CXX,
+#else
+# ifdef GCC_IS_NATIVE
+# ifdef __MSDOS__
+ "CXX", "gpp", /* g++ is an invalid name on MSDOS */
+# else
+ "CXX", "gcc",
+# endif /* __MSDOS__ */
+# else
+ "CXX", "g++",
+# endif
+#endif
/* This expands to $(CO) $(COFLAGS) $< $@ if $@ does not exist,
and to the empty string if $@ does exist. */
"CHECKOUT,v", "+$(if $(wildcard $@),,$(CO) $(COFLAGS) $< $@)",