diff options
author | Ton Voon <tonvoon@users.sourceforge.net> | 2007-01-24 22:47:25 +0000 |
---|---|---|
committer | Ton Voon <tonvoon@users.sourceforge.net> | 2007-01-24 22:47:25 +0000 |
commit | fe856aa957978504137c1d425815d4ed8a22be40 (patch) | |
tree | a5bb46ce0e64b2056f75700eadbf27aba7c39418 /gl/m4/getopt.m4 | |
parent | 210f39bc84cfbb21cd72dc054e43f13815ee0616 (diff) | |
download | monitoring-plugins-fe856aa957978504137c1d425815d4ed8a22be40.tar.gz |
Sync with gnulib - lots of extraneous code removed in preference to GNU code
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1580 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'gl/m4/getopt.m4')
-rw-r--r-- | gl/m4/getopt.m4 | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/gl/m4/getopt.m4 b/gl/m4/getopt.m4 new file mode 100644 index 00000000..c0a73b2c --- /dev/null +++ b/gl/m4/getopt.m4 | |||
@@ -0,0 +1,83 @@ | |||
1 | # getopt.m4 serial 13 | ||
2 | dnl Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. | ||
3 | dnl This file is free software; the Free Software Foundation | ||
4 | dnl gives unlimited permission to copy and/or distribute it, | ||
5 | dnl with or without modifications, as long as this notice is preserved. | ||
6 | |||
7 | # The getopt module assume you want GNU getopt, with getopt_long etc, | ||
8 | # rather than vanilla POSIX getopt. This means your code should | ||
9 | # always include <getopt.h> for the getopt prototypes. | ||
10 | |||
11 | AC_DEFUN([gl_GETOPT_SUBSTITUTE], | ||
12 | [ | ||
13 | AC_LIBOBJ([getopt]) | ||
14 | 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_]], | ||
23 | [Define to rpl_ if the getopt replacement functions and variables | ||
24 | should be used.]) | ||
25 | AC_SUBST([GETOPT_H]) | ||
26 | ]) | ||
27 | |||
28 | AC_DEFUN([gl_GETOPT_CHECK_HEADERS], | ||
29 | [ | ||
30 | if test -z "$GETOPT_H"; then | ||
31 | AC_CHECK_HEADERS([getopt.h], [], [GETOPT_H=getopt.h]) | ||
32 | fi | ||
33 | |||
34 | if test -z "$GETOPT_H"; then | ||
35 | AC_CHECK_FUNCS([getopt_long_only], [], [GETOPT_H=getopt.h]) | ||
36 | fi | ||
37 | |||
38 | dnl BSD getopt_long uses an incompatible method to reset option processing, | ||
39 | dnl and (as of 2004-10-15) mishandles optional option-arguments. | ||
40 | if test -z "$GETOPT_H"; then | ||
41 | AC_CHECK_DECL([optreset], [GETOPT_H=getopt.h], [], [#include <getopt.h>]) | ||
42 | fi | ||
43 | |||
44 | dnl Solaris 10 getopt doesn't handle `+' as a leading character in an | ||
45 | dnl option string (as of 2005-05-05). | ||
46 | if test -z "$GETOPT_H"; then | ||
47 | AC_CACHE_CHECK([for working GNU getopt function], [gl_cv_func_gnu_getopt], | ||
48 | [AC_RUN_IFELSE( | ||
49 | [AC_LANG_PROGRAM([#include <getopt.h>], | ||
50 | [[ | ||
51 | char *myargv[3]; | ||
52 | myargv[0] = "conftest"; | ||
53 | myargv[1] = "-+"; | ||
54 | myargv[2] = 0; | ||
55 | return getopt (2, myargv, "+a") != '?'; | ||
56 | ]])], | ||
57 | [gl_cv_func_gnu_getopt=yes], | ||
58 | [gl_cv_func_gnu_getopt=no], | ||
59 | [dnl cross compiling - pessimistically guess based on decls | ||
60 | dnl Solaris 10 getopt doesn't handle `+' as a leading character in an | ||
61 | dnl option string (as of 2005-05-05). | ||
62 | AC_CHECK_DECL([getopt_clip], | ||
63 | [gl_cv_func_gnu_getopt=no], [gl_cv_func_gnu_getopt=yes], | ||
64 | [#include <getopt.h>])])]) | ||
65 | if test "$gl_cv_func_gnu_getopt" = "no"; then | ||
66 | GETOPT_H=getopt.h | ||
67 | fi | ||
68 | fi | ||
69 | ]) | ||
70 | |||
71 | AC_DEFUN([gl_GETOPT_IFELSE], | ||
72 | [ | ||
73 | AC_REQUIRE([gl_GETOPT_CHECK_HEADERS]) | ||
74 | AS_IF([test -n "$GETOPT_H"], [$1], [$2]) | ||
75 | ]) | ||
76 | |||
77 | AC_DEFUN([gl_GETOPT], [gl_GETOPT_IFELSE([gl_GETOPT_SUBSTITUTE])]) | ||
78 | |||
79 | # Prerequisites of lib/getopt*. | ||
80 | AC_DEFUN([gl_PREREQ_GETOPT], | ||
81 | [ | ||
82 | AC_CHECK_DECLS_ONCE([getenv]) | ||
83 | ]) | ||