From 6cc037526e0ce59d63fd772e7af99258becab3a1 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Mon, 6 Feb 2017 15:10:13 -0500 Subject: autotools: move -W flags to configure detection This lets us use the flags with clang, and to add more flags easily. Change-Id: I51bb53ffd5ab6da769cdfb422a2c88442f1ff9ad Reviewed-on: https://chromium-review.googlesource.com/441864 Reviewed-by: Ivan Penkov --- configure | 145 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 131 insertions(+), 14 deletions(-) (limited to 'configure') diff --git a/configure b/configure index 3de6e284..8d92159f 100755 --- a/configure +++ b/configure @@ -648,6 +648,7 @@ ANDROID_HOST_FALSE ANDROID_HOST_TRUE LINUX_HOST_FALSE LINUX_HOST_TRUE +WARN_CXXFLAGS HAVE_CXX11 PTHREAD_CFLAGS PTHREAD_LIBS @@ -655,8 +656,6 @@ PTHREAD_CC ax_pthread_config EGREP GREP -GCC_FALSE -GCC_TRUE RANLIB am__fastdepCXX_FALSE am__fastdepCXX_TRUE @@ -5737,14 +5736,6 @@ else RANLIB="$ac_cv_prog_RANLIB" fi - if test "$GCC" = yes; then - GCC_TRUE= - GCC_FALSE='#' -else - GCC_TRUE='#' - GCC_FALSE= -fi - # let the Makefile know if we're gcc # Check whether --enable-m32 was given. if test "${enable_m32+set}" = set; then : @@ -7254,6 +7245,136 @@ $as_echo "#define HAVE_CXX11 1" >>confdefs.h fi +WARN_CXXFLAGS= +ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C++ compiler accepts -Werror=unknown-warning-option" >&5 +$as_echo_n "checking whether C++ compiler accepts -Werror=unknown-warning-option... " >&6; } +if ${ax_cv_check_cxxflags___Werror_unknown_warning_option+:} false; then : + $as_echo_n "(cached) " >&6 +else + + ax_check_save_flags=$CXXFLAGS + CXXFLAGS="$CXXFLAGS -Werror=unknown-warning-option" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ax_cv_check_cxxflags___Werror_unknown_warning_option=yes +else + ax_cv_check_cxxflags___Werror_unknown_warning_option=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + CXXFLAGS=$ax_check_save_flags +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_check_cxxflags___Werror_unknown_warning_option" >&5 +$as_echo "$ax_cv_check_cxxflags___Werror_unknown_warning_option" >&6; } +if test "x$ax_cv_check_cxxflags___Werror_unknown_warning_option" = xyes; then : + + ax_compiler_flags_test="-Werror=unknown-warning-option" + +else + + ax_compiler_flags_test="" + +fi + + + + + +for flag in -Wmissing-braces -Wnon-virtual-dtor -Woverloaded-virtual -Wreorder -Wsign-compare -Wunused-variable -Wvla ; do + as_CACHEVAR=`$as_echo "ax_cv_check_cxxflags_${ax_compiler_flags_test}_$flag" | $as_tr_sh` +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C++ compiler accepts $flag" >&5 +$as_echo_n "checking whether C++ compiler accepts $flag... " >&6; } +if eval \${$as_CACHEVAR+:} false; then : + $as_echo_n "(cached) " >&6 +else + + ax_check_save_flags=$CXXFLAGS + CXXFLAGS="$CXXFLAGS ${ax_compiler_flags_test} $flag" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + eval "$as_CACHEVAR=yes" +else + eval "$as_CACHEVAR=no" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + CXXFLAGS=$ax_check_save_flags +fi +eval ac_res=\$$as_CACHEVAR + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +if eval test \"x\$"$as_CACHEVAR"\" = x"yes"; then : + +if ${WARN_CXXFLAGS+:} false; then : + + case " $WARN_CXXFLAGS " in #( + *" $flag "*) : + { { $as_echo "$as_me:${as_lineno-$LINENO}: : WARN_CXXFLAGS already contains \$flag"; } >&5 + (: WARN_CXXFLAGS already contains $flag) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } ;; #( + *) : + + as_fn_append WARN_CXXFLAGS " $flag" + { { $as_echo "$as_me:${as_lineno-$LINENO}: : WARN_CXXFLAGS=\"\$WARN_CXXFLAGS\""; } >&5 + (: WARN_CXXFLAGS="$WARN_CXXFLAGS") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } + ;; +esac + +else + + WARN_CXXFLAGS=$flag + { { $as_echo "$as_me:${as_lineno-$LINENO}: : WARN_CXXFLAGS=\"\$WARN_CXXFLAGS\""; } >&5 + (: WARN_CXXFLAGS="$WARN_CXXFLAGS") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } + +fi + +else + : +fi + +done + +as_fn_append WARN_CXXFLAGS " -Werror" +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + # Only build Linux client libs when compiling for Linux case $host in *-*-linux* | *-android* ) @@ -7780,10 +7901,6 @@ if test -z "${am__fastdepCXX_TRUE}" && test -z "${am__fastdepCXX_FALSE}"; then as_fn_error $? "conditional \"am__fastdepCXX\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi -if test -z "${GCC_TRUE}" && test -z "${GCC_FALSE}"; then - as_fn_error $? "conditional \"GCC\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi if test -z "${LINUX_HOST_TRUE}" && test -z "${LINUX_HOST_FALSE}"; then as_fn_error $? "conditional \"LINUX_HOST\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 -- cgit v1.2.1