bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Build failure on Darwin


From: Simon Josefsson
Subject: Re: Build failure on Darwin
Date: Mon, 07 Dec 2009 11:40:58 +0100
User-agent: Gnus/5.110011 (No Gnus v0.11) Emacs/23.1 (gnu/linux)

Simon Josefsson <address@hidden> writes:

> address@hidden (Ludovic Courtès) writes:
>
>> Hello,
>>
>> Current Git fails to build on Darwin:
>>
>>   http://hydra.nixos.org/build/175517/log/raw
>>
>> I haven’t investigated any further, though.
>
> Darwin has forkpty in util.h instead of the glibc name of pty.h.  I'm
> working on a gnulib module to provide compatibility mappings... stay
> tuned.

Here it is.  Tested on glibc debian and Mac OS X 10.5.  Objections to
pushing this to gnulib?  Once that has been done, we could import it to
inetutils.  I will also be able to test whether InetUtils actually
builds and works on my PowerBook after this.

/Simon

>From b2b1a270872c51d14cb4db088e9a97663464a6d5 Mon Sep 17 00:00:00 2001
From: Simon Josefsson <address@hidden>
Date: Mon, 7 Dec 2009 11:38:17 +0100
Subject: [PATCH] Add new pty module.

---
 ChangeLog                  |    8 ++++++
 doc/glibc-headers/pty.texi |    6 ++++-
 m4/pty.m4                  |   29 +++++++++++++++++++++++
 modules/pty                |   30 ++++++++++++++++++++++++
 modules/pty-tests          |    7 +++++
 tests/test-pty.c           |   55 ++++++++++++++++++++++++++++++++++++++++++++
 6 files changed, 134 insertions(+), 1 deletions(-)
 create mode 100644 m4/pty.m4
 create mode 100644 modules/pty
 create mode 100644 modules/pty-tests
 create mode 100644 tests/test-pty.c

diff --git a/ChangeLog b/ChangeLog
index 977285c..47c86dd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2009-12-07  Simon Josefsson  <address@hidden>
+
+       * modules/pty: New file.
+       * modules/pty-tests: New file.
+       * doc/glibc-headers/pty.texi: New file.
+       * m4/pty.m4: New file.
+       * tests/test-pty.c: New file.
+
 2009-12-06  Bruno Haible  <address@hidden>
 
        * lib/cloexec.c (dup_cloexec): Fix handling of _gl_register_dup return
diff --git a/doc/glibc-headers/pty.texi b/doc/glibc-headers/pty.texi
index 26d7764..ec0d7fa 100644
--- a/doc/glibc-headers/pty.texi
+++ b/doc/glibc-headers/pty.texi
@@ -16,10 +16,14 @@ Documentation:
 
@uref{http://www.kernel.org/doc/man-pages/online/pages/man3/openpty.3.html,,man 
openpty}.
 @end itemize
 
-Gnulib module: ---
+Gnulib module: pty
 
 Portability problems fixed by Gnulib:
 @itemize
address@hidden
+This header file is missing on Mac OS X where the functions are
+declared by util.h instead, and there is no requirement to link with
address@hidden
 @end itemize
 
 Portability problems not fixed by Gnulib:
diff --git a/m4/pty.m4 b/m4/pty.m4
new file mode 100644
index 0000000..3ceca6e
--- /dev/null
+++ b/m4/pty.m4
@@ -0,0 +1,29 @@
+# pty.m4 serial 1
+dnl Copyright (C) 2009 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
+# --------------------
+# Test whether forkpty is provided by pty.h and -lutil.  When forkpty
+# is declared by util.h and available without -lutil instead (as it is
+# on Mac OS X), provide a pty.h replacement.  Always define $(PTY_LIB)
+# to the library.
+AC_DEFUN([gl_PTY],
+[
+  PTY_H=''
+  PTY_LIB='-lutil'
+  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
+      AC_MSG_WARN([[Cannot find forkpty, build will likely fail]])
+    else
+      PTY_H='pty.h'
+      PTY_LIB=''
+    fi
+  fi
+  AC_SUBST([PTY_H])
+  AC_SUBST([PTY_LIB])
+])
diff --git a/modules/pty b/modules/pty
new file mode 100644
index 0000000..0488df3
--- /dev/null
+++ b/modules/pty
@@ -0,0 +1,30 @@
+Description:
+A <pty.h> for systems that lacks it.
+
+Files:
+m4/pty.m4
+
+configure.ac:
+gl_PTY
+
+Makefile.am:
+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:
+       echo '#include <util.h>' > address@hidden && \
+       mv address@hidden $@
+MOSTLYCLEANFILES += pty.h pty.h-t
+
+Include:
+<pty.h>
+
+Link:
+$(PTY_LIB)
+
+License:
+LGPL
+
+Maintainer:
+Simon Josefsson
diff --git a/modules/pty-tests b/modules/pty-tests
new file mode 100644
index 0000000..2d8b9c3
--- /dev/null
+++ b/modules/pty-tests
@@ -0,0 +1,7 @@
+Files:
+tests/test-pty.c
+
+Makefile.am:
+TESTS += test-pty
+check_PROGRAMS += test-pty
+test_pty_LDADD = $(PTY_LIB)
diff --git a/tests/test-pty.c b/tests/test-pty.c
new file mode 100644
index 0000000..cd24f0d
--- /dev/null
+++ b/tests/test-pty.c
@@ -0,0 +1,55 @@
+/* Test of pty.h and openpty/forkpty functions.
+   Copyright (C) 2009 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 3 of the License, 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, see <http://www.gnu.org/licenses/>.  */
+
+/* Written by Simon Josefsson <address@hidden>, 2009.  */
+
+#include <config.h>
+
+#include <pty.h>
+
+#include <stdio.h>
+
+int
+main ()
+{
+  int res;
+  int amaster;
+  int aslave;
+
+  res = openpty (&amaster, &aslave, NULL, NULL, NULL);
+  if (res != 0)
+    {
+      printf ("openpty returned %d\n", res);
+      return 1;
+    }
+
+  res = forkpty (&amaster, NULL, NULL, NULL);
+  if (res == 0)
+    {
+      /* child process */
+    }
+  else if (res > 0)
+    {
+      /* parent */
+    }
+  else
+    {
+      printf ("forkpty returned %d\n", res);
+      return 1;
+    }
+
+  return 0;
+}
-- 
1.6.5.3





reply via email to

[Prev in Thread] Current Thread [Next in Thread]