[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCHv2 1/3] pty: improve replacement header
From: |
Eric Blake |
Subject: |
[PATCHv2 1/3] pty: improve replacement header |
Date: |
Thu, 18 Mar 2010 20:28:36 -0600 |
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 <address@hidden>
---
ChangeLog | 12 ++++++++
lib/pty.in.h | 67 ++++++++++++++++++++++++++++++++++++++++++++++++
m4/pty.m4 | 43 ------------------------------
m4/pty_h.m4 | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
modules/pty | 24 +++++++++++++---
5 files changed, 179 insertions(+), 48 deletions(-)
create mode 100644 lib/pty.in.h
delete mode 100644 m4/pty.m4
create mode 100644 m4/pty_h.m4
diff --git a/ChangeLog b/ChangeLog
index 58be46a..73d2cd5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2010-03-18 Eric Blake <address@hidden>
+
+ 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.
+
2010-03-18 Bruno Haible <address@hidden>
Fix link errors on Solaris 8.
diff --git a/lib/pty.in.h b/lib/pty.in.h
new file mode 100644
index 0000000..8d80f8a
--- /dev/null
+++ b/lib/pty.in.h
@@ -0,0 +1,67 @@
+/* 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
address@hidden@
+#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 */
diff --git a/m4/pty.m4 b/m4/pty.m4
deleted file mode 100644
index 35ff929..0000000
--- a/m4/pty.m4
+++ /dev/null
@@ -1,43 +0,0 @@
-# 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])
-])
diff --git a/m4/pty_h.m4 b/m4/pty_h.m4
new file mode 100644
index 0000000..3b6d910
--- /dev/null
+++ b/m4/pty_h.m4
@@ -0,0 +1,81 @@
+# 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])
+])
diff --git a/modules/pty b/modules/pty
index 66cecef..ef064be 100644
--- a/modules/pty
+++ b/modules/pty
@@ -2,22 +2,36 @@ Description:
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 address@hidden $@ && \
{ 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; \
} > address@hidden && \
- mv -f address@hidden $@
+ mv address@hidden $@
MOSTLYCLEANFILES += pty.h pty.h-t
Include:
--
1.6.6.1
- Re: [PATCH 2/3] forkpty, openpty: split functions into new modules, (continued)
- Re: [PATCH 2/3] forkpty, openpty: split functions into new modules, Bruno Haible, 2010/03/19
- [PATCH 1/3] pty: improve replacement header, Eric Blake, 2010/03/18
- Re: [PATCH 1/3] pty: improve replacement header, Bruno Haible, 2010/03/18
- Re: [PATCH 1/3] pty: improve replacement header, Bruno Haible, 2010/03/19
- [PATCH 3/3] forkpty, openpty: prefer glibc's const-safe prototype, Eric Blake, 2010/03/18
- Re: [PATCH 3/3] forkpty, openpty: prefer glibc's const-safe prototype, Bruno Haible, 2010/03/18
- Re: [PATCH 3/3] forkpty, openpty: prefer glibc's const-safe prototype, Eric Blake, 2010/03/18
- [PATCHv2 1/3] pty: improve replacement header,
Eric Blake <=
- [PATCHv2 2/3] forkpty, openpty: split functions into new modules, Eric Blake, 2010/03/18
- Re: [PATCHv2 2/3] forkpty, openpty: split functions into new modules, Bruno Haible, 2010/03/21
- Re: [PATCHv2 2/3] forkpty, openpty: split functions into new modules, Eric Blake, 2010/03/22
- [PATCHv2 3/3] forkpty, openpty: prefer glibc's const-safe prototype, Eric Blake, 2010/03/18
- Re: [PATCHv2 3/3] forkpty, openpty: prefer glibc's const-safe prototype, Bruno Haible, 2010/03/19