buildsys: sync `ax_check_compile_flag.m4` with autoconf archive

Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
This commit is contained in:
Yury V. Zaytsev 2024-10-18 21:05:37 +02:00
parent b8e2a376e3
commit fc96f96c6a
1 changed files with 13 additions and 8 deletions

View File

@ -34,19 +34,24 @@
# and this notice are preserved. This file is offered as-is, without any
# warranty.
# Yury Zaytsev:
# Toggle Werror since at some point clang started treating unknown -W
# flags as warnings, succeeding with the build, yet issuing an annoying
# warning.
#serial 6
#serial 11
AC_DEFUN([AX_CHECK_COMPILE_FLAG],
[AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF
AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl
AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [
AC_CACHE_CHECK([whether the _AC_LANG compiler accepts $1], CACHEVAR, [
ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS
_AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1 -Werror"
if test x"m4_case(_AC_LANG,
[C], [$GCC],
[C++], [$GXX],
[Fortran], [$GFC],
[Fortran 77], [$G77],
[Objective C], [$GOBJC],
[Objective C++], [$GOBJCXX],
[no])" = xyes ; then
add_gnu_werror="-Werror"
fi
_AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1 $add_gnu_werror"
AC_COMPILE_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])],
[AS_VAR_SET(CACHEVAR,[yes])],
[AS_VAR_SET(CACHEVAR,[no])])