Build pty.h in the same way as all other replacement headers.
* lib/pty.in.h: New file.
* modules/pty (Files): Ship it.
(Makefile.am): Always build replacement.
* m4/pty.m4: Rename...
* m4/pty_h.m4: ...to this.
(gl_PTY): Modernize setting of witness macros; update check of
forkpty to take proper advantage of cache.
(gl_PTY_MODULE_INDICATOR, gl_PTY_H_DEFAULTS): New macros.
Signed-off-by: Eric Blake <eblake@redhat.com>
2010-03-19 Eric Blake <eblake@redhat.com>
+ pty: improve replacement header
+ * lib/pty.in.h: New file.
+ * modules/pty (Files): Ship it.
+ (Makefile.am): Always build replacement.
+ * m4/pty.m4: Rename...
+ * m4/pty_h.m4: ...to this.
+ (gl_PTY): Modernize setting of witness macros; update check of
+ forkpty to take proper advantage of cache.
+ (gl_PTY_MODULE_INDICATOR, gl_PTY_H_DEFAULTS): New macros.
+
getopt: avoid compiler warning
* lib/getopt.c (attribute_hidden): Remove unused macro.
--- /dev/null
+/* Substitute for and wrapper around <pty.h>.
+ Copyright (C) 2010 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+#ifndef _GL_PTY_H
+
+#if __GNUC__ >= 3
+@PRAGMA_SYSTEM_HEADER@
+#endif
+
+/* The include_next requires a split double-inclusion guard. */
+#if @HAVE_PTY_H@
+# @INCLUDE_NEXT@ @NEXT_PTY_H@
+#endif
+
+#ifndef _GL_PTY_H
+#define _GL_PTY_H
+
+/* Some platforms declare this in a different header than glibc. */
+#if @HAVE_UTIL_H@
+# include <util.h>
+#endif
+#if @HAVE_LIBUTIL_H@
+# include <libutil.h>
+#endif
+
+/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
+
+/* The definition of _GL_WARN_ON_USE is copied here. */
+
+
+/* Declare overridden functions. */
+
+#if 1 /* FIXME - split forkpty into separate module */
+#elif defined GNULIB_POSIXCHECK
+# undef forkpty
+# if HAVE_RAW_DECL_FORKPTY
+_GL_WARN_ON_USE (forkpty, "forkpty is not declared consistently - "
+ "use gnulib module pty for portability");
+# endif
+#endif
+
+#if 1 /* FIXME - split openpty into separate module */
+#elif defined GNULIB_POSIXCHECK
+# undef openpty
+# if HAVE_RAW_DECL_OPENPTY
+_GL_WARN_ON_USE (openpty, "openpty is not declared consistently - "
+ "use gnulib module pty for portability");
+# endif
+#endif
+
+
+#endif /* _GL_PTY_H */
+#endif /* _GL_PTY_H */
+++ /dev/null
-# pty.m4 serial 1
-dnl Copyright (C) 2009, 2010 Free Software Foundation, Inc.
-dnl This file is free software; the Free Software Foundation
-dnl gives unlimited permission to copy and/or distribute it,
-dnl with or without modifications, as long as this notice is preserved.
-
-# gl_PTY
-# ------
-# Make sure that pty.h provides forkpty, or sets up a replacement header.
-# Also define automake variable PTY_LIB to the library needed (if any).
-AC_DEFUN([gl_PTY],
-[
- PTY_H=''
- PTY_LIB=''
- # First make sure that pty.h provides forkpty, or setup the replacement.
- AC_CHECK_HEADERS_ONCE([pty.h])
- if test $ac_cv_header_pty_h != yes; then
- AC_CHECK_DECL([forkpty],,, [[#include <util.h>]])
- if test $ac_cv_have_decl_forkpty = no; then
- unset ac_cv_have_decl_forkpty
- AC_CHECK_DECL([forkpty],,, [[#include <libutil.h>]])
- if test $ac_cv_have_decl_forkpty = no; then
- AC_MSG_WARN([[Cannot find forkpty, build will likely fail]])
- else
- PTY_H='pty.h'
- PTY_HEADER='libutil.h'
- fi
- else
- PTY_H='pty.h'
- PTY_HEADER='util.h'
- fi
- fi
- # Second check for the library required for forkpty.
- save_LIBS="$LIBS"
- AC_SEARCH_LIBS([forkpty], [util],
- [if test "$ac_cv_search_forkpty" != "none required"; then
- PTY_LIB="$ac_cv_search_forkpty"
- fi])
- LIBS="$save_LIBS"
- AC_SUBST([PTY_H])
- AC_SUBST([PTY_LIB])
- AC_SUBST([PTY_HEADER])
-])
--- /dev/null
+# pty_h.m4 serial 2
+dnl Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+# gl_PTY
+# ------
+# Make sure that pty.h provides forkpty, or sets up a replacement header.
+# Also define automake variable PTY_LIB to the library needed (if any).
+AC_DEFUN_ONCE([gl_PTY],
+[
+ AC_REQUIRE([gl_PTY_H_DEFAULTS])
+
+ PTY_LIB=''
+ # First make sure that pty.h provides forkpty, or setup the replacement.
+ 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
+ AC_CHECK_DECLS([forkpty],,, [[
+#if HAVE_UTIL_H
+# include <util.h>
+#endif
+#if HAVE_LIBUTIL_H
+# include <libutil.h>
+#endif
+]])
+ if test $ac_cv_have_decl_forkpty = no; then
+ AC_MSG_WARN([[Cannot find forkpty, build will likely fail]])
+ fi
+ else # Have <pty.h>, assume forkpty is declared there.
+ HAVE_PTY_H=1
+ fi
+ AC_SUBST([HAVE_PTY_H])
+ dnl <pty.h> is always overridden, because of GNULIB_POSIXCHECK.
+ gl_CHECK_NEXT_HEADERS([pty.h])
+
+ # Second check for the library required for forkpty.
+ save_LIBS="$LIBS"
+ AC_SEARCH_LIBS([forkpty], [util],
+ [if test "$ac_cv_search_forkpty" != "none required"; then
+ PTY_LIB="$ac_cv_search_forkpty"
+ fi])
+ LIBS="$save_LIBS"
+ AC_SUBST([PTY_LIB])
+
+ dnl Check for declarations of anything we want to poison if the
+ dnl corresponding gnulib module is not in use.
+ gl_WARN_ON_USE_PREPARE([[
+#if HAVE_PTY_H
+# include <pty.h>
+#endif
+#if HAVE_UTIL_H
+# include <util.h>
+#endif
+#if HAVE_LIBUTIL_H
+# include <libutil.h>
+#endif
+ ]], [forkpty openpty])
+])
+
+AC_DEFUN([gl_PTY_MODULE_INDICATOR],
+[
+ dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
+ AC_REQUIRE([gl_PTY_H_DEFAULTS])
+ GNULIB_[]m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=1
+])
+
+AC_DEFUN([gl_PTY_H_DEFAULTS],
+[
+ dnl Assume proper GNU behavior unless another module says otherwise.
+ HAVE_UTIL_H=0; AC_SUBST([HAVE_UTIL_H])
+ HAVE_LIBUTIL_H=0; AC_SUBST([HAVE_LIBUTIL_H])
+])
A <pty.h> for systems that lacks it.
Files:
-m4/pty.m4
+lib/pty.in.h
+m4/pty_h.m4
+
+Depends-on:
+c++defs
+include_next
+warn-on-use
configure.ac:
gl_PTY
Makefile.am:
-BUILT_SOURCES += $(PTY_H)
+BUILT_SOURCES += pty.h
# We need the following in order to create <pty.h> when the system
# doesn't have one that works with the given compiler.
-pty.h:
+pty.h: pty.in.h $(CXXDEFS_H) $(WARN_ON_USE_H)
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
- echo '#include <'$(PTY_HEADER)'>'; \
+ sed -e 's|@''HAVE_PTY_H''@|$(HAVE_PTY_H)|g' \
+ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+ -e 's|@''NEXT_PTY_H''@|$(NEXT_PTY_H)|g' \
+ -e 's|@''HAVE_UTIL_H''@|$(HAVE_UTIL_H)|g' \
+ -e 's|@''HAVE_LIBUTIL_H''@|$(HAVE_LIBUTIL_H)|g' \
+ -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
+ -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
+ < $(srcdir)/pty.in.h; \
} > $@-t && \
- mv -f $@-t $@
+ mv $@-t $@
MOSTLYCLEANFILES += pty.h pty.h-t
Include: