use -Wno-unused-but-set-variable only if compiler knows it

since APPLE's clang warns about it on every file.
This commit is contained in:
rofl0r 2017-12-03 14:22:51 +00:00
parent 98c162d198
commit ffc0957d30
4 changed files with 111 additions and 1 deletions

View File

@ -8,7 +8,6 @@ INC=-Ilibwps -I. -Ilwe
DISABLED_WARNINGS= \
-Wno-unused-variable \
-Wno-unused-but-set-variable \
-Wno-unused-function \
-Wno-pointer-sign

41
src/configure vendored
View File

@ -2018,6 +2018,7 @@ ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $
ac_compiler_gnu=$ac_cv_c_compiler_gnu
ac_config_files="$ac_config_files config.mak"
ac_ext=c
@ -3300,6 +3301,46 @@ if test "${enable_savetocurrent+set}" = set; then :
fi
DESIRED_FLAGS="-Wno-unused-but-set-variable"
for flag in $DESIRED_FLAGS; do
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking to see if compiler understands $flag" >&5
$as_echo_n "checking to see if compiler understands $flag... " >&6; }
save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $flag"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
main ()
{
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
flag_ok=yes
else
flag_ok=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
CFLAGS="$save_CFLAGS"
if test "X$flag_ok" = Xyes ; then
CFLAGS="$CFLAGS $flag"
true
else
true
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $flag_ok" >&5
$as_echo "$flag_ok" >&6; }
done
cp confdefs.h config.h
target=$PACKAGE_NAME

View File

@ -1,4 +1,5 @@
AC_INIT(reaver, 1.6.3)
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_FILES([config.mak])
AC_PROG_CC
AC_LANG(C)
@ -15,6 +16,11 @@ AC_HELP_STRING([--enable-savetocurrent],
[saves the current session file to the directory reaver was started from])
, [ CFLAGS="$CFLAGS -DSAVETOCURRENT" ])
DESIRED_FLAGS="-Wno-unused-but-set-variable"
for flag in $DESIRED_FLAGS; do
AS_COMPILER_FLAG([$flag], [CFLAGS="$CFLAGS $flag"])
done
cp confdefs.h config.h
AC_SUBST(target, $PACKAGE_NAME)

View File

@ -0,0 +1,64 @@
dnl as-compiler-flag.m4 0.1.0
dnl autostars m4 macro for detection of compiler flags
dnl David Schleef <ds@schleef.org>
dnl Tim-Philipp Müller <tim centricular net>
dnl AS_COMPILER_FLAG(CFLAGS, ACTION-IF-ACCEPTED, [ACTION-IF-NOT-ACCEPTED])
dnl Tries to compile with the given CFLAGS.
dnl Runs ACTION-IF-ACCEPTED if the compiler can compile with the flags,
dnl and ACTION-IF-NOT-ACCEPTED otherwise.
AC_DEFUN([AS_COMPILER_FLAG],
[
AC_MSG_CHECKING([to see if compiler understands $1])
save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $1"
AC_TRY_COMPILE([ ], [], [flag_ok=yes], [flag_ok=no])
CFLAGS="$save_CFLAGS"
if test "X$flag_ok" = Xyes ; then
$2
true
else
$3
true
fi
AC_MSG_RESULT([$flag_ok])
])
dnl AS_CXX_COMPILER_FLAG(CPPFLAGS, ACTION-IF-ACCEPTED, [ACTION-IF-NOT-ACCEPTED])
dnl Tries to compile with the given CPPFLAGS.
dnl Runs ACTION-IF-ACCEPTED if the compiler can compile with the flags,
dnl and ACTION-IF-NOT-ACCEPTED otherwise.
AC_DEFUN([AS_CXX_COMPILER_FLAG],
[
AC_REQUIRE([AC_PROG_CXX])
AC_MSG_CHECKING([to see if c++ compiler understands $1])
save_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $1"
AC_LANG_PUSH(C++)
AC_TRY_COMPILE([ ], [], [flag_ok=yes], [flag_ok=no])
CPPFLAGS="$save_CPPFLAGS"
if test "X$flag_ok" = Xyes ; then
$2
true
else
$3
true
fi
AC_LANG_POP(C++)
AC_MSG_RESULT([$flag_ok])
])