1# sys_random_h.m4 serial 4 2dnl Copyright (C) 2020 Free Software Foundation, Inc. 3dnl This file is free software; the Free Software Foundation 4dnl gives unlimited permission to copy and/or distribute it, 5dnl with or without modifications, as long as this notice is preserved. 6 7AC_DEFUN([gl_HEADER_SYS_RANDOM], 8[ 9 AC_REQUIRE([gl_SYS_RANDOM_H_DEFAULTS]) 10 dnl <sys/random.h> is always overridden, because of GNULIB_POSIXCHECK. 11 gl_CHECK_NEXT_HEADERS([sys/random.h]) 12 if test $ac_cv_header_sys_random_h = yes; then 13 HAVE_SYS_RANDOM_H=1 14 else 15 HAVE_SYS_RANDOM_H=0 16 fi 17 AC_SUBST([HAVE_SYS_RANDOM_H]) 18 19 m4_ifdef([gl_UNISTD_H_DEFAULTS], [AC_REQUIRE([gl_UNISTD_H_DEFAULTS])]) 20 if test $ac_cv_header_sys_random_h = yes; then 21 UNISTD_H_HAVE_SYS_RANDOM_H=1 22 fi 23 24 dnl Check for declarations of anything we want to poison if the 25 dnl corresponding gnulib module is not in use. 26 gl_WARN_ON_USE_PREPARE([[ 27#if HAVE_SYS_RANDOM_H 28/* Additional includes are needed before <sys/random.h> on Mac OS X. */ 29# include <sys/types.h> 30# include <stdlib.h> 31# include <sys/random.h> 32#endif 33 ]], 34 [getrandom]) 35]) 36 37AC_DEFUN([gl_SYS_RANDOM_MODULE_INDICATOR], 38[ 39 dnl Use AC_REQUIRE here, so that the default settings are expanded once only. 40 AC_REQUIRE([gl_SYS_RANDOM_H_DEFAULTS]) 41 gl_MODULE_INDICATOR_SET_VARIABLE([$1]) 42 dnl Define it also as a C macro, for the benefit of the unit tests. 43 gl_MODULE_INDICATOR_FOR_TESTS([$1]) 44]) 45 46AC_DEFUN([gl_SYS_RANDOM_H_DEFAULTS], 47[ 48 GNULIB_GETRANDOM=0; AC_SUBST([GNULIB_GETRANDOM]) 49 dnl Assume proper GNU behavior unless another module says otherwise. 50 HAVE_GETRANDOM=1; AC_SUBST([HAVE_GETRANDOM]) 51 REPLACE_GETRANDOM=0; AC_SUBST([REPLACE_GETRANDOM]) 52]) 53