getopt: fix inclusion guards for cygwin
authorEric Blake <ebb9@byu.net>
Thu, 24 Sep 2009 16:57:14 +0000 (10:57 -0600)
committerEric Blake <ebb9@byu.net>
Fri, 25 Sep 2009 01:27:18 +0000 (19:27 -0600)
commit6471b4628903c7b85e6922e53b4205103b506c97
tree85bb82e9ba23418f5f63597128caddc1a1c8f750
parentd2ce0449310435ff3ae29a08f74c21a961bd5e56
getopt: fix inclusion guards for cygwin

cygwin <unistd.h> includes <getopt.h>, but gnulib <getopt.h> includes
<unistd.h>, so system declarations were happening after gnulib
replacements, leading to multiply-defined rpl_readlink error on
cygwin 1.5.  The solution is to ensure that the system <unistd.h>
is complete prior to any of gnulib's contents, by picking up
system <getopt.h> in preference to a cycle to <unistd.h>.

* modules/getopt-posix (Depends-on): Add include-next.
(Makefile.am): Substitute more items in replacement header.
* m4/getopt.m4 (gl_GETOPT_CHECK_HEADERS): Also check for native
<getopt.h>.
* lib/getopt.in.h (includes): Use split inclusion guard, and
prefer <getopt.h> over include <unistd.h> when one is present.
(option): Also override name of 'struct option'.

Signed-off-by: Eric Blake <ebb9@byu.net>
ChangeLog
lib/getopt.in.h
m4/getopt.m4
modules/getopt-posix