2003-11-23 18:29:08 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
2005-01-04 21:13:58 +00:00
|
|
|
libsl=""
|
|
|
|
|
|
|
|
doautolib=1
|
|
|
|
verbose=0
|
|
|
|
|
|
|
|
if [ "x$1" = "x-l" ]
|
|
|
|
then
|
|
|
|
shift
|
|
|
|
doautolib=0
|
|
|
|
elif [ "x$1" = "x-v" ]
|
|
|
|
then
|
|
|
|
shift
|
|
|
|
verbose=1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ $doautolib = 1 ]
|
|
|
|
then
|
|
|
|
ofiles=""
|
|
|
|
for i
|
|
|
|
do
|
|
|
|
case "$i" in
|
|
|
|
[^-]*.o)
|
|
|
|
ofiles="$ofiles $i"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
# echo "ofiles $ofiles"
|
|
|
|
autolibs=""
|
|
|
|
if [ "x$ofiles" != "x" ]
|
|
|
|
then
|
|
|
|
autolibs=`
|
|
|
|
nm $ofiles |
|
|
|
|
grep '__p9l_autolib_[a-zA-Z0-9+-]*$' |
|
|
|
|
sed 's/.* __p9l_autolib_//' |
|
|
|
|
sort -u
|
|
|
|
`
|
|
|
|
fi
|
|
|
|
# echo "autolibs $autolibs"
|
|
|
|
|
|
|
|
libsl=""
|
|
|
|
special="mp draw 9pclient mux thread bio" # order matters
|
|
|
|
for i in $special
|
|
|
|
do
|
|
|
|
eval "need$i=0"
|
|
|
|
done
|
|
|
|
|
|
|
|
for i in $autolibs
|
|
|
|
do
|
|
|
|
case "$i" in
|
|
|
|
9pclient)
|
|
|
|
need9pclient=1
|
|
|
|
needmux=1
|
|
|
|
needthread=1
|
|
|
|
;;
|
|
|
|
bio)
|
|
|
|
needbio=1
|
|
|
|
;;
|
|
|
|
draw)
|
|
|
|
needdraw=1
|
|
|
|
;;
|
|
|
|
mp)
|
|
|
|
needmp=1
|
|
|
|
;;
|
|
|
|
mux)
|
|
|
|
needmux=1
|
|
|
|
needthread=1
|
|
|
|
;;
|
|
|
|
plumb)
|
|
|
|
need9pclient=1
|
|
|
|
needmux=1
|
|
|
|
needthread=1
|
|
|
|
libsl="$libsl -lplumb"
|
|
|
|
;;
|
|
|
|
sec)
|
|
|
|
needmp=1
|
|
|
|
libsl="$libsl -lsec"
|
|
|
|
;;
|
|
|
|
thread)
|
|
|
|
needthread=1
|
|
|
|
;;
|
|
|
|
venti)
|
|
|
|
libsl="$libsl -lventi"
|
|
|
|
needthread=1
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
libsl="$libsl -l$i"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
for i in $special
|
|
|
|
do
|
|
|
|
if eval "[ \$need$i = 1 ]"
|
|
|
|
then
|
|
|
|
libsl="$libsl -l$i"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
libsl="$libsl -l9"
|
|
|
|
|
|
|
|
if [ $needdraw = 1 ]
|
|
|
|
then
|
|
|
|
if [ "x$X11" = "x" ]
|
|
|
|
then
|
|
|
|
X11=/usr/X11R6
|
|
|
|
fi
|
|
|
|
libsl="$libsl -L$X11/lib -lX11"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2004-03-26 02:09:17 +00:00
|
|
|
extralibs="-lm"
|
2004-03-02 17:34:15 +00:00
|
|
|
tag="${SYSNAME:-`uname`}-${OBJTYPE:-`uname -m`}"
|
2003-11-23 18:29:08 +00:00
|
|
|
case "$tag" in
|
2004-03-25 23:03:22 +00:00
|
|
|
*OpenBSD*) ld=gcc
|
2004-03-26 02:09:17 +00:00
|
|
|
extralibs="$extralibs -lutil -lpthread"
|
|
|
|
;;
|
|
|
|
*BSD*) ld=gcc
|
|
|
|
extralibs="$extralibs -lutil"
|
|
|
|
;;
|
|
|
|
*Linux*) ld=gcc
|
2004-09-17 22:09:31 +00:00
|
|
|
extralibs="$extralibs -lutil"
|
|
|
|
case "`uname -r`" in
|
|
|
|
2.6.*)
|
|
|
|
extralibs="$extralibs -lpthread"
|
|
|
|
;;
|
|
|
|
esac
|
2004-03-25 23:03:22 +00:00
|
|
|
;;
|
2003-11-23 18:29:08 +00:00
|
|
|
*Darwin*) ld=gcc ;;
|
2003-11-25 02:11:11 +00:00
|
|
|
*SunOS*) ld="${CC9:-cc} -g"
|
2003-11-23 19:49:17 +00:00
|
|
|
extralibs="$extralibs -lrt -lpthread -lsocket -lnsl"
|
2004-03-25 23:03:22 +00:00
|
|
|
# Record paths to shared libraries to avoid needing LD_LIBRARY_PATH
|
|
|
|
for i in "$@"
|
|
|
|
do
|
|
|
|
case "$i" in
|
|
|
|
-L*)
|
|
|
|
s=`echo $i | sed 's/-L/-R/'`
|
|
|
|
extralibs="$extralibs $s"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
2003-11-23 19:49:17 +00:00
|
|
|
;;
|
2003-11-23 18:29:08 +00:00
|
|
|
*)
|
|
|
|
echo do not know how to link on "$tag" 1>&2
|
|
|
|
exit 1
|
|
|
|
esac
|
|
|
|
|
2005-01-04 21:13:58 +00:00
|
|
|
if [ $verbose = 1 ]
|
|
|
|
then
|
|
|
|
echo $ld -L$PLAN9/lib "$@" $libsl $extralibs
|
|
|
|
fi
|
|
|
|
exec $ld -L$PLAN9/lib "$@" $libsl $extralibs
|