Commit | Line | Data |
---|---|---|
c0c3707f CB |
1 | # glob.m4 serial 23 |
2 | dnl Copyright (C) 2005-2007, 2009-2019 Free Software Foundation, Inc. | |
6ec2e0f5 SDJ |
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 glob module assumes you want GNU glob, with glob_pattern_p etc, | |
8 | # rather than vanilla POSIX glob. This means your code should | |
9 | # always include <glob.h> for the glob prototypes. | |
10 | ||
11 | AC_DEFUN([gl_GLOB], | |
c0c3707f CB |
12 | [ |
13 | AC_REQUIRE([gl_GLOB_H]) | |
14 | ||
15 | AC_CHECK_FUNCS_ONCE([glob glob_pattern_p]) | |
16 | if test $ac_cv_func_glob = no; then | |
17 | HAVE_GLOB=0 | |
18 | else | |
6ec2e0f5 | 19 | |
c0c3707f CB |
20 | AC_CACHE_CHECK([for GNU glob interface version 1 or 2], |
21 | [gl_cv_gnu_glob_interface_version_1_2], | |
6ec2e0f5 SDJ |
22 | [ AC_COMPILE_IFELSE([AC_LANG_SOURCE( |
23 | [[#include <gnu-versions.h> | |
c0c3707f CB |
24 | char a[_GNU_GLOB_INTERFACE_VERSION == 1 || _GNU_GLOB_INTERFACE_VERSION == 2 ? 1 : -1];]])], |
25 | [gl_cv_gnu_glob_interface_version_1_2=yes], | |
26 | [gl_cv_gnu_glob_interface_version_1_2=no])]) | |
27 | if test "$gl_cv_gnu_glob_interface_version_1_2" = "no"; then | |
28 | REPLACE_GLOB=1 | |
6ec2e0f5 | 29 | fi |
6ec2e0f5 | 30 | |
c0c3707f CB |
31 | if test $REPLACE_GLOB = 0; then |
32 | AC_CACHE_CHECK([whether glob lists broken symlinks], | |
33 | [gl_cv_glob_lists_symlinks], | |
34 | [if test $cross_compiling != yes; then | |
35 | if ln -s conf-doesntexist conf$$-globtest 2>/dev/null; then | |
36 | gl_cv_glob_lists_symlinks=maybe | |
37 | else | |
38 | # If we can't make a symlink, then we cannot test this issue. Be | |
39 | # pessimistic about this. | |
40 | gl_cv_glob_lists_symlinks=no | |
41 | fi | |
42 | if test $gl_cv_glob_lists_symlinks = maybe; then | |
43 | AC_RUN_IFELSE( | |
44 | [AC_LANG_PROGRAM( | |
45 | [[#include <stddef.h> | |
46 | #include <glob.h>]], | |
47 | [[glob_t found; | |
48 | if (glob ("conf*-globtest", 0, NULL, &found) == GLOB_NOMATCH) | |
49 | return 1; | |
50 | ]])], | |
51 | [gl_cv_glob_lists_symlinks=yes], | |
52 | [gl_cv_glob_lists_symlinks=no], | |
53 | [dnl We don't get here. | |
54 | : | |
55 | ]) | |
56 | fi | |
57 | rm -f conf$$-globtest | |
58 | else | |
59 | gl_cv_glob_lists_symlinks="$gl_cross_guess_normal" | |
60 | fi | |
61 | ]) | |
62 | case "$gl_cv_glob_lists_symlinks" in | |
63 | *yes) ;; | |
64 | *) REPLACE_GLOB=1 ;; | |
65 | esac | |
66 | fi | |
6ec2e0f5 | 67 | |
c0c3707f | 68 | fi |
6ec2e0f5 | 69 | |
c0c3707f CB |
70 | if test $ac_cv_func_glob_pattern_p = no; then |
71 | HAVE_GLOB_PATTERN_P=0 | |
72 | else | |
73 | if test $REPLACE_GLOB = 1; then | |
74 | REPLACE_GLOB_PATTERN_P=1 | |
6ec2e0f5 SDJ |
75 | fi |
76 | fi | |
77 | ||
c0c3707f CB |
78 | if test $HAVE_GLOB = 0 || test $REPLACE_GLOB = 1; then |
79 | gl_REPLACE_GLOB_H | |
80 | fi | |
6ec2e0f5 SDJ |
81 | ]) |
82 | ||
c0c3707f | 83 | # Prerequisites of lib/glob.c and lib/globfree.c. |
6ec2e0f5 SDJ |
84 | AC_DEFUN([gl_PREREQ_GLOB], |
85 | [ | |
c0c3707f CB |
86 | AC_REQUIRE([gl_CHECK_TYPE_STRUCT_DIRENT_D_TYPE]) |
87 | AC_CHECK_HEADERS_ONCE([unistd.h]) | |
88 | AC_CHECK_FUNCS_ONCE([getlogin_r getpwnam_r]) | |
6ec2e0f5 | 89 | ]) |