3 test -f $PLAN9/config && . $PLAN9/config
15 elif [ "x$1" = "x-v" ]
39 # echo "ofiles $ofiles"
41 if [ "x$ofiles" != "x" ]
45 grep '__p9l_autolib_[a-zA-Z0-9+-]*$' |
46 sed 's/.*__p9l_autolib_//' |
51 autolibs="$autolibs $i"
57 echo "autolibs1 $autolibs"
60 # fetch dependencies out of libraries
62 while [ "x$workq" != "x" ]
68 # can't trust the libraries about using
69 # libthread or libdraw - we might not be linking with
72 nm $PLAN9/lib/lib$i.a 2>/dev/null |
73 grep '__p9l_autolib_[a-zA-Z0-9+-]*$' |
74 sed 's/.*__p9l_autolib_//' |
76 egrep -v '^(thread|draw)$'
78 # fix up libraries that really need draw
79 if [ "x$i" = "xmemdraw" -o "x$i" = "xmemlayer" -o "x$i" = "xframe" ]
86 if eval "[ x\$need$j = x ]"
88 autolibs="$autolibs $j"
94 okayfn="$okayfn && have$j"
101 eval "can$i() { $okayfn; }"
106 echo "autolibs $autolibs"
111 eval "have$i() { false; }"
113 havethread() { false; }
115 canmemlayer() { havedraw; }
117 # now find correct order
119 while [ "x$autolibs" != x ]
128 eval "have$i() { true; }"
131 stillneed="$stillneed $i"
134 # break cycle by setting the last library on the list
135 # to have no dependencies
143 echo "dependency cycle: $autolibs; breaking with $j"
144 eval "can$j() { true; }"
146 autolibs="$stillneed"
150 echo "liborder $libsl"
154 # cycle: lib9 expects p9main, which is defined in libthread. oops.
157 libsl="$libsl -lthread -l9"
160 # cycle: lib9 netcrypt uses libsec
163 libsl="$libsl -lsec -l9"
166 if [ "x$needndb" = xtrue -a '(' -f /usr/lib/libresolv.a -o -f /usr/lib/libresolv.dylib ')' ]
168 libsl="$libsl -lresolv"
171 if [ "x$needX11" = xtrue -a "x$WSYSTYPE" != xnowsys ]
177 # x86_64 seems to put its 64-bit libraries in lib64.
178 if [ "${OBJTYPE:-`uname -m`}" = "x86_64" ]
180 libsl="$libsl -L$X11/lib64"
182 libsl="$libsl -L$X11/lib -lX11"
197 # echo "ofiles $ofiles"
199 if [ "x$ofiles" != "x" ]
203 grep '__p9l_autoframework_[a-zA-Z0-9+-]*$' |
204 sed 's/.*__p9l_autoframework_//' |
209 autoframeworks="$autoframeworks $i"
216 echo "autoframeworks $autoframeworks"
219 for i in $autoframeworks
221 eval "have$i() { false; }"
225 for i in $autoframeworks
227 frameworks="-framework $i $frameworks"
232 tag="${SYSNAME:-`uname`}-${OBJTYPE:-`uname -m`}"
237 extralibs="$extralibs -lutil"
240 extralibs="$extralibs -lkse"
243 extralibs="$extralibs -lpthread"
250 extralibs="$extralibs -lutil"
255 extralibs="$extralibs -lutil"
256 case "${SYSVERSION:-`uname -r`}" in
258 extralibs="$extralibs -lpthread"
267 extralibs="$extralibs -lrt -lpthread -lsocket -lnsl"
268 # Record paths to shared libraries to avoid needing LD_LIBRARY_PATH
273 s=`echo $i | sed 's/-L/-R/'`
274 extralibs="$extralibs $s"
278 case "${SYSVERSION:-`uname -r`}" in
280 echo do not know how to link right thread library on "$tag" 1>&2
283 # Some trickery is needed to force use of
284 # alternate thread lib from /usr/lib/lwp
285 # Likely, this only works with sun cc,
286 # for other compiler/loader we would need other flags.
288 extralibs="$extralibs /usr/lib/lwp/libthread.so -R/usr/lib/lwp:/usr/lib"
293 echo do not know how to link on "$tag" 1>&2
303 s=`echo $i | sed 's/-L/-Wl,-rpath,/'`
304 extralibs="$extralibs $s"
313 echo $ld -L$PLAN9/lib "$@" $libsl $extralibs $frameworks
316 xtmp=/tmp/9l.$$.$USER.out
318 sed 's/.*: In function `[^:]*: *//' $xtmp | egrep . |
319 egrep -v 'is (often|almost always) misused|is dangerous, better use'
323 if $ld -L$PLAN9/lib "$@" $libsl $extralibs $frameworks >$xtmp 2>&1