.
[gnulib.git] / m4 / lstat.m4
1 #serial 1
2
3 dnl From Jim Meyering.
4 dnl Determine whether lstat has the bug that it succeeds when given the
5 dnl zero-length file name argument.  The lstat 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_lstat if the replacement function should be used.  */
12 dnl  #undef lstat
13 dnl
14
15 AC_DEFUN(jm_FUNC_LSTAT,
16 [
17  AC_CACHE_CHECK([for working lstat], jm_cv_func_working_lstat,
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 (lstat ("", &sbuf) == 0 ? 1 : 0);
27     }
28           ],
29          jm_cv_func_working_lstat=yes,
30          jm_cv_func_working_lstat=no,
31          dnl When crosscompiling, assume lstat is broken.
32          jm_cv_func_working_lstat=no)
33   ])
34   if test $jm_cv_func_working_lstat = no; then
35     LIBOBJS="$LIBOBJS lstat.o"
36     AC_DEFINE_UNQUOTED(lstat, rpl_lstat)
37   fi
38 ])