From 92881f2066c03175f91e1ccc2ad687a10f867293 Mon Sep 17 00:00:00 2001 From: Jacob Nevins Date: Wed, 18 May 2022 18:48:28 +0100 Subject: [PATCH] Define OMIT_UTMP if there's no utmpx.h. Without this, the build of e.g. psusan would fail on systems without that header (such as Termux on Android). This is similar to how things were pre-cmake, but not identical. We used to treat lack of updwtmpx() as a reason to OMIT_UTMP (as of f0dfa73982), but usage of that function got conditionalised in c19e7215dd, so I haven't restored that exclusion. --- cmake/cmake.h.in | 1 + cmake/platforms/unix.cmake | 7 +++++++ unix/pty.c | 2 ++ 3 files changed, 10 insertions(+) diff --git a/cmake/cmake.h.in b/cmake/cmake.h.in index ed44b2ca..2041f096 100644 --- a/cmake/cmake.h.in +++ b/cmake/cmake.h.in @@ -16,6 +16,7 @@ #cmakedefine01 HAVE_DWMAPI_H #cmakedefine NOT_X_WINDOWS +#cmakedefine OMIT_UTMP #cmakedefine01 HAVE_ASM_HWCAP_H #cmakedefine01 HAVE_SYS_AUXV_H diff --git a/cmake/platforms/unix.cmake b/cmake/platforms/unix.cmake index cb47caf9..6a788cb4 100644 --- a/cmake/platforms/unix.cmake +++ b/cmake/platforms/unix.cmake @@ -19,6 +19,7 @@ check_include_file(sys/sysctl.h HAVE_SYS_SYSCTL_H) check_include_file(sys/types.h HAVE_SYS_TYPES_H) check_include_file(glob.h HAVE_GLOB_H) check_include_file(utmp.h HAVE_UTMP_H) +check_include_file(utmpx.h HAVE_UTMPX_H) check_symbol_exists(futimes "sys/time.h" HAVE_FUTIMES) check_symbol_exists(getaddrinfo "sys/types.h;sys/socket.h;netdb.h" @@ -56,6 +57,12 @@ else() set(NO_IPV6 ON) endif() +if(HAVE_UTMPX_H) + set(OMIT_UTMP OFF) +else() + set(OMIT_UTMP ON) +endif() + include(cmake/gtk.cmake) # See if we have X11 available. This requires libX11 itself, and also diff --git a/unix/pty.c b/unix/pty.c index 0747b584..625f1bb1 100644 --- a/unix/pty.c +++ b/unix/pty.c @@ -227,6 +227,8 @@ static void setup_utmp(char *ttyname, char *location) endutxent(); #if HAVE_UPDWTMPX + /* Reportedly, AIX 5.1 has and pututxline(), but no + * updwtmpx(). */ updwtmpx(WTMPX_FILE, &utmp_entry); #endif