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 - 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_//' |
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$needdraw" = xtrue ]
159 # x86_64 seems to put its 64-bit libraries in lib64.
160 if [ "${OBJTYPE:-`uname -m`}" = "x86_64" ]
162 libsl="$libsl -L$X11/lib64"
164 libsl="$libsl -L$X11/lib -lX11"
179 # echo "ofiles $ofiles"
181 if [ "x$ofiles" != "x" ]
185 grep '__p9l_autoframework_[a-zA-Z0-9+-]*$' |
186 sed 's/.*__p9l_autoframework_//' |
191 autoframeworks="$autoframeworks $i"
198 echo "autoframeworks $autoframeworks"
201 for i in $autoframeworks
203 eval "have$i() { false; }"
207 for i in $autoframeworks
209 frameworks="-framework $i $frameworks"
214 tag="${SYSNAME:-`uname`}-${OBJTYPE:-`uname -m`}"
219 extralibs="$extralibs -lutil"
222 extralibs="$extralibs -lkse"
225 extralibs="$extralibs -lpthread"
232 extralibs="$extralibs -lutil"
237 extralibs="$extralibs -lutil"
238 case "${SYSVERSION:-`uname -r`}" in
240 extralibs="$extralibs -lpthread"
249 extralibs="$extralibs -lrt -lpthread -lsocket -lnsl"
250 # Record paths to shared libraries to avoid needing LD_LIBRARY_PATH
255 s=`echo $i | sed 's/-L/-R/'`
256 extralibs="$extralibs $s"
260 case "${SYSVERSION:-`uname -r`}" in
262 echo do not know how to link right thread library on "$tag" 1>&2
265 # Some trickery is needed to force use of
266 # alternate thread lib from /usr/lib/lwp
267 # Likely, this only works with sun cc,
268 # for other compiler/loader we would need other flags.
270 extralibs="$extralibs /usr/lib/lwp/libthread.so -R/usr/lib/lwp:/usr/lib"
275 echo do not know how to link on "$tag" 1>&2
285 s=`echo $i | sed 's/-L/-Wl,-rpath,/'`
286 extralibs="$extralibs $s"
295 echo $ld -L$PLAN9/lib "$@" $libsl $extralibs $frameworks
298 xtmp=/tmp/9l.$$.$USER.out
300 egrep -v 'is almost always misused|: In function `' $xtmp
304 if $ld -L$PLAN9/lib "$@" $libsl $extralibs $frameworks >$xtmp 2>&1