1# sys_utsname_h.m4 serial 11
2dnl Copyright (C) 2009-2021 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
7dnl Written by Bruno Haible.
8
9AC_DEFUN_ONCE([gl_SYS_UTSNAME_H],
10[
11  dnl Ensure to expand the default settings once only, before all statements
12  dnl that occur in other macros.
13  AC_REQUIRE([gl_SYS_UTSNAME_H_DEFAULTS])
14
15  dnl <sys/utsname.h> is always overridden, because of GNULIB_POSIXCHECK.
16  gl_CHECK_NEXT_HEADERS([sys/utsname.h])
17  if test $ac_cv_header_sys_utsname_h != yes; then
18    HAVE_SYS_UTSNAME_H=0
19    HAVE_STRUCT_UTSNAME=0
20  else
21    HAVE_SYS_UTSNAME_H=1
22    AC_CHECK_TYPES([struct utsname], [], [HAVE_STRUCT_UTSNAME=0], [[
23/* Minix 3.1.8 has a bug: <stddef.h> must be included before
24   <sys/utsname.h>.  */
25#include <stddef.h>
26#include <sys/utsname.h>
27      ]])
28  fi
29  AC_SUBST([HAVE_SYS_UTSNAME_H])
30
31  dnl Check for declarations of anything we want to poison if the
32  dnl corresponding gnulib module is not in use.
33  gl_WARN_ON_USE_PREPARE([[
34    /* Minix 3.1.8 has a bug: <stddef.h> must be included before
35       <sys/utsname.h>.  */
36    #include <stddef.h>
37    #include <sys/utsname.h>
38    ]], [uname])
39])
40
41# gl_SYS_UTSNAME_MODULE_INDICATOR([modulename])
42# sets the shell variable that indicates the presence of the given module
43# to a C preprocessor expression that will evaluate to 1.
44# This macro invocation must not occur in macros that are AC_REQUIREd.
45AC_DEFUN([gl_SYS_UTSNAME_MODULE_INDICATOR],
46[
47  dnl Ensure to expand the default settings once only.
48  gl_SYS_UTSNAME_H_REQUIRE_DEFAULTS
49  gl_MODULE_INDICATOR_SET_VARIABLE([$1])
50])
51
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.
55AC_DEFUN([gl_SYS_UTSNAME_H_REQUIRE_DEFAULTS],
56[
57  m4_defun(GL_MODULE_INDICATOR_PREFIX[_SYS_UTSNAME_H_MODULE_INDICATOR_DEFAULTS], [
58    gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNAME])
59  ])
60  m4_require(GL_MODULE_INDICATOR_PREFIX[_SYS_UTSNAME_H_MODULE_INDICATOR_DEFAULTS])
61  AC_REQUIRE([gl_SYS_UTSNAME_H_DEFAULTS])
62])
63
64AC_DEFUN([gl_SYS_UTSNAME_H_DEFAULTS],
65[
66  dnl Assume proper GNU behavior unless another module says otherwise.
67  HAVE_UNAME=1;           AC_SUBST([HAVE_UNAME])
68  HAVE_STRUCT_UTSNAME=1;  AC_SUBST([HAVE_STRUCT_UTSNAME])
69])
70