1dnl Copyright (C) 1993-2002 Free Software Foundation, Inc.
2dnl This file is free software, distributed under the terms of the GNU
3dnl General Public License.  As a special exception to the GNU General
4dnl Public License, this file may be distributed as part of a program
5dnl that contains a configuration script generated by Autoconf, under
6dnl the same distribution terms as the rest of that program.
7
8dnl From Bruno Haible, Marcus Daniels.
9
10AC_PREREQ(2.13)
11
12AC_DEFUN([CL_PROG_LN],
13[AC_REQUIRE([CL_PROG_CP])dnl
14AC_CACHE_CHECK(how to make hard links, cl_cv_prog_LN, [
15rm -f conftestdata conftestfile
16echo data > conftestfile
17if ln conftestfile conftestdata 2>/dev/null; then
18  cl_cv_prog_LN=ln
19else
20  cl_cv_prog_LN="$cl_cv_prog_cp"
21fi
22rm -f conftestdata conftestfile
23])
24LN="$cl_cv_prog_LN"
25AC_SUBST(LN)dnl
26])
27
28AC_DEFUN([CL_PROG_LN_S],
29[AC_REQUIRE([CL_PROG_LN])dnl
30dnl Make a symlink if possible; otherwise try a hard link. On filesystems
31dnl which support neither symlink nor hard link, use a plain copy.
32AC_MSG_CHECKING(whether ln -s works)
33AC_CACHE_VAL(cl_cv_prog_LN_S, [
34rm -f conftestdata
35if ln -s X conftestdata 2>/dev/null; then
36  cl_cv_prog_LN_S="ln -s"
37else
38  cl_cv_prog_LN_S="$cl_cv_prog_LN"
39fi
40rm -f conftestdata
41])dnl
42if test "$cl_cv_prog_LN_S" = "ln -s"; then
43  AC_MSG_RESULT(yes)
44else
45  AC_MSG_RESULT(no)
46fi
47LN_S="$cl_cv_prog_LN_S"
48AC_SUBST(LN_S)dnl
49])
50
51AC_DEFUN([CL_PROG_HLN],
52[AC_REQUIRE([CL_PROG_LN_S])dnl
53dnl SVR4 "ln" makes hard links to symbolic links, instead of resolving the
54dnl symbolic link. To avoid this, use the "hln" program.
55AC_CACHE_CHECK(how to make hard links to symlinks, cl_cv_prog_hln, [
56cl_cv_prog_hln="ln"
57if test "$cl_cv_prog_LN_S" = "ln -s"; then
58echo "blabla" > conftest.x
59ln -s conftest.x conftest.y
60ln conftest.y conftest.z 2>&AC_FD_CC
61rm -f conftest.x
62if cat conftest.z > /dev/null 2>&1 ; then
63  # ln is usable.
64  cl_cv_prog_hln="ln"
65else
66  # conftest.z is a symbolic link to the non-existent conftest.x
67  cl_cv_prog_hln="hln"
68fi
69else
70# If there are no symbolic links, the problem cannot occur.
71cl_cv_prog_hln="ln"
72fi
73rm -f conftest*
74])
75HLN="$cl_cv_prog_hln"
76AC_SUBST(HLN)dnl
77])
78