Mercurial > emacs
comparison m4/getopt.m4 @ 112450:16ddab338c43
Remove HAVE_RAW_DECL_CHOWN etc. from config.h
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Sun, 23 Jan 2011 20:53:39 -0800 |
parents | c81ff7082a9a |
children |
comparison
equal
deleted
inserted
replaced
112447:bcecab2ad22d | 112450:16ddab338c43 |
---|---|
1 # getopt.m4 serial 33 | 1 # getopt.m4 serial 34 |
2 dnl Copyright (C) 2002-2006, 2008-2011 Free Software Foundation, Inc. | 2 dnl Copyright (C) 2002-2006, 2008-2011 Free Software Foundation, Inc. |
3 dnl This file is free software; the Free Software Foundation | 3 dnl This file is free software; the Free Software Foundation |
4 dnl gives unlimited permission to copy and/or distribute it, | 4 dnl gives unlimited permission to copy and/or distribute it, |
5 dnl with or without modifications, as long as this notice is preserved. | 5 dnl with or without modifications, as long as this notice is preserved. |
6 | 6 |
71 fi | 71 fi |
72 | 72 |
73 dnl Test whether the function getopt_long is available. | 73 dnl Test whether the function getopt_long is available. |
74 if test -z "$gl_replace_getopt" && test $gl_getopt_required = GNU; then | 74 if test -z "$gl_replace_getopt" && test $gl_getopt_required = GNU; then |
75 AC_CHECK_FUNCS([getopt_long_only], [], [gl_replace_getopt=yes]) | 75 AC_CHECK_FUNCS([getopt_long_only], [], [gl_replace_getopt=yes]) |
76 fi | |
77 | |
78 dnl BSD getopt_long uses an incompatible method to reset option processing. | |
79 dnl Existence of the variable, in and of itself, is not a reason to replace | |
80 dnl getopt, but knowledge of the variable is needed to determine how to | |
81 dnl reset and whether a reset reparses the environment. | |
82 dnl Solaris supports neither optreset nor optind=0, but keeps no state that | |
83 dnl needs a reset beyond setting optind=1; detect Solaris by getopt_clip. | |
84 if test -z "$gl_replace_getopt"; then | |
85 AC_CHECK_DECLS([optreset], [], | |
86 [AC_CHECK_DECLS([getopt_clip], [], [], | |
87 [[#include <getopt.h>]]) | |
88 ], | |
89 [[#include <getopt.h>]]) | |
90 fi | 76 fi |
91 | 77 |
92 dnl mingw's getopt (in libmingwex.a) does weird things when the options | 78 dnl mingw's getopt (in libmingwex.a) does weird things when the options |
93 dnl strings starts with '+' and it's not the first call. Some internal state | 79 dnl strings starts with '+' and it's not the first call. Some internal state |
94 dnl is left over from earlier calls, and neither setting optind = 0 nor | 80 dnl is left over from earlier calls, and neither setting optind = 0 nor |
100 dnl behavior with getopt-gnu. | 86 dnl behavior with getopt-gnu. |
101 if test -z "$gl_replace_getopt"; then | 87 if test -z "$gl_replace_getopt"; then |
102 AC_CACHE_CHECK([whether getopt is POSIX compatible], | 88 AC_CACHE_CHECK([whether getopt is POSIX compatible], |
103 [gl_cv_func_getopt_posix], | 89 [gl_cv_func_getopt_posix], |
104 [ | 90 [ |
91 dnl BSD getopt_long uses an incompatible method to reset | |
92 dnl option processing. Existence of the variable, in and of | |
93 dnl itself, is not a reason to replace getopt, but knowledge | |
94 dnl of the variable is needed to determine how to reset and | |
95 dnl whether a reset reparses the environment. Solaris | |
96 dnl supports neither optreset nor optind=0, but keeps no state | |
97 dnl that needs a reset beyond setting optind=1; detect Solaris | |
98 dnl by getopt_clip. | |
99 AC_COMPILE_IFELSE( | |
100 [AC_LANG_PROGRAM( | |
101 [[#include <unistd.h>]], | |
102 [[int *p = &optreset; return optreset;]])], | |
103 [gl_optind_min=1], | |
104 [AC_COMPILE_IFELSE( | |
105 [AC_LANG_PROGRAM( | |
106 [[#include <getopt.h>]], | |
107 [[return !getopt_clip;]])], | |
108 [gl_optind_min=1], | |
109 [gl_optind_min=0])]) | |
110 | |
105 dnl This test fails on mingw and succeeds on many other platforms. | 111 dnl This test fails on mingw and succeeds on many other platforms. |
112 gl_save_CPPFLAGS=$CPPFLAGS | |
113 CPPFLAGS="$CPPFLAGS -DOPTIND_MIN=$gl_optind_min" | |
106 AC_RUN_IFELSE([AC_LANG_SOURCE([[ | 114 AC_RUN_IFELSE([AC_LANG_SOURCE([[ |
107 #include <unistd.h> | 115 #include <unistd.h> |
108 #include <stdlib.h> | 116 #include <stdlib.h> |
109 #include <string.h> | 117 #include <string.h> |
110 | |
111 #if !HAVE_DECL_OPTRESET && !HAVE_DECL_GETOPT_CLIP | |
112 # define OPTIND_MIN 0 | |
113 #else | |
114 # define OPTIND_MIN 1 | |
115 #endif | |
116 | 118 |
117 int | 119 int |
118 main () | 120 main () |
119 { | 121 { |
120 { | 122 { |
199 mingw*) gl_cv_func_getopt_posix="guessing no";; | 201 mingw*) gl_cv_func_getopt_posix="guessing no";; |
200 darwin* | aix*) gl_cv_func_getopt_posix="guessing no";; | 202 darwin* | aix*) gl_cv_func_getopt_posix="guessing no";; |
201 *) gl_cv_func_getopt_posix="guessing yes";; | 203 *) gl_cv_func_getopt_posix="guessing yes";; |
202 esac | 204 esac |
203 ]) | 205 ]) |
206 CPPFLAGS=$gl_save_CPPFLAGS | |
204 ]) | 207 ]) |
205 case "$gl_cv_func_getopt_posix" in | 208 case "$gl_cv_func_getopt_posix" in |
206 *no) gl_replace_getopt=yes ;; | 209 *no) gl_replace_getopt=yes ;; |
207 esac | 210 esac |
208 fi | 211 fi |