1 |
# getopt.m4 serial 9 |
# getopt.m4 serial 10 |
2 |
dnl Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc. |
dnl Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc. |
3 |
dnl This file is free software; the Free Software Foundation |
dnl This file is free software; the Free Software Foundation |
4 |
dnl gives unlimited permission to copy and/or distribute it, |
dnl gives unlimited permission to copy and/or distribute it, |
10 |
|
|
11 |
AC_DEFUN([gl_GETOPT_SUBSTITUTE], |
AC_DEFUN([gl_GETOPT_SUBSTITUTE], |
12 |
[ |
[ |
|
GETOPT_H=getopt.h |
|
13 |
AC_LIBOBJ([getopt]) |
AC_LIBOBJ([getopt]) |
14 |
AC_LIBOBJ([getopt1]) |
AC_LIBOBJ([getopt1]) |
15 |
|
gl_GETOPT_SUBSTITUTE_HEADER |
16 |
|
gl_PREREQ_GETOPT |
17 |
|
]) |
18 |
|
|
19 |
|
AC_DEFUN([gl_GETOPT_SUBSTITUTE_HEADER], |
20 |
|
[ |
21 |
|
GETOPT_H=getopt.h |
22 |
AC_DEFINE([__GETOPT_PREFIX], [[rpl_]], |
AC_DEFINE([__GETOPT_PREFIX], [[rpl_]], |
23 |
[Define to rpl_ if the getopt replacement functions and variables |
[Define to rpl_ if the getopt replacement functions and variables |
24 |
should be used.]) |
should be used.]) |
25 |
AC_SUBST([GETOPT_H]) |
AC_SUBST([GETOPT_H]) |
26 |
]) |
]) |
27 |
|
|
28 |
AC_DEFUN([gl_GETOPT], |
AC_DEFUN([gl_GETOPT_CHECK_HEADERS], |
29 |
[ |
[ |
30 |
gl_PREREQ_GETOPT |
GETOPT_H= |
31 |
|
AC_CHECK_HEADERS([getopt.h], [], [GETOPT_H=getopt.h]) |
32 |
if test -z "$GETOPT_H"; then |
if test -z "$GETOPT_H"; then |
33 |
GETOPT_H= |
AC_CHECK_FUNCS([getopt_long_only], [], [GETOPT_H=getopt.h]) |
34 |
AC_CHECK_HEADERS([getopt.h], [], [GETOPT_H=getopt.h]) |
fi |
|
if test -z "$GETOPT_H"; then |
|
|
AC_CHECK_FUNCS([getopt_long_only], [], [GETOPT_H=getopt.h]) |
|
|
fi |
|
35 |
|
|
36 |
dnl BSD getopt_long uses an incompatible method to reset option processing, |
dnl BSD getopt_long uses an incompatible method to reset option processing, |
37 |
dnl and (as of 2004-10-15) mishandles optional option-arguments. |
dnl and (as of 2004-10-15) mishandles optional option-arguments. |
38 |
if test -z "$GETOPT_H"; then |
if test -z "$GETOPT_H"; then |
39 |
AC_CHECK_DECL([optreset], [GETOPT_H=getopt.h], [], [#include <getopt.h>]) |
AC_CHECK_DECL([optreset], [GETOPT_H=getopt.h], [], [#include <getopt.h>]) |
40 |
fi |
fi |
41 |
|
|
42 |
dnl Solaris 10 getopt doesn't handle `+' as a leading character in an |
dnl Solaris 10 getopt doesn't handle `+' as a leading character in an |
43 |
dnl option string (as of 2005-05-05). |
dnl option string (as of 2005-05-05). |
44 |
if test -z "$GETOPT_H"; then |
if test -z "$GETOPT_H"; then |
45 |
AC_CACHE_CHECK([for working GNU getopt function], [gl_cv_func_gnu_getopt], |
AC_CACHE_CHECK([for working GNU getopt function], [gl_cv_func_gnu_getopt], |
46 |
[AC_RUN_IFELSE( |
[AC_RUN_IFELSE( |
47 |
[AC_LANG_PROGRAM([#include <getopt.h>], |
[AC_LANG_PROGRAM([#include <getopt.h>], |
48 |
[[ |
[[ |
49 |
char *myargv[3]; |
char *myargv[3]; |
50 |
myargv[0] = "conftest"; |
myargv[0] = "conftest"; |
51 |
myargv[1] = "-+"; |
myargv[1] = "-+"; |
52 |
myargv[2] = 0; |
myargv[2] = 0; |
53 |
return getopt (2, myargv, "+a") != '?'; |
return getopt (2, myargv, "+a") != '?'; |
54 |
]])], |
]])], |
55 |
[gl_cv_func_gnu_getopt=yes], |
[gl_cv_func_gnu_getopt=yes], |
56 |
[gl_cv_func_gnu_getopt=no], |
[gl_cv_func_gnu_getopt=no], |
57 |
[dnl cross compiling - pessimistically guess based on decls |
[dnl cross compiling - pessimistically guess based on decls |
58 |
dnl Solaris 10 getopt doesn't handle `+' as a leading character in an |
dnl Solaris 10 getopt doesn't handle `+' as a leading character in an |
59 |
dnl option string (as of 2005-05-05). |
dnl option string (as of 2005-05-05). |
60 |
AC_CHECK_DECL([getopt_clip], |
AC_CHECK_DECL([getopt_clip], |
61 |
[gl_cv_func_gnu_getopt=no], [gl_cv_func_gnu_getopt=yes], |
[gl_cv_func_gnu_getopt=no], [gl_cv_func_gnu_getopt=yes], |
62 |
[#include <getopt.h>])])]) |
[#include <getopt.h>])])]) |
63 |
if test "$gl_cv_func_gnu_getopt" = "no"; then |
if test "$gl_cv_func_gnu_getopt" = "no"; then |
64 |
GETOPT_H=getopt.h |
GETOPT_H=getopt.h |
|
fi |
|
|
fi |
|
|
|
|
|
if test -n "$GETOPT_H"; then |
|
|
gl_GETOPT_SUBSTITUTE |
|
65 |
fi |
fi |
66 |
fi |
fi |
67 |
]) |
]) |
68 |
|
|
69 |
|
AC_DEFUN([gl_GETOPT_IFELSE], |
70 |
|
[ |
71 |
|
AC_REQUIRE([gl_GETOPT_CHECK_HEADERS]) |
72 |
|
AS_IF([test -n "$GETOPT_H"], [$1], [$2]) |
73 |
|
]) |
74 |
|
|
75 |
|
AC_DEFUN([gl_GETOPT], [gl_GETOPT_IFELSE([gl_GETOPT_SUBSTITUTE])]) |
76 |
|
|
77 |
# Prerequisites of lib/getopt*. |
# Prerequisites of lib/getopt*. |
78 |
AC_DEFUN([gl_PREREQ_GETOPT], [:]) |
AC_DEFUN([gl_PREREQ_GETOPT], [:]) |