#!/bin/ksh
# @(#) mkwhatis - rebuild /usr/lib/whatis for A/UX apropos(1)
#
# Bob Denny - Thu Feb 20 13:27:26 1992
# Jim Jagielski - Thu Aug 19 17:14:46 1993
#

#
# You _MUST_ change these to reflect your setup
#
WHEREAMI="/usr/tmp"
GZCAT="/usr/local/bin/gzcat"
GFIND="/usr/local/bin/gfind"

#
# Use 'find' to walk down /usr/catman instead of hard-wiring
#  the info
#
MANSUBS="$($GFIND /usr/catman -follow -type d -print)"

TEMP0="/usr/tmp/whatis$$.0"
TEMP1="/usr/tmp/whatis$$.1"
RESULT="/usr/lib/whatis.new"

trap "rm -f $TEMP0 $TEMP1 $RESULT ; exit" 1 2 15
trap "rm -f $TEMP0 $TEMP1 ; exit" EXIT

> $TEMP0	# Create tempfile
for dir in $MANSUBS ; do
	/bin/echo Doing $dir...
	cd $dir
	for i in * ; do
#		echo $i;
		if [[ -f $i ]]
		then
		    $GZCAT -f $i | $WHEREAMI/getname >> $TEMP0
		fi
	done
done	
/bin/echo Sorting...
/bin/sort $TEMP0 > $TEMP1
/bin/echo Removing duplicates...
/usr/bin/uniq $TEMP1 > $RESULT
/bin/echo Done!
exit 0
