From: Francois-Xavier Le Bail Date: Tue, 17 Jul 2018 21:08:03 +0000 (+0200) Subject: Compile with '-W' in devel mode if supported X-Git-Tag: libpcap-1.10-bp~912 X-Git-Url: https://git.tcpdump.org/libpcap/commitdiff_plain/4c12dde4e3b28d597562ebf416508ba3702c7811 Compile with '-W' in devel mode if supported --- diff --git a/aclocal.m4 b/aclocal.m4 index 32f828fd..bfae2962 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -878,6 +878,7 @@ AC_DEFUN(AC_LBL_DEVEL, # if test "$ac_lbl_cc_dont_try_gcc_dashW" != yes; then AC_LBL_CHECK_UNKNOWN_WARNING_OPTION_ERROR() + AC_LBL_CHECK_COMPILER_OPT($1, -W) AC_LBL_CHECK_COMPILER_OPT($1, -Wall) AC_LBL_CHECK_COMPILER_OPT($1, -Wcomma) AC_LBL_CHECK_COMPILER_OPT($1, -Wdeclaration-after-statement) diff --git a/configure b/configure index 38140717..a63dcf45 100755 --- a/configure +++ b/configure @@ -8534,6 +8534,88 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext CFLAGS="$save_CFLAGS" + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -W option" >&5 +$as_echo_n "checking whether the compiler supports the -W option... " >&6; } + save_CFLAGS="$CFLAGS" + if expr "x-W" : "x-W.*" >/dev/null + then + CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -W" + elif expr "x-W" : "x-f.*" >/dev/null + then + CFLAGS="$CFLAGS -Werror -W" + elif expr "x-W" : "x-m.*" >/dev/null + then + CFLAGS="$CFLAGS -Werror -W" + else + CFLAGS="$CFLAGS -W" + fi + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ +return 0 + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + can_add_to_cflags=yes + # + # The compile supports this; do we have some C code for + # which the warning should *not* appear? + # We test the fourth argument because the third argument + # could contain quotes, breaking the test. + # + if test "x" != "x" + then + CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors" + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -W " >&5 +$as_echo_n "checking whether -W ... " >&6; } + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + + # + # Not a problem. + # + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +else + + # + # A problem. + # + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + can_add_to_cflags=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + fi + CFLAGS="$save_CFLAGS" + if test x"$can_add_to_cflags" = "xyes" + then + V_CCOPT="$V_CCOPT -W" + fi + +else + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + CFLAGS="$save_CFLAGS" + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wall option" >&5 $as_echo_n "checking whether the compiler supports the -Wall option... " >&6; } save_CFLAGS="$CFLAGS"