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,
7 AC_CACHE_CHECK([whether link(2) follows symlinks],
8 jm_ac_cv_func_link_follows_symlink,
10 dnl poor-man's AC_REQUIRE: FIXME: repair this once autoconf-3 provides
11 dnl the appropriate framework.
12 test -z "$ac_cv_header_unistd_h" \
13 && AC_CHECK_HEADERS(unistd.h)
15 # Create a regular file.
19 # include <sys/types.h>
20 # include <sys/stat.h>
25 # define SAME_INODE(Stat_buf_1, Stat_buf_2) \
26 ((Stat_buf_1).st_ino == (Stat_buf_2).st_ino \
27 && (Stat_buf_1).st_dev == (Stat_buf_2).st_dev)
32 const char *file = "conftest.file";
33 const char *sym = "conftest.sym";
34 const char *hard = "conftest.hard";
35 struct stat sb_file, sb_hard;
37 /* Create a symlink to the regular file. */
38 if (symlink (file, sym))
41 /* Create a hard link to that symlink. */
45 if (lstat (hard, &sb_hard))
47 if (lstat (file, &sb_file))
50 /* If the dev/inode of hard and file are the same, then
51 the link call followed the symlink. */
52 return SAME_INODE (sb_hard, sb_file) ? 0 : 1;
55 jm_ac_cv_func_link_follows_symlink=yes,
56 jm_ac_cv_func_link_follows_symlink=no,
57 jm_ac_cv_func_link_follows_symlink=yes dnl We're cross compiling.
60 if test $jm_ac_cv_func_link_follows_symlink = yes; then
61 AC_DEFINE(LINK_FOLLOWS_SYMLINKS, 1,
62 [Define if `link(2)' dereferences symbolic links.])