[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
getopt: make declaration available from <unistd.h>
From: |
Bruno Haible |
Subject: |
getopt: make declaration available from <unistd.h> |
Date: |
Wed, 12 Aug 2009 17:28:10 +0200 |
User-agent: |
KMail/1.9.9 |
POSIX specifies that getopt() and the four variables optarg etc. should be
declared in <unistd.h>. But gnulib provides them only in <getopt.h>. This
fixes it.
2009-08-12 Bruno Haible <address@hidden>
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.
--- lib/unistd.in.h.orig 2009-08-12 17:22:21.000000000 +0200
+++ lib/unistd.in.h 2009-08-12 16:59:58.000000000 +0200
@@ -43,6 +43,11 @@
# 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@
--- m4/getopt.m4.orig 2009-08-12 17:22:21.000000000 +0200
+++ m4/getopt.m4 2009-08-12 17:21:29.000000000 +0200
@@ -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 @@
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
])
--- m4/unistd_h.m4.orig 2009-08-12 17:22:21.000000000 +0200
+++ m4/unistd_h.m4 2009-08-12 17:00:27.000000000 +0200
@@ -52,6 +52,7 @@
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.
--- modules/unistd.orig 2009-08-12 17:22:21.000000000 +0200
+++ modules/unistd 2009-08-12 17:00:48.000000000 +0200
@@ -44,6 +44,7 @@
-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' \
- getopt: make declaration available from <unistd.h>,
Bruno Haible <=