.
[gnulib.git] / m4 / stat.m4
1 #serial 1
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 does this.
6 dnl
7 dnl If it doesn't, arrange to use the replacement function.
8 dnl
9 dnl If you use this macro in a package, you should
10 dnl add the following two lines to acconfig.h:
11 dnl  /* Define to rpl_stat if the replacement function should be used.  */
12 dnl  #undef stat
13 dnl
14
15 AC_DEFUN(jm_FUNC_STAT,
16 [
17  AC_CACHE_CHECK([for working stat], jm_cv_func_working_stat,
18   [AC_TRY_RUN([
19 #   include <sys/types.h>
20 #   include <sys/stat.h>
21
22     int
23     main ()
24     {
25       struct stat sbuf;
26       exit (stat ("", &sbuf) == 0 ? 1 : 0);
27     }
28           ],
29          jm_cv_func_working_stat=yes,
30          jm_cv_func_working_stat=no,
31          dnl When crosscompiling, assume stat is broken.
32          jm_cv_func_working_stat=no)
33   ])
34   if test $jm_cv_func_working_stat = no; then
35     LIBOBJS="$LIBOBJS stat.o"
36     AC_DEFINE_UNQUOTED(stat, rpl_stat)
37   fi
38 ])