Convert to a "flat" Makefile.
diff --git a/Doc/Makefile b/Doc/Makefile
index 0bc2b2e..cd2129a 100644
--- a/Doc/Makefile
+++ b/Doc/Makefile
@@ -69,112 +69,148 @@
 # names of the downloadable tarballs.
 RELEASE=2.1a2
 
+PYTHON=	   python
+DVIPS=	   dvips -N0 -t $(PAPER)
+
+MKHOWTO=   $(TOOLSDIR)/mkhowto
+MKHTML=	   $(MKHOWTO) --html --about html/stdabout.dat \
+		--address $(PYTHONDOCS) --up-link ../index.html \
+		--up-title "Python Documentation Index" \
+		--global-module-index "../modindex.html"
+MKPDF=	   $(MKHOWTO) --paper=$(PAPER) --pdf
+MKPS=	   $(MKHOWTO) --paper=$(PAPER) --ps
+
+BUILDINDEX=$(TOOLSDIR)/buildindex.py
+
+PYTHONDOCS='See <i><a href="about.html">About this document...</a></i> for information on suggesting changes.'
+HTMLBASE=  file:`pwd`
+
+# what's what
+MANDVIFILES=	paper-$(PAPER)/api.dvi paper-$(PAPER)/ext.dvi \
+		paper-$(PAPER)/lib.dvi paper-$(PAPER)/mac.dvi \
+		paper-$(PAPER)/ref.dvi paper-$(PAPER)/tut.dvi
+HOWTODVIFILES=	paper-$(PAPER)/doc.dvi paper-$(PAPER)/inst.dvi \
+		paper-$(PAPER)/dist.dvi
+
+MANPDFFILES=	paper-$(PAPER)/api.pdf paper-$(PAPER)/ext.pdf \
+		paper-$(PAPER)/lib.pdf paper-$(PAPER)/mac.pdf \
+		paper-$(PAPER)/ref.pdf paper-$(PAPER)/tut.pdf
+HOWTOPDFFILES=	paper-$(PAPER)/doc.pdf paper-$(PAPER)/inst.pdf \
+		paper-$(PAPER)/dist.pdf
+
+MANPSFILES=	paper-$(PAPER)/api.ps paper-$(PAPER)/ext.ps \
+		paper-$(PAPER)/lib.ps paper-$(PAPER)/mac.ps \
+		paper-$(PAPER)/ref.ps paper-$(PAPER)/tut.ps
+HOWTOPSFILES=	paper-$(PAPER)/doc.ps paper-$(PAPER)/inst.ps \
+		paper-$(PAPER)/dist.ps
+
+DVIFILES=	$(MANDVIFILES) $(HOWTODVIFILES)
+PDFFILES=	$(MANPDFFILES) $(HOWTOPDFFILES)
+PSFILES=	$(MANPSFILES) $(HOWTOPSFILES)
+
+INDEXFILES=html/api/api.html \
+	html/doc/doc.html \
+	html/ext/ext.html \
+	html/lib/lib.html \
+	html/mac/mac.html \
+	html/ref/ref.html \
+	html/tut/tut.html \
+	html/inst/inst.html \
+	html/dist/dist.html
+
+COMMONPERL= perl/manual.perl perl/python.perl perl/l2hinit.perl
+
+include Makefile.deps
 
 # These must be declared phony since there
 # are directories with matching names:
 .PHONY: api doc ext lib mac ref tut inst dist
-.PHONY: html info longhtml
+.PHONY: html info
 
 
 # Main target
 all:	html
 
-dvi:
-	(cd paper-$(PAPER); $(MAKE) dvi)
+dvi:	$(DVIFILES)
+pdf:	$(PDFFILES)
+ps:	$(PSFILES)
 
-pdf:
-	(cd paper-$(PAPER); $(MAKE) pdf)
+world:	ps pdf html distfiles
 
-ps:
-	(cd paper-$(PAPER); $(MAKE) ps)
 
-world:	ps pdf html tarballs
+# Rules to build PostScript and PDF formats
+.SUFFIXES: .dvi .ps
+
+.dvi.ps:
+	$(DVIPS) -o $@ $<
 
 
 # Targets for each document:
-api.ps:
-	(cd paper-$(PAPER); $(MAKE) api.ps)
+# Python/C API Reference Manual
+paper-$(PAPER)/api.dvi: paper-$(PAPER)/api.tex $(APIFILES)
+	(cd paper-$(PAPER); $(MKDVI) api.tex)
 
-doc.ps:
-	(cd paper-$(PAPER); $(MAKE) doc.ps)
+paper-$(PAPER)/api.pdf: paper-$(PAPER)/api.tex $(APIFILES)
+	(cd paper-$(PAPER); $(MKPDF) api.tex)
 
-ext.ps:
-	(cd paper-$(PAPER); $(MAKE) ext.ps)
+paper-$(PAPER)/api.tex: api/api.tex api/refcounts.dat tools/anno-api.py
+	$(PYTHON) $(TOOLSDIR)/anno-api.py -o $@ api/api.tex
 
-lib.ps:
-	(cd paper-$(PAPER); $(MAKE) lib.ps)
+# Distributing Python Modules
+paper-$(PAPER)/dist.dvi: $(DISTFILES)
+	(cd paper-$(PAPER); $(MKDVI) ../dist/dist.tex)
 
-mac.ps:
-	(cd paper-$(PAPER); $(MAKE) mac.ps)
+paper-$(PAPER)/dist.pdf: $(DISTFILES)
+	(cd paper-$(PAPER); $(MKPDF) ../dist/dist.tex
 
-ref.ps:
-	(cd paper-$(PAPER); $(MAKE) ref.ps)
+# Documenting Python
+paper-$(PAPER)/doc.dvi: $(DOCFILES)
+	(cd paper-$(PAPER); $(MKDVI) ../doc/doc.tex
 
-tut.ps:
-	(cd paper-$(PAPER); $(MAKE) tut.ps)
+paper-$(PAPER)/doc.pdf: $(DOCFILES)
+	(cd paper-$(PAPER); $(MKPDF) ../doc/doc.tex_
 
-inst.ps:
-	(cd paper-$(PAPER); $(MAKE) inst.ps)
+# Extending and Embedding the Python Interpreter
+paper-$(PAPER)/ext.dvi: $(EXTFILES)
+	(cd paper-$(PAPER); $(MKDVI) ../ext/ext.tex)
 
-dist.ps:
-	(cd paper-$(PAPER); $(MAKE) dist.ps)
+paper-$(PAPER)/ext.pdf: $(EXTFILES)
+	(cd paper-$(PAPER); $(MKPDF) ../ext/ext.tex)
 
+# Installing Python Modules
+paper-$(PAPER)/inst.dvi: $(INSTFILES)
+	(cd paper-$(PAPER); $(MKDVI) ../inst/inst.tex)
 
-api.dvi:
-	(cd paper-$(PAPER); $(MAKE) api.dvi)
+paper-$(PAPER)/inst.pdf: $(INSTFILES)
+	(cd paper-$(PAPER); $(MKPDF) ../inst/inst.tex)
 
-doc.dvi:
-	(cd paper-$(PAPER); $(MAKE) doc.dvi)
+# Python Library Reference
+paper-$(PAPER)/lib.dvi: $(LIBFILES)
+	(cd paper-$(PAPER); $(MKDVI) ../lib/lib.tex)
 
-ext.dvi:
-	(cd paper-$(PAPER); $(MAKE) ext.dvi)
+paper-$(PAPER)/lib.pdf: $(LIBFILES)
+	(cd paper-$(PAPER); $(MKPDF) ../lib/lib.tex)
 
-lib.dvi:
-	(cd paper-$(PAPER); $(MAKE) lib.dvi)
+# Macintosh Library Modules
+paper-$(PAPER)/mac.dvi: $(MACFILES)
+	(cd paper-$(PAPER); $(MKDVI) ../mac/mac.tex)
 
-mac.dvi:
-	(cd paper-$(PAPER); $(MAKE) mac.dvi)
+paper-$(PAPER)/mac.pdf: $(MACFILES)
+	(cd paper-$(PAPER); $(MKPDF) ../mac/mac.tex)
 
-ref.dvi:
-	(cd paper-$(PAPER); $(MAKE) ref.dvi)
+# Python Reference Manual
+paper-$(PAPER)/ref.dvi: $(REFFILES)
+	(cd paper-$(PAPER); $(MKDVI) ../ref/ref.tex)
 
-tut.dvi:
-	(cd paper-$(PAPER); $(MAKE) tut.dvi)
+paper-$(PAPER)/ref.pdf: $(REFFILES)
+	(cd paper-$(PAPER); $(MKPDF) ../ref/ref.tex)
 
-inst.dvi:
-	(cd paper-$(PAPER); $(MAKE) inst.dvi)
+# Python Tutorial
+paper-$(PAPER)/tut.dvi: $(TUTFILES)
+	(cd paper-$(PAPER); $(MKDVI) ../tut/tut.tex)
 
-dist.dvi:
-	(cd paper-$(PAPER); $(MAKE) dist.dvi)
-
-
-api.pdf:
-	(cd paper-$(PAPER); $(MAKE) api.pdf)
-
-doc.pdf:
-	(cd paper-$(PAPER); $(MAKE) doc.pdf)
-
-ext.pdf:
-	(cd paper-$(PAPER); $(MAKE) ext.pdf)
-
-lib.pdf:
-	(cd paper-$(PAPER); $(MAKE) lib.pdf)
-
-mac.pdf:
-	(cd paper-$(PAPER); $(MAKE) mac.pdf)
-
-ref.pdf:
-	(cd paper-$(PAPER); $(MAKE) ref.pdf)
-
-tut.pdf:
-	(cd paper-$(PAPER); $(MAKE) tut.pdf)
-
-inst.pdf:
-	(cd paper-$(PAPER); $(MAKE) inst.pdf)
-
-dist.pdf:
-	(cd paper-$(PAPER); $(MAKE) dist.pdf)
-
+paper-$(PAPER)/tut.pdf: $(TUTFILES)
+	(cd paper-$(PAPER); $(MKPDF) ../tut/tut.tex)
 
 # The remaining part of the Makefile is concerned with various
 # conversions, as described above.  See also the README file.
@@ -198,47 +234,80 @@
 # instead.  The standard set does *not* include all the icons used in the
 # Python documentation.
 
-html:
-	(cd $(HTMLDIR); $(MAKE) PAPER=$(PAPER) -f ../html/Makefile)
+$(INDEXFILES): $(COMMONPERL) html/about.dat tools/node2label.pl
 
-api htmlapi:
-	(cd $(HTMLDIR); $(MAKE) PAPER=$(PAPER) -f ../html/Makefile api)
+html/acks.html: ACKS $(TOOLSDIR)/support.py $(TOOLSDIR)/mkackshtml
+	$(TOOLSDIR)/mkackshtml --address $(PYTHONDOCS) \
+		--output html/acks.html <../ACKS
 
-doc htmldoc:
-	(cd $(HTMLDIR); $(MAKE) PAPER=$(PAPER) -f ../html/Makefile doc)
+html/modindex.html: $(TOOLSDIR)/support.py $(TOOLSDIR)/mkmodindex
+html/modindex.html: html/lib/lib.html html/mac/mac.html
+	$(TOOLSDIR)/mkmodindex --columns 4 --output html/modindex.html \
+		--address $(PYTHONDOCS) \
+		html/lib/modindex.html html/mac/modindex.html
 
-ext htmlext:
-	(cd $(HTMLDIR); $(MAKE) PAPER=$(PAPER) -f ../html/Makefile ext)
+html:	$(INDEXFILES) html/index.html html/modindex.html html/acks.html
 
-lib htmllib:
-	(cd $(HTMLDIR); $(MAKE) PAPER=$(PAPER) -f ../html/Makefile lib)
+api html/api/api.html: $(APIFILES)
+	$(MKHTML) --dir html/api api/api.tex
 
-mac htmlmac:
-	(cd $(HTMLDIR); $(MAKE) PAPER=$(PAPER) -f ../html/Makefile mac)
+doc html/doc/doc.html: $(DOCFILES)
+	$(MKHTML) --dir html/doc doc/doc.tex
 
-ref htmlref:
-	(cd $(HTMLDIR); $(MAKE) PAPER=$(PAPER) -f ../html/Makefile ref)
+ext html/ext/ext.html: $(EXTFILES)
+	$(MKHTML) --dir html/ext ext/ext.tex
 
-tut htmltut:
-	(cd $(HTMLDIR); $(MAKE) PAPER=$(PAPER) -f ../html/Makefile tut)
+lib html/lib/lib.html: $(LIBFILES)
+	$(MKHTML) --dir html/lib lib/lib.tex
 
-inst htmlinst:
-	(cd $(HTMLDIR); $(MAKE) PAPER=$(PAPER) -f ../html/Makefile inst)
+mac html/mac/mac.html: $(MACFILES)
+	$(MKHTML) --dir html/mac mac/mac.tex
 
-dist htmldist:
-	(cd $(HTMLDIR); $(MAKE) PAPER=$(PAPER) -f ../html/Makefile dist)
+ref html/ref/ref.html: $(REFFILES)
+	$(MKHTML) --dir html/ref ref/ref.tex
 
-longhtml:
-	(cd longhtml; $(MAKE) PAPER=$(PAPER))
+tut html/tut/tut.html: $(TUTFILES)
+	$(MKHTML) --dir html/tut --numeric --split 3 tut/tut.tex
+
+inst html/inst/inst.html: $(INSTFILES) perl/distutils.perl
+	$(MKHTML) --dir html/inst inst/inst.tex
+
+dist html/dist/dist.html: $(DISTFILES) perl/distutils.perl
+	$(MKHTML) --dir html/dist dist/dist.tex
 
 
 # webchecker needs an extra flag to process the huge index from the libref
-webcheck:
-	(cd $(HTMLDIR); $(MAKE) -f ../html/Makefile webcheck)
+WEBCHECKER=$(PYTHON) ../Tools/webchecker/webchecker.py
+HTMLBASE=  file:`pwd`/html
+
+webcheck: html
+	$(WEBCHECKER) $(HTMLBASE)/api/
+	$(WEBCHECKER) $(HTMLBASE)/doc/
+	$(WEBCHECKER) $(HTMLBASE)/ext/
+	$(WEBCHECKER) -m290000 $(HTMLBASE)/lib/
+	$(WEBCHECKER) $(HTMLBASE)/mac/
+	$(WEBCHECKER) $(HTMLBASE)/ref/
+	$(WEBCHECKER) $(HTMLBASE)/tut/
+	$(WEBCHECKER) $(HTMLBASE)/dist/
+	$(WEBCHECKER) $(HTMLBASE)/inst/
+
+fastwebcheck: html
+	$(WEBCHECKER) -x $(HTMLBASE)/api/
+	$(WEBCHECKER) -x $(HTMLBASE)/doc/
+	$(WEBCHECKER) -x $(HTMLBASE)/ext/
+	$(WEBCHECKER) -x -m290000 $(HTMLBASE)/lib/
+	$(WEBCHECKER) -x $(HTMLBASE)/mac/
+	$(WEBCHECKER) -x $(HTMLBASE)/ref/
+	$(WEBCHECKER) -x $(HTMLBASE)/tut/
+	$(WEBCHECKER) -x $(HTMLBASE)/dist/
+	$(WEBCHECKER) -x $(HTMLBASE)/inst/
 
 
 # Release packaging targets:
 
+paper-$(PAPER)/README: ps $(TOOLSDIR)/getpagecounts
+	(cd paper-$(PAPER); ../$(TOOLSDIR)/getpagecounts >$@)
+
 info-$(RELEASE).tgz: info
 	(cd $(INFODIR); tar cf - README python.dir python-???.info*) \
 		| gzip -9 >$@
@@ -267,16 +336,13 @@
 	rm -f $@
 	(cd paper-$(PAPER); zip -q -9 ../$@ *.pdf)
 
-postscript-$(PAPER)-$(RELEASE).tar.bz2: ps
-	(cd paper-$(PAPER); $(MAKE) README)
+postscript-$(PAPER)-$(RELEASE).tar.bz2: ps paper-$(PAPER)/README
 	(cd paper-$(PAPER); tar cf - *.ps README) | bzip2 -9 >$@
 
-postscript-$(PAPER)-$(RELEASE).tgz: ps
-	(cd paper-$(PAPER); $(MAKE) README)
+postscript-$(PAPER)-$(RELEASE).tgz: ps paper-$(PAPER)/README
 	(cd paper-$(PAPER); tar cf - *.ps README) | gzip -9 >$@
 
-postscript-$(PAPER)-$(RELEASE).zip: ps
-	(cd paper-$(PAPER); $(MAKE) README)
+postscript-$(PAPER)-$(RELEASE).zip: ps paper-$(PAPER)/README
 	rm -f $@
 	(cd paper-$(PAPER); zip -q -9 ../$@ *.ps README)
 
@@ -295,11 +361,6 @@
 	(cd $(HTMLDIR); \
 		zip -q -9 ../$@ *.html */*.css */*.html */*.gif)
 
-longhtml-$(RELEASE).zip:	longhtml
-	rm -f $@
-	(cd longhtml; \
-		zip -q -9 ../$@ */*.css */*.html */*.gif)
-
 # convenience targets:
 
 tarhtml:	html-$(RELEASE).tgz
@@ -311,15 +372,10 @@
 tarballs:	tarpdf tarps tarhtml
 
 ziphtml:	html-$(RELEASE).zip
-ziplonghtml:	longhtml-$(RELEASE).zip
 zipps:		postscript-$(PAPER)-$(RELEASE).zip
 zippdf:		pdf-$(PAPER)-$(RELEASE).zip
 ziplatex:	latex-$(RELEASE).zip
 
-# Only build the longhtml version for final releases; use the second
-# version of this for pre-release versions.
-#
-#zips:		zippdf zipps ziphtml ziplonghtml
 zips:		zippdf zipps ziphtml
 
 bziphtml:	html-$(RELEASE).tar.bz2
@@ -341,24 +397,32 @@
 # - useful results: .dvi, .pdf, .ps, .texi, .info
 clean:
 	(cd paper-$(PAPER); $(MAKE) clean)
-	(cd longhtml; $(MAKE) clean)
-	(cd $(HTMLDIR); $(MAKE) clean)
 	(cd $(INFODIR); $(MAKE) clean)
 
-l2hclean:
-	(cd $(HTMLDIR); $(MAKE) clean)
-
 # Remove temporaries as well as final products
 clobber:
-	(cd $(HTMLDIR); $(MAKE) clobber)
 	rm -f html-$(RELEASE).tgz info-$(RELEASE).tgz
 	rm -f pdf-$(RELEASE).tgz postscript-$(RELEASE).tgz
 	rm -f latex-$(RELEASE).tgz html-$(RELEASE).zip
 	rm -f pdf-$(RELEASE).zip postscript-$(RELEASE).zip
-	(cd paper-$(PAPER); $(MAKE) clobber)
-	(cd longhtml; $(MAKE) clobber)
-	(cd $(HTMLDIR); $(MAKE) clobber)
+	rm -f $(DVIFILES) $(PSFILES) $(PDFFILES)
 	(cd $(INFODIR); $(MAKE) clobber)
+	rm -rf html/index.html html/modindex.html html/acks.html
+	rm -rf html/api/ html/doc/ html/ext/ html/lib/ html/mac/
+	rm -rf html/ref/ html/tut/ html/inst/ html/dist/
 
-realclean:  clobber
-distclean:  clobber
+realclean distclean:  clobber
+
+
+# html/index.html is dependent on $(INDEXFILES) since we want the date
+# on the front index to be updated whenever any of the child documents
+# are updated and boilerplate.tex uses \today as the date.
+
+# It's at the end of the file since it wedges font-lock in XEmacs.
+
+BOILERPLATE=texinputs/boilerplate.tex
+html/index.html: html/index.html.in $(BOILERPLATE) $(INDEXFILES)
+	DATE=`grep '\\date{' $(BOILERPLATE) | sed 's/.*\\date{\(.*\)}.*$$/\1/'` ; \
+	if [ "$$DATE" = '\today' ] ; then DATE=`date '+%B %e, %Y'`;fi;\
+	sed -e "s/@DATE@/$$DATE/g" -e "s/@RELEASE@/$(RELEASE)/g" \
+		$< >$@