Update gnulib to current upstream master
[deliverable/binutils-gdb.git] / gdb / gnulib / import / m4 / glob.m4
1 # glob.m4 serial 21
2 dnl Copyright (C) 2005-2007, 2009-2018 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 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],
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
19
20 AC_CACHE_CHECK([for GNU glob interface version 1 or 2],
21 [gl_cv_gnu_glob_interface_version_1_2],
22 [ AC_COMPILE_IFELSE([AC_LANG_SOURCE(
23 [[#include <gnu-versions.h>
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
29 fi
30
31 if test $REPLACE_GLOB = 0; then
32 AC_CACHE_CHECK([whether glob lists broken symlinks],
33 [gl_cv_glob_lists_symlinks],
34 [if ln -s conf-doesntexist conf$$-globtest 2>/dev/null; then
35 gl_cv_glob_lists_symlinks=maybe
36 else
37 # If we can't make a symlink, then we cannot test this issue. Be
38 # pessimistic about this.
39 gl_cv_glob_lists_symlinks=no
40 fi
41 if test $gl_cv_glob_lists_symlinks = maybe; then
42 AC_RUN_IFELSE(
43 [AC_LANG_PROGRAM(
44 [[#include <stddef.h>
45 #include <glob.h>]],
46 [[glob_t found;
47 if (glob ("conf*-globtest", 0, NULL, &found) == GLOB_NOMATCH)
48 return 1;
49 ]])],
50 [gl_cv_glob_lists_symlinks=yes],
51 [gl_cv_glob_lists_symlinks=no],
52 [gl_cv_glob_lists_symlinks=no])
53 fi
54 rm -f conf$$-globtest
55 ])
56 if test $gl_cv_glob_lists_symlinks = no; then
57 REPLACE_GLOB=1
58 fi
59 fi
60
61 fi
62
63 if test $ac_cv_func_glob_pattern_p = no; then
64 HAVE_GLOB_PATTERN_P=0
65 else
66 if test $REPLACE_GLOB = 1; then
67 REPLACE_GLOB_PATTERN_P=1
68 fi
69 fi
70
71 if test $HAVE_GLOB = 0 || test $REPLACE_GLOB = 1; then
72 gl_REPLACE_GLOB_H
73 fi
74 ])
75
76 # Prerequisites of lib/glob.c and lib/globfree.c.
77 AC_DEFUN([gl_PREREQ_GLOB],
78 [
79 AC_REQUIRE([gl_CHECK_TYPE_STRUCT_DIRENT_D_TYPE])
80 AC_CHECK_HEADERS_ONCE([unistd.h])
81 AC_CHECK_FUNCS_ONCE([getlogin_r getpwnam_r])
82 ])
This page took 0.031244 seconds and 4 git commands to generate.