# Makefile to do the equivalent of "catman", i.e. build cat pages from
# man pages, and build the "whatis" database, under NetBSD.  Place this
# makefile in the appropriate man "source" directory, i.e. one which
# contains subdirectories man1,man2,... and cat1,cat2,....
#
# Authors: Anne Bennett <anne@rodents.montreal.qc.ca>
#          der Mouse   <mouse@rodents.montreal.qc.ca>
# Date:    1996/08/11
# We place this code in the public domain; enjoy.

CATPAGES != ls man?/* 2>/dev/null | sed -e 's/^man/cat/' -e 's/[1-9]$$/0/'

all: $(CATPAGES) whatis.db

# This astonishing expression translates "cat1/dig.0" to "man1/dig.1"
$(CATPAGES): $(.TARGET:S=^cat=man=:S=0$==)$(.TARGET:H:S=cat==)
	-nroff -mandoc $(.ALLSRC) > $(.TARGET)
	-chmod 644 $(.TARGET)

whatis.db: $(CATPAGES) cat?/*
	/usr/libexec/makewhatis .

# Note: makewhatis above expects to "install -o -g" the built file
# from /tmp, so this won't work if you're not running as root.
