#-----------------------------------------------------------------------------
#
# make man -	convert all the tex source files into nroff files, using
#		texman.
#
#-----------------------------------------------------------------------------

CFLAGS = -O $(TRACE)

.SUFFIXES: .tex .nr

.tex.nr: ;	texman < $*.tex > $*.nr

basicProgram(texman,texman.o $(LLIBC),)

texman.c: texman.l
	flex  -t texman.l > texman.c
	gcc -O -o texman texman.c



MANLIST	= 1 3 5 7

man:	texman
	- cd tex1 ;\
	for i in $(MANLIST) ; do\
	  cd ../tex$$i ; echo $$i -- ;\
	     for k in `/bin/ls *.tex .*.tex | sed -e 's/.tex$$//'` ; do\
		../../bin/tcmp -s -f ../man$$i/$$k.$$i $$k.tex ; \
		case $$? in \
		255) echo texman '<' $$k.tex '>' ../man$$i/$$k.$$i ; \
		    for j in `../texman -N < $$k.tex` ; do \
		      if [ $$k != $$j ] ; then \
		         echo + $$j.$$i ; \
		         (cd ../man$$i; rm -f $$j.$$i; \
					ln -s $$k.$$i $$j.$$i) ; \
		      fi \
		    done ; \
		    ../texman < $$k.tex > ../man$$i/$$k.$$i;;\
		*) : echo no ../texman $$k;;\
		esac\
	     done\
	done
#ifndef AixArch		/* Don't have catman working on AIX yet */
	@if test -r /etc/catman ; then				\
	   echo /etc/catman -w -M . ; 				\
	   /etc/catman -w -M . ; 				\
	elif test -r /usr/etc/catman ; then			\
	   echo /usr/etc/catman -w -M . ;			\
	   /usr/etc/catman -w -M . ; 				\
	else							\
	   echo can\'t find catman to make whatis database ;	\
	fi		
#endif

clean::
	rm -f *.BAK texman texman.o texman.c whatis
	for i in $(MANLIST) ; do\
	   rm -r -f man$$i ; mkdir man$$i ; \
	   rm -r -f cat$$i ; mkdir cat$$i ; \
	   rm -f tex$$i/$(EMPTY)*.CKP tex$$i/$(EMPTY)*.BAK ; \
	done
