2 dnl Run a program to determine whether whether link(2) follows symlinks.
3 dnl Set LINK_FOLLOWS_SYMLINKS accordingly.
5 AC_DEFUN([jm_AC_FUNC_LINK_FOLLOWS_SYMLINK],
8 [whether link(2) dereferences a symlink specified with a trailing slash],
9 jm_ac_cv_func_link_follows_symlink,
11 dnl poor-man's AC_REQUIRE: FIXME: repair this once autoconf-3 provides
12 dnl the appropriate framework.
13 test -z "$ac_cv_header_unistd_h" \
14 && AC_CHECK_HEADERS(unistd.h)
16 # Create a regular file.
20 # include <sys/types.h>
21 # include <sys/stat.h>
26 # define SAME_INODE(Stat_buf_1, Stat_buf_2) \
27 ((Stat_buf_1).st_ino == (Stat_buf_2).st_ino \
28 && (Stat_buf_1).st_dev == (Stat_buf_2).st_dev)
33 const char *file = "conftest.file";
34 const char *sym = "conftest.sym";
35 const char *hard = "conftest.hard";
36 struct stat sb_file, sb_hard;
38 /* Create a symlink to the regular file. */
39 if (symlink (file, sym))
42 /* Create a hard link to that symlink. */
46 if (lstat (hard, &sb_hard))
48 if (lstat (file, &sb_file))
51 /* If the dev/inode of hard and file are the same, then
52 the link call followed the symlink. */
53 return SAME_INODE (sb_hard, sb_file) ? 0 : 1;
56 jm_ac_cv_func_link_follows_symlink=yes,
57 jm_ac_cv_func_link_follows_symlink=no,
58 jm_ac_cv_func_link_follows_symlink=yes dnl We're cross compiling.
61 if test $jm_ac_cv_func_link_follows_symlink = yes; then
62 AC_DEFINE(LINK_FOLLOWS_SYMLINKS, 1,
63 [Define if `link(2)' dereferences symbolic links.])