#=======================================================================
# Makefile for files in ~beebe/public_html/support/myman2html/testdata.
#
# These files serve as an extensive test suite for man2html.  They are
# almost all authored by me, thereby avoiding copyright questions.
#
# Most Sun Microsystems manual page files will also be processed
# correctly by man2html, but for copyright reasons, they cannot be
# used in a freely-distributable test suite.
#
# Most of the software that these files document is also written by
# me, and is freely available. The master anonymous ftp archive site
# is at ftp://ftp.math.utah.edu, and the packages reside mostly in the
# directories
#
#	ftp://ftp.math.utah.edu/pub/mg
#	ftp://ftp.math.utah.edu/pub/misc
#	ftp://ftp.math.utah.edu/pub/sgml
#	ftp://ftp.math.utah.edu/pub/tex/bib
#
# Those archives are mirrored to several other Internet hosts, but the
# above site should always have the most recent versions.
#
# About three dozen of the files document software in the PLOT79
# graphics system.  This is a licensed product that is not freely
# distributable; contact me for details.
#
# Some of these files result in error messages from man2html, which
# may indicate limitations of man2html, or else actual errors in the
# original .man files.  Since the purpose of a test suite is to test
# both successful and unsuccessful processing, these error messages
# are preserved in .err files.
#
# A successful "make check" will leave no new files in the directory.
# Any failures will result in *.err and *.html files being left for
# manual examination; a list of them will be printed at the conclusion
# of the tests.
#
# [25-Oct-1997]
#=======================================================================

AWK		= gawk

CMP		= cmp

FIND		= find

MAN2HTML	= $(AWK) -f ../man2html.awk

HTML-FILES	= $(MAN-FILES:.man=.html)

MAN-FILES       = PSlabels.man acroread.man archie.man bibcheck.man \
		  bibclean.man bibdup.man bibextract.man bibindex.man \
		  bibjoin.man biblabel.man biblex.man biblook.man \
		  biborder.man bibparse.man bibsearch.man bibsort.man \
		  bibunlex.man bsplit.man checksum.man chkdelim.man \
		  citefind.man citesub.man citetags.man copy.man \
		  dcl2inc.man dired.man document.man dos2mac.man \
		  dos2ux.man dt2dv.man dtoq.man dtos.man dv2dt.man \
		  dvi.man dw.man epsutil.man flex.man fpp.man \
		  ftnchek.man graph.man graph3.man hp4m-envfdr.man \
		  hp4m-manfdr.man hpset.man html-check.man \
		  html-ncheck.man html-norm.man html-pretty.man \
		  labels.man linestyle.man lprsf3.man lptops.man \
		  ltrtops.man mac2dos.man mac2ux.man makeindex.man \
		  man2html.man markstyle.man mg.man nametags.man \
		  p79-intro.man pfort.man pick.man piecht.man \
		  plot79-intro.man plot79.man plotfont.man \
		  plottips.man pltde.man pluto.man polyfill.man \
		  pretty.man print-ps-oneside.man print-ps-twoside.man \
		  psmultipage.man psposter.man qtod.man randsp.man \
		  rdinfo.man sf3.man sf3lex.man sf3pretty.man \
		  sf3tags.man sgmlnorm.man slides.man spheres.man \
		  sphplt.man splinepar.man stod.man strsf3.man \
		  tekalw.man tex-pretty.man textfmt.man tfmpk.man \
		  tgrind.man tkvecs.man tmacro.man tolower.man \
		  trim.man ux2dos.man ux2mac.man vvdecode.man \
		  vvencode.man wf.man wl.man world.man x79.man \
		  x79ps.man xref.man xsf3.man xxdecode.man \
		  xxencode.man

RM              = /bin/rm -f

SED		= /bin/sed

SEDFILTER	= $(SED) -e '2,3d' -e '/<LINK REV="made" HREF="mailto:.*$$/d'

SHELL		= /bin/sh

#=======================================================================

.SUFFIXES:

.SUFFIXES:	.html .man

.man.html:
	$(MAN2HTML) $< >$*.html 2>$*.err
	@if test -s $*.err ; then true ; else $(RM) $*.err ; fi

#=======================================================================

all:	check

check:
	@echo "The following comparisons should show only the test names..."
	@for f in $(MAN-FILES) ; \
	do \
		g=`basename $$f .man` ; \
		echo $$g ; \
		$(MAN2HTML) $$f >$$g.html 2>$$g.err ; \
		$(SEDFILTER) $$g.html >$$g.html.1 ; \
		$(SEDFILTER) okay/$$g.html >$$g.html.2 ; \
		if $(CMP) $$g.html.1 $$g.html.2 ; \
		then \
			$(RM) $$g.html ; \
		fi ; \
		$(RM) $$g.html.1 $$g.html.2 ; \
		if test -s $$g.err ; \
		then \
			if $(CMP) $$g.err okay/$$g.err ; \
			then \
				$(RM) $$g.err ; \
			fi ; \
		else \
			if test -f okay/$$g.err ; \
			then \
				echo ERROR: expected to find errors in $$g.err file ; \
			fi ; \
			$(RM) $$g.err ; \
		fi ; \
	done
	BADFILES=`$(FIND) . -type f -mtime -1 -print` ; \
	if test "xx$$BADFILES" = "xx" ; \
	then \
		true ; \
	else \
		echo These files differ from the expected ones: ; \
		ls -l $$BADFILES ; \
	fi

clean mostlyclean:
	-$(RM) *.i
	-$(RM) *.o
	-$(RM) *~
	-$(RM) \#*
	-$(RM) a.out
	-$(RM) core

clobber distclean:	clean
	-$(RM) *.err
	-$(RM) *.html
	-$(RM) *.html.1
	-$(RM) *.html.2

html-files:	$(HTML-FILES)

maintainer-clean:	distclean
	@echo "This command is intended for maintainers to use;"
	@echo "it deletes files that may require special tools to rebuild."
