3 test -f $PLAN9/config && . $PLAN9/config
15 elif [ "x$1" = "x-v" ]
38 l=`echo $i | sed 's/-L//'`
50 if [ "x$ofiles" != "x" ]
54 grep '__p9l_autolib_[a-zA-Z0-9+-]*$' |
55 sed 's/.*__p9l_autolib_//' |
60 autolibs="$autolibs $i"
66 echo "autolibs1 $autolibs"
69 # fetch dependencies out of libraries
71 while [ "x$workq" != "x" ]
77 # can't trust the libraries about using
78 # libthread or libdraw - we might not be linking with
84 nm $lpath/lib$i.a 2>/dev/null |
85 grep '__p9l_autolib_[a-zA-Z0-9+-]*$' |
86 sed 's/.*__p9l_autolib_//' |
88 egrep -v '^(thread|draw)$'
92 # fix up libraries that really need draw
93 if [ "x$i" = "xmemdraw" -o "x$i" = "xmemlayer" -o "x$i" = "xframe" ]
100 if eval "[ x\$need$j = x ]"
102 autolibs="$autolibs $j"
108 okayfn="$okayfn && have$j"
113 echo "can$i: $okayfn"
115 eval "can$i() { $okayfn; }"
120 echo "autolibs $autolibs"
125 eval "have$i() { false; }"
127 havethread() { false; }
129 canmemlayer() { havedraw; }
131 # now find correct order
133 while [ "x$autolibs" != x ]
142 eval "have$i() { true; }"
145 stillneed="$stillneed $i"
148 # break cycle by setting the last library on the list
149 # to have no dependencies
157 echo "dependency cycle: $autolibs; breaking with $j"
158 eval "can$j() { true; }"
160 autolibs="$stillneed"
164 echo "liborder $libsl"
168 # cycle: lib9 expects p9main, which is defined in libthread. oops.
171 libsl="$libsl -lthread -l9"
174 # cycle: lib9 netcrypt uses libsec
177 libsl="$libsl -lsec -l9"
180 if [ "x$needndb" = xtrue -a '(' -f /usr/lib/libresolv.a -o -f /usr/lib/libresolv.dylib ')' ]
182 libsl="$libsl -lresolv"
185 if [ "x$needX11" = xtrue -a "x$WSYSTYPE" != xnowsys ]
191 # x86_64 seems to put its 64-bit libraries in lib64.
192 if [ "${OBJTYPE:-`uname -m`}" = "x86_64" ]
194 libsl="$libsl -L$X11/lib64"
196 libsl="$libsl -L$X11/lib -lX11"
211 # echo "ofiles $ofiles"
213 if [ "x$ofiles" != "x" ]
217 grep '__p9l_autoframework_[a-zA-Z0-9+-]*$' |
218 sed 's/.*__p9l_autoframework_//' |
223 autoframeworks="$autoframeworks $i"
230 echo "autoframeworks $autoframeworks"
233 for i in $autoframeworks
235 eval "have$i() { false; }"
239 for i in $autoframeworks
241 frameworks="-framework $i $frameworks"
246 tag="${SYSNAME:-`uname`}-${OBJTYPE:-`uname -m`}"
251 extralibs="$extralibs -lutil"
254 extralibs="$extralibs -lkse"
257 extralibs="$extralibs -lpthread"
264 extralibs="$extralibs -lutil"
269 extralibs="$extralibs -lutil"
270 case "${SYSVERSION:-`uname -r`}" in
272 extralibs="$extralibs -lpthread"
281 extralibs="$extralibs -lrt -lpthread -lsocket -lnsl"
282 # Record paths to shared libraries to avoid needing LD_LIBRARY_PATH
287 s=`echo $i | sed 's/-L/-R/'`
288 extralibs="$extralibs $s"
292 case "${SYSVERSION:-`uname -r`}" in
294 echo do not know how to link right thread library on "$tag" 1>&2
297 # Some trickery is needed to force use of
298 # alternate thread lib from /usr/lib/lwp
299 # Likely, this only works with sun cc,
300 # for other compiler/loader we would need other flags.
302 extralibs="$extralibs /usr/lib/lwp/libthread.so -R/usr/lib/lwp:/usr/lib"
307 echo do not know how to link on "$tag" 1>&2
317 s=`echo $i | sed 's/-L/-Wl,-rpath,/'`
318 extralibs="$extralibs $s"
327 echo $ld -L$PLAN9/lib "$@" $libsl $extralibs $frameworks
330 xtmp=/tmp/9l.$$.$USER.out
332 sed 's/.*: In function `[^:]*: *//' $xtmp | egrep . |
333 egrep -v 'is (often|almost always) misused|is dangerous, better use'
337 if $ld -L$PLAN9/lib "$@" $libsl $extralibs $frameworks >$xtmp 2>&1