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 |
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; }
101 # now find correct order
103 while [ "x$autolibs" != x ]
112 eval "have$i() { true; }"
115 stillneed="$stillneed $i"
118 # break cycle by setting the last library on the list
119 # to have no dependencies
127 echo "dependency cycle: $autolibs; breaking with $j"
128 eval "can$j() { true; }"
130 autolibs="$stillneed"
134 echo "liborder $libsl"
138 # cycle: lib9 expects p9main, which is defined in libthread. oops.
141 libsl="$libsl -lthread -l9"
144 if [ "x$needdraw" = xtrue ]
150 # x86_64 seems to put its 64-bit libraries in lib64.
151 if [ "${OBJTYPE:-`uname -m`}" = "x86_64" ]
153 libsl="$libsl -L$X11/lib64"
155 libsl="$libsl -L$X11/lib -lX11"
160 tag="${SYSNAME:-`uname`}-${OBJTYPE:-`uname -m`}"
165 extralibs="$extralibs -lutil -lpthread"
170 extralibs="$extralibs -lutil"
173 extralibs="$extralibs -lkse"
176 extralibs="$extralibs -lpthread"
183 extralibs="$extralibs -lutil"
188 extralibs="$extralibs -lutil"
189 case "${SYSVERSION:-`uname -r`}" in
191 extralibs="$extralibs -lpthread"
200 extralibs="$extralibs -lrt -lpthread -lsocket -lnsl"
201 # Record paths to shared libraries to avoid needing LD_LIBRARY_PATH
206 s=`echo $i | sed 's/-L/-R/'`
207 extralibs="$extralibs $s"
211 case "${SYSVERSION:-`uname -r`}" in
213 echo do not know how to link right thread library on "$tag" 1>&2
216 # Some trickery is needed to force use of
217 # alternate thread lib from /usr/lib/lwp
218 # Likely, this only works with sun cc,
219 # for other compiler/loader we would need other flags.
221 extralibs="$extralibs /usr/lib/lwp/libthread.so -R/usr/lib/lwp:/usr/lib"
226 echo do not know how to link on "$tag" 1>&2
236 s=`echo $i | sed 's/-L/-Wl,-rpath,/'`
237 extralibs="$extralibs $s"
246 echo $ld -L$PLAN9/lib "$@" $libsl $extralibs
248 if $ld -L$PLAN9/lib "$@" $libsl $extralibs