doc: List library dependencies.
[gnulib.git] / m4 / strerrorname_np.m4
blobac0211715ac8196d45c0d9115aa12f4c11990d7e
1 # strerrorname_np.m4
2 # serial 6
3 dnl Copyright (C) 2020-2024 Free Software Foundation, Inc.
4 dnl This file is free software; the Free Software Foundation
5 dnl gives unlimited permission to copy and/or distribute it,
6 dnl with or without modifications, as long as this notice is preserved.
8 AC_DEFUN([gl_FUNC_STRERRORNAME_NP],
10   AC_REQUIRE([gl_STRING_H_DEFAULTS])
12   AC_REQUIRE([gl_CHECK_STRERRORNAME_NP])
13   if test $ac_cv_func_strerrorname_np = yes; then
14     case "$gl_cv_func_strerrorname_np_works" in
15       *yes) ;;
16       *) REPLACE_STRERRORNAME_NP=1 ;;
17     esac
18   else
19     HAVE_STRERRORNAME_NP=0
20   fi
23 # Check for a working strerrorname_np function.
24 # Sets ac_cv_func_strerrorname_np, gl_cv_func_strerrorname_np_works.
25 AC_DEFUN([gl_CHECK_STRERRORNAME_NP],
27   dnl Persuade glibc <string.h> to declare strerrorname_np().
28   AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
30   AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
32   AC_CHECK_FUNCS([strerrorname_np])
33   if test $ac_cv_func_strerrorname_np = yes; then
34     dnl In glibc 2.32, strerrorname_np returns English error descriptions, not
35     dnl error names.
36     dnl See <https://sourceware.org/bugzilla/show_bug.cgi?id=26555>.
37     dnl In glibc 2.36, strerrorname_np returns NULL for EDEADLOCK on powerpc and
38     dnl sparc platforms.
39     dnl See <https://sourceware.org/bugzilla/show_bug.cgi?id=29545>.
40     dnl In glibc 2.37, strerrorname_np returns NULL for ENOSYM and
41     dnl EREMOTERELEASE on hppa platforms.
42     dnl See <https://sourceware.org/bugzilla/show_bug.cgi?id=31080>.
43     AC_CACHE_CHECK([whether strerrorname_np works],
44       [gl_cv_func_strerrorname_np_works],
45       [AC_RUN_IFELSE(
46          [AC_LANG_PROGRAM(
47             [[#include <errno.h>
48               #include <string.h>
49             ]],
50             [[return
51                 strcmp (strerrorname_np (EINVAL), "EINVAL") != 0
52                 #ifdef EDEADLOCK
53                 || strerrorname_np (EDEADLOCK) == NULL
54                 #endif
55                 #ifdef ENOSYM
56                 || strerrorname_np (ENOSYM) == NULL
57                 #endif
58                 ;
59             ]])],
60          [gl_cv_func_strerrorname_np_works=yes],
61          [gl_cv_func_strerrorname_np_works=no],
62          [case "$host_os" in
63             # Guess no on glibc systems.
64             *-gnu* | gnu*)
65               gl_cv_func_strerrorname_np_works="guessing no" ;;
66             # Otherwise obey --enable-cross-guesses.
67             *)
68               gl_cv_func_strerrorname_np_works="$gl_cross_guess_normal" ;;
69           esac
70          ])
71       ])
72   fi
75 # Prerequisite for using strerrorname_np when available.
76 AC_DEFUN_ONCE([gl_OPTIONAL_STRERRORNAME_NP],
78   AC_REQUIRE([gl_CHECK_STRERRORNAME_NP])
79   if test $ac_cv_func_strerrorname_np = yes; then
80     case "$gl_cv_func_strerrorname_np_works" in
81       *yes)
82         AC_DEFINE([HAVE_WORKING_STRERRORNAME_NP], [1],
83           [Define to 1 if the function strerrorname_np exists and works.])
84         ;;
85     esac
86   fi