diff options
Diffstat (limited to 'gl/m4/00gnulib.m4')
| -rw-r--r-- | gl/m4/00gnulib.m4 | 91 |
1 files changed, 73 insertions, 18 deletions
diff --git a/gl/m4/00gnulib.m4 b/gl/m4/00gnulib.m4 index d4ad759f..7fe03e0b 100644 --- a/gl/m4/00gnulib.m4 +++ b/gl/m4/00gnulib.m4 | |||
| @@ -1,27 +1,82 @@ | |||
| 1 | # 00gnulib.m4 serial 2 | 1 | # 00gnulib.m4 serial 8 |
| 2 | dnl Copyright (C) 2009-2013 Free Software Foundation, Inc. | 2 | dnl Copyright (C) 2009-2023 Free Software Foundation, Inc. |
| 3 | dnl This file is free software; the Free Software Foundation | 3 | dnl This file is free software; the Free Software Foundation |
| 4 | dnl gives unlimited permission to copy and/or distribute it, | 4 | dnl gives unlimited permission to copy and/or distribute it, |
| 5 | dnl with or without modifications, as long as this notice is preserved. | 5 | dnl with or without modifications, as long as this notice is preserved. |
| 6 | 6 | ||
| 7 | dnl This file must be named something that sorts before all other | 7 | dnl This file must be named something that sorts before all other |
| 8 | dnl gnulib-provided .m4 files. It is needed until such time as we can | 8 | dnl gnulib-provided .m4 files. It is needed until the clang fix has |
| 9 | dnl assume Autoconf 2.64, with its improved AC_DEFUN_ONCE semantics. | 9 | dnl been included in Autoconf. |
| 10 | 10 | ||
| 11 | # AC_DEFUN_ONCE([NAME], VALUE) | 11 | # The following definitions arrange to use a compiler option |
| 12 | # ---------------------------- | 12 | # -Werror=implicit-function-declaration in AC_CHECK_DECL, when the |
| 13 | # Define NAME to expand to VALUE on the first use (whether by direct | 13 | # compiler is clang. Without it, clang implicitly declares "known" |
| 14 | # expansion, or by AC_REQUIRE), and to nothing on all subsequent uses. | 14 | # library functions in C mode, but not in C++ mode, which would cause |
| 15 | # Avoid bugs in AC_REQUIRE in Autoconf 2.63 and earlier. This | 15 | # Gnulib to omit a declaration and thus later produce an error in C++ |
| 16 | # definition is slower than the version in Autoconf 2.64, because it | 16 | # mode. As of clang 9.0, these "known" functions are identified through |
| 17 | # can only use interfaces that existed since 2.59; but it achieves the | 17 | # LIBBUILTIN invocations in the LLVM source file |
| 18 | # same effect. Quoting is necessary to avoid confusing Automake. | 18 | # llvm/tools/clang/include/clang/Basic/Builtins.def. |
| 19 | m4_version_prereq([2.63.263], [], | 19 | # It's not possible to AC_REQUIRE the extra tests from AC_CHECK_DECL, |
| 20 | [m4_define([AC][_DEFUN_ONCE], | 20 | # because AC_CHECK_DECL, like other Autoconf built-ins, is not supposed |
| 21 | [AC][_DEFUN([$1], | 21 | # to AC_REQUIRE anything: some configure.ac files have their first |
| 22 | [AC_REQUIRE([_gl_DEFUN_ONCE([$1])], | 22 | # AC_CHECK_DECL executed conditionally. Therefore append the extra tests |
| 23 | [m4_indir([_gl_DEFUN_ONCE([$1])])])])]dnl | 23 | # to AC_PROG_CC. |
| 24 | [AC][_DEFUN([_gl_DEFUN_ONCE([$1])], [$2])])]) | 24 | AC_DEFUN([gl_COMPILER_CLANG], |
| 25 | [ | ||
| 26 | dnl AC_REQUIRE([AC_PROG_CC]) | ||
| 27 | AC_CACHE_CHECK([whether the compiler is clang], | ||
| 28 | [gl_cv_compiler_clang], | ||
| 29 | [dnl Use _AC_COMPILE_IFELSE instead of AC_EGREP_CPP, to avoid error | ||
| 30 | dnl "circular dependency of AC_LANG_COMPILER(C)" if AC_PROG_CC has | ||
| 31 | dnl not yet been invoked. | ||
| 32 | _AC_COMPILE_IFELSE( | ||
| 33 | [AC_LANG_PROGRAM([[ | ||
| 34 | #ifdef __clang__ | ||
| 35 | barfbarf | ||
| 36 | #endif | ||
| 37 | ]],[[]]) | ||
| 38 | ], | ||
| 39 | [gl_cv_compiler_clang=no], | ||
| 40 | [gl_cv_compiler_clang=yes]) | ||
| 41 | ]) | ||
| 42 | ]) | ||
| 43 | AC_DEFUN([gl_COMPILER_PREPARE_CHECK_DECL], | ||
| 44 | [ | ||
| 45 | dnl AC_REQUIRE([AC_PROG_CC]) | ||
| 46 | dnl AC_REQUIRE([gl_COMPILER_CLANG]) | ||
| 47 | AC_CACHE_CHECK([for compiler option needed when checking for declarations], | ||
| 48 | [gl_cv_compiler_check_decl_option], | ||
| 49 | [if test $gl_cv_compiler_clang = yes; then | ||
| 50 | dnl Test whether the compiler supports the option | ||
| 51 | dnl '-Werror=implicit-function-declaration'. | ||
| 52 | save_ac_compile="$ac_compile" | ||
| 53 | ac_compile="$ac_compile -Werror=implicit-function-declaration" | ||
| 54 | dnl Use _AC_COMPILE_IFELSE instead of AC_COMPILE_IFELSE, to avoid a | ||
| 55 | dnl warning "AC_COMPILE_IFELSE was called before AC_USE_SYSTEM_EXTENSIONS". | ||
| 56 | _AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]],[[]])], | ||
| 57 | [gl_cv_compiler_check_decl_option='-Werror=implicit-function-declaration'], | ||
| 58 | [gl_cv_compiler_check_decl_option=none]) | ||
| 59 | ac_compile="$save_ac_compile" | ||
| 60 | else | ||
| 61 | gl_cv_compiler_check_decl_option=none | ||
| 62 | fi | ||
| 63 | ]) | ||
| 64 | if test "x$gl_cv_compiler_check_decl_option" != xnone; then | ||
| 65 | ac_compile_for_check_decl="$ac_compile $gl_cv_compiler_check_decl_option" | ||
| 66 | else | ||
| 67 | ac_compile_for_check_decl="$ac_compile" | ||
| 68 | fi | ||
| 69 | ]) | ||
| 70 | dnl Redefine _AC_CHECK_DECL_BODY so that it references ac_compile_for_check_decl | ||
| 71 | dnl instead of ac_compile. If, for whatever reason, the override of AC_PROG_CC | ||
| 72 | dnl in zzgnulib.m4 is inactive, use the original ac_compile. | ||
| 73 | m4_define([_AC_CHECK_DECL_BODY], | ||
| 74 | [ ac_save_ac_compile="$ac_compile" | ||
| 75 | if test -n "$ac_compile_for_check_decl"; then | ||
| 76 | ac_compile="$ac_compile_for_check_decl" | ||
| 77 | fi] | ||
| 78 | m4_defn([_AC_CHECK_DECL_BODY])[ ac_compile="$ac_save_ac_compile" | ||
| 79 | ]) | ||
| 25 | 80 | ||
| 26 | # gl_00GNULIB | 81 | # gl_00GNULIB |
| 27 | # ----------- | 82 | # ----------- |
