diff options
Diffstat (limited to 'm4/00gnulib.m4')
-rw-r--r-- | m4/00gnulib.m4 | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/m4/00gnulib.m4 b/m4/00gnulib.m4 new file mode 100644 index 00000000..dea34e83 --- /dev/null +++ b/m4/00gnulib.m4 | |||
@@ -0,0 +1,85 @@ | |||
1 | # 00gnulib.m4 serial 8 | ||
2 | dnl Copyright (C) 2009-2022 Free Software Foundation, Inc. | ||
3 | dnl This file is free software; the Free Software Foundation | ||
4 | dnl gives unlimited permission to copy and/or distribute it, | ||
5 | dnl with or without modifications, as long as this notice is preserved. | ||
6 | |||
7 | dnl This file must be named something that sorts before all other | ||
8 | dnl gnulib-provided .m4 files. It is needed until the clang fix has | ||
9 | dnl been included in Autoconf. | ||
10 | |||
11 | # The following definitions arrange to use a compiler option | ||
12 | # -Werror=implicit-function-declaration in AC_CHECK_DECL, when the | ||
13 | # compiler is clang. Without it, clang implicitly declares "known" | ||
14 | # library functions in C mode, but not in C++ mode, which would cause | ||
15 | # Gnulib to omit a declaration and thus later produce an error in C++ | ||
16 | # mode. As of clang 9.0, these "known" functions are identified through | ||
17 | # LIBBUILTIN invocations in the LLVM source file | ||
18 | # llvm/tools/clang/include/clang/Basic/Builtins.def. | ||
19 | # It's not possible to AC_REQUIRE the extra tests from AC_CHECK_DECL, | ||
20 | # because AC_CHECK_DECL, like other Autoconf built-ins, is not supposed | ||
21 | # to AC_REQUIRE anything: some configure.ac files have their first | ||
22 | # AC_CHECK_DECL executed conditionally. Therefore append the extra tests | ||
23 | # to AC_PROG_CC. | ||
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 | ]) | ||
80 | |||
81 | # gl_00GNULIB | ||
82 | # ----------- | ||
83 | # Witness macro that this file has been included. Needed to force | ||
84 | # Automake to include this file prior to all other gnulib .m4 files. | ||
85 | AC_DEFUN([gl_00GNULIB]) | ||