Newer
Older
Handbook / make-includes / build_lecture_rules.make
  1. ################################################################################
  2. #
  3. # File: $Id$
  4. #
  5. # Standard variables and rules for building a set of lecture files.
  6. # Altering these definitions will affect ALL LECTURE MAKEFILES FOR ALL
  7. # PAPERS!! If you need to do something specific for a particular paper,
  8. # include a custom rule in its makefile. DON'T add it here!
  9. #
  10. ################################################################################
  11.  
  12.  
  13. ################################################################################
  14. #
  15. # Add standard file suffixes.
  16. #
  17. include $(GLOBAL_HANDBOOK_INCLUDE)/standard_suffixes.make
  18.  
  19.  
  20. ################################################################################
  21. #
  22. # Standard directories.
  23. #
  24. IMGDIR=images
  25.  
  26.  
  27. ################################################################################
  28. #
  29. # Standard paths.
  30. #
  31. include $(GLOBAL_HANDBOOK_INCLUDE)/standard_paths.make
  32.  
  33.  
  34. ################################################################################
  35. #
  36. # Files to be cleaned by the various "clean" targets. Note that we don't
  37. # "tidy" .aux files because they may be needed by the xr package for inter-
  38. # document cross references, but won't get regenerated if the final target
  39. # PDF files exist. They will be caught by by the "clean" target though.
  40. #
  41. TIDY_FILES+=*.tmp *.out *.log *.nav *.toc *.snm *.head *.dvi \
  42. slides-combined.pdf slides-notes.pdf
  43. CLEAN_FILES+=*.aux *.pdf
  44.  
  45.  
  46. ################################################################################
  47. #
  48. # Various environment variables.
  49. #
  50. include $(GLOBAL_HANDBOOK_INCLUDE)/standard_environment.make
  51. #
  52. # Base file names for the various documents.
  53. #
  54. SLIDES?=Chapter$(CHAPTER)slides
  55. FIGURES?=Chapter$(CHAPTER)figures
  56. COMBINED?=Chapter$(CHAPTER)combined
  57. NOTES?=Chapter$(CHAPTER)notes
  58. #
  59. # Standard files to be installed on the web server.
  60. #
  61. ifneq ($(strip $(SLIDES)),)
  62. INSTALL_FILES+=$(SLIDES).pdf
  63. endif
  64. ifneq ($(strip $(FIGURES)),)
  65. INSTALL_FILES+=$(FIGURES).pdf $(FIGURES)-reduced.pdf
  66. endif
  67. ifneq ($(strip $(COMBINED)),)
  68. INSTALL_FILES+=$(COMBINED).pdf
  69. endif
  70. INSTALL_FILES+=$(wildcard *.mp3)
  71. #
  72. # List of standard "phony" build targets.
  73. #
  74. TARGETS+=slides notes slides-combined slides-notes figures figures2up combined
  75. #
  76. .PHONY: $(TARGETS)
  77.  
  78.  
  79. ################################################################################
  80. #
  81. # Display a message if someone tries to build a target that has been
  82. # disabled (by setting the appropriate variable to empty in the makefile).
  83. #
  84. disabled_message=@$(ECHO) The \"$(1)\" target has been disabled for this chapter.
  85.  
  86.  
  87. ################################################################################
  88. #
  89. # Build everything.
  90. #
  91. all: slides notes figures figures2up combined
  92.  
  93.  
  94. ################################################################################
  95. #
  96. # Build presentation slides. If $(SLIDES) is empty, these rules are ignored.
  97. #
  98. ifneq ($(strip $(SLIDES)),)
  99.  
  100. #
  101. # Set the prerequisites for the "slides" build target, depending on
  102. # whether the figures document exists. If $(FIGURES) is non-empty, we need
  103. # to include the figures .aux file for inter-document cross-references.
  104. #
  105. ifeq ($(strip $(FIGURES)),)
  106. SLIDES_PREREQS:=$(SLIDES).pdf
  107. else
  108. SLIDES_PREREQS:=figures $(SLIDES).pdf
  109. endif
  110.  
  111. #
  112. # Build the slides for the presentation.
  113. #
  114. slides: $(SLIDES_PREREQS)
  115.  
  116. $(SLIDES).pdf: $(SLIDES).tex $(SLIDE_IMAGES) $(SLIDE_BACKGROUNDS) $(SLIDE_FILES)
  117. $(PDFLATEX) --jobname=$(SLIDES) '\documentclass[$(LATEX_OPTS)]{lectureslides}\input{$(SLIDES)}'
  118. $(PDFLATEX) --jobname=$(SLIDES) '\documentclass[$(LATEX_OPTS)]{lectureslides}\input{$(SLIDES)}'
  119.  
  120. else
  121.  
  122. slides:
  123. $(call disabled_message,$@)
  124.  
  125. endif
  126.  
  127.  
  128. ################################################################################
  129. #
  130. # Build the presentation notes. If $(NOTES) is empty, these rules are
  131. # ignored.
  132. #
  133. ifneq ($(strip $(NOTES)),)
  134.  
  135. #
  136. # Build the slides with notes.
  137. #
  138. slides-notes: slides-notes.pdf
  139.  
  140. slides-notes.pdf: $(SLIDES).tex $(SLIDE_IMAGES) $(SLIDE_BACKGROUNDS) $(SLIDE_FILES)
  141. $(PDFLATEX) --jobname=slides-notes '\documentclass[$(LATEX_OPTS),notes=onlyslideswithnotes]{lectureslides}\input{$(SLIDES)}'
  142. $(PDFLATEX) --jobname=slides-notes '\documentclass[$(LATEX_OPTS),notes=onlyslideswithnotes]{lectureslides}\input{$(SLIDES)}'
  143.  
  144. #
  145. # Build the slides with notes, 6-up.
  146. #
  147. notes: $(NOTES).pdf
  148.  
  149. $(NOTES).pdf: $(NOTES).tex slides-notes.pdf
  150. $(PDFLATEX) $<
  151. $(PDFLATEX) $<
  152.  
  153. else
  154.  
  155. notes slides-notes:
  156. $(call disabled_message,$@)
  157.  
  158. endif
  159.  
  160.  
  161. ################################################################################
  162. #
  163. # Build the complete combined lecture document. If $(COMBINED) is empty,
  164. # these rules are ignored.
  165. #
  166. ifneq ($(strip $(COMBINED)),)
  167.  
  168. #
  169. # Set the prerequisites for the "combined" build target, depending on
  170. # whether the figures document exists. If $(FIGURES) is empty, they are
  171. # omitted from the combined document.
  172. #
  173. ifeq ($(strip $(FIGURES)),)
  174. COMBINED_PREREQS:=$(COMBINED).tex slides-combined.pdf
  175. else
  176. COMBINED_PREREQS:=$(COMBINED).tex slides-combined.pdf $(FIGURES).pdf
  177. endif
  178.  
  179. #
  180. # Build the slides for the combined document.
  181. #
  182. slides-combined: slides-combined.pdf
  183.  
  184. slides-combined.pdf: $(SLIDES).tex $(SLIDE_IMAGES) $(SLIDE_BACKGROUNDS)
  185. $(PDFLATEX) --jobname=slides-combined '\documentclass[$(LATEX_OPTS),handout]{lectureslides}\input{$(SLIDES)}'
  186. $(PDFLATEX) --jobname=slides-combined '\documentclass[$(LATEX_OPTS),handout]{lectureslides}\input{$(SLIDES)}'
  187.  
  188. #
  189. # Build the complete combined document.
  190. #
  191. combined: $(COMBINED).pdf
  192.  
  193. $(COMBINED).pdf: $(COMBINED_PREREQS) $(COMBI_IMAGES) $(COMBI_FILES)
  194. $(PDFLATEX) $<
  195. $(PDFLATEX) $<
  196.  
  197. else
  198.  
  199. combined slides-combined:
  200. $(call disabled_message,$@)
  201.  
  202. endif
  203.  
  204.  
  205. ################################################################################
  206. #
  207. # Build the figures and examples document. If $(FIGURES) is empty, these
  208. # rules are ignored.
  209. #
  210. ifneq ($(strip $(FIGURES)),)
  211.  
  212. figures: $(FIGURES).pdf
  213.  
  214. $(FIGURES).pdf: $(FIGURES).tex $(FIG_IMAGES) $(FIG_FILES)
  215. $(PDFLATEX) $<
  216. $(PDFLATEX) $<
  217.  
  218. figures2up: $(FIGURES)-reduced.pdf
  219.  
  220. $(FIGURES)-reduced.pdf: $(FIGURES).pdf
  221. $(PDFNUP) $< --nup 2x1 --outfile $@
  222.  
  223. else
  224.  
  225. figures figures2up:
  226. $(call disabled_message,$@)
  227.  
  228. endif
  229.  
  230.  
  231. ################################################################################
  232. #
  233. # Build the test document.
  234. #
  235. test: test.pdf
  236.  
  237. test.pdf: test.tex
  238.  
  239.  
  240. ################################################################################
  241. #
  242. # Deploy the appropriate files into a shared folder, which is then synchronised
  243. # with Blackbaord. This relies on the environment variable HANDBOOK_INSTALL_ROOT
  244. # being defined, and (assuming that this variable points to a directory on the
  245. # network) the appropriate share has been mounted.
  246. #
  247. # See build_document_rules.make for an explanation of why the install
  248. # uses a foreach.
  249. #
  250. # Note that this won't do anything clever if you give it files that are
  251. # in subdirectories of the current directory. Everything will be flattened
  252. # at the other end. That is, something like "images/foo.pdf" will go into
  253. # the installation directory as "foo.pdf", not "images/foo.pdf".
  254. #
  255. # If the variable NOSYNC is set (to anything), then files won't be synchronised
  256. # with Blackboard.
  257. #
  258. install:
  259. @$(ANNOUNCE) "Deploying files into $(INSTALL_DIRECTORY)"
  260. @$(TEST) -d $(HANDBOOK_INSTALL_ROOT)
  261. @$(MKDIR_P) $(INSTALL_DIRECTORY)
  262. @$(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;)
  263. ifndef NOSYNC
  264. @$(ANNOUNCE) "Synchronising with Blackboard"
  265. @$(SITECOPY) --update Blackboard$(PAPER_NUMBER)
  266. endif
  267.  
  268.  
  269. ################################################################################
  270. #
  271. # Debugging: print the values of the standard variables.
  272. #
  273. debug:
  274. @$(ANNOUNCE) Externally defined variables
  275. @$(ECHO) "TEACHING_SHARED = [$(TEACHING_SHARED)]"
  276. @$(ECHO) "HANDBOOK_INSTALL_ROOT = [$(HANDBOOK_INSTALL_ROOT)]"
  277. @$(ECHO) "CHAPTER = [$(CHAPTER)]"
  278. @$(ANNOUNCE) Internally defined variables
  279. @$(ECHO) "SUBJECT_CODE = [$(SUBJECT_CODE)]"
  280. @$(ECHO) "PAPER_NUMBER = [$(PAPER_NUMBER)]"
  281. @$(ECHO) "GLOBAL_HANDBOOK_INCLUDE = [$(GLOBAL_HANDBOOK_INCLUDE)]"
  282. @$(ECHO) "INSTALL_DIRECTORY = [$(INSTALL_DIRECTORY)]"
  283. @$(ECHO) "BUILD_DIR = [$(BUILD_DIR)]"
  284. @$(ECHO) "INSTALL_FILES = [$(INSTALL_FILES)]"
  285. @$(ECHO) "SLIDE_IMAGES = [$(SLIDE_IMAGES)]"
  286. @$(ECHO) "SLIDE_BACKGROUNDS = [$(SLIDE_BACKGROUNDS)]"
  287. @$(ECHO) "SLIDE_FILES = [$(SLIDE_FILES)]"
  288. @$(ECHO) "FIG_IMAGES = [$(FIG_IMAGES)]"
  289. @$(ECHO) "FIG_FILES = [$(FIG_FILES)]"
  290. @$(ECHO) "TIDY_FILES = [$(TIDY_FILES)]"
  291. @$(ECHO) "CLEAN_FILES = [$(CLEAN_FILES)]"
  292. @$(ECHO) "DRAFT = [$(DRAFT)]"
  293. @$(ECHO) "LATEX_OPTS = [$(LATEX_OPTS)]"
  294. @$(ECHO) "SLIDES = [$(SLIDES)]"
  295. @$(ECHO) "FIGURES = [$(FIGURES)]"
  296. @$(ECHO) "COMBINED = [$(COMBINED)]"
  297. @$(ECHO) "NOTES = [$(NOTES)]"
  298. @$(ECHO) "SLIDES_PREREQS = [$(SLIDES_PREREQS)]"
  299. @$(ECHO) "COMBINED_PREREQS = [$(COMBINED_PREREQS)]"
  300. @$(ECHO) "TARGETS = [$(TARGETS)]"
  301.  
  302.  
  303. ################################################################################
  304. #
  305. # Clean up: get rid of all the temporary files.
  306. #
  307. tidy:
  308. $(RM) -f $(TIDY_FILES)
  309. #
  310. # Clean up: get rid of everything except the original source.
  311. #
  312. clean: tidy
  313. $(RM) -f $(CLEAN_FILES)
  314.  
  315.  
  316. ################################################################################
  317. #
  318. # List all "phony" build targets.
  319. #
  320. targets:
  321. @$(ECHO) "targets: $(TARGETS)"
  322.  
  323.  
  324. ################################################################################
  325. #
  326. # Standard default rules.
  327. #
  328. include $(GLOBAL_HANDBOOK_INCLUDE)/standard_rules.make