| 1 |
# readutmp.m4 |
| 2 |
# serial 32 |
| 3 |
dnl Copyright (C) 2002-2026 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. |
| 8 |
|
| 9 |
AC_DEFUN([gl_READUTMP], |
| 10 |
[ |
| 11 |
AC_REQUIRE([gl_SYSTEMD_CHOICE]) |
| 12 |
|
| 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. |
| 17 |
READUTMP_LIB= |
| 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" |
| 25 |
AC_LINK_IFELSE( |
| 26 |
[AC_LANG_PROGRAM([[ |
| 27 |
#include <stdint.h> |
| 28 |
#include <systemd/sd-login.h> |
| 29 |
]], [[ |
| 30 |
uint64_t st; |
| 31 |
sd_session_get_start_time ("1", &st); |
| 32 |
]]) |
| 33 |
], |
| 34 |
[gl_cv_lib_readutmp_systemd=yes], |
| 35 |
[gl_cv_lib_readutmp_systemd=no]) |
| 36 |
LIBS="$gl_saved_LIBS" |
| 37 |
]) |
| 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' |
| 42 |
fi |
| 43 |
fi |
| 44 |
fi |
| 45 |
AC_SUBST([READUTMP_LIB]) |
| 46 |
|
| 47 |
gl_PREREQ_READUTMP_H |
| 48 |
]) |
| 49 |
|
| 50 |
# Prerequisites of readutmp.h and boot-time-aux.h. |
| 51 |
AC_DEFUN_ONCE([gl_PREREQ_READUTMP_H], |
| 52 |
[ |
| 53 |
dnl Persuade utmpx.h to declare utmpxname |
| 54 |
AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) |
| 55 |
|
| 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> |
| 63 |
#ifdef HAVE_UTMP_H |
| 64 |
# include <utmp.h> |
| 65 |
#endif |
| 66 |
]]) |
| 67 |
utmp_includes="\ |
| 68 |
AC_INCLUDES_DEFAULT |
| 69 |
#ifdef HAVE_UTMPX_H |
| 70 |
# include <utmpx.h> |
| 71 |
#endif |
| 72 |
#ifdef HAVE_UTMP_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 |
| 77 |
# endif |
| 78 |
# include <utmp.h> |
| 79 |
#endif |
| 80 |
" |
| 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]) |
| 98 |
|
| 99 |
AC_CHECK_MEMBERS([struct utmpx.ut_exit.e_exit],,,[$utmp_includes]) |
| 100 |
AC_CHECK_MEMBERS([struct utmp.ut_exit.e_exit],,,[$utmp_includes]) |
| 101 |
|
| 102 |
AC_CHECK_MEMBERS([struct utmpx.ut_exit.e_termination],,,[$utmp_includes]) |
| 103 |
AC_CHECK_MEMBERS([struct utmp.ut_exit.e_termination],,,[$utmp_includes]) |
| 104 |
fi |
| 105 |
|
| 106 |
AC_CHECK_DECLS([sysinfo],,,[[ |
| 107 |
#include <sys/sysinfo.h> |
| 108 |
]]) |
| 109 |
|
| 110 |
AC_CHECK_HEADERS_ONCE([sys/param.h]) |
| 111 |
dnl <sys/sysctl.h> requires <sys/param.h> on OpenBSD 4.0. |
| 112 |
AC_CHECK_HEADERS([sys/sysctl.h],,, |
| 113 |
[AC_INCLUDES_DEFAULT |
| 114 |
#if HAVE_SYS_PARAM_H |
| 115 |
# include <sys/param.h> |
| 116 |
#endif |
| 117 |
]) |
| 118 |
AC_CHECK_FUNCS([sysctl]) |
| 119 |
|
| 120 |
AC_CHECK_HEADERS_ONCE([OS.h]) |
| 121 |
]) |