aboutsummaryrefslogtreecommitdiffstats
path: root/acinclude.m4
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2012-03-16 00:49:01 +0000
committerGuy Harris <guy@alum.mit.edu>2012-03-16 00:49:01 +0000
commitb53e379447636d7f6699b3bfb42140b2ffe44e2a (patch)
treee76518887b866a2fbf6948326804b16d429d166f /acinclude.m4
parent74f884820e808b7bef840ca2f09123747072b018 (diff)
Have AC_WIRESHARK_GCC_CFLAGS_CHECK take an optional second flag to
indicate whether the flag is C-only, C++-only, or for both compilers; pass the appropriate value for C-only flags. Have the "Checking for..." message indicate whether we're adding to CFLAGS, CXXFLAGS, or both. (Yes, the macro should probably be renamed. "GCC" refers to the GNU Compiler Collection, which includes a C++ compiler, although that's also used for compilers that are more-or-less compatible with the ones from the GNU Compiler Collection, such as the clang compilers.) We set -Wformat-security whether or not --enable-extra-gcc-checks was specified, so we don't need to do it again if it was specified. svn path=/trunk/; revision=41586
Diffstat (limited to 'acinclude.m4')
-rw-r--r--acinclude.m490
1 files changed, 74 insertions, 16 deletions
diff --git a/acinclude.m4 b/acinclude.m4
index 7409bd7067..6a11a8b60d 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -1574,6 +1574,7 @@ fi
# AC_WIRESHARK_GCC_CFLAGS_CHECK
#
# $1 : cflags to test
+# $2 : if supplied, C for C-only flags, CXX for C++-only flags
#
# The macro first determines if the compiler supports GCC-style flags.
# Then it attempts to compile with the defined cflags. The defined
@@ -1590,24 +1591,81 @@ fi
#
AC_DEFUN([AC_WIRESHARK_GCC_CFLAGS_CHECK],
[GCC_OPTION="$1"
-AC_MSG_CHECKING(whether we can add $GCC_OPTION to CFLAGS)
+case "$2" in
+C)
+ AC_MSG_CHECKING(whether we can add $GCC_OPTION to CFLAGS)
+ ;;
+
+CXX)
+ AC_MSG_CHECKING(whether we can add $GCC_OPTION to CXXFLAGS)
+ ;;
+
+*)
+ AC_MSG_CHECKING(whether we can add $GCC_OPTION to CFLAGS and CXXFLAGS)
+ ;;
+esac
+
if test "x$ac_supports_gcc_flags" = "xyes" ; then
- CFLAGS_saved="$CFLAGS"
- CFLAGS="$CFLAGS $GCC_OPTION"
- if test "x$CC" = "xclang" ; then
- CFLAGS="$CFLAGS -Werror=unknown-warning-option"
+ if test "$2" != CXX ; then
+ #
+ # Not C++-only; if this can be added to the C compiler flags, add them.
+ #
+ CFLAGS_saved="$CFLAGS"
+ CFLAGS="$CFLAGS $GCC_OPTION"
+ if test "x$CC" = "xclang" ; then
+ #
+ # Force clang to fail on an unknown warning option; by default,
+ # it whines but doesn't fail, so we add unknown options and,
+ # as a result, get a lot of that whining when we compile.
+ #
+ CFLAGS="$CFLAGS -Werror=unknown-warning-option"
+ fi
+ AC_COMPILE_IFELSE([
+ AC_LANG_SOURCE([[
+ int foo;
+ ]])],
+ [
+ AC_MSG_RESULT(yes)
+ #
+ # Remove -Werror=unknown-warning-option, if we
+ # added it, by setting CFLAGS to the saved value
+ # plus just the new option.
+ #
+ CFLAGS="$CFLAGS_saved $GCC_OPTION"
+ if test "$2" != C ; then
+ #
+ # Add it to the C++ flags as well.
+ #
+ CXXFLAGS="$CXXFLAGS $GCC_OPTION"
+ fi
+ ],
+ [
+ AC_MSG_RESULT(no)
+ CFLAGS="$CFLAGS_saved"
+ ])
+ else
+ #
+ # C++-only; if this can be added to the C++ compiler flags, add them.
+ #
+ CXXFLAGS_saved="$CXXFLAGS"
+ CXXFLAGS="$CXXFLAGS $GCC_OPTION"
+ if test "x$CC" = "xclang" ; then
+ CXXFLAGS="$CXXFLAGS -Werror=unknown-warning-option"
+ fi
+ AC_LANG_PUSH([C++])
+ AC_COMPILE_IFELSE([
+ AC_LANG_SOURCE([[
+ int foo;
+ ]])],
+ [
+ AC_MSG_RESULT(yes)
+ ],
+ [
+ AC_MSG_RESULT(no)
+ CXXFLAGS="$CXXFLAGS_saved"
+ ])
+ AC_LANG_POP([C++])
fi
- AC_COMPILE_IFELSE([
- AC_LANG_SOURCE([[
- int foo;
- ]])],
- [
- AC_MSG_RESULT(yes)
- ],
- [
- AC_MSG_RESULT(no)
- CFLAGS="$CFLAGS_saved"
- ])
else
AC_MSG_RESULT(no)
fi