#! /bin/sh
#
#	$NetBSD: ckso,v 1.3 2003/05/06 10:46:44 jmmv Exp $
#
set x $*
. ./.param

for dir in $DIRLST
do
	> $TMPDIR/tmp.$$
	date > $TMPDIR/badso$dir
	echo >> $TMPDIR/badso$dir
	date > $TMPDIR/needso$dir
	echo >> $TMPDIR/needso$dir
	cd $MANDIR/man$dir
	for file in $FILLST
	do
		ln=`line < $file`
		so=`echo $ln | sed "s/ .*//"`
		if test "$so" = ".so"
		then
			so=`echo $ln | sed -e "s/.so//" -e "s/^/ls/"`
			echo $so >> $TMPDIR/tmp.$$
		else
			ed - $file > $TMPDIR/tmp2.$$ <<!
				/^\.SH NAME/+s/ .-.*//p
				q
!
			name=`line < $TMPDIR/tmp2.$$`
			echo $name | grep "," > /dev/null
			if test $? -eq 0
			then
				name=`echo $name | sed "s/,/ /g"`
				for ent in $name
				do
					if test $ent = `echo $file | sed "s/\..*//"`
					then
						continue
					fi
					ls $MANDIR/man$dir/$ent.* 2>&1 | grep "not found" >> $TMPDIR/needso$dir
				done
			fi
		fi
	done

	cd $TMPDIR
	sh tmp.$$ 2>&1 | grep "not found" >> badso$dir
	rm -f tmp.$$ tmp2.$$
done
