3 dnl Copyright (C) 2002-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.
7 dnl This file is offered as-is, without any warranty.
9 AC_DEFUN([gl_READUTMP],
11 AC_REQUIRE([gl_SYSTEMD_CHOICE])
13 dnl Set READUTMP_LIB to '-lsystemd' or '', depending on whether use of
14 dnl systemd APIs is possible and desired (only the systemd login API, here).
15 dnl AC_LIB_LINKFLAGS_BODY would be overkill here, since few people install
16 dnl libsystemd in non-system directories.
18 if test "$SYSTEMD_CHOICE" = yes; then
19 AC_CHECK_HEADER([systemd/sd-login.h])
20 if test $ac_cv_header_systemd_sd_login_h = yes; then
21 AC_CACHE_CHECK([for libsystemd version >= 254],
22 [gl_cv_lib_readutmp_systemd],
23 [gl_saved_LIBS="$LIBS"
24 LIBS="$LIBS -lsystemd"
28 #include <systemd/sd-login.h>
31 sd_session_get_start_time ("1", &st);
34 [gl_cv_lib_readutmp_systemd=yes],
35 [gl_cv_lib_readutmp_systemd=no])
38 if test $gl_cv_lib_readutmp_systemd = yes; then
39 AC_DEFINE([READUTMP_USE_SYSTEMD], [1],
40 [Define if the readutmp module should use the systemd login API.])
41 READUTMP_LIB='-lsystemd'
45 AC_SUBST([READUTMP_LIB])
50 # Prerequisites of readutmp.h and boot-time-aux.h.
51 AC_DEFUN_ONCE([gl_PREREQ_READUTMP_H],
53 dnl Persuade utmpx.h to declare utmpxname
54 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
56 AC_CHECK_HEADERS_ONCE([utmp.h utmpx.h])
57 if test $ac_cv_header_utmp_h = yes || test $ac_cv_header_utmpx_h = yes; then
58 dnl Prerequisites of lib/readutmp.h and lib/readutmp.c.
59 AC_CHECK_FUNCS_ONCE([utmpname utmpxname])
60 AC_CHECK_DECLS([endutent],,,[[
61 /* <sys/types.h> is a prerequisite of <utmp.h> on FreeBSD 8.0, OpenBSD 4.6. */
62 #include <sys/types.h>
73 # if defined _THREAD_SAFE && defined UTMP_DATA_INIT
74 /* When including both utmp.h and utmpx.h on AIX 4.3, with _THREAD_SAFE
75 defined, work around the duplicate struct utmp_data declaration. */
76 # define utmp_data gl_aix_4_3_workaround_utmp_data
81 AC_CHECK_MEMBERS([struct utmpx.ut_user],,,[$utmp_includes])
82 AC_CHECK_MEMBERS([struct utmp.ut_user],,,[$utmp_includes])
83 AC_CHECK_MEMBERS([struct utmpx.ut_name],,,[$utmp_includes])
84 AC_CHECK_MEMBERS([struct utmp.ut_name],,,[$utmp_includes])
85 AC_CHECK_MEMBERS([struct utmpx.ut_type],,,[$utmp_includes])
86 AC_CHECK_MEMBERS([struct utmp.ut_type],,,[$utmp_includes])
87 AC_CHECK_MEMBERS([struct utmpx.ut_pid],,,[$utmp_includes])
88 AC_CHECK_MEMBERS([struct utmp.ut_pid],,,[$utmp_includes])
89 AC_CHECK_MEMBERS([struct utmp.ut_tv],,,[$utmp_includes])
90 AC_CHECK_MEMBERS([struct utmpx.ut_host],,,[$utmp_includes])
91 AC_CHECK_MEMBERS([struct utmp.ut_host],,,[$utmp_includes])
92 AC_CHECK_MEMBERS([struct utmpx.ut_id],,,[$utmp_includes])
93 AC_CHECK_MEMBERS([struct utmp.ut_id],,,[$utmp_includes])
94 AC_CHECK_MEMBERS([struct utmpx.ut_session],,,[$utmp_includes])
95 AC_CHECK_MEMBERS([struct utmp.ut_session],,,[$utmp_includes])
96 AC_CHECK_MEMBERS([struct utmpx.ut_exit],,,[$utmp_includes])
97 AC_CHECK_MEMBERS([struct utmp.ut_exit],,,[$utmp_includes])
99 AC_CHECK_MEMBERS([struct utmpx.ut_exit.ut_exit],,,[$utmp_includes])
100 AC_CHECK_MEMBERS([struct utmpx.ut_exit.e_exit],,,[$utmp_includes])
101 AC_CHECK_MEMBERS([struct utmp.ut_exit.e_exit],,,[$utmp_includes])
103 AC_CHECK_MEMBERS([struct utmpx.ut_exit.ut_termination],,,[$utmp_includes])
104 AC_CHECK_MEMBERS([struct utmpx.ut_exit.e_termination],,,[$utmp_includes])
105 AC_CHECK_MEMBERS([struct utmp.ut_exit.e_termination],,,[$utmp_includes])
108 AC_CHECK_DECLS([sysinfo],,,[[
109 #include <sys/sysinfo.h>
112 AC_CHECK_HEADERS_ONCE([sys/param.h])
113 dnl <sys/sysctl.h> requires <sys/param.h> on OpenBSD 4.0.
114 AC_CHECK_HEADERS([sys/sysctl.h],,,
117 # include <sys/param.h>
120 AC_CHECK_FUNCS([sysctl])
122 AC_CHECK_HEADERS_ONCE([OS.h])