aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastien Tandel <sebastien@tandel.be>2007-04-22 09:27:21 +0000
committerSebastien Tandel <sebastien@tandel.be>2007-04-22 09:27:21 +0000
commit706627f882078eda3937374183766e0a8e3017df (patch)
tree517d1907bb773519676d82bb0b40a60e387d34c9
parent23faf81799bbbf4c68f4d16fe5ef5ad3962f7321 (diff)
adding AC_(WIRESHARK|WIRETAP)_GCC_CFLAGS_OPTION macro to test whether gcc
supports the options passed as arguments. If the options are supported, they are added to CFLAGS. svn path=/trunk/; revision=21493
-rw-r--r--acinclude.m430
-rw-r--r--configure.in72
-rw-r--r--wiretap/acinclude.m431
-rw-r--r--wiretap/configure.in73
4 files changed, 112 insertions, 94 deletions
diff --git a/acinclude.m4 b/acinclude.m4
index fd1d86ac04..127fc77905 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -1503,3 +1503,33 @@ AC_DEFUN([AC_WIRESHARK_KRB5_CHECK],
AC_SUBST(KRB5_LIBS)
])
+#
+# AC_WIRESHARK_GCC_CFLAGS_CHECK
+#
+# $1 : cflags to test
+#
+# The macro first determines if the compiler is GCC. Then compile with the
+# defined cflags. The defined flags are added to CFLAGS only if the compilation
+# succeeds.
+#
+AC_DEFUN([AC_WIRESHARK_GCC_CFLAGS_CHECK],
+[GCC_OPTION="$1"
+AC_MSG_CHECKING(whether we can add $GCC_OPTION to CFLAGS)
+if test "x$GCC" != "x"; then
+ CFLAGS_saved="$CFLAGS"
+ CFLAGS="$CFLAGS $GCC_OPTION"
+ 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
+])
diff --git a/configure.in b/configure.in
index fcf4da6e52..71f65cfa9f 100644
--- a/configure.in
+++ b/configure.in
@@ -148,14 +148,7 @@ AC_WIRESHARK_RPM_CHECK
AC_SUBST(HAVE_RPM)
#
-# If we're running gcc, add '-Wall -Wpointer-arith -W' to CFLAGS, and add
-# '-D_U_="__attribute__((unused))"' as well, so we can use _U_ to
-# flag unused function arguments and not get warnings about them.
-# If "--with-extra-gcc-checks" was specified, add some additional
-# warning checks.
-#
-# Otherwise, add '-D_U_=""', so that _U_ used to flag an unused function
-# argument will compile with non-GCC compilers.
+# Try to add some additional gcc checks to CFLAGS
#
AC_ARG_ENABLE(extra-gcc-checks,
AC_HELP_STRING( [--enable-extra-gcc-checks],
@@ -163,52 +156,37 @@ AC_ARG_ENABLE(extra-gcc-checks,
[
if test $enableval != no
then
- wireshark_extra_gcc_flags=" -Wcast-qual -Wcast-align -Wbad-function-cast -pedantic -Wstrict-prototypes -Wmissing-declarations -Wwrite-strings"
+ AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wcast-qual)
+ AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wcast-align)
+ AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wbad-function-cast)
+ AC_WIRESHARK_GCC_CFLAGS_CHECK(-pedantic)
+ AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wstrict-prototypes)
+ AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wmissing-declarations)
+ AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wwrite-strings)
fi
],)
-AC_MSG_CHECKING(whether we can add '-Wall -Wpointer-arith -W$wireshark_extra_gcc_flags' to CFLAGS)
-if test "x$GCC" = "xyes" ; then
- CFLAGS="-D_U_=\"__attribute__((unused))\" -Wall -Wpointer-arith -W $wireshark_extra_gcc_flags $CFLAGS"
- AC_MSG_RESULT(yes)
-else
- CFLAGS="-D_U_=\"\" $CFLAGS"
- AC_MSG_RESULT(no)
-fi
-
-AC_MSG_CHECKING(whether we can add '-Wdeclaration-after-statement' to CFLAGS)
-if test "x$GCC" = "xyes" ; then
- # some versions of GCC support this directive
- rm -rf conftest*
- echo "int foo;" >>conftest.c
- if $CC -c -o conftest.o conftest.c -Wdeclaration-after-statement > /dev/null 2>&1 ; then
- CFLAGS="$CFLAGS -Wdeclaration-after-statement"
- AC_MSG_RESULT(yes)
- else
- AC_MSG_RESULT(no)
- fi
-else
- # non-gcc compilers do not support this directive
- AC_MSG_RESULT(no)
-fi
-rm -rf conftest*
+AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wall -W)
+AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wpointer-arith)
+AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wdeclaration-after-statement)
+AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wno-pointer-sign)
-AC_MSG_CHECKING(whether we can add '-Wno-pointer-sign' to CFLAGS)
+#
+# If we're running gcc add '-D_U_="__attribute__((unused))"' to CFLAGS as well,
+# so we can use _U_ to flag unused function arguments and not get warnings
+# about them. Otherwise, add '-D_U_=""', so that _U_ used to flag an unused
+# function argument will compile with non-GCC compilers.
+#
if test "x$GCC" = "xyes" ; then
- # some versions of GCC support this directive
- rm -rf conftest*
- echo "int foo;" >>conftest.c
- if $CC -c -o conftest.o conftest.c -Wno-pointer-sign > /dev/null 2>&1 ; then
- CFLAGS="$CFLAGS -Wno-pointer-sign"
- AC_MSG_RESULT(yes)
- else
- AC_MSG_RESULT(no)
- fi
+ CFLAGS="-D_U_=\"__attribute__((unused))\" $CFLAGS"
else
- # non-gcc compilers do not support this directive
- AC_MSG_RESULT(no)
+ CFLAGS="-D_U_=\"\" $CFLAGS"
fi
-rm -rf conftest*
+#
+# If we're running gcc, will enable a barrier "stop on warning".
+# This barrier is set for a very large part of the code. However, it is
+# typically not set for "generated" code (lex, ans2wrs, idl2wrs, ...)
+#
AC_MSG_CHECKING(whether we should treat compiler warnings as errors)
AC_ARG_ENABLE(warnings-as-errors,
AC_HELP_STRING( [--enable-warnings-as-errors],
diff --git a/wiretap/acinclude.m4 b/wiretap/acinclude.m4
index 306caec591..1d3174801d 100644
--- a/wiretap/acinclude.m4
+++ b/wiretap/acinclude.m4
@@ -272,3 +272,34 @@ AC_DEFUN([AC_WIRETAP_CHECK_64BIT_FORMAT],
$2
])
])
+
+#
+# AC_WIRETAP_GCC_CFLAGS_CHECK
+#
+# $1 : cflags to test
+#
+# The macro first determines if the compiler is GCC. Then compile with the
+# defined cflags. The defined flags are added to CFLAGS only if the compilation
+# succeeds.
+#
+AC_DEFUN([AC_WIRETAP_GCC_CFLAGS_CHECK],
+[GCC_OPTION="$1"
+AC_MSG_CHECKING(whether we can add $GCC_OPTION to CFLAGS)
+if test "x$GCC" != "x"; then
+ CFLAGS_saved="$CFLAGS"
+ CFLAGS="$CFLAGS $GCC_OPTION"
+ 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
+])
diff --git a/wiretap/configure.in b/wiretap/configure.in
index 5f140c8721..e7dd32febb 100644
--- a/wiretap/configure.in
+++ b/wiretap/configure.in
@@ -22,15 +22,9 @@ AC_PATH_PROG(LEX, flex)
AC_SUBST(FLEX_PATH)
+
#
-# If we're running gcc, add '-Wall -Wpointer-arith -W' to CFLAGS, and add
-# '-D_U_="__attribute__((unused))"' as well, so we can use _U_ to
-# flag unused function arguments and not get warnings about them.
-# If "--with-extra-gcc-checks" was specified, add some additional
-# warning checks.
-#
-# Otherwise, add '-D_U_=""', so that _U_ used to flag an unused function
-# argument will compile with non-GCC compilers.
+# Try to add some additional gcc checks to CFLAGS
#
AC_ARG_ENABLE(extra-gcc-checks,
AC_HELP_STRING( [--enable-extra-gcc-checks],
@@ -38,52 +32,37 @@ AC_ARG_ENABLE(extra-gcc-checks,
[
if test $enableval != no
then
- wireshark_extra_gcc_flags=" -Wcast-qual -Wcast-align -Wbad-function-cast -pedantic -Wstrict-prototypes -Wmissing-declarations -Wwrite-strings"
+ AC_WIRETAP_GCC_CFLAGS_CHECK(-Wcast-qual)
+ AC_WIRETAP_GCC_CFLAGS_CHECK(-Wcast-align)
+ AC_WIRETAP_GCC_CFLAGS_CHECK(-Wbad-function-cast)
+ AC_WIRETAP_GCC_CFLAGS_CHECK(-pedantic)
+ AC_WIRETAP_GCC_CFLAGS_CHECK(-Wstrict-prototypes)
+ AC_WIRETAP_GCC_CFLAGS_CHECK(-Wmissing-declarations)
+ AC_WIRETAP_GCC_CFLAGS_CHECK(-Wwrite-strings)
fi
],)
-AC_MSG_CHECKING(whether we can add '-Wall -Wpointer-arith -W$wireshark_extra_gcc_flags' to CFLAGS)
-if test "x$GCC" = "xyes" ; then
- CFLAGS="-D_U_=\"__attribute__((unused))\" -Wall -Wpointer-arith -W$wireshark_extra_gcc_flags $CFLAGS"
- AC_MSG_RESULT(yes)
-else
- CFLAGS="-D_U_=\"\" $CFLAGS"
- AC_MSG_RESULT(no)
-fi
+AC_WIRETAP_GCC_CFLAGS_CHECK(-Wall -W)
+AC_WIRETAP_GCC_CFLAGS_CHECK(-Wpointer-arith)
+AC_WIRETAP_GCC_CFLAGS_CHECK(-Wdeclaration-after-statement)
+AC_WIRETAP_GCC_CFLAGS_CHECK(-Wno-pointer-sign)
-AC_MSG_CHECKING(whether we can add '-Wdeclaration-after-statement' to CFLAGS)
-if test "x$GCC" = "xyes" ; then
- # some versions of GCC support this directive
- rm -rf conftest*
- echo "int foo;" >>conftest.c
- if $CC -c -o conftest.o conftest.c -Wdeclaration-after-statement > /dev/null 2>&1 ; then
- CFLAGS="$CFLAGS -Wdeclaration-after-statement"
- AC_MSG_RESULT(yes)
- else
- AC_MSG_RESULT(no)
- fi
-else
- # non-gcc compilers do not support this directive
- AC_MSG_RESULT(no)
-fi
-rm -rf conftest*
-
-AC_MSG_CHECKING(to see if we can add '-Wno-pointer-sign' to CFLAGS)
+#
+# If we're running gcc add '-D_U_="__attribute__((unused))"' to CFLAGS as well,
+# so we can use _U_ to flag unused function arguments and not get warnings
+# about them. Otherwise, add '-D_U_=""', so that _U_ used to flag an unused
+# function argument will compile with non-GCC compilers.
+#
if test "x$GCC" = "xyes" ; then
- # some versions of GCC support this directive
- rm -rf conftest*
- echo "int foo;" >>conftest.c
- if $CC -c -o conftest.o conftest.c -Wno-pointer-sign > /dev/null 2>&1 ; then
- CFLAGS="$CFLAGS -Wno-pointer-sign"
- AC_MSG_RESULT(yes)
- else
- AC_MSG_RESULT(no)
- fi
+ CFLAGS="-D_U_=\"__attribute__((unused))\" $CFLAGS"
else
- # non-gcc compilers do not support this directive
- AC_MSG_RESULT(no)
+ CFLAGS="-D_U_=\"\" $CFLAGS"
fi
-rm -rf conftest*
+#
+# If we're running gcc, will enable a barrier "stop on warning".
+# This barrier is set for a very large part of the code. However, it is
+# typically not set for "generated" code (lex, ans2wrs, idl2wrs, ...)
+#
AC_MSG_CHECKING(whether we should treat compiler warnings as errors)
AC_ARG_ENABLE(warnings-as-errors,
AC_HELP_STRING( [--enable-warnings-as-errors],