Browse Source

Require a C99 compiler, not a C11 compiler and improve the C99 detection logic.

master
Reece H. Dunn 9 years ago
parent
commit
a63caac1ed
1 changed files with 16 additions and 19 deletions
  1. 16
    19
      configure.ac

+ 16
- 19
configure.ac View File

@@ -19,50 +19,47 @@ AC_PROG_MAKE_SET
AC_PROG_LIBTOOL

dnl ================================================================
dnl C11 compiler checks.
dnl C99 compiler checks.
dnl ================================================================

AC_LANG_PUSH(C)
AC_MSG_CHECKING([if $CC supports C11 without any flags])
AC_MSG_CHECKING([if $CC supports C99 without any flags])
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM(
[[// test]],
[[static inline int c99_restrict(int *restrict c99_restrict) {}]],
[[]])],
[AC_MSG_RESULT([yes])
have_c11_native=yes],
have_c99_native=yes],
[AC_MSG_RESULT([no])
have_c11_native=no])
have_c99_native=no])
AC_LANG_POP(C)

AC_LANG_PUSH(C)
TEMP_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -std=c11"
AC_MSG_CHECKING([if $CC supports C11 with the -std=c11 flag])
CFLAGS="$CFLAGS -std=c99"
AC_MSG_CHECKING([if $CC supports C99 with the -std=c99 flag])
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM(
[[// test]],
[[static inline int c99_restrict(int *restrict c99_restrict) {}]],
[[]])],
[AC_MSG_RESULT([yes])
have_c11_c11=yes],
have_c99_c99=yes],
[AC_MSG_RESULT([no])
have_c11_c11=no])
have_c99_c99=no])
CFLAGS="$TEMP_CFLAGS"
AC_LANG_POP(C)

AC_MSG_CHECKING([if $CC supports C11])
if test "$have_c11_c11" = yes ; then
AC_MSG_RESULT([-std=c11])
CFLAGS="$CFLAGS -std=c11"
elif test "$have_c11_native" = yes ; then
AC_MSG_CHECKING([if $CC supports C99])
if test "$have_c99_c99" = yes ; then
AC_MSG_RESULT([-std=c99])
CFLAGS="$CFLAGS -std=c99"
elif test "$have_c99_native" = yes ; then
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
AC_MSG_ERROR([C11 is not supported by $CC.])
AC_MSG_ERROR([C99 is not supported by $CC.])
fi

AC_C_INLINE
AC_C_RESTRICT

dnl ================================================================
dnl library checks.
dnl ================================================================

Loading…
Cancel
Save