annotate m4/getopt.m4 @ 5838:dcdcb5e92aa2

* getopt.m4 (gl_GETOPT): Check for Solaris 10 bug, not decl, when possible.
author Paul Eggert <eggert@cs.ucla.edu>
date Tue, 10 May 2005 19:11:00 +0000
parents 16b0f8ffe787
children 5b580599ba01
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5838
dcdcb5e92aa2 * getopt.m4 (gl_GETOPT): Check for Solaris 10 bug, not decl, when
Paul Eggert <eggert@cs.ucla.edu>
parents: 5819
diff changeset
1 # getopt.m4 serial 9
5819
16b0f8ffe787 * getopt.m4 (gl_GETOPT): Check for Solaris 10 getopt, and avoid
Paul Eggert <eggert@cs.ucla.edu>
parents: 5611
diff changeset
2 dnl Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
5611
87c42e194f4a Use an all-permissive copyright notice, recommended by RMS.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5478
diff changeset
3 dnl This file is free software; the Free Software Foundation
87c42e194f4a Use an all-permissive copyright notice, recommended by RMS.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5478
diff changeset
4 dnl gives unlimited permission to copy and/or distribute it,
87c42e194f4a Use an all-permissive copyright notice, recommended by RMS.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5478
diff changeset
5 dnl with or without modifications, as long as this notice is preserved.
4107
7c1a6b73f48e An autoconf macro for its associated module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
6
5193
f9f7d9ea394a (gl_GETOPT_SUBSTITUTE, gl_PREREQ_GETOPT): New macros.
Paul Eggert <eggert@cs.ucla.edu>
parents: 4653
diff changeset
7 # The getopt module assume you want GNU getopt, with getopt_long etc,
f9f7d9ea394a (gl_GETOPT_SUBSTITUTE, gl_PREREQ_GETOPT): New macros.
Paul Eggert <eggert@cs.ucla.edu>
parents: 4653
diff changeset
8 # rather than vanilla POSIX getopt. This means your your code should
f9f7d9ea394a (gl_GETOPT_SUBSTITUTE, gl_PREREQ_GETOPT): New macros.
Paul Eggert <eggert@cs.ucla.edu>
parents: 4653
diff changeset
9 # always include <getopt.h> for the getopt prototypes.
f9f7d9ea394a (gl_GETOPT_SUBSTITUTE, gl_PREREQ_GETOPT): New macros.
Paul Eggert <eggert@cs.ucla.edu>
parents: 4653
diff changeset
10
f9f7d9ea394a (gl_GETOPT_SUBSTITUTE, gl_PREREQ_GETOPT): New macros.
Paul Eggert <eggert@cs.ucla.edu>
parents: 4653
diff changeset
11 AC_DEFUN([gl_GETOPT_SUBSTITUTE],
f9f7d9ea394a (gl_GETOPT_SUBSTITUTE, gl_PREREQ_GETOPT): New macros.
Paul Eggert <eggert@cs.ucla.edu>
parents: 4653
diff changeset
12 [
f9f7d9ea394a (gl_GETOPT_SUBSTITUTE, gl_PREREQ_GETOPT): New macros.
Paul Eggert <eggert@cs.ucla.edu>
parents: 4653
diff changeset
13 GETOPT_H=getopt.h
f9f7d9ea394a (gl_GETOPT_SUBSTITUTE, gl_PREREQ_GETOPT): New macros.
Paul Eggert <eggert@cs.ucla.edu>
parents: 4653
diff changeset
14 AC_LIBOBJ([getopt])
f9f7d9ea394a (gl_GETOPT_SUBSTITUTE, gl_PREREQ_GETOPT): New macros.
Paul Eggert <eggert@cs.ucla.edu>
parents: 4653
diff changeset
15 AC_LIBOBJ([getopt1])
5427
e314bbc551bf (gl_GETOPT_SUBSTITUTE): Define __GETOPT_PREFIX instead
Paul Eggert <eggert@cs.ucla.edu>
parents: 5423
diff changeset
16 AC_DEFINE([__GETOPT_PREFIX], [[rpl_]],
e314bbc551bf (gl_GETOPT_SUBSTITUTE): Define __GETOPT_PREFIX instead
Paul Eggert <eggert@cs.ucla.edu>
parents: 5423
diff changeset
17 [Define to rpl_ if the getopt replacement functions and variables
e314bbc551bf (gl_GETOPT_SUBSTITUTE): Define __GETOPT_PREFIX instead
Paul Eggert <eggert@cs.ucla.edu>
parents: 5423
diff changeset
18 should be used.])
5193
f9f7d9ea394a (gl_GETOPT_SUBSTITUTE, gl_PREREQ_GETOPT): New macros.
Paul Eggert <eggert@cs.ucla.edu>
parents: 4653
diff changeset
19 AC_SUBST([GETOPT_H])
f9f7d9ea394a (gl_GETOPT_SUBSTITUTE, gl_PREREQ_GETOPT): New macros.
Paul Eggert <eggert@cs.ucla.edu>
parents: 4653
diff changeset
20 ])
f9f7d9ea394a (gl_GETOPT_SUBSTITUTE, gl_PREREQ_GETOPT): New macros.
Paul Eggert <eggert@cs.ucla.edu>
parents: 4653
diff changeset
21
4107
7c1a6b73f48e An autoconf macro for its associated module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
22 AC_DEFUN([gl_GETOPT],
7c1a6b73f48e An autoconf macro for its associated module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
23 [
5193
f9f7d9ea394a (gl_GETOPT_SUBSTITUTE, gl_PREREQ_GETOPT): New macros.
Paul Eggert <eggert@cs.ucla.edu>
parents: 4653
diff changeset
24 gl_PREREQ_GETOPT
f9f7d9ea394a (gl_GETOPT_SUBSTITUTE, gl_PREREQ_GETOPT): New macros.
Paul Eggert <eggert@cs.ucla.edu>
parents: 4653
diff changeset
25
5478
fca5a7f08a72 (gl_GETOPT): Check if GETOPT_H is already set, in
Sergey Poznyakoff <gray@gnu.org.ua>
parents: 5427
diff changeset
26 if test -z "$GETOPT_H"; then
fca5a7f08a72 (gl_GETOPT): Check if GETOPT_H is already set, in
Sergey Poznyakoff <gray@gnu.org.ua>
parents: 5427
diff changeset
27 GETOPT_H=
fca5a7f08a72 (gl_GETOPT): Check if GETOPT_H is already set, in
Sergey Poznyakoff <gray@gnu.org.ua>
parents: 5427
diff changeset
28 AC_CHECK_HEADERS([getopt.h], [], [GETOPT_H=getopt.h])
5819
16b0f8ffe787 * getopt.m4 (gl_GETOPT): Check for Solaris 10 getopt, and avoid
Paul Eggert <eggert@cs.ucla.edu>
parents: 5611
diff changeset
29 if test -z "$GETOPT_H"; then
16b0f8ffe787 * getopt.m4 (gl_GETOPT): Check for Solaris 10 getopt, and avoid
Paul Eggert <eggert@cs.ucla.edu>
parents: 5611
diff changeset
30 AC_CHECK_FUNCS([getopt_long_only], [], [GETOPT_H=getopt.h])
16b0f8ffe787 * getopt.m4 (gl_GETOPT): Check for Solaris 10 getopt, and avoid
Paul Eggert <eggert@cs.ucla.edu>
parents: 5611
diff changeset
31 fi
5193
f9f7d9ea394a (gl_GETOPT_SUBSTITUTE, gl_PREREQ_GETOPT): New macros.
Paul Eggert <eggert@cs.ucla.edu>
parents: 4653
diff changeset
32
5478
fca5a7f08a72 (gl_GETOPT): Check if GETOPT_H is already set, in
Sergey Poznyakoff <gray@gnu.org.ua>
parents: 5427
diff changeset
33 dnl BSD getopt_long uses an incompatible method to reset option processing,
fca5a7f08a72 (gl_GETOPT): Check if GETOPT_H is already set, in
Sergey Poznyakoff <gray@gnu.org.ua>
parents: 5427
diff changeset
34 dnl and (as of 2004-10-15) mishandles optional option-arguments.
5819
16b0f8ffe787 * getopt.m4 (gl_GETOPT): Check for Solaris 10 getopt, and avoid
Paul Eggert <eggert@cs.ucla.edu>
parents: 5611
diff changeset
35 if test -z "$GETOPT_H"; then
16b0f8ffe787 * getopt.m4 (gl_GETOPT): Check for Solaris 10 getopt, and avoid
Paul Eggert <eggert@cs.ucla.edu>
parents: 5611
diff changeset
36 AC_CHECK_DECL([optreset], [GETOPT_H=getopt.h], [], [#include <getopt.h>])
16b0f8ffe787 * getopt.m4 (gl_GETOPT): Check for Solaris 10 getopt, and avoid
Paul Eggert <eggert@cs.ucla.edu>
parents: 5611
diff changeset
37 fi
16b0f8ffe787 * getopt.m4 (gl_GETOPT): Check for Solaris 10 getopt, and avoid
Paul Eggert <eggert@cs.ucla.edu>
parents: 5611
diff changeset
38
16b0f8ffe787 * getopt.m4 (gl_GETOPT): Check for Solaris 10 getopt, and avoid
Paul Eggert <eggert@cs.ucla.edu>
parents: 5611
diff changeset
39 dnl Solaris 10 getopt doesn't handle `+' as a leading character in an
16b0f8ffe787 * getopt.m4 (gl_GETOPT): Check for Solaris 10 getopt, and avoid
Paul Eggert <eggert@cs.ucla.edu>
parents: 5611
diff changeset
40 dnl option string (as of 2005-05-05).
16b0f8ffe787 * getopt.m4 (gl_GETOPT): Check for Solaris 10 getopt, and avoid
Paul Eggert <eggert@cs.ucla.edu>
parents: 5611
diff changeset
41 if test -z "$GETOPT_H"; then
5838
dcdcb5e92aa2 * getopt.m4 (gl_GETOPT): Check for Solaris 10 bug, not decl, when
Paul Eggert <eggert@cs.ucla.edu>
parents: 5819
diff changeset
42 AC_CACHE_CHECK([for working GNU getopt function], [gl_cv_func_gnu_getopt],
dcdcb5e92aa2 * getopt.m4 (gl_GETOPT): Check for Solaris 10 bug, not decl, when
Paul Eggert <eggert@cs.ucla.edu>
parents: 5819
diff changeset
43 [AC_RUN_IFELSE(
dcdcb5e92aa2 * getopt.m4 (gl_GETOPT): Check for Solaris 10 bug, not decl, when
Paul Eggert <eggert@cs.ucla.edu>
parents: 5819
diff changeset
44 [AC_LANG_PROGRAM([#include <getopt.h>],
dcdcb5e92aa2 * getopt.m4 (gl_GETOPT): Check for Solaris 10 bug, not decl, when
Paul Eggert <eggert@cs.ucla.edu>
parents: 5819
diff changeset
45 [[
dcdcb5e92aa2 * getopt.m4 (gl_GETOPT): Check for Solaris 10 bug, not decl, when
Paul Eggert <eggert@cs.ucla.edu>
parents: 5819
diff changeset
46 char *myargv[3];
dcdcb5e92aa2 * getopt.m4 (gl_GETOPT): Check for Solaris 10 bug, not decl, when
Paul Eggert <eggert@cs.ucla.edu>
parents: 5819
diff changeset
47 myargv[0] = "conftest";
dcdcb5e92aa2 * getopt.m4 (gl_GETOPT): Check for Solaris 10 bug, not decl, when
Paul Eggert <eggert@cs.ucla.edu>
parents: 5819
diff changeset
48 myargv[1] = "-+";
dcdcb5e92aa2 * getopt.m4 (gl_GETOPT): Check for Solaris 10 bug, not decl, when
Paul Eggert <eggert@cs.ucla.edu>
parents: 5819
diff changeset
49 myargv[2] = 0;
dcdcb5e92aa2 * getopt.m4 (gl_GETOPT): Check for Solaris 10 bug, not decl, when
Paul Eggert <eggert@cs.ucla.edu>
parents: 5819
diff changeset
50 return getopt (2, myargv, "+a") != '?';
dcdcb5e92aa2 * getopt.m4 (gl_GETOPT): Check for Solaris 10 bug, not decl, when
Paul Eggert <eggert@cs.ucla.edu>
parents: 5819
diff changeset
51 ]])],
dcdcb5e92aa2 * getopt.m4 (gl_GETOPT): Check for Solaris 10 bug, not decl, when
Paul Eggert <eggert@cs.ucla.edu>
parents: 5819
diff changeset
52 [gl_cv_func_gnu_getopt=yes],
dcdcb5e92aa2 * getopt.m4 (gl_GETOPT): Check for Solaris 10 bug, not decl, when
Paul Eggert <eggert@cs.ucla.edu>
parents: 5819
diff changeset
53 [gl_cv_func_gnu_getopt=no],
dcdcb5e92aa2 * getopt.m4 (gl_GETOPT): Check for Solaris 10 bug, not decl, when
Paul Eggert <eggert@cs.ucla.edu>
parents: 5819
diff changeset
54 [dnl cross compiling - pessimistically guess based on decls
dcdcb5e92aa2 * getopt.m4 (gl_GETOPT): Check for Solaris 10 bug, not decl, when
Paul Eggert <eggert@cs.ucla.edu>
parents: 5819
diff changeset
55 dnl Solaris 10 getopt doesn't handle `+' as a leading character in an
dcdcb5e92aa2 * getopt.m4 (gl_GETOPT): Check for Solaris 10 bug, not decl, when
Paul Eggert <eggert@cs.ucla.edu>
parents: 5819
diff changeset
56 dnl option string (as of 2005-05-05).
dcdcb5e92aa2 * getopt.m4 (gl_GETOPT): Check for Solaris 10 bug, not decl, when
Paul Eggert <eggert@cs.ucla.edu>
parents: 5819
diff changeset
57 AC_CHECK_DECL([getopt_clip],
dcdcb5e92aa2 * getopt.m4 (gl_GETOPT): Check for Solaris 10 bug, not decl, when
Paul Eggert <eggert@cs.ucla.edu>
parents: 5819
diff changeset
58 [gl_cv_func_gnu_getopt=no], [gl_cv_func_gnu_getopt=yes],
dcdcb5e92aa2 * getopt.m4 (gl_GETOPT): Check for Solaris 10 bug, not decl, when
Paul Eggert <eggert@cs.ucla.edu>
parents: 5819
diff changeset
59 [#include <getopt.h>])])])
dcdcb5e92aa2 * getopt.m4 (gl_GETOPT): Check for Solaris 10 bug, not decl, when
Paul Eggert <eggert@cs.ucla.edu>
parents: 5819
diff changeset
60 if test "$gl_cv_func_gnu_getopt" = "no"; then
dcdcb5e92aa2 * getopt.m4 (gl_GETOPT): Check for Solaris 10 bug, not decl, when
Paul Eggert <eggert@cs.ucla.edu>
parents: 5819
diff changeset
61 GETOPT_H=getopt.h
dcdcb5e92aa2 * getopt.m4 (gl_GETOPT): Check for Solaris 10 bug, not decl, when
Paul Eggert <eggert@cs.ucla.edu>
parents: 5819
diff changeset
62 fi
5819
16b0f8ffe787 * getopt.m4 (gl_GETOPT): Check for Solaris 10 getopt, and avoid
Paul Eggert <eggert@cs.ucla.edu>
parents: 5611
diff changeset
63 fi
5354
4456e7b1cfcd (gl_GETOPT): Detect and reject the incompatible BSD
Paul Eggert <eggert@cs.ucla.edu>
parents: 5193
diff changeset
64
5478
fca5a7f08a72 (gl_GETOPT): Check if GETOPT_H is already set, in
Sergey Poznyakoff <gray@gnu.org.ua>
parents: 5427
diff changeset
65 if test -n "$GETOPT_H"; then
fca5a7f08a72 (gl_GETOPT): Check if GETOPT_H is already set, in
Sergey Poznyakoff <gray@gnu.org.ua>
parents: 5427
diff changeset
66 gl_GETOPT_SUBSTITUTE
fca5a7f08a72 (gl_GETOPT): Check if GETOPT_H is already set, in
Sergey Poznyakoff <gray@gnu.org.ua>
parents: 5427
diff changeset
67 fi
5193
f9f7d9ea394a (gl_GETOPT_SUBSTITUTE, gl_PREREQ_GETOPT): New macros.
Paul Eggert <eggert@cs.ucla.edu>
parents: 4653
diff changeset
68 fi
4107
7c1a6b73f48e An autoconf macro for its associated module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
69 ])
5193
f9f7d9ea394a (gl_GETOPT_SUBSTITUTE, gl_PREREQ_GETOPT): New macros.
Paul Eggert <eggert@cs.ucla.edu>
parents: 4653
diff changeset
70
f9f7d9ea394a (gl_GETOPT_SUBSTITUTE, gl_PREREQ_GETOPT): New macros.
Paul Eggert <eggert@cs.ucla.edu>
parents: 4653
diff changeset
71 # Prerequisites of lib/getopt*.
f9f7d9ea394a (gl_GETOPT_SUBSTITUTE, gl_PREREQ_GETOPT): New macros.
Paul Eggert <eggert@cs.ucla.edu>
parents: 4653
diff changeset
72 AC_DEFUN([gl_PREREQ_GETOPT], [:])