]> Savannah Git Hosting - gnulib.git/commitdiff
utmp: Avoid using HAVE_* macros in *.in.h files.
authorBruno Haible <bruno@clisp.org>
Thu, 13 Apr 2023 19:43:51 +0000 (21:43 +0200)
committerBruno Haible <bruno@clisp.org>
Thu, 13 Apr 2023 19:43:51 +0000 (21:43 +0200)
* m4/pty_h.m4 (gl_PTY_CHECK_UTIL_H): New macro, extracted from gl_PTY_H.
(gl_PTY_H): Invoke it.
* m4/utmp_h.m4 (gl_UTMP_H): Invoke gl_PTY_CHECK_UTIL_H and set
HAVE_TERMIOS_H.
(gl_UTMP_H_DEFAULTS): Require gl_PTY_H_DEFAULTS, gl_TERMIOS_H_DEFAULTS.
* modules/utmp (Files): Add m4/pty_h.m4, m4/termios_h.m4.
(Makefile.am): Substitute also HAVE_UTIL_H, HAVE_LIBUTIL_H,
HAVE_TERMIOS_H.
* lib/utmp.in.h: Test HAVE_UTIL_H, HAVE_LIBUTIL_H, HAVE_TERMIOS_H as
Autoconf variables.

ChangeLog
lib/utmp.in.h
m4/pty_h.m4
m4/utmp_h.m4
modules/utmp

index 5e1fab0cfc675c451434075c3729211ae61d8454..eb270cf699bc8862e69dd30d04d17cee3f1a19bb 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2023-04-13  Bruno Haible  <bruno@clisp.org>
+
+       utmp: Avoid using HAVE_* macros in *.in.h files.
+       * m4/pty_h.m4 (gl_PTY_CHECK_UTIL_H): New macro, extracted from gl_PTY_H.
+       (gl_PTY_H): Invoke it.
+       * m4/utmp_h.m4 (gl_UTMP_H): Invoke gl_PTY_CHECK_UTIL_H and set
+       HAVE_TERMIOS_H.
+       (gl_UTMP_H_DEFAULTS): Require gl_PTY_H_DEFAULTS, gl_TERMIOS_H_DEFAULTS.
+       * modules/utmp (Files): Add m4/pty_h.m4, m4/termios_h.m4.
+       (Makefile.am): Substitute also HAVE_UTIL_H, HAVE_LIBUTIL_H,
+       HAVE_TERMIOS_H.
+       * lib/utmp.in.h: Test HAVE_UTIL_H, HAVE_LIBUTIL_H, HAVE_TERMIOS_H as
+       Autoconf variables.
+
 2023-04-13  Bruno Haible  <bruno@clisp.org>
 
        getprogname: Avoid using HAVE_* macros in *.in.h files.
index 895704cb1b2be6f1a18e371edc5ddcf2a8d2a343..6c47ca7b2a950d8086b8123879e41dea97e98842 100644 (file)
    <termios.h>, not in <utmp.h>.  */
 /* But in any case avoid namespace pollution on glibc systems.  */
 #if (@GNULIB_LOGIN_TTY@ || defined GNULIB_POSIXCHECK) && ! defined __GLIBC__
-# if HAVE_UTIL_H      /* macOS, NetBSD, OpenBSD, Minix */
+# if @HAVE_UTIL_H@      /* macOS, NetBSD, OpenBSD, Minix */
 #  include <util.h>
-# elif HAVE_LIBUTIL_H /* FreeBSD, Haiku */
+# elif @HAVE_LIBUTIL_H@ /* FreeBSD, Haiku */
 #  include <libutil.h>
-# elif HAVE_TERMIOS_H /* Solaris */
+# elif @HAVE_TERMIOS_H@ /* Solaris */
 #  include <termios.h>
 # endif
 #endif
index 1fce4b98e489e540553ec02f2db685d781433121..2c0f8bc9eaa958b190182112f1a334a3c813e4fd 100644 (file)
@@ -1,4 +1,4 @@
-# pty_h.m4 serial 14
+# pty_h.m4 serial 15
 dnl Copyright (C) 2009-2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -15,13 +15,7 @@ AC_DEFUN_ONCE([gl_PTY_H],
   AC_CHECK_HEADERS_ONCE([pty.h])
   if test $ac_cv_header_pty_h != yes; then
     HAVE_PTY_H=0
-    AC_CHECK_HEADERS([util.h libutil.h])
-    if test $ac_cv_header_util_h = yes; then
-      HAVE_UTIL_H=1
-    fi
-    if test $ac_cv_header_libutil_h = yes; then
-      HAVE_LIBUTIL_H=1
-    fi
+    gl_PTY_CHECK_UTIL_H
     AC_CHECK_HEADERS_ONCE([termios.h])
   else # Have <pty.h>, assume forkpty is declared there.
     HAVE_PTY_H=1
@@ -50,6 +44,19 @@ AC_DEFUN_ONCE([gl_PTY_H],
     ]], [forkpty openpty])
 ])
 
+dnl Test for <util.h> and <libutil.h>.
+AC_DEFUN([gl_PTY_CHECK_UTIL_H],
+[
+  AC_REQUIRE([gl_PTY_H_DEFAULTS])
+  AC_CHECK_HEADERS([util.h libutil.h])
+  if test $ac_cv_header_util_h = yes; then
+    HAVE_UTIL_H=1
+  fi
+  if test $ac_cv_header_libutil_h = yes; then
+    HAVE_LIBUTIL_H=1
+  fi
+])
+
 # gl_PTY_MODULE_INDICATOR([modulename])
 # sets the shell variable that indicates the presence of the given module
 # to a C preprocessor expression that will evaluate to 1.
index fff6dbdfe71bb674e221cc997e846641bbd8b04d..6dd5eb989b0d7c4ae434f5c7597458d4ac6d713d 100644 (file)
@@ -5,7 +5,7 @@
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
-# serial 1
+# serial 2
 
 AC_DEFUN_ONCE([gl_UTMP_H],
 [
@@ -21,6 +21,13 @@ AC_DEFUN_ONCE([gl_UTMP_H],
   fi
   AC_SUBST([HAVE_UTMP_H])
 
+  gl_PTY_CHECK_UTIL_H
+
+  AC_CHECK_HEADERS_ONCE([termios.h])
+  if test $ac_cv_header_termios_h != yes; then
+    HAVE_TERMIOS_H=0
+  fi
+
   dnl Check for declarations of anything we want to poison if the
   dnl corresponding gnulib module is not in use, and which is not
   dnl guaranteed by C89.
@@ -58,6 +65,10 @@ AC_DEFUN([gl_UTMP_H_REQUIRE_DEFAULTS],
 
 AC_DEFUN([gl_UTMP_H_DEFAULTS],
 [
+  dnl For HAVE_UTIL_H, HAVE_LIBUTIL_H.
+  AC_REQUIRE([gl_PTY_H_DEFAULTS])
+  dnl For HAVE_TERMIOS_H.
+  AC_REQUIRE([gl_TERMIOS_H_DEFAULTS])
   dnl Assume proper GNU behavior unless another module says otherwise.
   HAVE_LOGIN_TTY=1;             AC_SUBST([HAVE_LOGIN_TTY])
   REPLACE_LOGIN_TTY=0;          AC_SUBST([REPLACE_LOGIN_TTY])
index 3a02f013646f29cca0e495941f629d7fe9bff23c..d5ba411d875666d3fd7cb38333a46c46e420fbbf 100644 (file)
@@ -4,6 +4,8 @@ A GNU-like <utmp.h>.
 Files:
 lib/utmp.in.h
 m4/utmp_h.m4
+m4/pty_h.m4
+m4/termios_h.m4
 
 Depends-on:
 gen-header
@@ -30,6 +32,9 @@ utmp.h: utmp.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H)
              -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
              -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
              -e 's|@''NEXT_UTMP_H''@|$(NEXT_UTMP_H)|g' \
+             -e 's|@''HAVE_UTIL_H''@|$(HAVE_UTIL_H)|g' \
+             -e 's|@''HAVE_LIBUTIL_H''@|$(HAVE_LIBUTIL_H)|g' \
+             -e 's|@''HAVE_TERMIOS_H''@|$(HAVE_TERMIOS_H)|g' \
              -e 's/@''GNULIB_LOGIN_TTY''@/$(GNULIB_LOGIN_TTY)/g' \
              -e 's|@''HAVE_LOGIN_TTY''@|$(HAVE_LOGIN_TTY)|g' \
              -e 's|@''REPLACE_LOGIN_TTY''@|$(REPLACE_LOGIN_TTY)|g' \