| AC_PROG_LIBTOOL | AC_PROG_LIBTOOL | ||||
| dnl ================================================================ | dnl ================================================================ | ||||
| dnl C11 compiler checks. | |||||
| dnl C99 compiler checks. | |||||
| dnl ================================================================ | dnl ================================================================ | ||||
| AC_LANG_PUSH(C) | 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_COMPILE_IFELSE( | ||||
| [AC_LANG_PROGRAM( | [AC_LANG_PROGRAM( | ||||
| [[// test]], | |||||
| [[static inline int c99_restrict(int *restrict c99_restrict) {}]], | |||||
| [[]])], | [[]])], | ||||
| [AC_MSG_RESULT([yes]) | [AC_MSG_RESULT([yes]) | ||||
| have_c11_native=yes], | |||||
| have_c99_native=yes], | |||||
| [AC_MSG_RESULT([no]) | [AC_MSG_RESULT([no]) | ||||
| have_c11_native=no]) | |||||
| have_c99_native=no]) | |||||
| AC_LANG_POP(C) | AC_LANG_POP(C) | ||||
| AC_LANG_PUSH(C) | AC_LANG_PUSH(C) | ||||
| TEMP_CFLAGS="$CFLAGS" | 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_COMPILE_IFELSE( | ||||
| [AC_LANG_PROGRAM( | [AC_LANG_PROGRAM( | ||||
| [[// test]], | |||||
| [[static inline int c99_restrict(int *restrict c99_restrict) {}]], | |||||
| [[]])], | [[]])], | ||||
| [AC_MSG_RESULT([yes]) | [AC_MSG_RESULT([yes]) | ||||
| have_c11_c11=yes], | |||||
| have_c99_c99=yes], | |||||
| [AC_MSG_RESULT([no]) | [AC_MSG_RESULT([no]) | ||||
| have_c11_c11=no]) | |||||
| have_c99_c99=no]) | |||||
| CFLAGS="$TEMP_CFLAGS" | CFLAGS="$TEMP_CFLAGS" | ||||
| AC_LANG_POP(C) | 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]) | AC_MSG_RESULT([yes]) | ||||
| else | else | ||||
| AC_MSG_RESULT([no]) | AC_MSG_RESULT([no]) | ||||
| AC_MSG_ERROR([C11 is not supported by $CC.]) | |||||
| AC_MSG_ERROR([C99 is not supported by $CC.]) | |||||
| fi | fi | ||||
| AC_C_INLINE | |||||
| AC_C_RESTRICT | |||||
| dnl ================================================================ | dnl ================================================================ | ||||
| dnl library checks. | dnl library checks. | ||||
| dnl ================================================================ | dnl ================================================================ |