build: adjust compiler/C11 bits for autoconf 2.70+

`autoconf` finally arrived in the 2010s and tries to do ISO C11.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
This commit is contained in:
David Lamparter 2021-11-11 12:18:44 +01:00
parent 6125c10c29
commit 5b21845971

View file

@ -180,8 +180,6 @@ AM_PROG_CC_C_O
dnl remove autoconf default "-g -O2"
CFLAGS="$orig_cflags"
CXXFLAGS="$orig_cxxflags"
AC_PROG_CC_C99
dnl NB: see C11 below
dnl Some special handling for ICC later on
if test "$CC" = "icc"; then
@ -254,12 +252,24 @@ if test "$cc_is_icc" = "yes"; then
AC_C_FLAG([-diag-error 10006])
fi
dnl AC_PROG_CC_C99 may change CC to include -std=gnu99 or something
ac_cc="$CC"
CC="${CC% -std=gnu99}"
CC="${CC% -std=c99}"
dnl autoconf 2.69 AC_PROG_CC_C99 is "state of the art"
dnl autoconf 2.70 AC_PROG_CC_C99 is deprecated and AC_PROC_CC tries to do C11
m4_if(m4_version_compare(m4_defn([AC_AUTOCONF_VERSION]), [2.70]), [-1], [dnl
dnl autoconf < 2.70
AC_PROG_CC_C99
AC_C_FLAG([-std=gnu11], [CC="$ac_cc"], [CC="$CC -std=gnu11"])
dnl AC_PROG_CC_C99 may change CC to include -std=gnu99 or something
ac_cc="$CC"
CC="${CC% -std=gnu99}"
CC="${CC% -std=c99}"
AC_C_FLAG([-std=gnu11], [CC="$ac_cc"], [CC="$CC -std=gnu11"])
], [
dnl autoconf >= 2.70
if test "$ac_cv_prog_cc_c11" = "no"; then
AC_MSG_ERROR([ISO C11 compiler support (with GNU extensions) is required.])
fi
])
dnl if the user has specified any CFLAGS, override our settings
if test "$enable_gcov" = "yes"; then