Set GNU warning options in CFLAGS and CXXFLAGS separately, avoiding options
authorKen Raeburn <raeburn@mit.edu>
Wed, 31 Oct 2007 11:37:57 +0000 (11:37 +0000)
committerKen Raeburn <raeburn@mit.edu>
Wed, 31 Oct 2007 11:37:57 +0000 (11:37 +0000)
in CXXFLAGS that G++ doesn't support.

git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@20159 dc483132-0cff-0310-8789-dd5450dbe970

src/aclocal.m4
src/configure.in

index 7d7d2120fe0f0df68063197738d5e4282b6266cb..10803cc544cf420473220e7b902dab9562cf59ed 100644 (file)
@@ -588,12 +588,15 @@ dnl
 dnl
 AC_DEFUN(KRB5_AC_CHECK_FOR_CFLAGS,[
 AC_BEFORE([$0],[AC_PROG_CC])
+AC_BEFORE([$0],[AC_PROG_CXX])
 krb5_ac_cflags_set=${CFLAGS+set}
+krb5_ac_cxxflags_set=${CXXFLAGS+set}
 ])
 dnl
 AC_DEFUN(WITH_CC,[dnl
 AC_REQUIRE([KRB5_AC_CHECK_FOR_CFLAGS])dnl
 AC_REQUIRE([AC_PROG_CC])dnl
+AC_REQUIRE([AC_PROG_CXX])dnl
 if test $ac_cv_c_compiler_gnu = yes ; then
      HAVE_GCC=yes
      else HAVE_GCC=
@@ -609,14 +612,14 @@ if test "$GCC" = yes; then
 fi])
 # maybe add -Waggregate-return, or can we assume that actually works by now?
 # -Wno-long-long, if needed, for k5-platform.h without inttypes.h etc.
-extra_gcc_warn_opts="-Wall -Wmissing-prototypes -Wcast-qual \
- -Wcast-align -Wconversion -Wshadow"
+extra_gcc_warn_opts="-Wall -Wcast-qual -Wcast-align -Wconversion -Wshadow"
+# -Wmissing-prototypes
 if test "$GCC" = yes ; then
   if test "x$krb5_ac_cflags_set" = xset ; then
     AC_MSG_NOTICE(not adding extra gcc warning flags because CFLAGS was set)
   else
     AC_MSG_NOTICE(adding extra warning flags for gcc)
-    CFLAGS="$CFLAGS $extra_gcc_warn_opts"
+    CFLAGS="$CFLAGS $extra_gcc_warn_opts -Wmissing-prototypes"
     if test "`uname -s`" = Darwin ; then
       AC_MSG_NOTICE(skipping pedantic warnings on Darwin)
     elif test "`uname -s`" = Linux ; then
@@ -624,6 +627,16 @@ if test "$GCC" = yes ; then
     else
       CFLAGS="$CFLAGS -pedantic"
     fi
+    if test "$ac_cv_cxx_compiler_gnu" = yes; then
+      if test "x$krb5_ac_cxxflags_set" = xset ; then
+        AC_MSG_NOTICE(not adding extra g++ warnings because CXXFLAGS was sent)
+      else
+        AC_MSG_NOTICE(adding extra warning flags for g++)
+        CXXFLAGS="$CXXFLAGS $extra_gcc_warn_opts"
+      fi
+    fi
+    # Currently, G++ does not support -Wno-format-zero-length.
+    # So only add it to CFLAGS.
     AC_CACHE_CHECK([if GCC supports -Wno-format-zero-length],
                   krb5_cv_gcc_Wno_format_zero_length,
     [# first try without, then with
index f1f415e20521d009f2f3c817d30bcebeb0188883..d010d03883cdf83fdd5216fe76639091354a8406 100644 (file)
@@ -1057,8 +1057,6 @@ AC_SUBST(ldap_plugin_dir)
 
 AC_CHECK_HEADERS(Python.h python2.3/Python.h)
 
-AC_PROG_CXX
-
 dnl
 dnl Kludge for simple server --- FIXME is this the best way to do this?
 dnl