declare smobs in alloc.c
[bpt/emacs.git] / m4 / lstat.m4
CommitLineData
f64898ab 1# serial 26
ae0d7250 2
ba318903 3# Copyright (C) 1997-2001, 2003-2014 Free Software Foundation, Inc.
ae0d7250
PE
4#
5# This file is free software; the Free Software Foundation
6# gives unlimited permission to copy and/or distribute it,
7# with or without modifications, as long as this notice is preserved.
8
9dnl From Jim Meyering.
10
11AC_DEFUN([gl_FUNC_LSTAT],
12[
13 AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS])
14 dnl If lstat does not exist, the replacement <sys/stat.h> does
15 dnl "#define lstat stat", and lstat.c is a no-op.
16 AC_CHECK_FUNCS_ONCE([lstat])
17 if test $ac_cv_func_lstat = yes; then
bf4846e7 18 AC_REQUIRE([gl_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK])
caf8a9b2
PE
19 case "$gl_cv_func_lstat_dereferences_slashed_symlink" in
20 *no)
21 REPLACE_LSTAT=1
22 ;;
23 esac
ae0d7250
PE
24 else
25 HAVE_LSTAT=0
26 fi
27])
28
8aeb5be9 29# Prerequisites of lib/lstat.c.
f64898ab 30AC_DEFUN([gl_PREREQ_LSTAT], [:])
8aeb5be9
PE
31
32AC_DEFUN([gl_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK],
33[
34 dnl We don't use AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK any more, because it
35 dnl is no longer maintained in Autoconf and because it invokes AC_LIBOBJ.
ae0d7250 36 AC_CACHE_CHECK([whether lstat correctly handles trailing slash],
8aeb5be9 37 [gl_cv_func_lstat_dereferences_slashed_symlink],
ae0d7250
PE
38 [rm -f conftest.sym conftest.file
39 echo >conftest.file
40 if test "$as_ln_s" = "ln -s" && ln -s conftest.file conftest.sym; then
41 AC_RUN_IFELSE(
42 [AC_LANG_PROGRAM(
43 [AC_INCLUDES_DEFAULT],
44 [[struct stat sbuf;
45 /* Linux will dereference the symlink and fail, as required by
46 POSIX. That is better in the sense that it means we will not
47 have to compile and use the lstat wrapper. */
48 return lstat ("conftest.sym/", &sbuf) == 0;
49 ]])],
8aeb5be9
PE
50 [gl_cv_func_lstat_dereferences_slashed_symlink=yes],
51 [gl_cv_func_lstat_dereferences_slashed_symlink=no],
caf8a9b2
PE
52 [case "$host_os" in
53 # Guess yes on glibc systems.
54 *-gnu*) gl_cv_func_lstat_dereferences_slashed_symlink="guessing yes" ;;
55 # If we don't know, assume the worst.
56 *) gl_cv_func_lstat_dereferences_slashed_symlink="guessing no" ;;
57 esac
ae0d7250
PE
58 ])
59 else
60 # If the 'ln -s' command failed, then we probably don't even
61 # have an lstat function.
caf8a9b2 62 gl_cv_func_lstat_dereferences_slashed_symlink="guessing no"
ae0d7250
PE
63 fi
64 rm -f conftest.sym conftest.file
65 ])
caf8a9b2
PE
66 case "$gl_cv_func_lstat_dereferences_slashed_symlink" in
67 *yes)
68 AC_DEFINE_UNQUOTED([LSTAT_FOLLOWS_SLASHED_SYMLINK], [1],
69 [Define to 1 if 'lstat' dereferences a symlink specified
70 with a trailing slash.])
71 ;;
72 esac
ae0d7250 73])