From: Bruno Haible Date: Thu, 13 Apr 2023 19:43:51 +0000 (+0200) Subject: utmp: Avoid using HAVE_* macros in *.in.h files. X-Git-Tag: v1.0~1452 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=ffb4ed843f5a18175bc07ef190b9db700c3b5eba;p=gnulib.git 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. --- diff --git a/ChangeLog b/ChangeLog index 5e1fab0cfc..eb270cf699 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2023-04-13 Bruno Haible + + 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 getprogname: Avoid using HAVE_* macros in *.in.h files. diff --git a/lib/utmp.in.h b/lib/utmp.in.h index 895704cb1b..6c47ca7b2a 100644 --- a/lib/utmp.in.h +++ b/lib/utmp.in.h @@ -42,11 +42,11 @@ , not in . */ /* 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 -# elif HAVE_LIBUTIL_H /* FreeBSD, Haiku */ +# elif @HAVE_LIBUTIL_H@ /* FreeBSD, Haiku */ # include -# elif HAVE_TERMIOS_H /* Solaris */ +# elif @HAVE_TERMIOS_H@ /* Solaris */ # include # endif #endif diff --git a/m4/pty_h.m4 b/m4/pty_h.m4 index 1fce4b98e4..2c0f8bc9ea 100644 --- a/m4/pty_h.m4 +++ b/m4/pty_h.m4 @@ -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 , assume forkpty is declared there. HAVE_PTY_H=1 @@ -50,6 +44,19 @@ AC_DEFUN_ONCE([gl_PTY_H], ]], [forkpty openpty]) ]) +dnl Test for and . +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. diff --git a/m4/utmp_h.m4 b/m4/utmp_h.m4 index fff6dbdfe7..6dd5eb989b 100644 --- a/m4/utmp_h.m4 +++ b/m4/utmp_h.m4 @@ -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]) diff --git a/modules/utmp b/modules/utmp index 3a02f01364..d5ba411d87 100644 --- a/modules/utmp +++ b/modules/utmp @@ -4,6 +4,8 @@ A GNU-like . 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' \