blob: be4014418ad963ccfc05e81af83abe4ff4fe399c (
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
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
|
#!/bin/sh
libsl=""
doautolib=1
verbose=0
if [ "x$1" = "x-l" ]
then
shift
doautolib=0
elif [ "x$1" = "x-v" ]
then
shift
verbose=1
fi
if [ $doautolib = 1 ]
then
ofiles=""
for i
do
case "$i" in
[^-]*.o)
ofiles="$ofiles $i"
;;
esac
done
# echo "ofiles $ofiles"
autolibs=""
if [ "x$ofiles" != "x" ]
then
autolibs=`
nm $ofiles |
grep '__p9l_autolib_[a-zA-Z0-9+-]*$' |
sed 's/.* __p9l_autolib_//' |
sort -u
`
fi
# echo "autolibs $autolibs"
libsl=""
special="mp draw 9pclient mux thread bio" # order matters
for i in $special
do
eval "need$i=0"
done
for i in $autolibs
do
case "$i" in
9pclient)
need9pclient=1
needmux=1
needthread=1
;;
bio)
needbio=1
;;
draw)
needdraw=1
;;
mp)
needmp=1
;;
mux)
needmux=1
needthread=1
;;
plumb)
need9pclient=1
needmux=1
needthread=1
libsl="$libsl -lplumb"
;;
sec)
needmp=1
libsl="$libsl -lsec"
;;
thread)
needthread=1
;;
venti)
libsl="$libsl -lventi"
needthread=1
;;
*)
libsl="$libsl -l$i"
;;
esac
done
for i in $special
do
if eval "[ \$need$i = 1 ]"
then
libsl="$libsl -l$i"
fi
done
libsl="$libsl -l9"
if [ $needdraw = 1 ]
then
if [ "x$X11" = "x" ]
then
X11=/usr/X11R6
fi
libsl="$libsl -L$X11/lib -lX11"
fi
fi
extralibs="-lm"
tag="${SYSNAME:-`uname`}-${OBJTYPE:-`uname -m`}"
case "$tag" in
*OpenBSD*) ld=gcc
extralibs="$extralibs -lutil -lpthread"
;;
*BSD*) ld=gcc
extralibs="$extralibs -lutil"
;;
*Linux*) ld=gcc
extralibs="$extralibs -lutil"
case "`uname -r`" in
2.6.*)
extralibs="$extralibs -lpthread"
;;
esac
;;
*Darwin*) ld=gcc ;;
*SunOS*) ld="${CC9:-cc} -g"
extralibs="$extralibs -lrt -lpthread -lsocket -lnsl"
# Record paths to shared libraries to avoid needing LD_LIBRARY_PATH
for i in "$@"
do
case "$i" in
-L*)
s=`echo $i | sed 's/-L/-R/'`
extralibs="$extralibs $s"
;;
esac
done
;;
*)
echo do not know how to link on "$tag" 1>&2
exit 1
esac
if [ $verbose = 1 ]
then
echo $ld -L$PLAN9/lib "$@" $libsl $extralibs
fi
exec $ld -L$PLAN9/lib "$@" $libsl $extralibs
|