3 test -f $PLAN9/config && . $PLAN9/config
13 elif [ "x$1" = "x-v" ]
37 # echo "ofiles $ofiles"
39 if [ "x$ofiles" != "x" ]
43 grep '__p9l_autolib_[a-zA-Z0-9+-]*$' |
44 sed 's/.*__p9l_autolib_//' |
49 autolibs="$autolibs $i"
54 # fetch dependencies out of libraries
56 while [ "x$workq" != "x" ]
62 # can't trust the libraries about using
63 # libthread - we might not be linking with
66 nm $PLAN9/lib/lib$i.a 2>/dev/null |
67 grep '__p9l_autolib_[a-zA-Z0-9+-]*$' |
68 sed 's/.*__p9l_autolib_//' |
75 if eval "[ x\$need$j = x ]"
77 autolibs="$autolibs $j"
83 okayfn="$okayfn && have$j"
86 # echo "can$i: $okayfn"
87 eval "can$i() { $okayfn; }"
92 echo "autolibs $autolibs"
97 eval "have$i() { false; }"
99 havethread() { false; }
102 # now find correct order
104 while [ "x$autolibs" != x ]
113 eval "have$i() { true; }"
116 stillneed="$stillneed $i"
119 # break cycle by setting the last library on the list
120 # to have no dependencies
128 echo "dependency cycle: $autolibs; breaking with $j"
129 eval "can$j() { true; }"
131 autolibs="$stillneed"
135 echo "liborder $libsl"
139 # cycle: lib9 expects p9main, which is defined in libthread. oops.
142 libsl="$libsl -lthread -l9"
145 # cycle: lib9 netcrypt uses libsec
148 libsl="$libsl -lsec -l9"
151 if [ "x$needdraw" = xtrue ]
157 # x86_64 seems to put its 64-bit libraries in lib64.
158 if [ "${OBJTYPE:-`uname -m`}" = "x86_64" ]
160 libsl="$libsl -L$X11/lib64"
162 libsl="$libsl -L$X11/lib -lX11"
167 tag="${SYSNAME:-`uname`}-${OBJTYPE:-`uname -m`}"
172 extralibs="$extralibs -lutil"
177 extralibs="$extralibs -lutil"
180 extralibs="$extralibs -lkse"
183 extralibs="$extralibs -lpthread"
190 extralibs="$extralibs -lutil"
195 extralibs="$extralibs -lutil"
196 case "${SYSVERSION:-`uname -r`}" in
198 extralibs="$extralibs -lpthread"
207 extralibs="$extralibs -lrt -lpthread -lsocket -lnsl"
208 # Record paths to shared libraries to avoid needing LD_LIBRARY_PATH
213 s=`echo $i | sed 's/-L/-R/'`
214 extralibs="$extralibs $s"
218 case "${SYSVERSION:-`uname -r`}" in
220 echo do not know how to link right thread library on "$tag" 1>&2
223 # Some trickery is needed to force use of
224 # alternate thread lib from /usr/lib/lwp
225 # Likely, this only works with sun cc,
226 # for other compiler/loader we would need other flags.
228 extralibs="$extralibs /usr/lib/lwp/libthread.so -R/usr/lib/lwp:/usr/lib"
233 echo do not know how to link on "$tag" 1>&2
243 s=`echo $i | sed 's/-L/-Wl,-rpath,/'`
244 extralibs="$extralibs $s"
253 echo $ld -L$PLAN9/lib "$@" $libsl $extralibs
256 xtmp=/tmp/9l.$$.$USER.out
258 egrep -v ': In function `' $xtmp
262 if $ld -L$PLAN9/lib "$@" $libsl $extralibs >$xtmp 2>&1