- AC_CACHE_CHECK([whether linkat(,AT_SYMLINK_FOLLOW) works],
- [gl_cv_func_linkat_follow],
- [rm -rf conftest.f1 conftest.f2
- touch conftest.f1
- AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
-#include <fcntl.h>
-#include <unistd.h>
-#ifdef __linux__
-/* Linux added linkat in 2.6.16, but did not add AT_SYMLINK_FOLLOW
- until 2.6.18. Always replace linkat to support older kernels. */
-choke me
-#endif
-]], [return linkat (AT_FDCWD, "conftest.f1", AT_FDCWD, "conftest.f2",
- AT_SYMLINK_FOLLOW);])],
- [gl_cv_func_linkat_follow=yes],
- [gl_cv_func_linkat_follow="need runtime check"])
- rm -rf conftest.f1 conftest.f2])
+ dnl OS X Yosemite has linkat() but it's not sufficient
+ dnl to our needs since it doesn't support creating
+ dnl hardlinks to symlinks. Therefore check for that
+ dnl capability before considering using the system version.
+ AC_CACHE_CHECK([whether linkat() can link symlinks],
+ [gl_cv_func_linkat_nofollow],
+ [rm -rf conftest.l1 conftest.l2
+ ln -s target conftest.l1
+ AC_RUN_IFELSE([AC_LANG_PROGRAM(
+ [[#include <fcntl.h>
+ #include <unistd.h>
+ ]],
+ [return linkat (AT_FDCWD, "conftest.l1", AT_FDCWD,
+ "conftest.l2", 0);
+ ])],
+ [gl_cv_func_linkat_nofollow=yes],
+ [gl_cv_func_linkat_nofollow=no],
+ [case "$host_os" in
+ darwin*) gl_cv_func_linkat_nofollow="guessing no" ;;
+ *) gl_cv_func_linkat_nofollow="guessing yes" ;;
+ esac])
+
+ rm -rf conftest.l1 conftest.l2])
+
+ case $gl_cv_func_linkat_nofollow in
+ *no) LINKAT_SYMLINK_NOTSUP=1 ;;
+ *yes) LINKAT_SYMLINK_NOTSUP=0 ;;
+ esac
+