*** empty log message ***
[findutils.git] / m4 / stat.m4
blobc232df9a328aa2c268729515fc5f5a2f907063b6
1 #serial 2
3 dnl From Jim Meyering.
4 dnl Determine whether stat has the bug that it succeeds when given the
5 dnl zero-length file name argument.  The stat from SunOS4.1.4 and the Hurd
6 dnl (as of 1998-11-01) do this.
7 dnl
8 dnl If it does, then define HAVE_STAT_EMPTY_STRING_BUG and arrange to
9 dnl compile the wrapper function.
10 dnl
12 AC_DEFUN(jm_FUNC_STAT,
14  AC_CACHE_CHECK([whether stat accepts an empty string],
15   jm_cv_func_stat_empty_string_bug,
16   [AC_TRY_RUN([
17 #   include <sys/types.h>
18 #   include <sys/stat.h>
20     int
21     main ()
22     {
23       struct stat sbuf;
24       exit (stat ("", &sbuf) ? 1 : 0);
25     }
26           ],
27          jm_cv_func_stat_empty_string_bug=yes,
28          jm_cv_func_stat_empty_string_bug=no,
29          dnl When crosscompiling, assume stat is broken.
30          jm_cv_func_stat_empty_string_bug=yes)
31   ])
32   if test $jm_cv_func_stat_empty_string_bug = yes; then
34     LIBOBJS="$LIBOBJS stat.o"
36     if test $jm_cv_func_stat_empty_string_bug = yes; then
37       if test x = y; then
38         # This code is deliberately never run via ./configure.
39         # FIXME: this is a hack to make autoheader put the corresponding
40         # HAVE_* undef for this symbol in config.h.in.  This saves me the
41         # trouble of having to maintain the #undef in acconfig.h manually.
42         AC_CHECK_FUNCS(STAT_EMPTY_STRING_BUG)
43       fi
44       # Defining it this way (rather than via AC_DEFINE) short-circuits the
45       # autoheader check -- autoheader doesn't know it's already been taken
46       # care of by the hack above.
47       ac_kludge=HAVE_STAT_EMPTY_STRING_BUG
48       AC_DEFINE_UNQUOTED($ac_kludge)
49     fi
50   fi