Ensure that getopt() gets declared by <unistd.h>.
authorBruno Haible <bruno@clisp.org>
Wed, 12 Aug 2009 15:25:09 +0000 (17:25 +0200)
committerBruno Haible <bruno@clisp.org>
Wed, 12 Aug 2009 15:25:09 +0000 (17:25 +0200)
ChangeLog
lib/unistd.in.h
m4/getopt.m4
m4/unistd_h.m4
modules/unistd

index fccd8abf909484fc553f27dd85b84b2df6c6ca2b..1f797cc1b7bff9eaafb9f9d85b0282c95393cec9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2009-08-12  Bruno Haible  <bruno@clisp.org>
+
+       Ensure that getopt() gets declared by <unistd.h>.
+       * lib/unistd.in.h: Conditionally include getopt.h.
+       * m4/getopt.m4 (gl_GETOPT_SUBSTITUTE): Require gl_UNISTD_H_DEFAULTS.
+       Set GNULIB_UNISTD_H_GETOPT.
+       * m4/unistd_h.m4 (gl_UNISTD_H_DEFAULTS): Initialize
+       GNULIB_UNISTD_H_GETOPT.
+       * modules/unistd (Makefile.am): Substitute GNULIB_UNISTD_H_GETOPT.
+
 2009-08-12  Bruno Haible  <bruno@clisp.org>
 
        Clarify logic.
index 28d52e5a4049b436044c9d32a435a3708195aa37..5cad6c8ad98b905bb8ed638ac20704bb4597b365 100644 (file)
 # include <sys/types.h>
 #endif
 
+/* Get getopt(), optarg, optind, opterr, optopt.  */
+#if @GNULIB_UNISTD_H_GETOPT@
+# include <getopt.h>
+#endif
+
 #if @GNULIB_GETHOSTNAME@
 /* Get all possible declarations of gethostname().  */
 # if @UNISTD_H_HAVE_WINSOCK2_H@
index 52478ece450f15c69541f300542373afdeac5f1b..66164c7abdb0efbf2cfb42629a50704ea1e59c90 100644 (file)
@@ -1,4 +1,4 @@
-# getopt.m4 serial 16
+# getopt.m4 serial 17
 dnl Copyright (C) 2002-2006, 2008-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,
@@ -10,9 +10,14 @@ dnl with or without modifications, as long as this notice is preserved.
 
 AC_DEFUN([gl_GETOPT_SUBSTITUTE],
 [
+  AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
+  dnl Arrange for getopt.h to be created.
+  gl_GETOPT_SUBSTITUTE_HEADER
+  dnl Arrange for unistd.h to include getopt.h.
+  GNULIB_UNISTD_H_GETOPT=1
+  dnl Arrange to compile the getopt implementation.
   AC_LIBOBJ([getopt])
   AC_LIBOBJ([getopt1])
-  gl_GETOPT_SUBSTITUTE_HEADER
   gl_PREREQ_GETOPT
 ])
 
index 16c40e539040c72546c08c11eac52e0953b21b5d..d7a89e1302b1c16e77dc82e5f3c176575255098f 100644 (file)
@@ -52,6 +52,7 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS],
   GNULIB_LSEEK=0;            AC_SUBST([GNULIB_LSEEK])
   GNULIB_READLINK=0;         AC_SUBST([GNULIB_READLINK])
   GNULIB_SLEEP=0;            AC_SUBST([GNULIB_SLEEP])
+  GNULIB_UNISTD_H_GETOPT=0;  AC_SUBST([GNULIB_UNISTD_H_GETOPT])
   GNULIB_UNISTD_H_SIGPIPE=0; AC_SUBST([GNULIB_UNISTD_H_SIGPIPE])
   GNULIB_WRITE=0;            AC_SUBST([GNULIB_WRITE])
   dnl Assume proper GNU behavior unless another module says otherwise.
index 0091a1218b7c53642376d43d5a06a6bd9bd3f212..06f77c5d34977d1afd5dece4deb4eade0c94d7fe 100644 (file)
@@ -44,6 +44,7 @@ unistd.h: unistd.in.h
              -e 's|@''GNULIB_LSEEK''@|$(GNULIB_LSEEK)|g' \
              -e 's|@''GNULIB_READLINK''@|$(GNULIB_READLINK)|g' \
              -e 's|@''GNULIB_SLEEP''@|$(GNULIB_SLEEP)|g' \
+             -e 's|@''GNULIB_UNISTD_H_GETOPT''@|$(GNULIB_UNISTD_H_GETOPT)|g' \
              -e 's|@''GNULIB_UNISTD_H_SIGPIPE''@|$(GNULIB_UNISTD_H_SIGPIPE)|g' \
              -e 's|@''GNULIB_WRITE''@|$(GNULIB_WRITE)|g' \
              -e 's|@''HAVE_DUP2''@|$(HAVE_DUP2)|g' \