Remove leftover generated .h files after config.status changed.
[gnulib.git] / m4 / glob.m4
1 # glob.m4 serial 12
2 dnl Copyright (C) 2005-2007, 2009-2011 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_SUBSTITUTE],
12 [
13   AC_LIBOBJ([glob])
14   gl_PREREQ_GLOB
15
16   GLOB_H=glob.h
17   AC_SUBST([GLOB_H])
18   AM_CONDITIONAL([GL_GENERATE_GLOB_H], [test -n "$GLOB_H"])
19 ])
20
21 AC_DEFUN([gl_GLOB],
22 [ GLOB_H=
23   AC_CHECK_HEADERS([glob.h], [], [GLOB_H=glob.h])
24
25   if test -z "$GLOB_H"; then
26     AC_CACHE_CHECK([for GNU glob interface version 1],
27       [gl_cv_gnu_glob_interface_version_1],
28 [     AC_COMPILE_IFELSE([AC_LANG_SOURCE(
29 [[#include <gnu-versions.h>
30 char a[_GNU_GLOB_INTERFACE_VERSION == 1 ? 1 : -1];]])],
31         [gl_cv_gnu_glob_interface_version_1=yes],
32         [gl_cv_gnu_glob_interface_version_1=no])])
33
34     if test "$gl_cv_gnu_glob_interface_version_1" = "no"; then
35       GLOB_H=glob.h
36     fi
37   fi
38
39   if test -z "$GLOB_H"; then
40     AC_CACHE_CHECK([whether glob lists broken symlinks],
41                    [gl_cv_glob_lists_symlinks],
42 [     if ln -s conf-doesntexist conf$$-globtest 2>/dev/null; then
43         gl_cv_glob_lists_symlinks=maybe
44       else
45         # If we can't make a symlink, then we cannot test this issue.  Be
46         # pessimistic about this.
47         gl_cv_glob_lists_symlinks=no
48       fi
49
50       if test $gl_cv_glob_lists_symlinks = maybe; then
51         AC_RUN_IFELSE([
52 AC_LANG_PROGRAM(
53 [[#include <stddef.h>
54 #include <glob.h>]],
55 [[glob_t found;
56 if (glob ("conf*-globtest", 0, NULL, &found) == GLOB_NOMATCH) return 1;]])],
57           [gl_cv_glob_lists_symlinks=yes],
58           [gl_cv_glob_lists_symlinks=no], [gl_cv_glob_lists_symlinks=no])
59       fi])
60
61     if test $gl_cv_glob_lists_symlinks = no; then
62       GLOB_H=glob.h
63     fi
64   fi
65
66   rm -f conf$$-globtest
67
68   if test -n "$GLOB_H"; then
69     AC_LIBOBJ([glob])
70     gl_PREREQ_GLOB
71   fi
72   AC_SUBST([GLOB_H])
73   AM_CONDITIONAL([GL_GENERATE_GLOB_H], [test -n "$GLOB_H"])
74 ])
75
76 # Prerequisites of lib/glob.*.
77 AC_DEFUN([gl_PREREQ_GLOB],
78 [
79   AC_REQUIRE([gl_CHECK_TYPE_STRUCT_DIRENT_D_TYPE])dnl
80   AC_REQUIRE([AC_C_RESTRICT])dnl
81   AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])dnl
82   AC_CHECK_HEADERS_ONCE([sys/cdefs.h unistd.h])dnl
83   if test $ac_cv_header_sys_cdefs_h = yes; then
84     HAVE_SYS_CDEFS_H=1
85   else
86     HAVE_SYS_CDEFS_H=0
87   fi
88   AC_SUBST([HAVE_SYS_CDEFS_H])
89   AC_CHECK_FUNCS_ONCE([fstatat getlogin_r getpwnam_r])dnl
90 ])