#=======================================================================
# Makefile for files in $HOME/public_html.
#
# Current target list:
#	all			make dw and spell
#	clean
#	mostlyclean
#	clobber
#	distclean
#	realclean
#	dw			doubled-word check
#	spell			spelling check
#
# [07-Apr-1995]
#=======================================================================

BASENAME	= basename
CAT		= cat
DEHTML		= dehtml
DW		= dw
ISPELL		= ispell
HTMLFILES	= *.html
RM		= /bin/rm -f
SHELL		= /bin/sh
SORT		= sort
SPELL		= spell
SPELLDICT	= spell.dict
SUBDIRS		= fonts
TEST		= test
TOUCH		= touch

all:	dw spell

clean mostlyclean:
	-$(RM) *.i
	-$(RM) *.o
	-$(RM) *~
	-$(RM) \#*
	-$(RM) a.out
	-$(RM) core
	for dir in $(SUBDIRS) ; \
	do \
		(cd $$dir ; $(MAKE) $@ ) ; \
	done

clobber distclean realclean:	clean
	for f in $(SUBDIRS) ; \
	do \
		(cd $$dir ; $(MAKE) $@ ) ; \
	done

dw:
	@for f in $(HTMLFILES) ; \
	do \
		echo ; \
		echo Doubled word check in $$f ... ; \
		$(DEHTML) < $$f | $(DW) ; \
	done
	@for dir in $(SUBDIRS) ; \
	do \
		(cd $$dir ; $(MAKE) $@ ) ; \
	done

spell:	spell-this spell-subdirs

spell-this:
	@for f in $(HTMLFILES) ; \
	do \
		echo Spelling check in $$f ... ; \
		g=`$(BASENAME) $$f .html` ; \
		$(TEST) -f $$g.sok || $(TOUCH) $$g.sok ; \
		$(DEHTML) < $$f | $(SPELL) +$$g.sok > $$g.tmp-ser ; \
		$(DEHTML) < $$f | $(ISPELL) -l -p $$g.sok > $$g.tmp-ser 2>/dev/null; \
		$(SORT) -u $$g.tmp-ser > $$g.ser ; \
		$(CAT) $$g.ser ; \
		$(TEST) -s $$g.ser || $(RM) $$g.ser ; \
		$(RM) $$g.tmp-ser ; \
	done

spell-subdirs:
	@for dir in $(SUBDIRS) ; \
	do \
		(cd $$dir ; $(MAKE) $@ ) ; \
	done
