#! /bin/sh
#
# lint for the V-System, 68000 source code
#
# Note: -V or -xV should really be the first argument, so -n works correctly
#
# Alan Hastings	7/15/85		- adapted /usr/bin/lint script
#
# WARNING:  WILL HAVE TO BE FIXED on the next V release, so that
#  V versions of things are searched for in /usr/V instead of /usr/sun
#

L=/usr/lib/lint/lint
LL=/usr/lib/lint
T=/usr/tmp/lint.$$
PATH=/bin:/usr/bin:/usr/stanford/bin
O="-C -Dlint"
X=
P=unix
C=
cpp=/lib/cpp

trap "rm -f $T; exit" 1 2 15

for A in $*
do
	case $A in
	-n)	P= ;;
	-p)	P=port ;;
	esac

	case $A in
	*.ln)	cat $A >>$T ;;
	-l*)	cat $LL/llib$A.ln >>$T ;;
	-C?*)	P= C=`echo $A | sed -e s/-C/llib-l/` ; X="$X -L -C$C" ;;
	-[IDOU]*)	O="$O $A" ;;
	-X)	LL=/usr/src/usr.bin/lint L=/usr/src/usr.bin/lint/lpass ;;
	-V|-vV)	case $P in
		  xV) ;;
		  *)  X="$X -n";
		      cpp="cc68 -V -E";
		      P=V; ;;
		esac ;;
	-xV|-vxV|-vx)
		X="$X -n";
		cpp="cc68 -vx -V -E";
		P=xV; ;;
	-*)	X="$X $A" ;;
	*)	echo "$A:" ; ($cpp $O $A | ${L}1 $X >>$T)2>&1
	esac
done

case $P in
	unix)	cat $LL/llib-lc.ln >>$T ;;
	port)	cat $LL/llib-port.ln >>$T ;;
	V)	cat /usr/sun/lib/llib-lV.ln >>$T ;;
	xV)	cat /usr/xV/lib/m68k/llib-lV.ln >>$T ;;
	"")	cat /dev/null >>$T ;;
esac

case $C in
	"")	${L}2 $T $X ;;
	*)	cp $T $C.ln ;;
esac

rm -f $T
