* ChangeLog: Fix misspelling
[gnulib.git] / m4 / sys_random_h.m4
blob62fd519e365119b11b9c546b567a3ea5bbef06ac
1 # sys_random_h.m4
2 # serial 8
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_ONCE([gl_SYS_RANDOM_H],
10   AC_REQUIRE([gl_SYS_RANDOM_H_DEFAULTS])
11   dnl <sys/random.h> is always overridden, because of GNULIB_POSIXCHECK.
12   gl_CHECK_NEXT_HEADERS([sys/random.h])
13   if test $ac_cv_header_sys_random_h = yes; then
14     HAVE_SYS_RANDOM_H=1
15   else
16     HAVE_SYS_RANDOM_H=0
17   fi
18   AC_SUBST([HAVE_SYS_RANDOM_H])
20   m4_ifdef([gl_UNISTD_H_DEFAULTS], [AC_REQUIRE([gl_UNISTD_H_DEFAULTS])])
21   if test $ac_cv_header_sys_random_h = yes; then
22     UNISTD_H_HAVE_SYS_RANDOM_H=1
23   fi
25   dnl Check for declarations of anything we want to poison if the
26   dnl corresponding gnulib module is not in use.
27   gl_WARN_ON_USE_PREPARE([[
28 #if HAVE_SYS_RANDOM_H
29 /* Additional includes are needed before <sys/random.h> on uClibc
30    and Mac OS X.  */
31 # include <sys/types.h>
32 # include <stdlib.h>
33 # include <sys/random.h>
34 #endif
35     ]],
36     [getrandom])
39 # gl_SYS_RANDOM_MODULE_INDICATOR([modulename])
40 # sets the shell variable that indicates the presence of the given module
41 # to a C preprocessor expression that will evaluate to 1.
42 # This macro invocation must not occur in macros that are AC_REQUIREd.
43 AC_DEFUN([gl_SYS_RANDOM_MODULE_INDICATOR],
45   dnl Ensure to expand the default settings once only.
46   gl_SYS_RANDOM_H_REQUIRE_DEFAULTS
47   gl_MODULE_INDICATOR_SET_VARIABLE([$1])
48   dnl Define it also as a C macro, for the benefit of the unit tests.
49   gl_MODULE_INDICATOR_FOR_TESTS([$1])
52 # Initializes the default values for AC_SUBSTed shell variables.
53 # This macro must not be AC_REQUIREd.  It must only be invoked, and only
54 # outside of macros or in macros that are not AC_REQUIREd.
55 AC_DEFUN([gl_SYS_RANDOM_H_REQUIRE_DEFAULTS],
57   m4_defun(GL_MODULE_INDICATOR_PREFIX[_SYS_RANDOM_H_MODULE_INDICATOR_DEFAULTS], [
58     gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETRANDOM])
59   ])
60   m4_require(GL_MODULE_INDICATOR_PREFIX[_SYS_RANDOM_H_MODULE_INDICATOR_DEFAULTS])
61   AC_REQUIRE([gl_SYS_RANDOM_H_DEFAULTS])
64 AC_DEFUN([gl_SYS_RANDOM_H_DEFAULTS],
66   dnl Assume proper GNU behavior unless another module says otherwise.
67   HAVE_GETRANDOM=1;       AC_SUBST([HAVE_GETRANDOM])
68   REPLACE_GETRANDOM=0;    AC_SUBST([REPLACE_GETRANDOM])