# Makefile for ~lp/html

DIRS = commands glossary logic misc news operation ordering proof settings \
       symbols

.SILENT:

.SUFFIXES: .html .tex

.tex.html: 
	echo 'sed -f tex2html $*.tex | sed -f tex2html > $*.html'
	sed -f tex2html $*.tex | sed -f tex2html > $*.html

all: local
	for i in ${DIRS}; do (cd $$i; make all); done

local: files

again:
	make clean Makefile 
	for i in ${DIRS}; do (cd $$i; make clean Makefile); done	
	make all

Makefile: fictitious_file
	mv Makefile Makefile.bak
	/bin/rm -f Index.html *.tex
	ln -s ../help/*.tex .
	grep -v '^files:' Makefile.bak > Makefile
	echo '<pre>' > Index.html
	for i in `ls *.tex | sed "s/.tex/.html/"`;		\
	    do echo files: $$i >> Makefile;			\
	       echo "<a href=\"$$i\">$$i</a>" >> Index.html;	\
	    done
	echo '</pre>' >> Index.html

fictitious_file:

xref:
	cat *.html						\
	  | tr '>' '\012' 					\
          | sed -n '/.*<a href="\([^"]*\)"/s//\1/p' 		\
          | sort -u						\
	  > tmp
	for j in `grep -v \# tmp`;				\
	    do if test -s $$j;					\
	       then true;					\
	       else echo $$j; 					\
	       fi;						\
	    done
	sed -n '/\(.*\)\#\(.*\)/s//if ( ! { grep -s name=\\"\2\\" \1 } ) echo \1	\2/p' tmp > tmp1
	csh -f tmp1

tidy:   tidy1
	for i in ${DIRS}; do (cd $$i; make tidy); done

tidy1:
	/bin/rm -f *~ *.bak *.tex tmp tmp1

clean: tidy1
	/bin/rm -f *.html *.tex
	for i in ${DIRS}; do (cd $$i; make clean); done

files: contents.html
files: overview.html
