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 # Create a regular file.
14 # include <sys/types.h>
15 # include <sys/stat.h>
20 # define SAME_INODE(Stat_buf_1, Stat_buf_2) \
21 ((Stat_buf_1).st_ino == (Stat_buf_2).st_ino \
22 && (Stat_buf_1).st_dev == (Stat_buf_2).st_dev)
27 const char *file = "conftest.file";
28 const char *sym = "conftest.sym";
29 const char *hard = "conftest.hard";
30 struct stat sb_file, sb_hard;
32 /* Create a symlink to the regular file. */
33 if (symlink (file, sym))
36 /* Create a hard link to that symlink. */
40 if (lstat (hard, &sb_hard))
42 if (lstat (file, &sb_file))
45 /* If the dev/inode of hard and file are the same, then
46 the link call followed the symlink. */
47 return SAME_INODE (sb_hard, sb_file) ? 0 : 1;
50 jm_ac_cv_func_link_follows_symlink=yes,
51 jm_ac_cv_func_link_follows_symlink=no,
52 jm_ac_cv_func_link_follows_symlink=yes, We're cross compiling.