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"
56 # fetch dependencies out of libraries
58 while [ "x$workq" != "x" ]
64 # can't trust the libraries about using
65 # libthread or libdraw - we might not be linking with
68 nm $PLAN9/lib/lib$i.a 2>/dev/null |
69 grep '__p9l_autolib_[a-zA-Z0-9+-]*$' |
70 sed 's/.*__p9l_autolib_//' |
72 egrep -v 'thread|draw'
77 if eval "[ x\$need$j = x ]"
79 autolibs="$autolibs $j"
85 okayfn="$okayfn && have$j"
88 # echo "can$i: $okayfn"
89 eval "can$i() { $okayfn; }"
94 echo "autolibs $autolibs"
99 eval "have$i() { false; }"
101 havethread() { false; }
104 # now find correct order
106 while [ "x$autolibs" != x ]
115 eval "have$i() { true; }"
118 stillneed="$stillneed $i"
121 # break cycle by setting the last library on the list
122 # to have no dependencies
130 echo "dependency cycle: $autolibs; breaking with $j"
131 eval "can$j() { true; }"
133 autolibs="$stillneed"
137 echo "liborder $libsl"
141 # cycle: lib9 expects p9main, which is defined in libthread. oops.
144 libsl="$libsl -lthread -l9"
147 # cycle: lib9 netcrypt uses libsec
150 libsl="$libsl -lsec -l9"
153 if [ "x$needndb" = xtrue -a '(' -f /usr/lib/libresolv.a -o -f /usr/lib/libresolv.dylib ')' ]
155 libsl="$libsl -lresolv"
158 if [ "x$needdraw" = xtrue -a "x$WSYSTYPE" != xnowsys ]
164 # x86_64 seems to put its 64-bit libraries in lib64.
165 if [ "${OBJTYPE:-`uname -m`}" = "x86_64" ]
167 libsl="$libsl -L$X11/lib64"
169 libsl="$libsl -L$X11/lib -lX11"
184 # echo "ofiles $ofiles"
186 if [ "x$ofiles" != "x" ]
190 grep '__p9l_autoframework_[a-zA-Z0-9+-]*$' |
191 sed 's/.*__p9l_autoframework_//' |
196 autoframeworks="$autoframeworks $i"
203 echo "autoframeworks $autoframeworks"
206 for i in $autoframeworks
208 eval "have$i() { false; }"
212 for i in $autoframeworks
214 frameworks="-framework $i $frameworks"
219 tag="${SYSNAME:-`uname`}-${OBJTYPE:-`uname -m`}"
224 extralibs="$extralibs -lutil"
227 extralibs="$extralibs -lkse"
230 extralibs="$extralibs -lpthread"
237 extralibs="$extralibs -lutil"
242 extralibs="$extralibs -lutil"
243 case "${SYSVERSION:-`uname -r`}" in
245 extralibs="$extralibs -lpthread"
254 extralibs="$extralibs -lrt -lpthread -lsocket -lnsl"
255 # Record paths to shared libraries to avoid needing LD_LIBRARY_PATH
260 s=`echo $i | sed 's/-L/-R/'`
261 extralibs="$extralibs $s"
265 case "${SYSVERSION:-`uname -r`}" in
267 echo do not know how to link right thread library on "$tag" 1>&2
270 # Some trickery is needed to force use of
271 # alternate thread lib from /usr/lib/lwp
272 # Likely, this only works with sun cc,
273 # for other compiler/loader we would need other flags.
275 extralibs="$extralibs /usr/lib/lwp/libthread.so -R/usr/lib/lwp:/usr/lib"
280 echo do not know how to link on "$tag" 1>&2
290 s=`echo $i | sed 's/-L/-Wl,-rpath,/'`
291 extralibs="$extralibs $s"
300 echo $ld -L$PLAN9/lib "$@" $libsl $extralibs $frameworks
303 xtmp=/tmp/9l.$$.$USER.out
305 sed 's/.*: In function `[^:]*: *//' $xtmp | egrep . |
306 egrep -v 'is almost always misused'
310 if $ld -L$PLAN9/lib "$@" $libsl $extralibs $frameworks >$xtmp 2>&1