aboutsummaryrefslogtreecommitdiffstats
path: root/acinclude.m4
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2013-06-28 21:38:51 +0000
committerGuy Harris <guy@alum.mit.edu>2013-06-28 21:38:51 +0000
commit623cca3634c2759c33fc988651d2e9902768f8df (patch)
tree968a8335a85aa4b49e39d8b19a35f47de95c2d67 /acinclude.m4
parentcf647de6a1aa54bfbe0be1c43726d065b436ccac (diff)
When checking whether a given option should be added to the compiler
flags, if the option should be added to the flags for both C and C++, test both the C and C++ compilers and, if the answers are different, print a warning; the user might have (intentionally or unintentionally) selected mismatched compilers, e.g. clang and g++ on OS X. svn path=/trunk/; revision=50219
Diffstat (limited to 'acinclude.m4')
-rw-r--r--acinclude.m444
1 files changed, 16 insertions, 28 deletions
diff --git a/acinclude.m4 b/acinclude.m4
index 3bef361b1b..f66bdd98b5 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -1632,20 +1632,8 @@ AC_DEFUN([AC_WIRESHARK_CHECK_UNKNOWN_WARNING_OPTION_ERROR],
#
AC_DEFUN([AC_WIRESHARK_GCC_CFLAGS_CHECK],
[GCC_OPTION="$1"
-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
-
+can_add_to_cflags=""
+can_add_to_cxxflags=""
if test "x$ac_supports_gcc_flags" = "xyes" ; then
if test "$2" != CXX ; then
#
@@ -1663,6 +1651,7 @@ if test "x$ac_supports_gcc_flags" = "xyes" ; then
# with -Werror or annoying noise for files compiled without it.
# (Yeah, you, clang.)
#
+ AC_MSG_CHECKING(whether we can add $GCC_OPTION to CFLAGS)
CFLAGS_saved="$CFLAGS"
if expr "$GCC_OPTION" : "-W.*" >/dev/null
then
@@ -1677,6 +1666,7 @@ if test "x$ac_supports_gcc_flags" = "xyes" ; then
]])],
[
AC_MSG_RESULT(yes)
+ can_add_to_cflags=yes
#
# OK, do we have a test program? If so, check
# whether it fails with this option and -Werror,
@@ -1703,12 +1693,6 @@ if test "x$ac_supports_gcc_flags" = "xyes" ; then
# build tools.
#
CFLAGS_FOR_BUILD="$CFLAGS_FOR_BUILD $GCC_OPTION"
- if test "$2" != C ; then
- #
- # Add it to the C++ flags as well.
- #
- CXXFLAGS="$CXXFLAGS $GCC_OPTION"
- fi
],
[
AC_MSG_RESULT(yes)
@@ -1726,22 +1710,19 @@ if test "x$ac_supports_gcc_flags" = "xyes" ; then
# build tools.
#
CFLAGS_FOR_BUILD="$CFLAGS_FOR_BUILD $GCC_OPTION"
- if test "$2" != C ; then
- #
- # Add it to the C++ flags as well.
- #
- CXXFLAGS="$CXXFLAGS $GCC_OPTION"
- fi
fi
],
[
AC_MSG_RESULT(no)
+ can_add_to_cflags=no
CFLAGS="$CFLAGS_saved"
])
- else
+ fi
+ if test "$2" != C ; then
#
- # C++-only; if this can be added to the C++ compiler flags, add them.
+ # Not C-only; if this can be added to the C++ compiler flags, add them.
#
+ AC_MSG_CHECKING(whether we can add $GCC_OPTION to CXXFLAGS)
CXXFLAGS_saved="$CXXFLAGS"
if expr "$GCC_OPTION" : "-W.*" >/dev/null
then
@@ -1757,6 +1738,7 @@ if test "x$ac_supports_gcc_flags" = "xyes" ; then
]])],
[
AC_MSG_RESULT(yes)
+ can_add_to_cxxflags=yes
#
# OK, do we have a test program? If so, check
# whether it fails with this option and -Werror,
@@ -1794,10 +1776,16 @@ if test "x$ac_supports_gcc_flags" = "xyes" ; then
],
[
AC_MSG_RESULT(no)
+ can_add_to_cxxflags=no
CXXFLAGS="$CXXFLAGS_saved"
])
AC_LANG_POP([C++])
fi
+ if test "(" "$can_add_to_cflags" = "yes" -a "$can_add_to_cxxflags" = "no" ")" \
+ -o "(" "$can_add_to_cflags" = "no" -a "$can_add_to_cxxflags" = "yes" ")"
+ then
+ AC_MSG_WARN([$CC and $CXX appear to be a mismatched pair])
+ fi
else
AC_MSG_RESULT(no)
fi