Newer
Older
Handbook / make-includes / build_misc_rules.make
nstanger on 1 Mar 2010 5 KB - Enabled multiple base documents.
################################################################################
#
# File: $Id$
#
# Standard variables and rules for building a general standalone document
# that doesn't fall into any partcular category (such as lecture, tutorial).
# The makefile assumes a single document source file. Anything more
# complex than this will need to be handled by a custom makefile.
#
# Altering these definitions will affect ALL MAKEFILES FOR ALL PAPERS!! If
# you need to do something specific for a particular paper, include a
# custom rule in its makefile. DON'T add it here!
#
################################################################################


################################################################################
#
# Include XSLT functions.
#
include $(TEACHING_SHARED)/Authoring/Handbook/make-includes/xslt_functions.make


################################################################################
#
# Required make variables. These should be defined by the calling makefile.
#
# BASE_NAMES
#	The base name(s) of the document source file(s). It may be a list, which
#	enables multiple different documents to be built by the one Makefile.
# BASE_PDF
# BASE_PDF_2UP
# BASE_TEX
# BASE_HTML
#	Lists of various source and target files, all derived from BASE_NAMES.
#
BASE_NAMES?=$(error The required make variable BASE_NAMES has not been defined. Please set it to the base name(s) of the document source file(s))

BASE_PDF:=$(foreach n,$(BASE_NAMES),$(n).pdf)
BASE_PDF_2UP:=$(foreach n,$(BASE_NAMES),$(n)-2up.pdf)
BASE_TEX:=$(foreach n,$(BASE_NAMES),$(n).tex)
BASE_HTML:=$(foreach n,$(BASE_NAMES),$(n).html)


################################################################################
#
# Add standard file suffixes.
#
include $(GLOBAL_HANDBOOK_INCLUDE)/standard_suffixes.make


################################################################################
#
# Standard directories.
#
IMGDIR=images


################################################################################
#
# Standard paths.
#
include $(GLOBAL_HANDBOOK_INCLUDE)/standard_paths.make


################################################################################
#
# Files to be cleaned by the various "clean" targets. Note that we don't
# "tidy" .aux files because they may be needed by the xr package for inter-
# document cross references, but won't get regenerated if the final target
# PDF files exist. They will be caught by by the "clean" target though.
#
TIDY_FILES+=*.tmp *.out *.log *.nav *.toc *.snm *.head *.dvi \
	*-derived.xml
CLEAN_FILES+=*.aux *.pdf *.html


################################################################################
#
# Various environment variables.
#
include $(GLOBAL_HANDBOOK_INCLUDE)/standard_environment.make
#
# List of standard "phony" build targets.
#
TARGETS+=web print print2up $(BASE_NAMES)
#
.PHONY: $(TARGETS)


################################################################################
#
# Build everything.
#
all: web print print2up

$(BASE_NAMES): %: %.pdf %-2up.pdf %.html


################################################################################
#
# Build print version, 1-up or 2-up.
#
print: $(BASE_PDF)

$(BASE_PDF): %.pdf: %.tex $(PRINT_IMAGES) $(PRINT_FILES)

$(BASE_TEX): %.tex: %-derived.xml

print2up: $(BASE_PDF_2UP)

$(BASE_PDF_2UP): %-2up.pdf: %.pdf


################################################################################
#
# Build web version.
#
web: $(BASE_HTML)

$(BASE_HTML): %.html: %-derived.xml $(WEB_IMAGES) $(WEB_FILES)


################################################################################
#
# Build the test document.
#
test: test.pdf

test.pdf: test.tex


################################################################################
#
# Debugging: print the values of the standard variables.
#
debug:
	@announce Externally defined variables
	@echo "TEACHING_SHARED = [$(TEACHING_SHARED)]"
	@announce Internally defined variables
	@echo "GLOBAL_HANDBOOK_INCLUDE = [$(GLOBAL_HANDBOOK_INCLUDE)]"
	@echo "BASE_NAMES = [$(BASE_NAMES)]"
	@echo "BASE_PDF = [$(BASE_PDF)]"
	@echo "BASE_PDF_2UP = [$(BASE_PDF_2UP)]"
	@echo "BASE_TEX = [$(BASE_TEX)]"
	@echo "BASE_HTML = [$(BASE_HTML)]"
	@echo "PRINT_IMAGES = [$(PRINT_IMAGES)]"
	@echo "PRINT_FILES = [$(PRINT_FILES)]"
	@echo "WEB_IMAGES = [$(WEB_IMAGES)]"
	@echo "WEB_FILES = [$(WEB_FILES)]"
	@echo "TIDY_FILES = [$(TIDY_FILES)]"
	@echo "CLEAN_FILES = [$(CLEAN_FILES)]"
	@echo "DRAFT = [$(DRAFT)]"
	@echo "LATEX_OPTS = [$(LATEX_OPTS)]"
	@echo "TARGETS = [$(TARGETS)]"


################################################################################
#
# Clean up: get rid of all the temporary files.
#
tidy:
	rm -f $(TIDY_FILES)
#
# Clean up: get rid of everything except the original source.
#
clean: tidy
	rm -f $(CLEAN_FILES)


################################################################################
#
# List all "phony" build targets.
#
targets:
	@echo "targets: $(TARGETS)"


################################################################################
#
# Standard default rules.
#
include $(GLOBAL_HANDBOOK_INCLUDE)/standard_rules.make