getopt.m4
1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
## $Id$
## Check for getopt_long. This can't be done in AC_CHECK_FUNCS since
## the function can be present in different libraries (namely, libmysqlclient)
## but the necessary header files may be absent, thus AC_CHECK_FUNCS will
## mark function as existent, whereas the compilation will bail out.
AH_TEMPLATE(HAVE_GNU_GETOPT, [Define if your system has GNU getopt functions])
AC_DEFUN([MU_REPLACE_GNU_GETOPT],
[
AC_CHECK_HEADER([getopt.h],
mu_cv_have_getopt_h=yes
AC_DEFINE(HAVE_GETOPT_H,1,[Define if the system has getopt.h]),
mu_cv_have_getopt_h=no)
AC_CACHE_CHECK([for GNU getopt], mu_cv_have_gnu_getopt,
[
AC_TRY_RUN([
#include <unistd.h>
#ifdef HAVE_GETOPT_H
# include <getopt.h>
#endif
struct option longopt[] = {
"help", no_argument, 0, 'h',
(char*)0
};
main(argc, argv)
int argc; char **argv;
{
getopt_long_only(argc, argv, "h", longopt, (int*)0);
return 0;
} ],
mu_cv_have_gnu_getopt=yes,
mu_cv_have_gnu_getopt=no,
mu_cv_have_gnu_getopt=no)])
if test x"$mu_cv_have_gnu_getopt" != xyes ; then
mu_cv_have_getopt_h=no
MU_LIBOBJ(getopt)
MU_LIBOBJ(getopt1)
else
AC_DEFINE(HAVE_GNU_GETOPT)
fi
if test "$mu_cv_have_getopt_h" = no; then
MU_HEADER(getopt.h)
fi
])