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.
8 AC_DEFUN([gl_READUTMP],
10 AC_REQUIRE([gl_SYSTEMD_CHOICE])
12 dnl Set READUTMP_LIB to '-lsystemd' or '', depending on whether use of
13 dnl systemd APIs is possible and desired (only the systemd login API, here).
14 dnl AC_LIB_LINKFLAGS_BODY would be overkill here, since few people install
15 dnl libsystemd in non-system directories.
17 if test "$SYSTEMD_CHOICE" = yes; then
18 AC_CHECK_HEADER([systemd/sd-login.h])
19 if test $ac_cv_header_systemd_sd_login_h = yes; then
20 AC_CACHE_CHECK([for libsystemd version >= 254],
21 [gl_cv_lib_readutmp_systemd],
22 [gl_saved_LIBS="$LIBS"
23 LIBS="$LIBS -lsystemd"
27 #include <systemd/sd-login.h>
30 sd_session_get_start_time ("1", &st);
33 [gl_cv_lib_readutmp_systemd=yes],
34 [gl_cv_lib_readutmp_systemd=no])
37 if test $gl_cv_lib_readutmp_systemd = yes; then
38 AC_DEFINE([READUTMP_USE_SYSTEMD], [1],
39 [Define if the readutmp module should use the systemd login API.])
40 READUTMP_LIB='-lsystemd'
44 AC_SUBST([READUTMP_LIB])
49 # Prerequisites of readutmp.h and boot-time-aux.h.
50 AC_DEFUN_ONCE([gl_PREREQ_READUTMP_H],
52 dnl Persuade utmpx.h to declare utmpxname
53 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
55 AC_CHECK_HEADERS_ONCE([utmp.h utmpx.h])
56 if test $ac_cv_header_utmp_h = yes || test $ac_cv_header_utmpx_h = yes; then
57 dnl Prerequisites of lib/readutmp.h and lib/readutmp.c.
58 AC_CHECK_FUNCS_ONCE([utmpname utmpxname])
59 AC_CHECK_DECLS([endutent],,,[[
60 /* <sys/types.h> is a prerequisite of <utmp.h> on FreeBSD 8.0, OpenBSD 4.6. */
61 #include <sys/types.h>
72 # if defined _THREAD_SAFE && defined UTMP_DATA_INIT
73 /* When including both utmp.h and utmpx.h on AIX 4.3, with _THREAD_SAFE
74 defined, work around the duplicate struct utmp_data declaration. */
75 # define utmp_data gl_aix_4_3_workaround_utmp_data
80 AC_CHECK_MEMBERS([struct utmpx.ut_user],,,[$utmp_includes])
81 AC_CHECK_MEMBERS([struct utmp.ut_user],,,[$utmp_includes])
82 AC_CHECK_MEMBERS([struct utmpx.ut_name],,,[$utmp_includes])
83 AC_CHECK_MEMBERS([struct utmp.ut_name],,,[$utmp_includes])
84 AC_CHECK_MEMBERS([struct utmpx.ut_type],,,[$utmp_includes])
85 AC_CHECK_MEMBERS([struct utmp.ut_type],,,[$utmp_includes])
86 AC_CHECK_MEMBERS([struct utmpx.ut_pid],,,[$utmp_includes])
87 AC_CHECK_MEMBERS([struct utmp.ut_pid],,,[$utmp_includes])
88 AC_CHECK_MEMBERS([struct utmp.ut_tv],,,[$utmp_includes])
89 AC_CHECK_MEMBERS([struct utmpx.ut_host],,,[$utmp_includes])
90 AC_CHECK_MEMBERS([struct utmp.ut_host],,,[$utmp_includes])
91 AC_CHECK_MEMBERS([struct utmpx.ut_id],,,[$utmp_includes])
92 AC_CHECK_MEMBERS([struct utmp.ut_id],,,[$utmp_includes])
93 AC_CHECK_MEMBERS([struct utmpx.ut_session],,,[$utmp_includes])
94 AC_CHECK_MEMBERS([struct utmp.ut_session],,,[$utmp_includes])
95 AC_CHECK_MEMBERS([struct utmpx.ut_exit],,,[$utmp_includes])
96 AC_CHECK_MEMBERS([struct utmp.ut_exit],,,[$utmp_includes])
98 AC_CHECK_MEMBERS([struct utmpx.ut_exit.ut_exit],,,[$utmp_includes])
99 AC_CHECK_MEMBERS([struct utmpx.ut_exit.e_exit],,,[$utmp_includes])
100 AC_CHECK_MEMBERS([struct utmp.ut_exit.e_exit],,,[$utmp_includes])
102 AC_CHECK_MEMBERS([struct utmpx.ut_exit.ut_termination],,,[$utmp_includes])
103 AC_CHECK_MEMBERS([struct utmpx.ut_exit.e_termination],,,[$utmp_includes])
104 AC_CHECK_MEMBERS([struct utmp.ut_exit.e_termination],,,[$utmp_includes])
107 AC_CHECK_DECLS([sysinfo],,,[[
108 #include <sys/sysinfo.h>
111 AC_CHECK_HEADERS_ONCE([sys/param.h])
112 dnl <sys/sysctl.h> requires <sys/param.h> on OpenBSD 4.0.
113 AC_CHECK_HEADERS([sys/sysctl.h],,,
116 # include <sys/param.h>
119 AC_CHECK_FUNCS([sysctl])
121 AC_CHECK_HEADERS_ONCE([OS.h])