TEXSRC := $(wildcard *.tex)
HTML := $(foreach SRC,$(TEXSRC),$(addprefix $(subst .tex,,$(SRC))/,$(subst .tex,.html,$(SRC))))
TXT := $(wildcard *.txt)
HTML2 := $(subst txt,html,$(TXT))
PS := $(subst tex,ps,$(TEXSRC))

all: .identifier_save $(PS)

force:
	dbase_maker $(HTML) $(HTML2); linker $(HTML) $(HTML2); link_back $(HTML) $(HTML2);

clean: 
	rm */*.html *.ps *.html *~ identifier.html

.identifier_save: $(HTML) $(HTML2)
	dbase_maker $?; linker $?; link_back $?;

# this dependency isn't working.  Don't know why.
$(HTML): %.html: $(notdir $(%.tex)) 
	/usr/local/bin/latex2html -split 0 -link 0 -address 0 -no_navigation -info 0 -t $(notdir $(basename $@)) $(notdir $(subst html,tex,$@)); stable_sub "$(subst target,$(notdir $(subst html,tex,$@)),<hr> <a href=../target>source</a>)" "</body>" $@; stable_sub "$(subst target,$(notdir $(subst html,ps,$@)),<hr> <a href=../target>psfile</a>)" "</body>" $@; stable_sub " <A HREF="mailto:jl@crush.caltech.edu">jl@crush.caltech.edu</A>" "</body>" $@; stable_sub " <A HREF="identifier.html">index</A>" "</body>" $@;

%.dvi: %.tex
	latex $<

%.ps: %.dvi
	dvips $< -o $@

$(HTML2): %.html: %.txt
	txt2html $< > $@; stable_sub "$(subst target,$<,<hr> <a href=target>source</a>)" "</body>" $@; stable_sub " <A HREF="mailto:jl@crush.caltech.edu">jl@crush.caltech.edu</A>" "</body>" $@; stable_sub " <A HREF="identifier.html">index</A>" "</body>" $@;
