aboutsummaryrefslogtreecommitdiff
path: root/gdb/configure.ac
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/configure.ac')
-rw-r--r--gdb/configure.ac39
1 files changed, 35 insertions, 4 deletions
diff --git a/gdb/configure.ac b/gdb/configure.ac
index e72dfba..0898d0e 100644
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -27,6 +27,8 @@ AM_MAINTAINER_MODE
. $srcdir/../bfd/development.sh
AC_PROG_CC
+AC_PROG_CXX
+
AC_USE_SYSTEM_EXTENSIONS
ACX_LARGEFILE
AM_PROG_CC_STDC
@@ -36,6 +38,9 @@ AC_CONFIG_AUX_DIR(..)
AC_CANONICAL_SYSTEM
AC_ARG_PROGRAM
+# See if we are building with C++, and substitute COMPILER.
+GDB_AC_BUILD_WITH_CXX
+
# Dependency checking.
ZW_CREATE_DEPDIR
ZW_PROG_COMPILER_DEPENDENCIES([CC])
@@ -1959,8 +1964,11 @@ AC_ARG_ENABLE(werror,
*) AC_MSG_ERROR(bad value ${enableval} for --enable-werror) ;;
esac])
-# Enable -Werror by default when using gcc. Turn it off for releases.
-if test "${GCC}" = yes -a -z "${ERROR_ON_WARNING}" && $development; then
+# Enable -Werror by default when using gcc in C mode. Leave it off
+# for C++ until we're warning clean. Turn it off for releases.
+if test "${GCC}" = yes -a -z "${ERROR_ON_WARNING}" \
+ && test x"$enable_build_with_cxx" != x"yes" \
+ && $development; then
ERROR_ON_WARNING=yes
fi
@@ -1969,13 +1977,21 @@ if test "${ERROR_ON_WARNING}" = yes ; then
WERROR_CFLAGS="-Werror"
fi
+# These options work in either C or C++ modes.
build_warnings="-Wall -Wdeclaration-after-statement -Wpointer-arith \
--Wpointer-sign \
-Wno-unused -Wunused-value -Wunused-function \
-Wno-switch -Wno-char-subscripts -Wmissing-prototypes \
-Wdeclaration-after-statement -Wempty-body -Wmissing-parameter-type \
-Wold-style-declaration -Wold-style-definition"
+# Now add in C and C++ specific options, depending on mode.
+if test "$enable_build_with_cxx" = "yes"; then
+ build_warnings="$build_warnings -Wno-sign-compare -Wno-write-strings \
+-Wno-narrowing"
+else
+ build_warnings="$build_warnings -Wpointer-sign"
+fi
+
# Enable -Wno-format by default when using gcc on mingw since many
# GCC versions complain about %I64.
case "${host}" in
@@ -2011,6 +2027,13 @@ esac
if test x"$silent" != x"yes" && test x"$build_warnings" != x""; then
echo "Setting GDB specific compiler warning flags = $build_warnings" 6>&1
fi])dnl
+
+# The set of warnings supported by a C++ compiler is not the same as
+# of the C compiler.
+if test "$enable_build_with_cxx" = "yes"; then
+ AC_LANG_PUSH([C++])
+fi
+
WARN_CFLAGS=""
if test "x${build_warnings}" != x -a "x$GCC" = xyes
then
@@ -2020,11 +2043,15 @@ then
for w in ${build_warnings}; do
case $w in
-Werr*) WERROR_CFLAGS=-Werror ;;
- *) # Check that GCC accepts it
+ *)
+ # Check whether GCC accepts it.
saved_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $w"
+ saved_CXXFLAGS="$CXXFLAGS"
+ CXXFLAGS="$CXXFLAGS $w"
AC_TRY_COMPILE([],[],WARN_CFLAGS="${WARN_CFLAGS} $w",)
CFLAGS="$saved_CFLAGS"
+ CXXFLAGS="$saved_CXXFLAGS"
esac
done
AC_MSG_RESULT(${WARN_CFLAGS} ${WERROR_CFLAGS})
@@ -2032,6 +2059,10 @@ fi
AC_SUBST(WARN_CFLAGS)
AC_SUBST(WERROR_CFLAGS)
+if test "$enable_build_with_cxx" = "yes"; then
+ AC_LANG_POP([C++])
+fi
+
# In the Cygwin environment, we need some additional flags.
AC_CACHE_CHECK([for cygwin], gdb_cv_os_cygwin,
[AC_EGREP_CPP(^lose$, [