Commits

Stephen Turnbull  committed 1da4bd4

* Refactor Makefiles.
- Remove/fix bogus or outdated comments.
- Reduce Local.rules* to variable definitions and one default rule.
- Rename some targets.
- Improve environment sanity checking.
- Remove non-portable --max-chars option to xargs.

  • Participants
  • Parent commits 289e2fc

Comments (0)

Files changed (3)

File Local.rules.mk

-#   Include file for Local.rules.
+#   Set up variable defaults to be overridden by Local.rules.
+#   This file should contain only Make variable assignments!
 
-#   Sanity checks:
-
-ifeq (${XEMACS_WEBSITE_BASE},)
-___:= $(error XEMACS_WEBSITE_BASE not defined??)
-endif
-
-___:= $(shell [ -f ${XEMACS_WEBSITE_BASE}/Local.rules ] && echo exists)
-
-Local.rules: ${XEMACS_WEBSITE_BASE}/Local.rules
-.PHONY: Local.rules
-
-${XEMACS_WEBSITE_BASE}/Local.rules: ${XEMACS_WEBSITE_BASE}/Local.rules.template
-ifneq (${___},exists)
-	command := $(shell cp -p $< $@)
-	$(error You must edit "$(notdir $@)" and customize it for this build host.)
-else
-	$(error "$(notdir $<)" has been updated or is newer than "$(notdir $@)".  Merge the changes into your "$(notdir $@)".)
-endif
+XEMACS_WEBSITE_BASE := $(shell pwd)
+# "hidden" directory to hold timestamps
+STAMPS=.stamps
 
 #   Default program settings for Unix.
 #   DON'T CHANGE THIS FILE.  Override them in Local.rules.
 #   reasonable defaults for windows.
 
 XEMACS=xemacs
-FLAGS=-eval '(kill-emacs 0)' -batch -q -no-site-file
+FLAGS= -batch -q -no-site-file
 
 FIND=find
 MKDIR=mkdir
 LINKLINT_CASE=
 #   Ignore checking of links into the XEmacs CVS repository via ViewCVS.
 #   These checks are expensive and links are correct by design.
+#   #### This is out of date!!
 LINKLINT_IGNORESET=-ignore http://cvs.xemacs.org/viewcvs.cgi/XEmacs/@
 
 #   mknmz command
 
 TEXI2HTML = texi2html
 
-# "hidden" directory to hold timestamps
-STAMPS=.stamps
+include Local.rules

File Local.rules.template

-#   Local.rules - Site-Local definitions.
+##  Local.rules - Site-Local definitions.
 
 #   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.
 
+#   As distributed, this file is a no-op.
+#   To use, copy it to Local.rules.
+
+##  Targets
+#   Rules defined here should specify only dependencies.
+
 #   If uncommented, this will become the default target.
 
-#default: validate
+#default: validdocs
 
-#   Programs and their options
+##  Basic environment variables.
+#   If possible, it's best to fix problems without customizing these.
+
+#XEMACS_WEBSITE_BASE := $(shell pwd)
+#STAMPS=.stamps
+
+##  Programs and their options
+
+#   Make customizations to variables where needed, and uncomment them.
+#   If programs work with the default values, customization of the
+#   corresponding variables is unnecessary.
 
 #XEMACS=xemacs
 #FLAGS=-batch -vanilla
 #LINKLINT_CASE=
 #   Ignore checking of links into the XEmacs CVS repository via ViewCVS.
 #   These checks are expensive and links are correct by design.
+#   #### This is out of date!!
 #LINKLINT_IGNORESET=-ignore http://cvs.xemacs.org/viewcvs.cgi/XEmacs/@
 
 #   mknmz command
 
 #TEXI2HTML = texi2html
 
+##  Configurations used by XEmacs.org:
 #   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:
+#   www.us.xemacs.org (SourceForge):
 #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
-# -*-Makefile-*- Begin of xemacsweb Makefile
+# -*-Makefile-*-  for Unix and Windows NT.
 #
 # Adrian Aichner (APA), aichner@ecf.teradyne.com, Teradyne GmbH, 2000-07-29.
 # Stephen Turnbull (stephen), stephen@xemacs.org, 2008-02-02
 #
-# 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.)
 #
+# You *must* provide a Local.rules file, but it can be a no-op.
+# Templates are provided in Local.rules.template and Local.rules.windows.
+#
 # Supported targets:
 #
-# 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
+# all:              Builtin default target.  Runs "make validdocs checkconfig".
+# everything:       validdocs + namazu-re-index + Download/win32
+# validdocs:        Generate all .html files, and validate them
+# 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,
+# checkconfig:	    Check for problems in environment and fix where possible.
 
 ################ Override variables in Local.rules. ################
 ################  No user-serviceable parts below.  ################
 .SUFFIXES: .content .html .el .elc # Define our suffix list
 .PHONY: namazu-re-index linklint Documentation Download/win32
 
-XEMACS_WEBSITE_BASE := $(shell pwd)
+#   Include the default configuration.
+#   Local.rules.mk includes Local.rules itself, and sanity checks the result.
+include Local.rules.mk
 
-# Prune directories where we won't find .content files
-# or HTML files requiring validation.
+# Define collections of files to process.
+# The *_FILES variables are computed when accessed.
 
+# These are recursively-expanded, because 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) $(GENERATED_HTML_FILES)
+
+# Define directories to prune because we won't find .content files
+# or HTML files requiring validation in them.
 PRUNE_GENPAGE  := -path ./genpage -prune
 PRUNE_LINKLINT := -path "./linklint*" -prune
 PRUNE_215_TEXI := -path ./Documentation/21.5/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) $(GENERATED_HTML_FILES)
-
 # 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
-
-#   Targets
+#   Rules
 
 #   Default target; must come before other targets but after Local.rules.
-# all: validate
-# Just generate .html from .content without validate until validation
-# is working incrementally again.
-# APA: Must touch $(STAMPS)/htdocs as well since validation updates
-# dependencies of $(STAMPS)/htdocs
-all: FAQ Documentation validate namazu-re-index
+all: checkconfig validdocs
 
-everything: validate FAQ Documentation Download/win32 namazu-re-index
+validdocs: $(ELCS) htdocs $(STAMPS)/validate
 
-validate: htdocs $(ELCS) $(STAMPS)/validate
+everything: checkconfig validate FAQ Documentation Download/win32 namazu-re-index
 
 htdocs: $(STAMPS)/htdocs
 
 # Create directory for commit logs.
 # Create compatibility link faq.
 # configure and build Texi2html.
-# APA: Build the genpage documentation.  Maintain a timestamp to avoid
-# needless re-generation of genpage release documentation.
-# 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:
-	if test ! -d $(STAMPS); then \
-	      $(MKDIR) $(STAMPS); \
-	fi;
-	if test ! -d logs; then \
-	      mkdir logs; \
-	fi;
-	if test ! -d $(LINKLINT_OUTDIR); then \
-	      mkdir $(LINKLINT_OUTDIR); \
-	fi;
-	if test ! -e faq; then \
-	      ln -s FAQ faq; \
-	fi;
+# Build the genpage documentation.
+checkconfig:
+	if test ! -d $(STAMPS); then $(MKDIR) $(STAMPS); fi
+	if test ! -d logs; then mkdir logs; fi
+	if test ! -d $(LINKLINT_OUTDIR); then mkdir $(LINKLINT_OUTDIR); fi
+	if test ! -e faq; then ln -s FAQ faq; fi
 	cd genpage; $(MAKE) gp
-	cd Texi2html; bash configure; make
+	cd Texi2html; \
+	if test configure -nt Makefile; then bash configure; fi; \
+	$(MAKE)
 	cd FAQ; $(MAKE)
+	@if test -z "${XEMACS_WEBSITE_BASE}"; then \
+	  echo Computation of XEMACS_WEBSITE_BASE failed.; \
+	  echo You may want to define XEMACS_WEBSITE_BASE in Local.rules.; \
+	  exit -10; \
+	fi
+	make Local.rules
+
+Local.rules: ${XEMACS_WEBSITE_BASE}/Local.rules
+.PHONY: Local.rules
+
+${XEMACS_WEBSITE_BASE}/Local.rules: ${XEMACS_WEBSITE_BASE}/Local.rules.template
+	$(error Your "$(notdir $@)" is out-of-date or non-existent.)
 
 # APA: When contentdir and outputdir are the same then, and only then,
 # genpage depends only on content files.  Copying of all other files
 	for i in $?; do \
 		echo $$i >> VALIDATE_HTML_FILES.txt; \
 	done
-	cat VALIDATE_HTML_FILES.txt | xargs --max-chars=1000 $(XEMACS) \
-	$(FLAGS) -l ./batch-psgml-validate.elc -f batch-psgml-validate
+	cat VALIDATE_HTML_FILES.txt | xargs $(XEMACS) $(FLAGS) \
+		-l ./batch-psgml-validate.elc -f batch-psgml-validate
 	touch $(STAMPS)/validate
 
-# 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.
 	fi;
 	touch $(STAMPS)/namazu-re-index
 
-# APA: Remove all .html files (and backups) generated from .content
-# files.  Need to remove timestamp files as well!
+# APA: Need to remove timestamp files as well!
 clean:
 	$(FIND) . \( -name "*.content" -o -name "*~" \) -print | perl -ne "{ chomp; s/\.content/.html/; unlink; }"
 	rm -f $(STAMPS)/htdocs
 Download/win32:
 	cd $@ && $(MAKE)
 
-# APA: Compile any lisp file for performance (a bit simple-minded, maybe).
 %.elc: %.el
 	$(XEMACS) $(FLAGS) -f batch-byte-compile $<
 
-#    Scaffolding
-
-# APA: A directory as dependency will always trigger the rule (cygwin, linux).
-# $(STAMPS):
-# 	$(MKDIR) $(STAMPS)
-
 # End of xemacsweb Makefile