# 	Generate TeX
#

W = ..
H = $(W)/..
TEX = ../Tools/TeX
GEN = ../Tools/HTMLGeneration

# 	ENTEX = sed -f html2latex.sed
LEVEL0 = sed -f $(TEX)/sub0.sed
FIRST0 = cat
LEVEL1 = sed -f $(TEX)/sub1.sed
LISTING = sed -f $(GEN)/txt2html.sed
XMP = sed -s $(TEX)/xmp.sed

TMP = /tmp/temp.html
TMPD = /tmp/daemon.html

#	The htmls type is an aglommeration of html files.

.SUFFIXES:
.SUFFIXES: .txt .ps .dvi .tex .htmls
#.SUFFIXES: .htmls .txt .tex .dvi .ps

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

#	Run TeX twice first to get the table of contents.
.tex.dvi :
	latex $<
	latex $<

.htmls.tex :
	rm -f $@
#	sed -f $(TEX)/html_clean.sed $< \
#	| sed -f $(TEX)/html2cernman.sed > $*.temp
	sed -f $(TEX)/html_clean.sed $< \
	| sed -f $(TEX)/html2rfc.sed > $*.temp
	cat $*.head $*.temp > $@
	sed -e '/documentstyle/s/times/cerndoc/' < $@ > $*-plain.tex


.htmls.txt :
	-rm junk.html
	cat $*-plainhead.html $< \
	  | sed -f $(TEX)/strip-title.sed > junk.html
	www -n -na -p54 -w70 junk.html | awk -f $*-plain.awk > $@


#	-cp $@ /pub/www/doc/$@

all :	http-spec.txt http-spec.ps \
	line-mode-guide.txt line-mode-guide.ps \
	html-spec.txt html-spec.ps \
	cvs-rcs.txt cvs-rcs.ps \
	cern-www-conditions.ps cern-www-conditions.txt \
	www-server-guide.ps www-server-guide.txt

clean :
	rm *.dvi *.log *.aux *.toc *.htmls *.temp


#		Checking for files we have missed
#		---------------------------------

html-files :
	find $(H) \! -perm -4 -prune -o -name "*.html" \! -name ",*" -print \
		> html-files
www-html-files :
	find $(W) \! -perm -4 -prune -o -name "*.html" \! -name ",*" -print \
		> $@
UP = \.\.\/
html-files2 : html-files Makefile
	sed -e 's?$(UP)$(UP)WWW/?$$(W)/?g' html-files \
	| sed -e 's?$(UP)$(UP)?$$(H)/?g' > $@

missing-files : html-files2
	-rm missing-files.bak
	-mv missing-files missing-files.bak
	grep '$$(W)' html-files2 | $(TEX)/find-missing | sort > missing-files


##	HTTP2 Protocol
#       --------------

http-spec.htmls :
	$(FIRST0)   $(W)/Protocols/HTTP/HTTP2.html > $@ 
	$(LEVEL0)   $(W)/Protocols/HTTP/Request.html >> $@   
	$(LEVEL1)     $(W)/Protocols/HTTP/Methods.html >> $@
	$(LEVEL3)	   $(W)/Protocols/HTTP/NoteMethodCS.html  >> $@
	$(LEVEL2)       $(W)/Protocols/HTTP/Methods/Get.html >> $@
	$(LEVEL3)	   $(W)/Protocols/HTTP/Methods/GetSearches.html  >> $@
	$(LEVEL2)	 $(W)/Protocols/HTTP/Methods/Link.html  >> $@
	$(LEVEL2)	 $(W)/Protocols/HTTP/Methods/Post.html  >> $@
	$(LEVEL2)	 $(W)/Protocols/HTTP/Methods/Search.html  >> $@
#	$(LEVEL1)     $(W)/Protocols/HTTP/old_Reasons.html >> $@

http-spec.tex : $(TEX)/html2cernman.sed http-spec.htmls
http-spec.dvi : http-spec.tex
http-spec.ps : http-spec.dvi
http-spec.txt : http-spec.htmls



