diff options
Diffstat (limited to 'gl/m4/warn-on-use.m4')
-rw-r--r-- | gl/m4/warn-on-use.m4 | 61 |
1 files changed, 38 insertions, 23 deletions
diff --git a/gl/m4/warn-on-use.m4 b/gl/m4/warn-on-use.m4 index e43beebd..10649c5c 100644 --- a/gl/m4/warn-on-use.m4 +++ b/gl/m4/warn-on-use.m4 | |||
@@ -1,11 +1,13 @@ | |||
1 | # warn-on-use.m4 serial 5 | 1 | # warn-on-use.m4 serial 10 |
2 | dnl Copyright (C) 2010-2013 Free Software Foundation, Inc. | 2 | dnl Copyright (C) 2010-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 | # gl_WARN_ON_USE_PREPARE(INCLUDES, NAMES) | 7 | # gl_WARN_ON_USE_PREPARE(INCLUDES, NAMES) |
8 | # --------------------------------------- | 8 | # --------------------------------------- |
9 | # If the module 'posixcheck' is in use: | ||
10 | # | ||
9 | # For each whitespace-separated element in the list of NAMES, define | 11 | # For each whitespace-separated element in the list of NAMES, define |
10 | # HAVE_RAW_DECL_name if the function has a declaration among INCLUDES | 12 | # HAVE_RAW_DECL_name if the function has a declaration among INCLUDES |
11 | # even after being undefined as a macro. | 13 | # even after being undefined as a macro. |
@@ -23,25 +25,38 @@ dnl with or without modifications, as long as this notice is preserved. | |||
23 | # needing gl_WARN_ON_USE_PREPARE. | 25 | # needing gl_WARN_ON_USE_PREPARE. |
24 | AC_DEFUN([gl_WARN_ON_USE_PREPARE], | 26 | AC_DEFUN([gl_WARN_ON_USE_PREPARE], |
25 | [ | 27 | [ |
26 | m4_foreach_w([gl_decl], [$2], | 28 | m4_ifdef([gl_POSIXCHECK], |
27 | [AH_TEMPLATE([HAVE_RAW_DECL_]AS_TR_CPP(m4_defn([gl_decl])), | 29 | [m4_foreach_w([gl_decl], [$2], |
28 | [Define to 1 if ]m4_defn([gl_decl])[ is declared even after | 30 | [AH_TEMPLATE([HAVE_RAW_DECL_]AS_TR_CPP(m4_defn([gl_decl])), |
29 | undefining macros.])])dnl | 31 | [Define to 1 if ]m4_defn([gl_decl])[ is declared even after |
30 | dnl FIXME: gl_Symbol must be used unquoted until we can assume | 32 | undefining macros.])])dnl |
31 | dnl autoconf 2.64 or newer. | 33 | for gl_func in m4_flatten([$2]); do |
32 | for gl_func in m4_flatten([$2]); do | 34 | AS_VAR_PUSHDEF([gl_Symbol], [gl_cv_have_raw_decl_$gl_func])dnl |
33 | AS_VAR_PUSHDEF([gl_Symbol], [gl_cv_have_raw_decl_$gl_func])dnl | 35 | dnl As a workaround to implicit built-in function declarations in |
34 | AC_CACHE_CHECK([whether $gl_func is declared without a macro], | 36 | dnl clang (e.g. strndup), reference ac_compile_for_check_decl instead |
35 | gl_Symbol, | 37 | dnl of ac_compile. If, for whatever reason, the override of AC_PROG_CC |
36 | [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([$1], | 38 | dnl in zzgnulib.m4 is inactive, use the original ac_compile. |
37 | [@%:@undef $gl_func | 39 | ac_save_ac_compile="$ac_compile" |
38 | (void) $gl_func;])], | 40 | if test -n "$ac_compile_for_check_decl"; then |
39 | [AS_VAR_SET(gl_Symbol, [yes])], [AS_VAR_SET(gl_Symbol, [no])])]) | 41 | ac_compile="$ac_compile_for_check_decl" |
40 | AS_VAR_IF(gl_Symbol, [yes], | 42 | fi |
41 | [AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_RAW_DECL_$gl_func]), [1]) | 43 | AC_CACHE_CHECK([whether $gl_func is declared without a macro], |
42 | dnl shortcut - if the raw declaration exists, then set a cache | 44 | [gl_Symbol], |
43 | dnl variable to allow skipping any later AC_CHECK_DECL efforts | 45 | [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([$1], |
44 | eval ac_cv_have_decl_$gl_func=yes]) | 46 | [[#undef $gl_func |
45 | AS_VAR_POPDEF([gl_Symbol])dnl | 47 | (void) $gl_func;]])], |
46 | done | 48 | [AS_VAR_SET([gl_Symbol], [yes])], [AS_VAR_SET([gl_Symbol], [no])])]) |
49 | ac_compile="$ac_save_ac_compile" | ||
50 | AS_VAR_IF([gl_Symbol], [yes], | ||
51 | [AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_RAW_DECL_$gl_func]), [1]) | ||
52 | dnl Shortcut for an AC_CHECK_DECL invocation that may come later: | ||
53 | dnl If the raw declaration exists with the given includes, then | ||
54 | dnl AC_CHECK_DECL with its many includes would see it as well. | ||
55 | dnl So, set a cache variable to allow skipping any later | ||
56 | dnl AC_CHECK_DECL invocation for $gl_func. | ||
57 | eval "ac_cv_have_decl_$gl_func=yes" | ||
58 | ]) | ||
59 | AS_VAR_POPDEF([gl_Symbol])dnl | ||
60 | done | ||
61 | ]) | ||
47 | ]) | 62 | ]) |