forked from SawfishWM/librep
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install-aliases
executable file
·129 lines (111 loc) · 2.89 KB
/
install-aliases
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#!/bin/sh
# script to extract and create aliases from source files
# $Id$
verbose=no
dry_run=no
# copy a .la file, editing the `dlname=' line to the new stem
copy_la_file () {
la_src="$1"; la_dest="$2"; shift 2
old_stem=`echo "$la_src" | sed -e 's|^.*/\([^/]*\)\.[^/]*$|\1|'`
new_stem=`echo "$la_dest" | sed -e 's|^.*/\([^/]*\)\.[^/]*$|\1|'`
sed -e '/^dlname=/ s/'"${old_stem}"'/'"${new_stem}"'/' \
< "$la_src" > "$la_dest"
}
# return the outermost directory of the filename
prefix () {
case "$1" in
*/*)
echo "$1" | sed -e 's|^\([^/]*\)/.*$|\1|'
;;
*)
echo ""
;;
esac
}
# return the filename without its outermost directory
postfix () {
echo "$1" | sed -e 's|^[^/]*/\(.*\)$|\1|'
}
# strip common leading directories from $2
strip_common_prefix () {
str1="$1"; str2="$2"; shift 2
pfx=`prefix "$str1"`; str1=`postfix "$str1"`
while [ x"$pfx" != x ]; do
case "$str2" in
$pfx*)
str2=`postfix "$str2"`
;;
*)
break
;;
esac
pfx=`prefix "$str1"`; str1=`postfix "$str1"`
done
echo "$str2"
}
# turns `FOO/BAR/BAZ' into `FOO/BAR/libBAZ'
lib_prefixed () {
echo "$1" | sed -e 's|\([^/]*\)$|lib\1|'
}
dosome () {
destroot="$1"; src="$2"; dest="$3"; shift 3
for g in `echo "${destroot}/${src}.*"`; do
if [ -r "$g" ]; then
suf=`echo "$g" | sed -e 's|^'"${destroot}/${src}"'\(.*\)$|\1|'`
if [ $verbose = yes ]; then
echo "${src}${suf} -> ${dest}${suf}"
fi
if [ $dry_run = no ]; then
rm -f "${destroot}/${dest}${suf}"
case "$suf" in
.la)
copy_la_file "${destroot}/${src}${suf}" \
"${destroot}/${dest}${suf}"
;;
*)
# make sure links are relative to their own directory
local_src=`strip_common_prefix "$dest" "$src"`
ln -s "${local_src}${suf}" "${destroot}/${dest}${suf}"
;;
esac
fi
fi
done
}
doit () {
destroot="$1"; shift
for f in $*; do
src=`echo "$f" | sed -e 's/^\(.*\)#\(.*\)$/\1/'`
dest=`echo "$f" | sed -e 's/^\(.*\)#\(.*\)$/\2/'`
dosome "$destroot" "$src" "$dest"
# libtool sometimes needs to prefix module libraries with a `lib'
# prefix; this will try to pick up such libraries
dosome "$destroot" `lib_prefixed "$src"` `lib_prefixed "$dest"`
done
}
while [ x"$1" != x ]; do
case $1 in
-l)
files=`find "$2" -name '*.jl' -print`
aliases=`grep '(define-structure-alias' $files |
sed -e 's/^.*(define-structure-alias \([^ ]*\) \([^ ]*\)).*$/\2#\1/' |
tr . /`
doit "$3" $aliases
shift 3
;;
-c)
files=`find "$2" -name '*.c' -print`
aliases=`grep '::alias:' $files |
sed -e 's/^.*::alias:\([^ ]*\) \(.*\)::.*$/\2#\1/' |
tr . /`
doit "$3" $aliases
shift 3
;;
-v) verbose=yes; shift ;;
-n) dry_run=yes; verbose=yes; shift ;;
*)
echo "usage [-v] [-n] [-l LISP-SRC-DIR LISP-INST-DIR] [-c C-SRC-DIR LA-INST-DIR]"
exit 1
;;
esac
done