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
- Corrected paper-period argument to period-code.
master
1 parent
833634b
commit
a91a6c07be9e0b50ada0d17bc05c1ee67c066136
nstanger
authored
on 15 Aug 2012
Patch
Showing
2 changed files
make-includes/build_misc_rules.make
make-includes/standard_rules.make
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 ################################################################################ # # 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 installed on web server. # ifdef HAS_ANSWERS QUESTION_INSTALL_FILES:=$(WEB_QUESTIONS_HTML) $(PRINT_QUESTIONS_PDF_1UP) \ $(PRINT_QUESTIONS_PDF_2UP) ANSWER_INSTALL_FILES:=$(WEB_ANSWERS_HTML) $(PRINT_ANSWERS_PDF_1UP) \ $(PRINT_ANSWERS_PDF_2UP) else INSTALL_FILES:=$(WEB_HTML) $(PRINT_PDF_1UP) $(PRINT_PDF_2UP) endif ################################################################################ # # 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,period-code,'$(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,period-code,'$(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,period-code,'$(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,period-code,'$(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,period-code,'$(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,period-code,'$(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,period-code,'$(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,period-code,'$(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 ################################################################################ # # Deploy the appropriate files into a shared folder, which is then synchronised # with Blackboard. This relies on the environment variable HANDBOOK_INSTALL_ROOT # being defined, and (assuming that this variable points to a directory on the # network) the appropriate share has been mounted. # # 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 @$(SITECOPY) --catchup Blackboard$(PAPER_NUMBER) @$(ANNOUNCE) "Deploying files into $(INSTALL_DIRECTORY)" @$(TEST) -d $(HANDBOOK_INSTALL_ROOT) @$(MKDIR_P) $(INSTALL_DIRECTORY) @if $(TEST) -n "$(WEB_IMAGES)"; then $(MKDIR_P) $(INSTALL_DIRECTORY)/$(IMGDIR); fi ifdef HAS_ANSWERS @$(foreach f,$(QUESTION_INSTALL_FILES) $(ANSWER_INSTALL_FILES),if $(TEST) ! -f $(INSTALL_DIRECTORY)/$(f) -o $(f) -nt $(INSTALL_DIRECTORY)/$(f); then $(ECHO) "Deploying $(f)"; $(CP) $(f) $(INSTALL_DIRECTORY); fi;) else @$(foreach f,$(INSTALL_FILES),if $(TEST) ! -f $(INSTALL_DIRECTORY)/$(f) -o $(f) -nt $(INSTALL_DIRECTORY)/$(f); then $(ECHO) "Deploying $(f)"; $(CP) $(f) $(INSTALL_DIRECTORY); fi;) endif @$(foreach f,$(WEB_IMAGES),if $(TEST) ! -f $(INSTALL_DIRECTORY)/$(IMGDIR)/$(f) -o $(IMGDIR)/$(f) -nt $(INSTALL_DIRECTORY)/$(IMGDIR)/$(f); then $(ECHO) "Deploying $(IMGDIR)/$(f)"; $(CP) $(IMGDIR)/$(f) $(INSTALL_DIRECTORY)/$(IMGDIR); 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 "INSTALL_DIRECTORY = [$(INSTALL_DIRECTORY)]" @echo "BUILD_DIR = [$(BUILD_DIR)]" @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 installed on web server. # ifdef HAS_ANSWERS QUESTION_INSTALL_FILES:=$(WEB_QUESTIONS_HTML) $(PRINT_QUESTIONS_PDF_1UP) \ $(PRINT_QUESTIONS_PDF_2UP) ANSWER_INSTALL_FILES:=$(WEB_ANSWERS_HTML) $(PRINT_ANSWERS_PDF_1UP) \ $(PRINT_ANSWERS_PDF_2UP) else INSTALL_FILES:=$(WEB_HTML) $(PRINT_PDF_1UP) $(PRINT_PDF_2UP) endif ################################################################################ # # 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 ################################################################################ # # Deploy the appropriate files into a shared folder, which is then synchronised # with Blackboard. This relies on the environment variable HANDBOOK_INSTALL_ROOT # being defined, and (assuming that this variable points to a directory on the # network) the appropriate share has been mounted. # # 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 @$(SITECOPY) --catchup Blackboard$(PAPER_NUMBER) @$(ANNOUNCE) "Deploying files into $(INSTALL_DIRECTORY)" @$(TEST) -d $(HANDBOOK_INSTALL_ROOT) @$(MKDIR_P) $(INSTALL_DIRECTORY) @if $(TEST) -n "$(WEB_IMAGES)"; then $(MKDIR_P) $(INSTALL_DIRECTORY)/$(IMGDIR); fi ifdef HAS_ANSWERS @$(foreach f,$(QUESTION_INSTALL_FILES) $(ANSWER_INSTALL_FILES),if $(TEST) ! -f $(INSTALL_DIRECTORY)/$(f) -o $(f) -nt $(INSTALL_DIRECTORY)/$(f); then $(ECHO) "Deploying $(f)"; $(CP) $(f) $(INSTALL_DIRECTORY); fi;) else @$(foreach f,$(INSTALL_FILES),if $(TEST) ! -f $(INSTALL_DIRECTORY)/$(f) -o $(f) -nt $(INSTALL_DIRECTORY)/$(f); then $(ECHO) "Deploying $(f)"; $(CP) $(f) $(INSTALL_DIRECTORY); fi;) endif @$(foreach f,$(WEB_IMAGES),if $(TEST) ! -f $(INSTALL_DIRECTORY)/$(IMGDIR)/$(f) -o $(IMGDIR)/$(f) -nt $(INSTALL_DIRECTORY)/$(IMGDIR)/$(f); then $(ECHO) "Deploying $(IMGDIR)/$(f)"; $(CP) $(IMGDIR)/$(f) $(INSTALL_DIRECTORY)/$(IMGDIR); 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 "INSTALL_DIRECTORY = [$(INSTALL_DIRECTORY)]" @echo "BUILD_DIR = [$(BUILD_DIR)]" @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
Ignore Space
Show notes
View
make-includes/standard_rules.make
################################################################################ # # File: $Id$ # # Standard rules for a variety of situations. Includes standard suffixes and # paths. # # ################################################################################ ################################################################################ # # Required make variables. These should be defined by the calling makefile. # # PAPER_NUMBER # The paper number for the current paper, e.g., 212. # PAPER_NUMBER?=$(error The required make variable PAPER_NUMBER has not been defined. Please set it to the correct value) # # IMGDIR # The path to the directory that contains images, e.g., images. # IMGDIR?=$(error The required make variable IMGDIR has not been defined. Please set it to the directory in which images are located) ################################################################################ # # Default rules. # # # PDF from LaTeX via DVI, typically for images drawn using PSTricks). # %.pdf %-print.pdf: $(IMGDIR)/%.tex $(LATEX) --jobname=$(IMGDIR)/$* $< $(DVIPS) -q -f $(IMGDIR)/$* | $(PS2EPS) --quiet --loose | $(EPSTOPDF) --filter --outfile=$(IMGDIR)/$@ # # PDF from LaTeX. # %.pdf: %.tex ifdef UNICODE $(XELATEX) $< $(XELATEX) $< else $(PDFLATEX) $< $(PDFLATEX) $< endif # # 2-up PDF from 1-up PDF. # %-2up.pdf: %.pdf $(PDFNUP) $< --nup 2x1 --outfile $@ # # Derived XML with inclusions from source XML without inclusions. # # This is done by simply running the original source through xmllint # with the --xinclude option to process any xi:include elements. # The result of this could just be 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: %.xml $(XMLLINT) --xinclude $< > $@ @$(SED) --in-place --expression='1a <!-- THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT! -->' $@ # # LaTeX from derived XML. # %.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,period-code,'$(PAPER_PERIOD)')) > $@ 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,period-code,'$(PAPER_PERIOD)')) > $@ endif # # HTML from derived XML. # %.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,period-code,'$(PAPER_PERIOD)')) > $@ 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,period-code,'$(PAPER_PERIOD)')) > $@ endif # # Image rules can be a bit messy, because the prerequisite might be in any one # of several different formats, but we want to apply the same commands anyway # (e.g., ImageMagick convert) to generate the target. It would be nice if we # could specify variable file types in a prerequisite of a pattern rule (e.g., # %-foo.png: %.png %.jpg %.tif), but unfortunately we can't :(. The solution is # to create a make function to refactor the commands, and then specify as many # rules as required depending on the number of file formats. We still end up # repeating the rule actions, but at least the guts of the action is coded only # once in the function. # # PNG from TIFF, JPEG, PICT (normal image) # Note: PNG prerequisites are dealt with further down. # convert_normal = $(CONVERT) "$(1)" "$(2)" %.png %-print.png %-web.png: %.tif $(call convert_normal,$<,$(IMGDIR)/$@) %.png %-print.png %-web.png: %.jpg $(call convert_normal,$<,$(IMGDIR)/$@) %.png %-print.png %-web.png: %.pict $(call convert_normal,$<,$(IMGDIR)/$@) # # PNG from PNG, TIFF, JPEG, PICT (slide background) # # We lighten these so that they don't overwhelm the text. Note that 15% is # too light for most data projectors, so let's try 33% and see what # happens... (this looks far too much on screen, but data projectors tend # to wash things out much, much more). # # Includes both blurred and unblurred versions, use as required. # # Unblurred: convert_bg = $(CONVERT) "$(1)" -threshold "-1" -depth 16 - | $(COMPOSITE) -dissolve 33% "$(1)" - "$(2)" %-BG.png: %.tif $(call convert_bg,$<,$(IMGDIR)/$@) %-BG.png: %.png $(call convert_bg,$<,$(IMGDIR)/$@) %-BG.png: %.jpg $(call convert_bg,$<,$(IMGDIR)/$@) %-BG.png: %.pict $(call convert_bg,$<,$(IMGDIR)/$@) # # Blurred: convert_bg_blur = $(CONVERT) -blur 0.5 "$(1)" "$(2)"; $(CONVERT) "$(2)" -threshold "-1" -depth 16 - | $(COMPOSITE) -dissolve 33% "$(2)" - "$(3)"; rm -f "$(2)" %-BG-blur.png: %.tif $(call convert_bg_blur,$<,$(IMGDIR)/$*-tmp.png,$(IMGDIR)/$@) %-BG-blur.png: %.png $(call convert_bg_blur,$<,$(IMGDIR)/$*-tmp.png,$(IMGDIR)/$@) %-BG-blur.png: %.jpg $(call convert_bg_blur,$<,$(IMGDIR)/$*-tmp.png,$(IMGDIR)/$@) %-BG-blur.png: %.pict $(call convert_bg_blur,$<,$(IMGDIR)/$*-tmp.png,$(IMGDIR)/$@) # # PNG from XCF. # %.png: %.xcf $(XCF2PNG) -o $(IMGDIR)/$@ $< # # PNG from EPS. # %.png %-print.png %-web.png: %.eps $(PS2EPS) --ignoreBB --nohires --loose --gsbbox < $< | \ $(GS) -q -dNOPAUSE -dBATCH -dSAFER -sDEVICE=png16m -dEPSCrop -r96 \ -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sOutputFile=$(IMGDIR)/$@ - %-web-zoom.png: %.eps $(PS2EPS) --ignoreBB --nohires --loose --gsbbox < $< | \ $(GS) -q -dNOPAUSE -dBATCH -dSAFER -sDEVICE=png16m -dEPSCrop -r144 \ -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sOutputFile=$(IMGDIR)/$@ - # # PNG from PS. # %-web.png: %.ps @$(PS2EPS) --ignoreBB --nohires --loose --gsbbox < $< | \ $(GS) -q -dNOPAUSE -dBATCH -dSAFER -sDEVICE=png16m -dEPSCrop -r96 \ -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sOutputFile=$(IMGDIR)/$@ - %-web-zoom.png: %.ps @$(PS2EPS) --ignoreBB --nohires --loose --gsbbox < $< | \ $(GS) -q -dNOPAUSE -dBATCH -dSAFER -sDEVICE=png16m -dEPSCrop -r144 \ -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sOutputFile=$(IMGDIR)/$@ - # # PNG from PDF. # %-web.png: %.pdf $(GS) -q -dNOPAUSE -dBATCH -dSAFER -sDEVICE=png16m -r96 \ -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sOutputFile=$(IMGDIR)/$@ $< %-web-zoom.png: %.pdf $(GS) -q -dNOPAUSE -dBATCH -dSAFER -sDEVICE=png16m -r144 \ -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sOutputFile=$(IMGDIR)/$@ $< # # PDF from Ploticus. # %.pdf %-print.pdf: %.plo $(PLOTICUS) -eps -tightcrop -o stdout $< | $(SHIFTBBOX) | $(EPSTOPDF) --filter --outfile=$(IMGDIR)/$@ # # PDF from R. # This assumes that the first argument to the R script is the output filename # for the resultant PDF. # %.pdf %-print.pdf: %.R $(R) --slave --file=$< --args "$(IMGDIR)/$@" $(PDFCROP) $(IMGDIR)/$@ $(IMGDIR)/$*-crop.pdf -$(MV) $(IMGDIR)/$*-crop.pdf $(IMGDIR)/$@ # # PDF from PS # %.pdf %-print.pdf: %.ps $(PS2EPS) --quiet --ignoreBB --nohires --loose < $< | $(EPSTOPDF) --filter --outfile=$(IMGDIR)/$@ # # PDF from EPS # %.pdf %-print.pdf: %.eps $(EPSTOPDF) --outfile=$(IMGDIR)/$@ $< # $(PS2EPS) --ignoreBB --nohires --loose < $< | $(PS2PDF) -dEPSCrop - $(IMGDIR)/$@ # # PDF from SVG (via Inkscape) # The --export-area-drawing option now appears to behave correctly with # PDFs (previously it over-cropped slightly). # %.pdf %-print.pdf: %.svg $(INKSCAPE) --file=$< --without-gui --export-area-drawing --export-pdf=$(IMGDIR)/$@ # # PNG from SVG (via Inkscape) # %.png %-print.png %-web.png: %.svg $(INKSCAPE) --file=$< --without-gui --export-area-drawing --export-background-opacity=1.0 --export-dpi=96 --export-png=$(IMGDIR)/$@ %-web-zoom.png: %.svg $(INKSCAPE) --file=$< --without-gui --export-area-drawing --export-background-opacity=1.0 --export-dpi=144 --export-png=$(IMGDIR)/$@ %-print-zoom.png: %.svg $(INKSCAPE) --file=$< --without-gui --export-area-drawing --export-background-opacity=1.0 --export-dpi=300 --export-png=$(IMGDIR)/$@ %-print-zoom-transparent.png: %.svg $(INKSCAPE) --file=$< --without-gui --export-area-drawing --export-background-opacity=0 --export-dpi=300 --export-png=$(IMGDIR)/$@ %-transparent.png: %.svg $(INKSCAPE) --file=$< --without-gui --export-area-drawing --export-background-opacity=0 --export-dpi=96 --export-png=$(IMGDIR)/$@ # # PNG from PNG (change the name). # These appear to need to be separate rules. If both variants need to be # created (i.e., both %-web.png and %-print.png), it only generates one of # them (most likely %-web.png as it's first in the rule) if the rules are # combined into one. This is Kind of Weird. # %-print.png: %.png $(CP) $< $(IMGDIR)/$@ %-web.png: %.png $(CP) $< $(IMGDIR)/$@
################################################################################ # # File: $Id$ # # Standard rules for a variety of situations. Includes standard suffixes and # paths. # # ################################################################################ ################################################################################ # # Required make variables. These should be defined by the calling makefile. # # PAPER_NUMBER # The paper number for the current paper, e.g., 212. # PAPER_NUMBER?=$(error The required make variable PAPER_NUMBER has not been defined. Please set it to the correct value) # # IMGDIR # The path to the directory that contains images, e.g., images. # IMGDIR?=$(error The required make variable IMGDIR has not been defined. Please set it to the directory in which images are located) ################################################################################ # # Default rules. # # # PDF from LaTeX via DVI, typically for images drawn using PSTricks). # %.pdf %-print.pdf: $(IMGDIR)/%.tex $(LATEX) --jobname=$(IMGDIR)/$* $< $(DVIPS) -q -f $(IMGDIR)/$* | $(PS2EPS) --quiet --loose | $(EPSTOPDF) --filter --outfile=$(IMGDIR)/$@ # # PDF from LaTeX. # %.pdf: %.tex ifdef UNICODE $(XELATEX) $< $(XELATEX) $< else $(PDFLATEX) $< $(PDFLATEX) $< endif # # 2-up PDF from 1-up PDF. # %-2up.pdf: %.pdf $(PDFNUP) $< --nup 2x1 --outfile $@ # # Derived XML with inclusions from source XML without inclusions. # # This is done by simply running the original source through xmllint # with the --xinclude option to process any xi:include elements. # The result of this could just be 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: %.xml $(XMLLINT) --xinclude $< > $@ @$(SED) --in-place --expression='1a <!-- THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT! -->' $@ # # LaTeX from derived XML. # %.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)')) > $@ 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)')) > $@ endif # # HTML from derived XML. # %.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)')) > $@ 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)')) > $@ endif # # Image rules can be a bit messy, because the prerequisite might be in any one # of several different formats, but we want to apply the same commands anyway # (e.g., ImageMagick convert) to generate the target. It would be nice if we # could specify variable file types in a prerequisite of a pattern rule (e.g., # %-foo.png: %.png %.jpg %.tif), but unfortunately we can't :(. The solution is # to create a make function to refactor the commands, and then specify as many # rules as required depending on the number of file formats. We still end up # repeating the rule actions, but at least the guts of the action is coded only # once in the function. # # PNG from TIFF, JPEG, PICT (normal image) # Note: PNG prerequisites are dealt with further down. # convert_normal = $(CONVERT) "$(1)" "$(2)" %.png %-print.png %-web.png: %.tif $(call convert_normal,$<,$(IMGDIR)/$@) %.png %-print.png %-web.png: %.jpg $(call convert_normal,$<,$(IMGDIR)/$@) %.png %-print.png %-web.png: %.pict $(call convert_normal,$<,$(IMGDIR)/$@) # # PNG from PNG, TIFF, JPEG, PICT (slide background) # # We lighten these so that they don't overwhelm the text. Note that 15% is # too light for most data projectors, so let's try 33% and see what # happens... (this looks far too much on screen, but data projectors tend # to wash things out much, much more). # # Includes both blurred and unblurred versions, use as required. # # Unblurred: convert_bg = $(CONVERT) "$(1)" -threshold "-1" -depth 16 - | $(COMPOSITE) -dissolve 33% "$(1)" - "$(2)" %-BG.png: %.tif $(call convert_bg,$<,$(IMGDIR)/$@) %-BG.png: %.png $(call convert_bg,$<,$(IMGDIR)/$@) %-BG.png: %.jpg $(call convert_bg,$<,$(IMGDIR)/$@) %-BG.png: %.pict $(call convert_bg,$<,$(IMGDIR)/$@) # # Blurred: convert_bg_blur = $(CONVERT) -blur 0.5 "$(1)" "$(2)"; $(CONVERT) "$(2)" -threshold "-1" -depth 16 - | $(COMPOSITE) -dissolve 33% "$(2)" - "$(3)"; rm -f "$(2)" %-BG-blur.png: %.tif $(call convert_bg_blur,$<,$(IMGDIR)/$*-tmp.png,$(IMGDIR)/$@) %-BG-blur.png: %.png $(call convert_bg_blur,$<,$(IMGDIR)/$*-tmp.png,$(IMGDIR)/$@) %-BG-blur.png: %.jpg $(call convert_bg_blur,$<,$(IMGDIR)/$*-tmp.png,$(IMGDIR)/$@) %-BG-blur.png: %.pict $(call convert_bg_blur,$<,$(IMGDIR)/$*-tmp.png,$(IMGDIR)/$@) # # PNG from XCF. # %.png: %.xcf $(XCF2PNG) -o $(IMGDIR)/$@ $< # # PNG from EPS. # %.png %-print.png %-web.png: %.eps $(PS2EPS) --ignoreBB --nohires --loose --gsbbox < $< | \ $(GS) -q -dNOPAUSE -dBATCH -dSAFER -sDEVICE=png16m -dEPSCrop -r96 \ -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sOutputFile=$(IMGDIR)/$@ - %-web-zoom.png: %.eps $(PS2EPS) --ignoreBB --nohires --loose --gsbbox < $< | \ $(GS) -q -dNOPAUSE -dBATCH -dSAFER -sDEVICE=png16m -dEPSCrop -r144 \ -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sOutputFile=$(IMGDIR)/$@ - # # PNG from PS. # %-web.png: %.ps @$(PS2EPS) --ignoreBB --nohires --loose --gsbbox < $< | \ $(GS) -q -dNOPAUSE -dBATCH -dSAFER -sDEVICE=png16m -dEPSCrop -r96 \ -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sOutputFile=$(IMGDIR)/$@ - %-web-zoom.png: %.ps @$(PS2EPS) --ignoreBB --nohires --loose --gsbbox < $< | \ $(GS) -q -dNOPAUSE -dBATCH -dSAFER -sDEVICE=png16m -dEPSCrop -r144 \ -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sOutputFile=$(IMGDIR)/$@ - # # PNG from PDF. # %-web.png: %.pdf $(GS) -q -dNOPAUSE -dBATCH -dSAFER -sDEVICE=png16m -r96 \ -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sOutputFile=$(IMGDIR)/$@ $< %-web-zoom.png: %.pdf $(GS) -q -dNOPAUSE -dBATCH -dSAFER -sDEVICE=png16m -r144 \ -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sOutputFile=$(IMGDIR)/$@ $< # # PDF from Ploticus. # %.pdf %-print.pdf: %.plo $(PLOTICUS) -eps -tightcrop -o stdout $< | $(SHIFTBBOX) | $(EPSTOPDF) --filter --outfile=$(IMGDIR)/$@ # # PDF from R. # This assumes that the first argument to the R script is the output filename # for the resultant PDF. # %.pdf %-print.pdf: %.R $(R) --slave --file=$< --args "$(IMGDIR)/$@" $(PDFCROP) $(IMGDIR)/$@ $(IMGDIR)/$*-crop.pdf -$(MV) $(IMGDIR)/$*-crop.pdf $(IMGDIR)/$@ # # PDF from PS # %.pdf %-print.pdf: %.ps $(PS2EPS) --quiet --ignoreBB --nohires --loose < $< | $(EPSTOPDF) --filter --outfile=$(IMGDIR)/$@ # # PDF from EPS # %.pdf %-print.pdf: %.eps $(EPSTOPDF) --outfile=$(IMGDIR)/$@ $< # $(PS2EPS) --ignoreBB --nohires --loose < $< | $(PS2PDF) -dEPSCrop - $(IMGDIR)/$@ # # PDF from SVG (via Inkscape) # The --export-area-drawing option now appears to behave correctly with # PDFs (previously it over-cropped slightly). # %.pdf %-print.pdf: %.svg $(INKSCAPE) --file=$< --without-gui --export-area-drawing --export-pdf=$(IMGDIR)/$@ # # PNG from SVG (via Inkscape) # %.png %-print.png %-web.png: %.svg $(INKSCAPE) --file=$< --without-gui --export-area-drawing --export-background-opacity=1.0 --export-dpi=96 --export-png=$(IMGDIR)/$@ %-web-zoom.png: %.svg $(INKSCAPE) --file=$< --without-gui --export-area-drawing --export-background-opacity=1.0 --export-dpi=144 --export-png=$(IMGDIR)/$@ %-print-zoom.png: %.svg $(INKSCAPE) --file=$< --without-gui --export-area-drawing --export-background-opacity=1.0 --export-dpi=300 --export-png=$(IMGDIR)/$@ %-print-zoom-transparent.png: %.svg $(INKSCAPE) --file=$< --without-gui --export-area-drawing --export-background-opacity=0 --export-dpi=300 --export-png=$(IMGDIR)/$@ %-transparent.png: %.svg $(INKSCAPE) --file=$< --without-gui --export-area-drawing --export-background-opacity=0 --export-dpi=96 --export-png=$(IMGDIR)/$@ # # PNG from PNG (change the name). # These appear to need to be separate rules. If both variants need to be # created (i.e., both %-web.png and %-print.png), it only generates one of # them (most likely %-web.png as it's first in the rule) if the rules are # combined into one. This is Kind of Weird. # %-print.png: %.png $(CP) $< $(IMGDIR)/$@ %-web.png: %.png $(CP) $< $(IMGDIR)/$@
Show line notes below