[web] Reorganize Makefiles

Stephen J. Turnbull stephen at xemacs.org
Wed Feb 20 01:53:31 EST 2008


web

Will commit after sufficient time for discussion (Adrian's been
inactive recently, definitely want his opinion).

I've been having problems for a while with "make validate" in the web
tree computing the set of changed HTML files incorrectly.  This turns
out to be a problem with a race between computation of the HTML
changes and actually regenerating the files: the computation generally
wins because that's done when the Makefile is read, before any
regeneration is done by the htdocs target.  I've fixed this by
delegating the validation step to a submake.

I also found the many examples of Windows usage in
Local.rules.template annoying for a long time.  It occurred to me that
Windows users probably find the Unixoid stuff just as annoying so I
decided to separate them into separate templates.

There was some stuff for compatibility with non-GNU Makes, but getting
the validation dependencies right requires using non-recursive
evaluation AFAICS.  So there's no chance we'll ever be able to use a
less capable Make, and nuked stuff like the phone FORCE target in
favor of the .PHONY directive.

I also moved all the timestamps into a subdirectory to get rid of the
clutter.

Finally, I updated .cvsignore for these changes.

Index: ChangeLog
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacsweb/ChangeLog,v
retrieving revision 1.280
diff -u -U0 -r1.280 ChangeLog
--- ChangeLog	11 Feb 2008 03:36:38 -0000	1.280
+++ ChangeLog	20 Feb 2008 06:34:02 -0000
@@ -0,0 +1,16 @@
+2008-02-19  Stephen J. Turnbull  <stephen at xemacs.org>
+
+	* .cvsignore: Add .stamps, some common generated files.
+	Remove no-longer-used stamp files in top-directory.
+
+	* Local.rules.windows: New template file for use on Windows.
+
+	* Local.rules.mk:
+	* Local.rules.template:
+	* Makefile:
+	Document public targets.
+	New everything target (not quite everything, doesn't linklint).
+	Fix bug in computing changed HTML for validate target.
+	Use a .stamps directory.  Reorganize stamping to use it.
+	Get rid of FORCE dependencies, since GNU Make supports .PHONY.
+

Index: .cvsignore
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacsweb/.cvsignore,v
retrieving revision 1.3
diff -u -r1.3 .cvsignore
--- .cvsignore	8 Jun 2003 23:14:41 -0000	1.3
+++ .cvsignore	20 Feb 2008 06:34:05 -0000
@@ -1,9 +1,10 @@
+*~
+*.rej
+*.orig
 *.err
 *.patch
 Local.rules
-genpage-time-stamp
-htdocs-time-stamp
 index.html
 linklint
 logs
-validate-time-stamp
+.stamps
Index: Local.rules.mk
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacsweb/Local.rules.mk,v
retrieving revision 1.1
diff -u -r1.1 Local.rules.mk
--- Local.rules.mk	15 Mar 2003 13:07:31 -0000	1.1
+++ Local.rules.mk	20 Feb 2008 06:34:06 -0000
@@ -1,4 +1,6 @@
-# Include file for Local.rules.
+#   Include file for Local.rules.
+
+#   Sanity checks:
 
 ifeq (${XEMACS_WEBSITE_BASE},)
 ___:= $(error XEMACS_WEBSITE_BASE not defined??)
@@ -16,3 +18,33 @@
 else
 	$(error "$(notdir $<)" has been updated or is newer than "$(notdir $@)".  Merge the changes into your "$(notdir $@)".)
 endif
+
+#   Default program settings for Unix.
+#   DON'T CHANGE THIS FILE.  Override them in Local.rules.
+#   For Windows, copy Local.rules.windows to Local.rules to get some
+#   reasonable defaults for windows.
+
+XEMACS=xemacs
+FLAGS=-batch -vanilla
+
+FIND=find
+MKDIR=mkdir
+
+LINKLINT=linklint
+LINKLINT_OUTDIR=linklint
+LINKLINT_CASE=
+#   Ignore checking of links into the XEmacs CVS repository via ViewCVS.
+#   These checks are expensive and links are correct by design.
+LINKLINT_IGNORESET=-ignore http://cvs.xemacs.org/viewcvs.cgi/XEmacs/@
+
+#   mknmz command
+#   used to reindex the site for namazu
+MKNMZ=mknmz
+#   location of namazu index directory
+#   Only www.xemacs.org is setup up for namazu indexing as of 2006-02-11.
+NAMAZU_INDEX_DIR=/web/http-xemacs/var/namazu/index
+
+TEXI2HTML = texi2html
+
+# "hidden" directory to hold timestamps
+STAMPS=.stamps
Index: Local.rules.template
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacsweb/Local.rules.template,v
retrieving revision 1.9
diff -u -r1.9 Local.rules.template
--- Local.rules.template	2 Oct 2007 19:41:56 -0000	1.9
+++ Local.rules.template	20 Feb 2008 06:34:06 -0000
@@ -1,57 +1,52 @@
-# Local.rules - Site-Local definitions.
+#   Local.rules - Site-Local definitions.
 
-# APA: This is what I use on my Windows 2000 machine:
-XEMACS=xemacs
-# XEMACS=c:/PROGRA~1/XEmacs/XEmacs-21.1.14/i386-pc-win32/xemacs.exe
-# XEMACS=/cygdrive/c/PROGRA~1/XEmacs/XEmacs-21.1.14/i386-pc-win32/xemacs.exe
-# FLAGS=-batch -q -no-site-file
-FLAGS=-batch -vanilla
-
-# APA: Windows has its own, inadequate find, use Cygwin instead!
-FIND=find
-# FIND=c:/cygwin/bin/find.exe
-
-# APA: Where to find and how to run linklint.
-LINKLINT=linklint
-# LINKLINT=perl linklint-2.3.6.d-adrian
-LINKLINT_OUTDIR=linklint
-# APA: Add -case switch on Windows to get correct filename case in
-# linklint log files.  This option causes error on UNIX.
-LINKLINT_CASE=
-# LINKLINT_CASE=-case
-# APA: Ignore checking of links into the XEmacs CVS repository via ViewCVS.
-# These checks are expensive and links are correct by design.
-LINKLINT_IGNORESET=-ignore http://cvs.xemacs.org/viewcvs.cgi/XEmacs/@
-
-GENPAGE_CONF="genpage.conf"
-
-ELCS=batch-psgml-validate.elc release-mail-to-html.elc
-
-# APA: Use these definitions for GNU make
-CONTENT_FILES=$(shell $(FIND) . -path ./genpage -prune -o -name "*.content" -print)
-GENERATED_HTML_FILES=$(CONTENT_FILES:.content=.html)
-# APA: Files generated by texi2html do not need to be validated.
-HTML_FILES=$(shell $(FIND) . \( -path "./Documentation/21.5/html/*" -o -path "./Documentation/packages/html/*" -o -path "./linklint*" -o -path "./Documentation/sources/*" -prune \) -o -name "*.html" -print)
-
-# mknmz command
-# used to reindex the site for namazu
-MKNMZ=mknmz
-# location of namazu index directory
-# Only www.xemacs.org is setup up for namazu indexing as of 2006-02-11.
-NAMAZU_INDEX_DIR=/web/http-xemacs/var/namazu/index
-
-TEXI2HTML = texi2html
-# www.xemacs.org:
-# TEXI2HTML = perl /web/http-xemacs/xemacsweb/Texi2html/texi2html
-# www.sunsite.dk:
-# TEXI2HTML = perl /pack/ftp/projects/xemacs/xemacsweb/Texi2html/texi2html
-# www.us.xemacs.org:
-# TEXI2HTML = perl /home/groups/x/xe/xemacs/xemacsweb/Texi2html/texi2html
-# TANG:
-# TEXI2HTML=perl "c:/Hacking/cvs.xemacs.org/XEmacs/xemacsweb/Texi2html/texi2html"
+#   This is the local rules file for *nix.
+#   The default values are the same as in Local.rules.mk.
+#   Copy it to Local.rules.  Then make any necessary customizations,
+#   and uncomment them.
+#   If you are running Windows, you may find Local.rules.windows more useful.
+
+#   If uncommented, this will become the default target.
+
+#default: validate
+
+#   Programs and their options
+
+#XEMACS=xemacs
+#FLAGS=-batch -vanilla
+
+#FIND=find
+#MKDIR=mkdir
+
+#LINKLINT=linklint
+#LINKLINT_OUTDIR=linklint
+#LINKLINT_CASE=
+#   Ignore checking of links into the XEmacs CVS repository via ViewCVS.
+#   These checks are expensive and links are correct by design.
+#LINKLINT_IGNORESET=-ignore http://cvs.xemacs.org/viewcvs.cgi/XEmacs/@
+
+#   mknmz command
+#   used to reindex the site for namazu
+#MKNMZ=mknmz
+#   location of namazu index directory
+#   Only www.xemacs.org is setup up for namazu indexing as of 2006-02-11.
+#NAMAZU_INDEX_DIR=/web/http-xemacs/var/namazu/index
+
+#TEXI2HTML = texi2html
+
+#   www.xemacs.org:
+#TEXI2HTML = perl /web/http-xemacs/xemacsweb/Texi2html/texi2html
+#   www.sunsite.dk:
+#TEXI2HTML = perl /pack/ftp/projects/xemacs/xemacsweb/Texi2html/texi2html
+#   www.us.xemacs.org:
+#TEXI2HTML = perl /home/groups/x/xe/xemacs/xemacsweb/Texi2html/texi2html
+#   TANG:
+#TEXI2HTML=perl "c:/Hacking/cvs.xemacs.org/XEmacs/xemacsweb/Texi2html/texi2html"
+
+#STAMPS=.stamps
 
 #
-# Local Variables:
-# mode: makefile
-# End:
+#   Local Variables:
+#   mode: makefile
+#   End:
 #
Index: Local.rules.windows
===================================================================
RCS file: Local.rules.windows
diff -N Local.rules.windows
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ Local.rules.windows	20 Feb 2008 06:34:06 -0000
@@ -0,0 +1,66 @@
+# Local.rules - Site-Local definitions.
+
+#   If uncommented, this will become the default target.
+
+#default: validate
+
+#   Programs and their options
+
+# APA: This is what I use on my Windows 2000 machine:
+XEMACS=xemacs
+# XEMACS=c:/PROGRA~1/XEmacs/XEmacs-21.1.14/i386-pc-win32/xemacs.exe
+# XEMACS=/cygdrive/c/PROGRA~1/XEmacs/XEmacs-21.1.14/i386-pc-win32/xemacs.exe
+# FLAGS=-batch -q -no-site-file
+FLAGS=-batch -vanilla
+
+# APA: Windows has its own, inadequate find, use Cygwin instead!
+FIND=find
+# FIND=c:/cygwin/bin/find.exe
+MKDIR=mkdir
+
+# APA: Where to find and how to run linklint.
+LINKLINT=linklint
+# LINKLINT=perl linklint-2.3.6.d-adrian
+LINKLINT_OUTDIR=linklint
+# APA: Add -case switch on Windows to get correct filename case in
+# linklint log files.  This option causes error on UNIX.
+LINKLINT_CASE=
+# LINKLINT_CASE=-case
+# APA: Ignore checking of links into the XEmacs CVS repository via ViewCVS.
+# These checks are expensive and links are correct by design.
+LINKLINT_IGNORESET=-ignore http://cvs.xemacs.org/viewcvs.cgi/XEmacs/@
+
+GENPAGE_CONF="genpage.conf"
+
+ELCS=batch-psgml-validate.elc release-mail-to-html.elc
+
+# APA: Use these definitions for GNU make
+CONTENT_FILES=$(shell $(FIND) . -path ./genpage -prune -o -name "*.content" -print)
+GENERATED_HTML_FILES=$(CONTENT_FILES:.content=.html)
+# APA: Files generated by texi2html do not need to be validated.
+HTML_FILES=$(shell $(FIND) . \( -path "./Documentation/21.5/html/*" -o -path "./Documentation/packages/html/*" -o -path "./linklint*" -o -path "./Documentation/sources/*" -prune \) -o -name "*.html" -print)
+
+# mknmz command
+# used to reindex the site for namazu
+MKNMZ=mknmz
+# location of namazu index directory
+# Only www.xemacs.org is setup up for namazu indexing as of 2006-02-11.
+NAMAZU_INDEX_DIR=/web/http-xemacs/var/namazu/index
+
+TEXI2HTML = texi2html
+# www.xemacs.org:
+# TEXI2HTML = perl /web/http-xemacs/xemacsweb/Texi2html/texi2html
+# www.sunsite.dk:
+# TEXI2HTML = perl /pack/ftp/projects/xemacs/xemacsweb/Texi2html/texi2html
+# www.us.xemacs.org:
+# TEXI2HTML = perl /home/groups/x/xe/xemacs/xemacsweb/Texi2html/texi2html
+# TANG:
+# TEXI2HTML=perl "c:/Hacking/cvs.xemacs.org/XEmacs/xemacsweb/Texi2html/texi2html"
+
+STAMPS=.stamps
+
+#
+# Local Variables:
+# mode: makefile
+# End:
+#
Index: Makefile
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacsweb/Makefile,v
retrieving revision 1.57
diff -u -r1.57 Makefile
--- Makefile	17 Dec 2007 23:17:30 -0000	1.57
+++ Makefile	20 Feb 2008 06:34:06 -0000
@@ -1,50 +1,82 @@
 # -*-Makefile-*- Begin of xemacsweb Makefile
 #
 # Adrian Aichner (APA), aichner at ecf.teradyne.com, Teradyne GmbH, 2000-07-29.
+# Stephen Turnbull (stephen), stephen at xemacs.org, 2008-02-02
 #
-# xemacsweb makefile for UNIX and Windows NT,
-# requiring GNU make, available on Windows NT via Cygwin
-#
-# Please adjust definitions of CONTENT_FILES and HTML_FILES for other
-# versions of make.
+# xemacsweb makefile for UNIX and Windows NT.
+# Requires GNU make, available on Windows NT via Cygwin and MSYS.
+# (This Makefile uses immediately-expanded assignments in an essential way.)
 #
 # Supported targets:
-# htdocs (default): creation of .html from .content files
-# validate: validation of all .html files using XEmacs/PSGML
-# all: creation and validation
 #
+# all:              same as validate [default target]
+# everything:       validate + namazu-re-index + Download/win32
+# validate:         htdocs + validation of all .html files using XEmacs/PSGML
+# htdocs:           creation of .html from .content files using genpage
+# linklint:         run linklint on the tree, including remote links
+# namazu-re-index:  run the namazu indexer on the tree
+# Documentation:    make HTML documents from XEmacs 21.5 sources
+# Download/win32:   update Win32 download information
 
-# Use a Local.rules file to specify what you wish to have installed
-XEMACS_WEBSITE_BASE:= $(shell pwd)
+################ Override variables in Local.rules. ################
+################  No user-serviceable parts below.  ################
 
-all: validate
+.SUFFIXES:			   # Delete the default suffixes
+.SUFFIXES: .content .html .el .elc # Define our suffix list
+.PHONY: namazu-re-index linklint Documentation Download/win32
+
+XEMACS_WEBSITE_BASE:= $(shell pwd)
+
+# Prune directories where we won't find .content files
+# or HTML files requiring validation.
+
+PRUNE_GENPAGE:= -path ./genpage -prune
+PRUNE_LINKLINT:= -path "./linklint*" -prune
+PRUNE_215_TEXI:= -path ./Documentation/21.5/html -prune
+PRUNE_PKG_TEXI:= -path ./Documentation/packages/html -prune
+PRUNES:= $(PRUNE_GENPAGE) -o $(PRUNE_LINKLINT)
+PRUNES:= \( $(PRUNES) -o $(PRUNE_215_TEXI) -o $(PRUNE_PKG_TEXI) \)
+
+# Define collections of files to process.
+
+# These must be recursively-expanded variables.  FIND is defined in Local.rules.
+CONTENT_FILES        = $(shell $(FIND) . $(PRUNES) -o -name "*.content" -print)
+GENERATED_HTML_FILES = $(CONTENT_FILES:.content=.html)
+VALIDATE_HTML_FILES  = $(shell $(FIND) . $(PRUNES) -o -name "*.html" -print)
+
+# Some prerequisites we use.
+
+GENPAGE_CONF:= "genpage.conf"
+ELCS:= batch-psgml-validate.elc release-mail-to-html.elc
+
+#   Include the sanity checks and default program locations.
 
 include Local.rules.mk
+# Include any local overrides specified by the user.
 -include Local.rules
 
-.SUFFIXES:			   # Delete the default suffixes
-.SUFFIXES: .content .html .el .elc # Define our suffix list
+#   Targets
 
-# APA: Default target (first to occur in file):
-validate: htdocs validate-time-stamp
+#   Default target; must come before other targets but after Local.rules.
+all: validate
 
-htdocs: $(ELCS) $(GENERATED_HTML_FILES)
+everything: validate Download/win32 namazu-re-index
 
-$(GENERATED_HTML_FILES): htdocs-time-stamp
+validate: htdocs $(STAMPS)/validate
 
-# APA: Compile any lisp file for performance (a bit simple-minded, maybe).
-%.elc: %.el
-	$(XEMACS) $(FLAGS) -f batch-byte-compile $<
+htdocs: $(GENERATED_HTML_FILES)
 
-all: Download/win32 validate namazu-re-index
+$(GENERATED_HTML_FILES): $(ELCS) $(STAMPS)/htdocs
 
 # APA: Run linklint on the local working directory tree, including
 # remote link checking (-net).
 # Use -output_index site so that all files are reachable in directory
 # and not hidden by index.html, which does not reference url*.html
 # files.
-linklint: FORCE
-	$(LINKLINT) $(LINKLINT_CASE) -docbase http://www.xemacs.org -net -limit 0 -db3 /@ -doc $(LINKLINT_OUTDIR) $(LINKLINT_IGNORESET) -output_index site -timeout 30
+linklint:
+	$(LINKLINT) $(LINKLINT_CASE) -docbase http://www.xemacs.org \
+		-net -limit 0 -db3 /@ -doc $(LINKLINT_OUTDIR) \
+		$(LINKLINT_IGNORESET) -output_index site -timeout 30
 
 # APA: To be run after initial checkout of module.
 # Create directory for commit logs.
@@ -55,7 +87,8 @@
 # APA: The genpage/content/index.content is not the only dependency,
 # but any improvements should go into the genpage/Makefile itself and
 # be integrated with a genpage release.
-init:
+init: $(STAMPS)/init
+	rm $(STAMPS)/init
 	if test ! -d logs; then \
 	      mkdir logs; \
 	fi;
@@ -68,12 +101,13 @@
 	cd genpage; $(MAKE) gp
 	cd Texi2html; bash configure; make
 	cd FAQ; $(MAKE)
+	touch $(STAMPS)/init
 
 # APA: When contentdir and outputdir are the same then, and only then,
 # genpage depends only on content files.  Copying of all other files
 # (from contentdir to outputdir) is not necessary in this case.
 # See $(GENPAGE_CONF).
-htdocs-time-stamp: $(CONTENT_FILES) \
+$(STAMPS)/htdocs: $(STAMPS) $(CONTENT_FILES) \
 	template.html \
 	template-de.html \
 	template-ja.html \
@@ -85,7 +119,7 @@
 	Download/win32/innosetup-win32.txt \
 	Download/win32/installshield-win32.txt
 	perl ./genpage/bin/genpage -q -p $(GENPAGE_CONF) -o "."
-	touch htdocs-time-stamp
+	touch $(STAMPS)/htdocs
 
 # APA: Validate only files younger than time-stamp file created by
 # previous validation
@@ -93,15 +127,26 @@
 # (defun batch-psgml-validate (&optional file-or-dir)
 # (defun batch-psgml-validate-file (file &optional insert-result indent)
 # (defun batch-psgml-validate-buffer (&optional insert-result indent)
-validate-time-stamp: $(HTML_FILES)
+
+# stephen: $(VALIDATE_HTML_FILES) *must* be evaluated when Make creates
+# its dependency graph, so that will happen before htdocs is made in the
+# toplevel make.  So we use a recursive make to ensure that htdocs has
+# already made all the needed HTML by the time the arguments to
+# batch-psgml-validate are computed.
+# The conditional is to avoid doing the find in the toplevel make.
+$(STAMPS)/validate: $(STAMPS) $(VALIDATE_HTML_FILES)
+	make real-validate SUBMAKE=validate
+	touch $(STAMPS)/validate
+ifeq ($(SUBMAKE),validate)
+real-validate: $(VALIDATE_HTML_FILES)
 	$(XEMACS) $(FLAGS) -l ./batch-psgml-validate.elc -f batch-psgml-validate $?
-	touch validate-time-stamp
+endif
 
 # PB: target for rebuilding the namazu index
 # APA: Touch index.html for index template files to be re-generated.
 # www.xemacs.org has a patched mknmz that will update index files,
 # unless they are newer than the associated template.
-namazu-re-index: FORCE
+namazu-re-index:
 	touch index.html
 	if test -n "$(NAMAZU_INDEX_DIR)" -a -d "$(NAMAZU_INDEX_DIR)"; then \
 		$(MKNMZ) --output-dir=$(NAMAZU_INDEX_DIR) . ; \
@@ -111,15 +156,22 @@
 # files.  Need to remove timestamp files as well!
 clean:
 	$(FIND) . \( -name "*.content" -o -name "*~" \) -print | perl -ne "{ chomp; s/\.content/.html/; unlink; }"
-	rm -f htdocs-time-stamp
-	rm -f validate-time-stamp
+	rm -f $(STAMPS)/htdocs
+	rm -f $(STAMPS)/validate
 
-Documentation: FORCE
+Documentation:
 	cd $@ && $(MAKE) TEXI2HTML="$(TEXI2HTML)" all
 
-Download/win32: FORCE
+Download/win32:
 	cd $@ && $(MAKE)
 
-FORCE:
+# APA: Compile any lisp file for performance (a bit simple-minded, maybe).
+%.elc: %.el
+	$(XEMACS) $(FLAGS) -f batch-byte-compile $<
+
+#    Scaffolding
+
+$(STAMPS):
+	$(MKDIR) $(STAMPS)
 
 # End of xemacsweb Makefile



More information about the XEmacs-Patches mailing list