GitBucket
4.21.2
Toggle navigation
Snippets
Sign in
Files
Branches
1
Releases
Issues
1
Pull requests
Labels
Priorities
Milestones
Wiki
Forks
nigel.stanger
/
Handbook
Browse code
- Switched to Blackboard deployment method.
master
1 parent
daca8c0
commit
0886de7001a6157ca4c11c2828b29bcff2708789
nstanger
authored
on 17 Jul 2012
Patch
Showing
2 changed files
make-includes/build_misc_rules.make
makefile-templates/Makefile.misc
Ignore Space
Show notes
View
make-includes/build_misc_rules.make
################################################################################ # # 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_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)) ################################################################################ # # Set up the context for the current document. # # SOURCE_XML is the original source XML, from which DERIVED_XML is # generated (the derived source has the includes for questions, etc., # inserted). # SOURCE_XML:=$(foreach n,$(BASE_NAMES),$(n).xml) DERIVED_XML:=$(SOURCE_XML:.xml=-derived.xml) # # Define the names of the output files. # ifdef HAS_ANSWERS WEB_QUESTIONS_HTML:=$(SOURCE_XML:.xml=-questions.html) WEB_ANSWERS_HTML:=$(SOURCE_XML:.xml=-answers.html) PRINT_QUESTIONS_TEX:=$(WEB_QUESTIONS_HTML:.html=.tex) PRINT_ANSWERS_TEX:=$(WEB_ANSWERS_HTML:.html=.tex) PRINT_QUESTIONS_PDF_1UP:=$(PRINT_QUESTIONS_TEX:.tex=.pdf) PRINT_ANSWERS_PDF_1UP:=$(PRINT_ANSWERS_TEX:.tex=.pdf) PRINT_QUESTIONS_PDF_2UP:=$(PRINT_QUESTIONS_TEX:.tex=-2up.pdf) PRINT_ANSWERS_PDF_2UP:=$(PRINT_ANSWERS_TEX:.tex=-2up.pdf) else WEB_HTML:=$(SOURCE_XML:.xml=.html) PRINT_TEX:=$(SOURCE_XML:.xml=.tex) PRINT_PDF_1UP:=$(SOURCE_XML:.xml=.pdf) PRINT_PDF_2UP:=$(SOURCE_XML:.xml=-2up.pdf) endif # # List of XSL stylesheets. If any of these change, we need to rebuild # everything. # # We can't use the resolver approach under Windows because of the DOS # pathnames. The style sheets come out of the resolver with paths like # C:\bar\foo\..., and make interprets the colon as an extra dependency # delimiter (tested and behaviour verified). Of course, this works fine on # any platform with sensible path standards. Quoting the value doesn't # help, unfortunately. Bugger :( # #XSLT_STYLESHEETS:=$(shell $(JAVA) org.apache.xml.resolver.apps.resolver -u file:///xml2html.xsl uri | ( $(GREP) 'Result: file:' || $(ECHO) '::xml2html.xsl' ) | $(CUT) -d':' -f3-) $(shell $(JAVA) org.apache.xml.resolver.apps.resolver -u file:///xml2latex.xsl uri | ( $(GREP) 'Result: file:' || $(ECHO) '::xml2latex.xsl' ) | $(CUT) -d':' -f3-) XSLT_STYLESHEETS:=$(TEACHING_SHARED)/Authoring/XML/xml2html.xsl $(TEACHING_SHARED)/Authoring/XML/xml2xhtml.xsl $(TEACHING_SHARED)/Authoring/XML/xml2latex.xsl $(TEACHING_SHARED)/Authoring/XML/xml2xelatex.xsl ################################################################################ # # Files to be installed on web server. # ifdef HAS_ANSWERS QUESTION_INSTALL_FILES:=$(WEB_QUESTIONS_HTML) $(PRINT_QUESTIONS_PDF_1UP) \ $(PRINT_QUESTIONS_PDF_2UP) $(wildcard *.png) ANSWER_INSTALL_FILES:=$(WEB_ANSWERS_HTML) $(PRINT_ANSWERS_PDF_1UP) \ $(PRINT_ANSWERS_PDF_2UP) $(wildcard *.png) else INSTALL_FILES:=$(WEB_HTML) $(PRINT_PDF_1UP) $(PRINT_PDF_2UP) $(wildcard *.png) endif ################################################################################ # # 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 $(IMGDIR)/*-print.pdf $(IMGDIR)/*-print.png \ $(IMGDIR)/*-web.png $(IMGDIR)/*-web-zoom.png ifdef HAS_ANSWERS TIDY_FILES+=$(PRINT_QUESTIONS_TEX) $(PRINT_ANSWERS_TEX) CLEAN_FILES+=$(WEB_QUESTIONS_HTML) $(WEB_ANSWERS_HTML) \ $(PRINT_QUESTIONS_PDF_1UP) $(PRINT_ANSWERS_PDF_1UP) \ $(PRINT_QUESTIONS_PDF_2UP) $(PRINT_ANSWERS_PDF_2UP) else TIDY_FILES+=$(PRINT_TEX) CLEAN_FILES+=$(WEB_HTML) $(PRINT_PDF_1UP) $(PRINT_PDF_2UP) endif ################################################################################ # # Various environment variables. # include $(GLOBAL_HANDBOOK_INCLUDE)/standard_environment.make # # List of standard "phony" build targets. Varies depending on whether # answers are enabled. # TARGETS+=web print $(BASE_NAMES) ifdef HAS_ANSWERS TARGETS+=web-questions web-answers \ print-questions print-answers \ questions answers endif # .PHONY: $(TARGETS) ################################################################################ # # Build everything. # all: web print ################################################################################ # # Build questions or answers only. # ifdef HAS_ANSWERS questions: web-questions print-questions answers: web-answers print-answers endif ################################################################################ # # Build web version only. # ifdef HAS_ANSWERS web: web-questions web-answers web-questions: $(WEB_QUESTIONS_HTML) $(WEB_IMAGES) $(WEB_FILES) $(WEB_QUESTIONS_HTML): %-questions.html: %-derived.xml ifdef UNICODE $(call xslt,$<,xml2xhtml.xsl,$(call xslt_parameter,subject-code,'$(SUBJECT_CODE)'),$(call xslt_parameter,paper-number,'$(PAPER_NUMBER)'),$(call xslt_parameter,paper-year,'$(PAPER_YEAR)'),$(call xslt_parameter,paper-period,'$(PAPER_PERIOD)'),$(call xslt_parameter,standalone,'yes'),$(call xslt_parameter,showanswers,'no'),$(call xslt_parameter,base-path,'.'),$(call xslt_parameter,image-format,'png')) > $@ else $(call xslt,$<,xml2html.xsl,$(call xslt_parameter,subject-code,'$(SUBJECT_CODE)'),$(call xslt_parameter,paper-number,'$(PAPER_NUMBER)'),$(call xslt_parameter,paper-year,'$(PAPER_YEAR)'),$(call xslt_parameter,paper-period,'$(PAPER_PERIOD)'),$(call xslt_parameter,standalone,'yes'),$(call xslt_parameter,showanswers,'no'),$(call xslt_parameter,base-path,'.'),$(call xslt_parameter,image-format,'png')) > $@ endif web-answers: $(WEB_ANSWERS_HTML) $(WEB_IMAGES) $(WEB_FILES) $(WEB_ANSWERS_HTML): %-answers.html: %-derived.xml ifdef UNICODE $(call xslt,$<,xml2xhtml.xsl,$(call xslt_parameter,subject-code,'$(SUBJECT_CODE)'),$(call xslt_parameter,paper-number,'$(PAPER_NUMBER)'),$(call xslt_parameter,paper-year,'$(PAPER_YEAR)'),$(call xslt_parameter,paper-period,'$(PAPER_PERIOD)'),$(call xslt_parameter,standalone,'yes'),$(call xslt_parameter,showanswers,'yes'),$(call xslt_parameter,base-path,'.'),$(call xslt_parameter,image-format,'png')) > $@ else $(call xslt,$<,xml2html.xsl,$(call xslt_parameter,subject-code,'$(SUBJECT_CODE)'),$(call xslt_parameter,paper-number,'$(PAPER_NUMBER)'),$(call xslt_parameter,paper-year,'$(PAPER_YEAR)'),$(call xslt_parameter,paper-period,'$(PAPER_PERIOD)'),$(call xslt_parameter,standalone,'yes'),$(call xslt_parameter,showanswers,'yes'),$(call xslt_parameter,base-path,'.'),$(call xslt_parameter,image-format,'png')) > $@ endif else web: $(WEB_HTML) $(WEB_IMAGES) $(WEB_FILES) endif ################################################################################ # # Build print version only. # ifdef HAS_ANSWERS print: print-questions print-answers print-questions: $(PRINT_QUESTIONS_PDF_1UP) $(PRINT_QUESTIONS_PDF_2UP) $(PRINT_QUESTIONS_PDF_1UP): $(PRINT_IMAGES) $(PRINT_FILES) $(PRINT_QUESTIONS_TEX): %-questions.tex: %-derived.xml ifdef UNICODE $(call xslt,$<,xml2xelatex.xsl,$(call xslt_parameter,subject-code,'$(SUBJECT_CODE)'),$(call xslt_parameter,paper-number,'$(PAPER_NUMBER)'),$(call xslt_parameter,paper-year,'$(PAPER_YEAR)'),$(call xslt_parameter,paper-period,'$(PAPER_PERIOD)'),$(call xslt_parameter,standalone,'yes'),$(call xslt_parameter,showanswers,'no'),$(call xslt_parameter,base-path,'.'),$(call xslt_parameter,image-format,'pdf')) > $@ else $(call xslt,$<,xml2latex.xsl,$(call xslt_parameter,subject-code,'$(SUBJECT_CODE)'),$(call xslt_parameter,paper-number,'$(PAPER_NUMBER)'),$(call xslt_parameter,paper-year,'$(PAPER_YEAR)'),$(call xslt_parameter,paper-period,'$(PAPER_PERIOD)'),$(call xslt_parameter,standalone,'yes'),$(call xslt_parameter,showanswers,'no'),$(call xslt_parameter,base-path,'.'),$(call xslt_parameter,image-format,'pdf')) > $@ endif print-answers: $(PRINT_ANSWERS_PDF_1UP) $(PRINT_ANSWERS_PDF_2UP) $(PRINT_ANSWERS_PDF_1UP): $(PRINT_IMAGES) $(PRINT_FILES) $(PRINT_ANSWERS_TEX): %-answers.tex: %-derived.xml ifdef UNICODE $(call xslt,$<,xml2xelatex.xsl,$(call xslt_parameter,subject-code,'$(SUBJECT_CODE)'),$(call xslt_parameter,paper-number,'$(PAPER_NUMBER)'),$(call xslt_parameter,paper-year,'$(PAPER_YEAR)'),$(call xslt_parameter,paper-period,'$(PAPER_PERIOD)'),$(call xslt_parameter,standalone,'yes'),$(call xslt_parameter,showanswers,'yes'),$(call xslt_parameter,base-path,'.'),$(call xslt_parameter,image-format,'pdf')) > $@ else $(call xslt,$<,xml2latex.xsl,$(call xslt_parameter,subject-code,'$(SUBJECT_CODE)'),$(call xslt_parameter,paper-number,'$(PAPER_NUMBER)'),$(call xslt_parameter,paper-year,'$(PAPER_YEAR)'),$(call xslt_parameter,paper-period,'$(PAPER_PERIOD)'),$(call xslt_parameter,standalone,'yes'),$(call xslt_parameter,showanswers,'yes'),$(call xslt_parameter,base-path,'.'),$(call xslt_parameter,image-format,'pdf')) > $@ endif else print: $(PRINT_PDF_1UP) $(PRINT_PDF_2UP) $(PRINT_PDF_1UP): $(PRINT_IMAGES) $(PRINT_FILES) endif ################################################################################ # # Generate the derived XML source from the original XML template. # This is done by simply running the original source through xmllint # with the --xinclude option to process all the xi:include elements. # The result of this could have just been piped into the XSLT processor, # except that (a) not all of the processors support input from stdin, # and (b) combining both xmllint and XSLT processing into one command # means that make won't stop if there's any errors from xmllint. # # Sed is used to add a comment to the derived XML file, warning that this # is generated and shouldn't be edited. Sed was used because the <?xml?> # processing instruction MUST be on the first line. The implication here # is that all input source files have an <?xml?> processing instruction # (which they should anyway). # $(DERIVED_XML): %-derived.xml: %.xml $(XSLT_STYLESHEETS) $(XMLLINT) --xinclude $< >$@ @$(SED) -i -e '1a <!-- THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT! -->' $@ ################################################################################ # # Build the test document. # test: test.pdf test.pdf: test.tex ################################################################################ # # Link the appropriate files to the deployment directory, then synchronise this # with Blackboard. This relies on the environment variable HANDBOOK_INSTALL_ROOT # being defined, and that it points to a valid directory. Note that all existing # symbolic links under the install directory are deleted first to ensure that # there are no dangling links. # # See build_document_rules.make for an explanation of why the install # uses a foreach. # # Note that this won't do anything clever if you give it files that are # in subdirectories of the current directory. Everything will be flattened # at the other end. That is, something like "images/foo.pdf" will go into # the installation directory as "foo.pdf", not "images/foo.pdf". # install: all @$(ANNOUNCE) "Building deployment links" @$(TEST) -d $(HANDBOOK_INSTALL_ROOT) @$(MKDIR_P) $(INSTALL_DIRECTORY) @$(FIND) $(INSTALL_DIRECTORY) -type l -delete ifdef HAS_ANSWERS @$(foreach f,$(QUESTION_INSTALL_FILES) $(ANSWER_INSTALL_FILES),if $(TEST) -f $(CURDIR)/$(f); then $(ECHO) "Linking $(f)"; $(LN_S) -f $(CURDIR)/$(f) $(INSTALL_DIRECTORY); fi;) else @$(foreach f,$(INSTALL_FILES),if $(TEST) -f $(CURDIR)/$(f); then $(ECHO) "Linking $(f)"; $(LN_S) -f $(CURDIR)/$(f) $(INSTALL_DIRECTORY); fi;) endif @$(ANNOUNCE) "Synchronising with Blackboard" @$(SITECOPY) --update Blackboard$(PAPER_NUMBER) ################################################################################ # # 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 "SOURCE_XML = [$(SOURCE_XML)]" @echo "DERIVED_XML = [$(DERIVED_XML)]" @echo "SUBJECT_CODE = [$(SUBJECT_CODE)]" @echo "PAPER_NUMBER = [$(PAPER_NUMBER)]" @echo "HAS_ANSWERS = [$(HAS_ANSWERS)]" ifdef HAS_ANSWERS @echo "WEB_QUESTIONS_HTML = [$(WEB_QUESTIONS_HTML)]" @echo "WEB_ANSWERS_HTML = [$(WEB_ANSWERS_HTML)]" @echo "PRINT_QUESTIONS_TEX = [$(PRINT_QUESTIONS_TEX)]" @echo "PRINT_ANSWERS_TEX = [$(PRINT_ANSWERS_TEX)]" @echo "PRINT_QUESTIONS_PDF_1UP = [$(PRINT_QUESTIONS_PDF_1UP)]" @echo "PRINT_ANSWERS_PDF_1UP = [$(PRINT_ANSWERS_PDF_1UP)]" @echo "PRINT_QUESTIONS_PDF_2UP = [$(PRINT_QUESTIONS_PDF_2UP)]" @echo "PRINT_ANSWERS_PDF_2UP = [$(PRINT_ANSWERS_PDF_2UP)]" @echo "QUESTION_INSTALL_FILES = [$(QUESTION_INSTALL_FILES)]" @echo "ANSWER_INSTALL_FILES = [$(ANSWER_INSTALL_FILES)]" else @echo "WEB_HTML = [$(WEB_HTML)]" @echo "PRINT_TEX = [$(PRINT_TEX)]" @echo "PRINT_PDF_1UP = [$(PRINT_PDF_1UP)]" @echo "PRINT_PDF_2UP = [$(PRINT_PDF_2UP)]" @echo "INSTALL_FILES = [$(INSTALL_FILES)]" endif @echo "XSLT_STYLESHEETS = [$(XSLT_STYLESHEETS)]" @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
################################################################################ # # 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_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)) ################################################################################ # # Set up the context for the current document. # # SOURCE_XML is the original source XML, from which DERIVED_XML is # generated (the derived source has the includes for questions, etc., # inserted). # SOURCE_XML:=$(foreach n,$(BASE_NAMES),$(n).xml) DERIVED_XML:=$(SOURCE_XML:.xml=-derived.xml) # # Define the names of the output files. # ifdef HAS_ANSWERS WEB_QUESTIONS_HTML:=$(SOURCE_XML:.xml=-questions.html) WEB_ANSWERS_HTML:=$(SOURCE_XML:.xml=-answers.html) PRINT_QUESTIONS_TEX:=$(WEB_QUESTIONS_HTML:.html=.tex) PRINT_ANSWERS_TEX:=$(WEB_ANSWERS_HTML:.html=.tex) PRINT_QUESTIONS_PDF_1UP:=$(PRINT_QUESTIONS_TEX:.tex=.pdf) PRINT_ANSWERS_PDF_1UP:=$(PRINT_ANSWERS_TEX:.tex=.pdf) PRINT_QUESTIONS_PDF_2UP:=$(PRINT_QUESTIONS_TEX:.tex=-2up.pdf) PRINT_ANSWERS_PDF_2UP:=$(PRINT_ANSWERS_TEX:.tex=-2up.pdf) else WEB_HTML:=$(SOURCE_XML:.xml=.html) PRINT_TEX:=$(SOURCE_XML:.xml=.tex) PRINT_PDF_1UP:=$(SOURCE_XML:.xml=.pdf) PRINT_PDF_2UP:=$(SOURCE_XML:.xml=-2up.pdf) endif # # List of XSL stylesheets. If any of these change, we need to rebuild # everything. # # We can't use the resolver approach under Windows because of the DOS # pathnames. The style sheets come out of the resolver with paths like # C:\bar\foo\..., and make interprets the colon as an extra dependency # delimiter (tested and behaviour verified). Of course, this works fine on # any platform with sensible path standards. Quoting the value doesn't # help, unfortunately. Bugger :( # #XSLT_STYLESHEETS:=$(shell $(JAVA) org.apache.xml.resolver.apps.resolver -u file:///xml2html.xsl uri | ( $(GREP) 'Result: file:' || $(ECHO) '::xml2html.xsl' ) | $(CUT) -d':' -f3-) $(shell $(JAVA) org.apache.xml.resolver.apps.resolver -u file:///xml2latex.xsl uri | ( $(GREP) 'Result: file:' || $(ECHO) '::xml2latex.xsl' ) | $(CUT) -d':' -f3-) XSLT_STYLESHEETS:=$(TEACHING_SHARED)/Authoring/XML/xml2html.xsl $(TEACHING_SHARED)/Authoring/XML/xml2xhtml.xsl $(TEACHING_SHARED)/Authoring/XML/xml2latex.xsl $(TEACHING_SHARED)/Authoring/XML/xml2xelatex.xsl ################################################################################ # # 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 $(IMGDIR)/*-print.pdf $(IMGDIR)/*-print.png \ $(IMGDIR)/*-web.png $(IMGDIR)/*-web-zoom.png ifdef HAS_ANSWERS TIDY_FILES+=$(PRINT_QUESTIONS_TEX) $(PRINT_ANSWERS_TEX) CLEAN_FILES+=$(WEB_QUESTIONS_HTML) $(WEB_ANSWERS_HTML) \ $(PRINT_QUESTIONS_PDF_1UP) $(PRINT_ANSWERS_PDF_1UP) \ $(PRINT_QUESTIONS_PDF_2UP) $(PRINT_ANSWERS_PDF_2UP) else TIDY_FILES+=$(PRINT_TEX) CLEAN_FILES+=$(WEB_HTML) $(PRINT_PDF_1UP) $(PRINT_PDF_2UP) endif ################################################################################ # # Various environment variables. # include $(GLOBAL_HANDBOOK_INCLUDE)/standard_environment.make # # List of standard "phony" build targets. Varies depending on whether # answers are enabled. # TARGETS+=web print $(BASE_NAMES) ifdef HAS_ANSWERS TARGETS+=web-questions web-answers \ print-questions print-answers \ questions answers endif # .PHONY: $(TARGETS) ################################################################################ # # Build everything. # all: web print ################################################################################ # # Build questions or answers only. # ifdef HAS_ANSWERS questions: web-questions print-questions answers: web-answers print-answers endif ################################################################################ # # Build web version only. # ifdef HAS_ANSWERS web: web-questions web-answers web-questions: $(WEB_QUESTIONS_HTML) $(WEB_IMAGES) $(WEB_FILES) $(WEB_QUESTIONS_HTML): %-questions.html: %-derived.xml ifdef UNICODE $(call xslt,$<,xml2xhtml.xsl,$(call xslt_parameter,subject-code,'$(SUBJECT_CODE)'),$(call xslt_parameter,paper-number,'$(PAPER_NUMBER)'),$(call xslt_parameter,paper-year,'$(PAPER_YEAR)'),$(call xslt_parameter,paper-period,'$(PAPER_PERIOD)'),$(call xslt_parameter,standalone,'yes'),$(call xslt_parameter,showanswers,'no'),$(call xslt_parameter,base-path,'.'),$(call xslt_parameter,image-format,'png')) > $@ else $(call xslt,$<,xml2html.xsl,$(call xslt_parameter,subject-code,'$(SUBJECT_CODE)'),$(call xslt_parameter,paper-number,'$(PAPER_NUMBER)'),$(call xslt_parameter,paper-year,'$(PAPER_YEAR)'),$(call xslt_parameter,paper-period,'$(PAPER_PERIOD)'),$(call xslt_parameter,standalone,'yes'),$(call xslt_parameter,showanswers,'no'),$(call xslt_parameter,base-path,'.'),$(call xslt_parameter,image-format,'png')) > $@ endif web-answers: $(WEB_ANSWERS_HTML) $(WEB_IMAGES) $(WEB_FILES) $(WEB_ANSWERS_HTML): %-answers.html: %-derived.xml ifdef UNICODE $(call xslt,$<,xml2xhtml.xsl,$(call xslt_parameter,subject-code,'$(SUBJECT_CODE)'),$(call xslt_parameter,paper-number,'$(PAPER_NUMBER)'),$(call xslt_parameter,paper-year,'$(PAPER_YEAR)'),$(call xslt_parameter,paper-period,'$(PAPER_PERIOD)'),$(call xslt_parameter,standalone,'yes'),$(call xslt_parameter,showanswers,'yes'),$(call xslt_parameter,base-path,'.'),$(call xslt_parameter,image-format,'png')) > $@ else $(call xslt,$<,xml2html.xsl,$(call xslt_parameter,subject-code,'$(SUBJECT_CODE)'),$(call xslt_parameter,paper-number,'$(PAPER_NUMBER)'),$(call xslt_parameter,paper-year,'$(PAPER_YEAR)'),$(call xslt_parameter,paper-period,'$(PAPER_PERIOD)'),$(call xslt_parameter,standalone,'yes'),$(call xslt_parameter,showanswers,'yes'),$(call xslt_parameter,base-path,'.'),$(call xslt_parameter,image-format,'png')) > $@ endif else web: $(WEB_HTML) $(WEB_IMAGES) $(WEB_FILES) endif ################################################################################ # # Build print version only. # ifdef HAS_ANSWERS print: print-questions print-answers print-questions: $(PRINT_QUESTIONS_PDF_1UP) $(PRINT_QUESTIONS_PDF_2UP) $(PRINT_QUESTIONS_PDF_1UP): $(PRINT_IMAGES) $(PRINT_FILES) $(PRINT_QUESTIONS_TEX): %-questions.tex: %-derived.xml ifdef UNICODE $(call xslt,$<,xml2xelatex.xsl,$(call xslt_parameter,subject-code,'$(SUBJECT_CODE)'),$(call xslt_parameter,paper-number,'$(PAPER_NUMBER)'),$(call xslt_parameter,paper-year,'$(PAPER_YEAR)'),$(call xslt_parameter,paper-period,'$(PAPER_PERIOD)'),$(call xslt_parameter,standalone,'yes'),$(call xslt_parameter,showanswers,'no'),$(call xslt_parameter,base-path,'.'),$(call xslt_parameter,image-format,'pdf')) > $@ else $(call xslt,$<,xml2latex.xsl,$(call xslt_parameter,subject-code,'$(SUBJECT_CODE)'),$(call xslt_parameter,paper-number,'$(PAPER_NUMBER)'),$(call xslt_parameter,paper-year,'$(PAPER_YEAR)'),$(call xslt_parameter,paper-period,'$(PAPER_PERIOD)'),$(call xslt_parameter,standalone,'yes'),$(call xslt_parameter,showanswers,'no'),$(call xslt_parameter,base-path,'.'),$(call xslt_parameter,image-format,'pdf')) > $@ endif print-answers: $(PRINT_ANSWERS_PDF_1UP) $(PRINT_ANSWERS_PDF_2UP) $(PRINT_ANSWERS_PDF_1UP): $(PRINT_IMAGES) $(PRINT_FILES) $(PRINT_ANSWERS_TEX): %-answers.tex: %-derived.xml ifdef UNICODE $(call xslt,$<,xml2xelatex.xsl,$(call xslt_parameter,subject-code,'$(SUBJECT_CODE)'),$(call xslt_parameter,paper-number,'$(PAPER_NUMBER)'),$(call xslt_parameter,paper-year,'$(PAPER_YEAR)'),$(call xslt_parameter,paper-period,'$(PAPER_PERIOD)'),$(call xslt_parameter,standalone,'yes'),$(call xslt_parameter,showanswers,'yes'),$(call xslt_parameter,base-path,'.'),$(call xslt_parameter,image-format,'pdf')) > $@ else $(call xslt,$<,xml2latex.xsl,$(call xslt_parameter,subject-code,'$(SUBJECT_CODE)'),$(call xslt_parameter,paper-number,'$(PAPER_NUMBER)'),$(call xslt_parameter,paper-year,'$(PAPER_YEAR)'),$(call xslt_parameter,paper-period,'$(PAPER_PERIOD)'),$(call xslt_parameter,standalone,'yes'),$(call xslt_parameter,showanswers,'yes'),$(call xslt_parameter,base-path,'.'),$(call xslt_parameter,image-format,'pdf')) > $@ endif else print: $(PRINT_PDF_1UP) $(PRINT_PDF_2UP) $(PRINT_PDF_1UP): $(PRINT_IMAGES) $(PRINT_FILES) endif ################################################################################ # # Generate the derived XML source from the original XML template. # This is done by simply running the original source through xmllint # with the --xinclude option to process all the xi:include elements. # The result of this could have just been piped into the XSLT processor, # except that (a) not all of the processors support input from stdin, # and (b) combining both xmllint and XSLT processing into one command # means that make won't stop if there's any errors from xmllint. # # Sed is used to add a comment to the derived XML file, warning that this # is generated and shouldn't be edited. Sed was used because the <?xml?> # processing instruction MUST be on the first line. The implication here # is that all input source files have an <?xml?> processing instruction # (which they should anyway). # $(DERIVED_XML): %-derived.xml: %.xml $(XSLT_STYLESHEETS) $(XMLLINT) --xinclude $< >$@ @$(SED) -i -e '1a <!-- THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT! -->' $@ ################################################################################ # # Build the test document. # test: test.pdf test.pdf: test.tex ################################################################################ # # Link the appropriate files to the deployment directory, then synchronise this # with Blackboard. This relies on the environment variable HANDBOOK_INSTALL_ROOT # being defined, and that it points to a valid directory. Note that all existing # symbolic links under the install directory are deleted first to ensure that # there are no dangling links. # # See build_document_rules.make for an explanation of why the install # uses a foreach. # # Note that this won't do anything clever if you give it files that are # in subdirectories of the current directory. Everything will be flattened # at the other end. That is, something like "images/foo.pdf" will go into # the installation directory as "foo.pdf", not "images/foo.pdf". # install: questions answers @$(ANNOUNCE) "Building deployment links" @$(TEST) -d $(HANDBOOK_INSTALL_ROOT) @$(MKDIR_P) $(INSTALL_DIRECTORY) @$(FIND) $(INSTALL_DIRECTORY) -type l -delete @$(foreach f,$(INSTALL_FILES),if $(TEST) ! -f $(INSTALL_DIRECTORY)/$(f) -o $(CURDIR)/$(f) -nt $(INSTALL_DIRECTORY)/$(f); then $(ECHO) "Linking $(f)"; $(LN_S) -f $(CURDIR)/$(f) $(INSTALL_DIRECTORY); fi;) @$(ANNOUNCE) "Synchronising with Blackboard" @$(SITECOPY) --update Blackboard$(PAPER_NUMBER) ################################################################################ # # 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 "SOURCE_XML = [$(SOURCE_XML)]" @echo "DERIVED_XML = [$(DERIVED_XML)]" @echo "SUBJECT_CODE = [$(SUBJECT_CODE)]" @echo "PAPER_NUMBER = [$(PAPER_NUMBER)]" @echo "HAS_ANSWERS = [$(HAS_ANSWERS)]" ifdef HAS_ANSWERS @echo "WEB_QUESTIONS_HTML = [$(WEB_QUESTIONS_HTML)]" @echo "WEB_ANSWERS_HTML = [$(WEB_ANSWERS_HTML)]" @echo "PRINT_QUESTIONS_TEX = [$(PRINT_QUESTIONS_TEX)]" @echo "PRINT_ANSWERS_TEX = [$(PRINT_ANSWERS_TEX)]" @echo "PRINT_QUESTIONS_PDF_1UP = [$(PRINT_QUESTIONS_PDF_1UP)]" @echo "PRINT_ANSWERS_PDF_1UP = [$(PRINT_ANSWERS_PDF_1UP)]" @echo "PRINT_QUESTIONS_PDF_2UP = [$(PRINT_QUESTIONS_PDF_2UP)]" @echo "PRINT_ANSWERS_PDF_2UP = [$(PRINT_ANSWERS_PDF_2UP)]" else @echo "WEB_HTML = [$(WEB_HTML)]" @echo "PRINT_TEX = [$(PRINT_TEX)]" @echo "PRINT_PDF_1UP = [$(PRINT_PDF_1UP)]" @echo "PRINT_PDF_2UP = [$(PRINT_PDF_2UP)]" endif @echo "XSLT_STYLESHEETS = [$(XSLT_STYLESHEETS)]" @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
Ignore Space
Show notes
View
makefile-templates/Makefile.misc
################################################################################ # # File: $Id$ # # Template makefile for building a general document. # ################################################################################ SHELL = /bin/sh ################################################################################ # # Required Environment Variables # # TEACHING_SHARED # This variable specifies the path to the top level of the teaching # shared directory hierarchy (e.g., /path/to/Teaching/Shared). # TEACHING_SHARED?=$(error The required environment variable TEACHING_SHARED has not been defined. It should point to the root level of the shared teaching directory (e.g., /path/to/Teaching/Shared)) ################################################################################ # # Set up paths to makefile include directories. # # GLOBAL_HANDBOOK_INCLUDE is the global include directory in the "Shared" # hierarchy, and is defined relative to the root of that hierarchy. # GLOBAL_HANDBOOK_INCLUDE?=$(TEACHING_SHARED)/Authoring/Handbook/make-includes ################################################################################ # # Include local system-specific configuration. # include $(GLOBAL_HANDBOOK_INCLUDE)/local_configuration.make ################################################################################ # # Clear out the suffixes list. DO NOT ALTER THIS LINE! # .SUFFIXES: # # Add any custom suffixes here (uncomment the line below). # The "standard" suffixes list currently includes: # .svg .pdf .tex .dvi .png .tif .plo .jpg .pict .eps .ps .R .xml # # .SUFFIXES: ################################################################################ # # Define paths for various items here. The "standard" paths currently include: # # vpath %.pdf $(IMGDIR) # vpath %.png $(IMGDIR) # vpath %.tif $(IMGDIR) # vpath %.jpg $(IMGDIR) # vpath %.plo $(IMGDIR) # vpath %.ps $(IMGDIR) # vpath %.eps $(IMGDIR) # vpath %.svg $(IMGDIR) # vpath %.pict $(IMGDIR) # vpath %.R $(IMGDIR) # # There's nothing to stop you adding new paths for these file types. # # vpath foo bar ################################################################################ # # Specify the current subject code and paper number. # THESE MUST BE DEFINED! # SUBJECT_CODE?=$(error The required variable SUBJECT_CODE has not been defined. Please set it to the correct value for this paper) PAPER_NUMBER?=$(error The required variable PAPER_NUMBER has not been defined. Please set it to the correct value for this paper) ################################################################################ # # Specify the base name(s) for the document source file(s). It may be a list. # THIS MUST BE DEFINED! # BASE_NAMES?=$(error The required variable BASE_NAME has not been defined. Please set it to the base name(s) of the document source file(s)) ################################################################################ # # Directory to install files into on web server. This is .../Misc/name of # build directory, to avoid similarly-named files overwriting each other. # BUILD_DIR:=$(lastword $(subst /, ,$(CURDIR))) INSTALL_DIRECTORY:=$(HANDBOOK_INSTALL_ROOT)/$(SUBJECT_CODE)$(PAPER_NUMBER)/Blackboard/Misc/$(BUILD_DIR) ################################################################################ # # Does this document have questions with associated answers that can be # shown or hidden? Define this variable (any value) to enable the targets # for this. Note that setting this will generate "questions" and "answers" # output for ALL targets, regardless of whether this is actually relevant. # This already happens with the handbooks anyway, so no real problem :) # You can always add the redundant files to the TIDY_FILES variable. # HAS_ANSWERS= ################################################################################ # # Standard file list variables. # Note that anything included in any of these variables (particularly the # FILES variables) will cause ALL of the relevant print or web targets to # be rebuilt, regardless of whether they are actually prerequisites. This # can be slightly annoying if some of the files are only relevant to one # target. To avoid this effect, define a custom rule at the bottom of # this file. # # List of images used in the print version as actual content. # PRINT_IMAGES= # # List of other files used in the print version as actual content. # PRINT_FILES= # # List of images used in the web version as actual content. # WEB_IMAGES= # # List of other files used in the web version as actual content. # WEB_FILES= # # Files to be cleaned by the various "clean" targets. The "standard" values # are currently: # TIDY_FILES=*.tmp *.out *.log *.nav *.toc *.snm *.head *.dvi \ # *-derived.xml $(derived .tex files) # CLEAN_FILES=*.aux $(IMGDIR)/*-print.pdf $(IMGDIR)/*-print.png \ # $(IMGDIR)/*-web.png $(IMGDIR)/*-web-zoom.png \ # $(derived HTML files) $(derived PDF files) # # $(TIDY_FILES) is a list of generated intermediate files to clean up. # TIDY_FILES= # # $(CLEAN_FILES) is everything else that might need to be cleaned up. # CLEAN_FILES= ################################################################################ # # Specify LaTeX document options (comma-separated list). The "standard" # value is currently: pdftex,usepdftitle=false,$(DRAFT).If you want to # override the "standard" options, redefine this variable after the # include line just below. # LATEX_OPTS= # # List of "phony" build targets (remember to define rules for # them!). The "standard" list is currently: # all debug test clean tidy targets web print print2up # TARGETS= ################################################################################ # # Add custom variables below here as necessary. # ################################################################################ # # Include standard variables and rules for building miscellaneous documents. # include $(GLOBAL_HANDBOOK_INCLUDE)/build_misc_rules.make ################################################################################ # # Add custom rules below here as necessary. # # If a custom rule has the same target and prerequisite as a default rule, # it overrides the default rule. If you want to replace it with a similar # but different target and prerequisite, cancel the existing rule first, # e.g.: # # %.foo : %.bar
################################################################################ # # File: $Id$ # # Template makefile for building a general document. # ################################################################################ SHELL = /bin/sh ################################################################################ # # Required Environment Variables # # TEACHING_SHARED # This variable specifies the path to the top level of the teaching # shared directory hierarchy (e.g., /path/to/Teaching/Shared). # TEACHING_SHARED?=$(error The required environment variable TEACHING_SHARED has not been defined. It should point to the root level of the shared teaching directory (e.g., /path/to/Teaching/Shared)) ################################################################################ # # Set up paths to makefile include directories. # # GLOBAL_HANDBOOK_INCLUDE is the global include directory in the "Shared" # hierarchy, and is defined relative to the root of that hierarchy. # GLOBAL_HANDBOOK_INCLUDE?=$(TEACHING_SHARED)/Authoring/Handbook/make-includes ################################################################################ # # Include local system-specific configuration. # include $(GLOBAL_HANDBOOK_INCLUDE)/local_configuration.make ################################################################################ # # Clear out the suffixes list. DO NOT ALTER THIS LINE! # .SUFFIXES: # # Add any custom suffixes here (uncomment the line below). # The "standard" suffixes list currently includes: # .svg .pdf .tex .dvi .png .tif .plo .jpg .pict .eps .ps .R .xml # # .SUFFIXES: ################################################################################ # # Define paths for various items here. The "standard" paths currently include: # # vpath %.pdf $(IMGDIR) # vpath %.png $(IMGDIR) # vpath %.tif $(IMGDIR) # vpath %.jpg $(IMGDIR) # vpath %.plo $(IMGDIR) # vpath %.ps $(IMGDIR) # vpath %.eps $(IMGDIR) # vpath %.svg $(IMGDIR) # vpath %.pict $(IMGDIR) # vpath %.R $(IMGDIR) # # There's nothing to stop you adding new paths for these file types. # # vpath foo bar ################################################################################ # # Specify the current subject code and paper number. # THESE MUST BE DEFINED! # SUBJECT_CODE?=$(error The required variable SUBJECT_CODE has not been defined. Please set it to the correct value for this paper) PAPER_NUMBER?=$(error The required variable PAPER_NUMBER has not been defined. Please set it to the correct value for this paper) ################################################################################ # # Specify the base name(s) for the document source file(s). It may be a list. # THIS MUST BE DEFINED! # BASE_NAMES?=$(error The required variable BASE_NAME has not been defined. Please set it to the base name(s) of the document source file(s)) ################################################################################ # # Does this document have questions with associated answers that can be # shown or hidden? Define this variable (any value) to enable the targets # for this. Note that setting this will generate "questions" and "answers" # output for ALL targets, regardless of whether this is actually relevant. # This already happens with the handbooks anyway, so no real problem :) # You can always add the redundant files to the TIDY_FILES variable. # HAS_ANSWERS= ################################################################################ # # Standard file list variables. # Note that anything included in any of these variables (particularly the # FILES variables) will cause ALL of the relevant print or web targets to # be rebuilt, regardless of whether they are actually prerequisites. This # can be slightly annoying if some of the files are only relevant to one # target. To avoid this effect, define a custom rule at the bottom of # this file. # # List of images used in the print version as actual content. # PRINT_IMAGES= # # List of other files used in the print version as actual content. # PRINT_FILES= # # List of images used in the web version as actual content. # WEB_IMAGES= # # List of other files used in the web version as actual content. # WEB_FILES= # # Files to be cleaned by the various "clean" targets. The "standard" values # are currently: # TIDY_FILES=*.tmp *.out *.log *.nav *.toc *.snm *.head *.dvi \ # *-derived.xml $(derived .tex files) # CLEAN_FILES=*.aux $(IMGDIR)/*-print.pdf $(IMGDIR)/*-print.png \ # $(IMGDIR)/*-web.png $(IMGDIR)/*-web-zoom.png \ # $(derived HTML files) $(derived PDF files) # # $(TIDY_FILES) is a list of generated intermediate files to clean up. # TIDY_FILES= # # $(CLEAN_FILES) is everything else that might need to be cleaned up. # CLEAN_FILES= ################################################################################ # # Specify LaTeX document options (comma-separated list). The "standard" # value is currently: pdftex,usepdftitle=false,$(DRAFT).If you want to # override the "standard" options, redefine this variable after the # include line just below. # LATEX_OPTS= # # List of "phony" build targets (remember to define rules for # them!). The "standard" list is currently: # all debug test clean tidy targets web print print2up # TARGETS= ################################################################################ # # Add custom variables below here as necessary. # ################################################################################ # # Include standard variables and rules for building miscellaneous documents. # include $(GLOBAL_HANDBOOK_INCLUDE)/build_misc_rules.make ################################################################################ # # Add custom rules below here as necessary. # # If a custom rule has the same target and prerequisite as a default rule, # it overrides the default rule. If you want to replace it with a similar # but different target and prerequisite, cancel the existing rule first, # e.g.: # # %.foo : %.bar
Show line notes below