annotate m4/getopt.m4 @ 400:573ed4940625 3.0-beta1 3.0-beta1

Fixed inclusion of documentation in make dist
author lost@l-w.ca
date Fri, 23 Jul 2010 17:32:29 -0600
parents 7987ee447833
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
398
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
1 # getopt.m4 serial 24
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
2 dnl Copyright (C) 2002-2006, 2008-2010 Free Software Foundation, Inc.
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
3 dnl This file is free software; the Free Software Foundation
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
4 dnl gives unlimited permission to copy and/or distribute it,
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
5 dnl with or without modifications, as long as this notice is preserved.
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
6
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
7 # Request a POSIX compliant getopt function.
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
8 AC_DEFUN([gl_FUNC_GETOPT_POSIX],
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
9 [
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
10 m4_divert_text([DEFAULTS], [gl_getopt_required=POSIX])
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
11 AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
12 gl_GETOPT_IFELSE([
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
13 gl_REPLACE_GETOPT
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
14 ],
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
15 [])
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
16 ])
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
17
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
18 # Request a POSIX compliant getopt function with GNU extensions (such as
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
19 # options with optional arguments) and the functions getopt_long,
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
20 # getopt_long_only.
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
21 AC_DEFUN([gl_FUNC_GETOPT_GNU],
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
22 [
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
23 m4_divert_text([INIT_PREPARE], [gl_getopt_required=GNU])
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
24
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
25 AC_REQUIRE([gl_FUNC_GETOPT_POSIX])
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
26 ])
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
27
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
28 # Request the gnulib implementation of the getopt functions unconditionally.
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
29 # argp.m4 uses this.
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
30 AC_DEFUN([gl_REPLACE_GETOPT],
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
31 [
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
32 dnl Arrange for getopt.h to be created.
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
33 gl_GETOPT_SUBSTITUTE_HEADER
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
34 dnl Arrange for unistd.h to include getopt.h.
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
35 GNULIB_UNISTD_H_GETOPT=1
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
36 dnl Arrange to compile the getopt implementation.
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
37 AC_LIBOBJ([getopt])
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
38 AC_LIBOBJ([getopt1])
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
39 gl_PREREQ_GETOPT
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
40 ])
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
41
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
42 # emacs' configure.in uses this.
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
43 AC_DEFUN([gl_GETOPT_IFELSE],
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
44 [
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
45 AC_REQUIRE([gl_GETOPT_CHECK_HEADERS])
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
46 AS_IF([test -n "$gl_replace_getopt"], [$1], [$2])
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
47 ])
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
48
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
49 # Determine whether to replace the entire getopt facility.
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
50 AC_DEFUN([gl_GETOPT_CHECK_HEADERS],
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
51 [
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
52 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
53
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
54 dnl Persuade Solaris <unistd.h> to declare optarg, optind, opterr, optopt.
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
55 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
56
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
57 gl_CHECK_NEXT_HEADERS([getopt.h])
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
58 AC_CHECK_HEADERS_ONCE([getopt.h])
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
59 if test $ac_cv_header_getopt_h = yes; then
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
60 HAVE_GETOPT_H=1
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
61 else
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
62 HAVE_GETOPT_H=0
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
63 fi
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
64 AC_SUBST([HAVE_GETOPT_H])
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
65
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
66 gl_replace_getopt=
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
67
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
68 dnl Test whether <getopt.h> is available.
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
69 if test -z "$gl_replace_getopt" && test $gl_getopt_required = GNU; then
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
70 AC_CHECK_HEADERS([getopt.h], [], [gl_replace_getopt=yes])
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
71 fi
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
72
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
73 dnl Test whether the function getopt_long is available.
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
74 if test -z "$gl_replace_getopt" && test $gl_getopt_required = GNU; then
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
75 AC_CHECK_FUNCS([getopt_long_only], [], [gl_replace_getopt=yes])
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
76 fi
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
77
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
78 dnl BSD getopt_long uses an incompatible method to reset option processing.
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
79 dnl Existence of the variable, in and of itself, is not a reason to replace
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
80 dnl getopt, but knowledge of the variable is needed to determine how to
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
81 dnl reset and whether a reset reparses the environment.
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
82 if test -z "$gl_replace_getopt" && test $gl_getopt_required = GNU; then
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
83 AC_CHECK_DECLS([optreset], [], [],
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
84 [[#include <getopt.h>]])
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
85 fi
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
86
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
87 dnl mingw's getopt (in libmingwex.a) does weird things when the options
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
88 dnl strings starts with '+' and it's not the first call. Some internal state
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
89 dnl is left over from earlier calls, and neither setting optind = 0 nor
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
90 dnl setting optreset = 1 get rid of this internal state.
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
91 dnl POSIX is silent on optind vs. optreset, so we allow either behavior.
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
92 if test -z "$gl_replace_getopt"; then
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
93 AC_CACHE_CHECK([whether getopt is POSIX compatible],
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
94 [gl_cv_func_getopt_posix],
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
95 [
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
96 dnl This test fails on mingw and succeeds on all other platforms.
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
97 AC_RUN_IFELSE([AC_LANG_SOURCE([[
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
98 #include <unistd.h>
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
99 #include <stdlib.h>
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
100 #include <string.h>
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
101
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
102 #if !HAVE_DECL_OPTRESET
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
103 # define OPTIND_MIN 0
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
104 #else
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
105 # define OPTIND_MIN 1
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
106 #endif
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
107
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
108 int
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
109 main ()
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
110 {
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
111 {
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
112 int argc = 0;
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
113 char *argv[10];
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
114 int c;
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
115
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
116 argv[argc++] = "program";
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
117 argv[argc++] = "-a";
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
118 argv[argc++] = "foo";
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
119 argv[argc++] = "bar";
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
120 argv[argc] = NULL;
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
121 optind = OPTIND_MIN;
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
122 opterr = 0;
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
123
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
124 c = getopt (argc, argv, "ab");
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
125 if (!(c == 'a'))
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
126 return 1;
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
127 c = getopt (argc, argv, "ab");
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
128 if (!(c == -1))
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
129 return 2;
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
130 if (!(optind == 2))
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
131 return 3;
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
132 }
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
133 /* Some internal state exists at this point. */
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
134 {
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
135 int argc = 0;
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
136 char *argv[10];
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
137 int c;
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
138
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
139 argv[argc++] = "program";
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
140 argv[argc++] = "donald";
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
141 argv[argc++] = "-p";
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
142 argv[argc++] = "billy";
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
143 argv[argc++] = "duck";
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
144 argv[argc++] = "-a";
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
145 argv[argc++] = "bar";
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
146 argv[argc] = NULL;
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
147 optind = OPTIND_MIN;
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
148 opterr = 0;
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
149
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
150 c = getopt (argc, argv, "+abp:q:");
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
151 if (!(c == -1))
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
152 return 4;
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
153 if (!(strcmp (argv[0], "program") == 0))
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
154 return 5;
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
155 if (!(strcmp (argv[1], "donald") == 0))
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
156 return 6;
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
157 if (!(strcmp (argv[2], "-p") == 0))
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
158 return 7;
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
159 if (!(strcmp (argv[3], "billy") == 0))
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
160 return 8;
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
161 if (!(strcmp (argv[4], "duck") == 0))
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
162 return 9;
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
163 if (!(strcmp (argv[5], "-a") == 0))
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
164 return 10;
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
165 if (!(strcmp (argv[6], "bar") == 0))
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
166 return 11;
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
167 if (!(optind == 1))
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
168 return 12;
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
169 }
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
170
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
171 return 0;
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
172 }
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
173 ]])],
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
174 [gl_cv_func_getopt_posix=yes], [gl_cv_func_getopt_posix=no],
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
175 [case "$host_os" in
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
176 mingw*) gl_cv_func_getopt_posix="guessing no";;
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
177 *) gl_cv_func_getopt_posix="guessing yes";;
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
178 esac
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
179 ])
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
180 ])
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
181 case "$gl_cv_func_getopt_posix" in
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
182 *no) gl_replace_getopt=yes ;;
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
183 esac
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
184 fi
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
185
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
186 if test -z "$gl_replace_getopt" && test $gl_getopt_required = GNU; then
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
187 AC_CACHE_CHECK([for working GNU getopt function], [gl_cv_func_getopt_gnu],
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
188 [# Even with POSIXLY_CORRECT, the GNU extension of leading '-' in the
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
189 # optstring is necessary for programs like m4 that have POSIX-mandated
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
190 # semantics for supporting options interspersed with files.
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
191 # Also, since getopt_long is a GNU extension, we require optind=0.
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
192 gl_had_POSIXLY_CORRECT=${POSIXLY_CORRECT:+yes}
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
193 POSIXLY_CORRECT=1
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
194 export POSIXLY_CORRECT
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
195 AC_RUN_IFELSE(
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
196 [AC_LANG_PROGRAM([[#include <getopt.h>
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
197 #include <stddef.h>
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
198 #include <string.h>
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
199 ]], [[
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
200 /* This code succeeds on glibc 2.8, OpenBSD 4.0, Cygwin, mingw,
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
201 and fails on MacOS X 10.5, AIX 5.2, HP-UX 11, IRIX 6.5,
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
202 OSF/1 5.1, Solaris 10. */
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
203 {
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
204 char *myargv[3];
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
205 myargv[0] = "conftest";
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
206 myargv[1] = "-+";
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
207 myargv[2] = 0;
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
208 opterr = 0;
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
209 if (getopt (2, myargv, "+a") != '?')
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
210 return 1;
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
211 }
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
212 /* This code succeeds on glibc 2.8, mingw,
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
213 and fails on MacOS X 10.5, OpenBSD 4.0, AIX 5.2, HP-UX 11,
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
214 IRIX 6.5, OSF/1 5.1, Solaris 10, Cygwin 1.5.x. */
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
215 {
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
216 char *argv[] = { "program", "-p", "foo", "bar", NULL };
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
217
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
218 optind = 1;
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
219 if (getopt (4, argv, "p::") != 'p')
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
220 return 2;
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
221 if (optarg != NULL)
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
222 return 3;
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
223 if (getopt (4, argv, "p::") != -1)
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
224 return 4;
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
225 if (optind != 2)
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
226 return 5;
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
227 }
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
228 /* This code succeeds on glibc 2.8 and fails on Cygwin 1.7.0. */
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
229 {
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
230 char *argv[] = { "program", "foo", "-p", NULL };
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
231 optind = 0;
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
232 if (getopt (3, argv, "-p") != 1)
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
233 return 6;
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
234 if (getopt (3, argv, "-p") != 'p')
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
235 return 7;
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
236 }
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
237 return 0;
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
238 ]])],
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
239 [gl_cv_func_getopt_gnu=yes],
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
240 [gl_cv_func_getopt_gnu=no],
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
241 [dnl Cross compiling. Guess based on host and declarations.
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
242 case $host_os:$ac_cv_have_decl_optreset in
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
243 *-gnu*:* | mingw*:*) gl_cv_func_getopt_gnu=no;;
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
244 *:yes) gl_cv_func_getopt_gnu=no;;
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
245 *) gl_cv_func_getopt_gnu=yes;;
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
246 esac
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
247 ])
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
248 if test "$gl_had_POSIXLY_CORRECT" != yes; then
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
249 AS_UNSET([POSIXLY_CORRECT])
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
250 fi
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
251 ])
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
252 if test "$gl_cv_func_getopt_gnu" = "no"; then
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
253 gl_replace_getopt=yes
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
254 fi
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
255 fi
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
256 ])
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
257
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
258 # emacs' configure.in uses this.
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
259 AC_DEFUN([gl_GETOPT_SUBSTITUTE_HEADER],
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
260 [
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
261 GETOPT_H=getopt.h
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
262 AC_DEFINE([__GETOPT_PREFIX], [[rpl_]],
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
263 [Define to rpl_ if the getopt replacement functions and variables
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
264 should be used.])
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
265 AC_SUBST([GETOPT_H])
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
266 ])
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
267
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
268 # Prerequisites of lib/getopt*.
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
269 # emacs' configure.in uses this.
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
270 AC_DEFUN([gl_PREREQ_GETOPT],
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
271 [
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
272 AC_CHECK_DECLS_ONCE([getenv])
7987ee447833 Added generated files for release
lost@l-w.ca
parents:
diff changeset
273 ])