Commit 05591c3c authored by Eddie Kohler's avatar Eddie Kohler

Configury: Detect C++11 features and -W -Wall compatibility better.

Clang takes -W -Wall, and needs -Werror to refuse rvalue references.
parent 0fb6e64d
......@@ -4712,8 +4712,65 @@ done
DEPCFLAGS="-MD -MP"
save_cflags="$CFLAGS"
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler accepts -W -Wall" >&5
$as_echo_n "checking whether the C compiler accepts -W -Wall... " >&6; }
if ${ac_cv_c_w_wall+:} false; then :
$as_echo_n "(cached) " >&6
else
CFLAGS="$CFLAGS -W -Wall"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int f(int x) { return x; }
int
main ()
{
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
ac_cv_c_w_wall=yes
else
ac_cv_c_w_wall=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_w_wall" >&5
$as_echo "$ac_cv_c_w_wall" >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler accepts -Werror" >&5
$as_echo_n "checking whether the C compiler accepts -Werror... " >&6; }
if ${ac_cv_c_werror+:} false; then :
$as_echo_n "(cached) " >&6
else
CFLAGS="$CFLAGS -Werror"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int f(int x) { return x; }
int
main ()
{
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
ac_cv_c_werror=yes
else
ac_cv_c_werror=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_werror" >&5
$as_echo "$ac_cv_c_werror" >&6; }
CFLAGS="$save_cflags"
WARNING_CFLAGS=
test -n "$GCC" -a -n "$ac_compile_with_warnings" && \
test -n "$ac_cv_c_w_wall" -a -n "$ac_compile_with_warnings" && \
WARNING_CFLAGS=" -W -Wall"
test -z "$ac_user_cflags" && \
......@@ -5284,6 +5341,9 @@ $as_echo "#define HAVE_NEW_H 1" >>confdefs.h
fi
fi
save_cxxflags="$CXXFLAGS"
test -n "$ac_cv_c_w_wall" && CXXFLAGS="$CXXFLAGS -W -Wall"
test -n "$ac_cv_c_werror" && CXXFLAGS="$CXXFLAGS -Werror"
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C++ compiler understands constexpr" >&5
$as_echo_n "checking whether the C++ compiler understands constexpr... " >&6; }
......@@ -5419,7 +5479,6 @@ if ${ac_cv_cxx_pragma_interface+:} false; then :
$as_echo_n "(cached) " >&6
else
save_cxxflags="$CXXFLAGS"; CXXFLAGS="$CXXFLAGS -Werror -Wall -W"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#pragma interface "foo.c"
......@@ -5438,8 +5497,6 @@ else
ac_cv_cxx_pragma_interface=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
CXXFLAGS="$save_cxxflags"
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cxx_pragma_interface" >&5
$as_echo "$ac_cv_cxx_pragma_interface" >&6; }
......@@ -5449,6 +5506,8 @@ $as_echo "#define HAVE_CXX_PRAGMA_INTERFACE 1" >>confdefs.h
fi
CXXFLAGS="$save_cxxflags"
ac_base_cxx="$CXX"
ac_base_cxxflags="$CXXFLAGS"
......@@ -7458,7 +7517,7 @@ else
ac_cv_endian=0
cat > conftest.$ac_ext <<EOF
#line 7461 "configure"
#line 7520 "configure"
#include "confdefs.h"
#include <$endian_hdr>
#ifdef __BYTE_ORDER
......
......@@ -51,8 +51,19 @@ AC_DEFUN([CLICK_PROG_CC], [
DEPCFLAGS="-MD -MP"
AC_SUBST(DEPCFLAGS)
save_cflags="$CFLAGS"
AC_CACHE_CHECK([whether the C compiler accepts -W -Wall], [ac_cv_c_w_wall], [
CFLAGS="$CFLAGS -W -Wall"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[int f(int x) { return x; }]], [[]])],
[ac_cv_c_w_wall=yes], [ac_cv_c_w_wall=no])])
AC_CACHE_CHECK([whether the C compiler accepts -Werror], [ac_cv_c_werror], [
CFLAGS="$CFLAGS -Werror"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[int f(int x) { return x; }]], [[]])],
[ac_cv_c_werror=yes], [ac_cv_c_werror=no])])
CFLAGS="$save_cflags"
WARNING_CFLAGS=
test -n "$GCC" -a -n "$ac_compile_with_warnings" && \
test -n "$ac_cv_c_w_wall" -a -n "$ac_compile_with_warnings" && \
WARNING_CFLAGS=" -W -Wall"
test -z "$ac_user_cflags" && \
......@@ -114,6 +125,9 @@ and Linux header files are GCC-specific.)
fi
dnl check for C++11 features
save_cxxflags="$CXXFLAGS"
test -n "$ac_cv_c_w_wall" && CXXFLAGS="$CXXFLAGS -W -Wall"
test -n "$ac_cv_c_werror" && CXXFLAGS="$CXXFLAGS -Werror"
AC_CACHE_CHECK([whether the C++ compiler understands constexpr], [ac_cv_cxx_constexpr], [
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[constexpr int f(int x) { return x + 1; }]], [[]])],
......@@ -144,15 +158,14 @@ and Linux header files are GCC-specific.)
fi
AC_CACHE_CHECK([[whether the C++ compiler understands #pragma interface]], [ac_cv_cxx_pragma_interface], [
save_cxxflags="$CXXFLAGS"; CXXFLAGS="$CXXFLAGS -Werror -Wall -W"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#pragma interface "foo.c"
#pragma implementation "foo.c"]], [[]])], [ac_cv_cxx_pragma_interface=yes], [ac_cv_cxx_pragma_interface=no])
CXXFLAGS="$save_cxxflags"
])
#pragma implementation "foo.c"]], [[]])], [ac_cv_cxx_pragma_interface=yes], [ac_cv_cxx_pragma_interface=no])])
if test "$ac_cv_cxx_pragma_interface" = yes; then
AC_DEFINE([HAVE_CXX_PRAGMA_INTERFACE], [1], [Define if the C++ compiler understands #pragma interface.])
fi
CXXFLAGS="$save_cxxflags"
dnl define correct warning options
ac_base_cxx="$CXX"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment