blob: 60af9363e16d12a689344425c77bacfe746ab0ad (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
dnl ===============================================================
dnl FOLLOW_SYMLINKS <path>
dnl Follows symbolic links on <path>,
dnl
dnl Arguments:
dnl the file which want to resolve the real file
dnl the real name of the file (for example, if we are looking for javac and
dnl it is a symlink to /usr/bin/gcj, we want to stay in the java dir where
dnl javac is found
dnl
dnl VARIABLES SET:
dnl SYMLINK_FOLLOWED_TO the "real" file
dnl ===============================================================
AC_DEFUN([FOLLOW_SYMLINKS],[
dnl find the include directory relative to the executable
_cur="$1"
if test ! -z "$2"; then
_fileNameWanted=$2
else
_fileNameWanted=$1
fi
while ls -ld "$_cur" 2>/dev/null | grep " -> " >/dev/null; do
AC_MSG_CHECKING(Symlink for $_cur)
_slink=`ls -ld "$_cur" | sed 's/.* -> //'`
if test "$_fileNameWanted" != "`basename $_slink`"; then
AC_MSG_RESULT(Filename changed... Keeping the one found before)
break
fi
case "$_slink" in
/*)
_cur="$_slink";;
# 'X' avoids triggering unwanted echo options.
*)
_cur=`echo "X$_cur" | sed -e 's/^X//' -e 's:[[^/]]*$::'`"$_slink";;
esac
AC_MSG_RESULT($_cur)
done
SYMLINK_FOLLOWED_TO="$_cur"
])# FOLLOW_SYMLINKS
|