summaryrefslogtreecommitdiff
path: root/acinclude.m4
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2015-11-26 11:26:13 +0100
committerAnders Broman <a.broman58@gmail.com>2015-11-27 08:56:56 +0000
commit20bfc3d5a9a44132e5cd1ffc3d9364dba7824574 (patch)
treeeb16997cd54eb659bc68ad6b376151147ab7bbd3 /acinclude.m4
parentc986188daed7cf1acf754243b7eebe80ee430bda (diff)
downloadwireshark-20bfc3d5a9a44132e5cd1ffc3d9364dba7824574.tar.gz
autotools: do not apply CFLAGS in reverse order
Fixes false "-Wvariadic-macros" because "-Wpedantic" came after "-Wno-variadic-macros". While at it, avoid (unintentionally?) adding -fPIE to all C++ programs (via CXXFLAGS). Availability of flags is checked by appending a flag (in case the user has something like CFLAGS=-Wno-error). This removes a -fPIE check for CXXFLAGS and removes 5 -Woverlength-strings and 9 -Wvariadic-macros warnings from make with Clang 3.7.0. configure and compile times were equal. (A diff between the configure outputs showed no other changes.) This reverts commit cf0d762d7304aa569ea25faf999c74bbe94f9023 and applies a different approach. Ping-Bug: 10791 Change-Id: Ic7b4137e2d98b06bc7625091be9bc7dd69182586 Reviewed-on: https://code.wireshark.org/review/12175 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com> (cherry picked from commit 470c745a7a0a5b930bdfb0edd8874436cb9beea0) Reviewed-on: https://code.wireshark.org/review/12186 Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'acinclude.m4')
-rw-r--r--acinclude.m442
1 files changed, 22 insertions, 20 deletions
diff --git a/acinclude.m4 b/acinclude.m4
index 83b7ca45d1..9c3ad2352c 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -1613,7 +1613,9 @@ AC_DEFUN([AC_WIRESHARK_CHECK_NON_CXX_WARNING_OPTION_ERROR],
#
# The macro first determines if the compiler supports GCC-style flags.
# Then it attempts to compile with the defined cflags. The defined
-# flags are added to CFLAGS only if the compilation succeeds.
+# flags are added to WS_CHECKED_CFLAGS only if the compilation succeeds.
+# CFLAGS remains unchanged. can_add_to_cflags is set to "no" when the
+# flag is checked but unavailable. (Like-wise for CXXFLAGS.)
#
# We do this because not all such options are necessarily supported by
# the version of the particular compiler we're using.
@@ -1641,17 +1643,18 @@ if test "x$ac_supports_gcc_flags" = "xyes" ; then
#
AC_MSG_CHECKING(whether we can add $GCC_OPTION to CFLAGS)
CFLAGS_saved="$CFLAGS"
+ CFLAGS="$WS_CHECKED_CFLAGS $CFLAGS"
if expr "x$GCC_OPTION" : "x-W.*" >/dev/null
then
- CFLAGS="$ac_wireshark_unknown_warning_option_error $GCC_OPTION $CFLAGS"
+ CFLAGS="$CFLAGS $ac_wireshark_unknown_warning_option_error $GCC_OPTION"
elif expr "x$GCC_OPTION" : "x-f.*" >/dev/null
then
- CFLAGS="-Werror $GCC_OPTION $CFLAGS"
+ CFLAGS="$CFLAGS -Werror $GCC_OPTION"
elif expr "x$GCC_OPTION" : "x-m.*" >/dev/null
then
- CFLAGS="-Werror $GCC_OPTION $CFLAGS"
+ CFLAGS="$CFLAGS -Werror $GCC_OPTION"
else
- CFLAGS="$GCC_OPTION $CFLAGS"
+ CFLAGS="$CFLAGS $GCC_OPTION"
fi
AC_COMPILE_IFELSE(
[
@@ -1672,7 +1675,7 @@ if test "x$ac_supports_gcc_flags" = "xyes" ; then
CFLAGS="$CFLAGS -Werror"
AC_MSG_CHECKING(whether $GCC_OPTION $4)
AC_COMPILE_IFELSE(
- [AC_LANG_SOURCE($3)],
+ [AC_LANG_SOURCE($3)],
[
AC_MSG_RESULT(no)
#
@@ -1680,19 +1683,18 @@ if test "x$ac_supports_gcc_flags" = "xyes" ; then
# added them, by setting CFLAGS to the saved value plus
# just the new option.
#
- CFLAGS="$GCC_OPTION $CFLAGS_saved"
+ WS_CHECKED_CFLAGS="$WS_CHECKED_CFLAGS $GCC_OPTION"
if test "$CC" = "$CC_FOR_BUILD"; then
#
# We're building the build tools with the same compiler
# with which we're building Wireshark, so add the flags
# to the flags for that compiler as well.
#
- CFLAGS_FOR_BUILD="$GCC_OPTION $CFLAGS_FOR_BUILD"
+ CFLAGS_FOR_BUILD="$CFLAGS_FOR_BUILD $GCC_OPTION"
fi
],
[
AC_MSG_RESULT(yes)
- CFLAGS="$CFLAGS_saved"
])
else
#
@@ -1700,22 +1702,22 @@ if test "x$ac_supports_gcc_flags" = "xyes" ; then
# added them, by setting CFLAGS to the saved value plus
# just the new option.
#
- CFLAGS="$GCC_OPTION $CFLAGS_saved"
+ WS_CHECKED_CFLAGS="$WS_CHECKED_CFLAGS $GCC_OPTION"
if test "$CC" = "$CC_FOR_BUILD"; then
#
# We're building the build tools with the same compiler
# with which we're building Wireshark, so add the flags
# to the flags for that compiler as well.
#
- CFLAGS_FOR_BUILD="$GCC_OPTION $CFLAGS_FOR_BUILD"
+ CFLAGS_FOR_BUILD="$CFLAGS_FOR_BUILD $GCC_OPTION"
fi
fi
],
[
AC_MSG_RESULT(no)
can_add_to_cflags=no
- CFLAGS="$CFLAGS_saved"
])
+ CFLAGS="$CFLAGS_saved"
fi
#
# Did we find a C++ compiler?
@@ -1747,17 +1749,18 @@ if test "x$ac_supports_gcc_flags" = "xyes" ; then
#
AC_MSG_CHECKING(whether we can add $GCC_OPTION to CXXFLAGS)
CXXFLAGS_saved="$CXXFLAGS"
+ CXXFLAGS="$WS_CHECKED_CXXFLAGS $CXXFLAGS"
if expr "x$GCC_OPTION" : "x-W.*" >/dev/null
then
- CXXFLAGS="$ac_wireshark_unknown_warning_option_error $ac_wireshark_non_cxx_warning_option_error $GCC_OPTION $CXXFLAGS"
+ CXXFLAGS="$CXXFLAGS $ac_wireshark_unknown_warning_option_error $ac_wireshark_non_cxx_warning_option_error $GCC_OPTION"
elif expr "x$GCC_OPTION" : "x-f.*" >/dev/null
then
- CXXFLAGS="-Werror $GCC_OPTION $CXXFLAGS"
+ CXXFLAGS="$CXXFLAGS -Werror $GCC_OPTION"
elif expr "x$GCC_OPTION" : "x-m.*" >/dev/null
then
- CXXFLAGS="-Werror $GCC_OPTION $CXXFLAGS"
+ CXXFLAGS="$CXXFLAGS -Werror $GCC_OPTION"
else
- CXXFLAGS="$GCC_OPTION $CXXFLAGS"
+ CXXFLAGS="$CXXFLAGS $GCC_OPTION"
fi
AC_LANG_PUSH([C++])
AC_COMPILE_IFELSE(
@@ -1787,11 +1790,10 @@ if test "x$ac_supports_gcc_flags" = "xyes" ; then
# added them, by setting CXXFLAGS to the saved value plus
# just the new option.
#
- CXXFLAGS="$GCC_OPTION $CXXFLAGS_saved"
+ WS_CHECKED_CXXFLAGS="$WS_CHECKED_CXXFLAGS $GCC_OPTION"
],
[
AC_MSG_RESULT(yes)
- CXXFLAGS="$CXXFLAGS_saved"
])
else
#
@@ -1799,14 +1801,14 @@ if test "x$ac_supports_gcc_flags" = "xyes" ; then
# added them, by setting CXXFLAGS to the saved value plus
# just the new option.
#
- CXXFLAGS="$GCC_OPTION $CXXFLAGS_saved"
+ WS_CHECKED_CXXFLAGS="$WS_CHECKED_CXXFLAGS $GCC_OPTION"
fi
],
[
AC_MSG_RESULT(no)
can_add_to_cxxflags=no
- CXXFLAGS="$CXXFLAGS_saved"
])
+ CXXFLAGS="$CXXFLAGS_saved"
AC_LANG_POP([C++])
fi
if test "(" "$can_add_to_cflags" = "yes" -a "$can_add_to_cxxflags" = "no" ")" \