aboutsummaryrefslogtreecommitdiffstats
path: root/util/mklink.sh
blob: 3eeba67b2e7ff4c3d3f62bbfc29458528cbb3954 (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
#!/bin/sh
#
# A bit of an ugly shell script used to actually 'link' files.
# Used by 'make links'
#

PATH=$PATH:.:util:../util:../../util
export PATH

from=$1
shift

here=`pwd`
tmp=`dirname $from`
prefix='..'

while [ `basename $tmp`x != ..x -a `basename $tmp`x != .x ]
do
	prefix=../$prefix
	tmp=`dirname $tmp`
done

to=''
while [ "$tmp"x != "x" -a "$tmp"x != ".x" ]
do
	t=`basename $here`
	here=`dirname $here`
	to="/$t$to"
	tmp=`dirname $tmp`
done
to=$prefix$to

if [ "$*"x != "x" ]; then
	for i in $*
	do
		rm -f $from/$i
		ln -s $to/$i $from/$i
		echo "$i => $from/$i"
	done
fi
exit 0;