Newer
Older
Handbook / make-includes / build_document_rules.make
nstanger on 13 Aug 2012 21 KB - Fixed typo.
  1. ################################################################################
  2. #
  3. # File: $Id$
  4. #
  5. # Standard variables and rules for building a particular document within a
  6. # section of the handbook (e.g., a single tutorial). Altering these
  7. # definitions will affect ALL DOCUMENT MAKEFILES FOR ALL PAPERS!! If you
  8. # need to do something specific for a particular paper, include a custom
  9. # rule in its makefile. DON'T add it here!
  10. #
  11. ################################################################################
  12.  
  13.  
  14. ################################################################################
  15. #
  16. # Run one-time initialisation stuff, _unless_ NOINIT is defined. Any
  17. # "parent" makefile that's already done the same one-time initialisation
  18. # and calls this one should define NOINIT (the value doesn't matter) to
  19. # switch off one-time initialisation in this makefile. Thus if the
  20. # "parent" makefile calls this makefile several times, things like the
  21. # content checking will only happen once for a single invocation of the
  22. # "parent" makefile.
  23. #
  24. # When running this makefile standalone, _don't_ define NOINIT, and
  25. # everything will still work as expected.
  26. #
  27. ifndef NOINIT
  28. include $(GLOBAL_HANDBOOK_INCLUDE)/remove_content_marker_files.make
  29. endif
  30.  
  31.  
  32. ################################################################################
  33. #
  34. # Given that we print out our own messages, I see no point in splurging
  35. # "Entering...leaving directory" messages all over the screen. It's hard
  36. # enough to figure out what's going on already :)
  37. #
  38. MAKEFLAGS=--no-print-directory
  39.  
  40.  
  41. ################################################################################
  42. #
  43. # Include variables defining the current paper.
  44. #
  45. include $(LOCAL_HANDBOOK_INCLUDE)/paper_variables.make
  46.  
  47.  
  48. ################################################################################
  49. #
  50. # We make quite a lot of reference to files in the handbook directory,
  51. # so set a variable to point to it. PAPER_ROOT is defined in the include
  52. # file paper_variables.make.
  53. #
  54. HANDBOOK_ROOT:=$(PAPER_ROOT)/Handbook
  55.  
  56.  
  57. ################################################################################
  58. #
  59. # Include XSLT functions.
  60. #
  61. include $(GLOBAL_HANDBOOK_INCLUDE)/xslt_functions.make
  62.  
  63.  
  64. ################################################################################
  65. #
  66. # Defines which section we are currently building. This is actually the
  67. # path to the main folder for the section. Normally this is passed in as
  68. # an argument to make from a higher-level makefile (i.e., "make
  69. # SECTION=path/to/section").
  70. #
  71. # Hmm, sh seems to convert uppercase letters in my paths to lowercase.
  72. # I'm not sure whether this will break anything or not...
  73. #
  74. # I _can_ confirm that having spaces anywhere in the parent path causes
  75. # serious breakage, because notdir returns bogus results in such cases.
  76. # All of the make functions assume whitespace delimitation, and there
  77. # doesn't seem to be any obvious way to work around this other than
  78. # eliminating spaces from the parent path (quoting the result of the
  79. # shell function below makes no difference). Fortunately, this is pretty
  80. # easy to do :)
  81. #
  82. #
  83. SECTION?=$(notdir $(shell cd ..; pwd))
  84.  
  85.  
  86. ################################################################################
  87. #
  88. # Set up the context for the current document.
  89. #
  90. # We use the same base name for both the directory and the document, which
  91. # makes life very easy :)
  92. #
  93. BASE_NAME:=$(notdir $(CURDIR))
  94.  
  95. #
  96. # SOURCE_XML is the original source XML, from which DERIVED_XML is
  97. # generated (the derived source has the includes for questions, etc.,
  98. # inserted).
  99. #
  100. SOURCE_XML:=$(BASE_NAME).xml
  101. DERIVED_XML:=$(SOURCE_XML:.xml=-derived.xml)
  102.  
  103. #
  104. # Define the names of the output files.
  105. #
  106. WEB_QUESTIONS_HTML:=$(BASE_NAME)-questions.html
  107. WEB_ANSWERS_HTML:=$(BASE_NAME)-answers.html
  108.  
  109. PRINT_QUESTIONS_TEX:=$(WEB_QUESTIONS_HTML:.html=.tex)
  110. PRINT_ANSWERS_TEX:=$(WEB_ANSWERS_HTML:.html=.tex)
  111.  
  112. PRINT_QUESTIONS_PDF_1UP:=$(PRINT_QUESTIONS_TEX:.tex=.pdf)
  113. PRINT_ANSWERS_PDF_1UP:=$(PRINT_ANSWERS_TEX:.tex=.pdf)
  114. PRINT_QUESTIONS_PDF_2UP:=$(PRINT_QUESTIONS_TEX:.tex=-2up.pdf)
  115. PRINT_ANSWERS_PDF_2UP:=$(PRINT_ANSWERS_TEX:.tex=-2up.pdf)
  116.  
  117. #
  118. # Groupings of various web- and print-related files, for easy reference.
  119. # Feel free to add to these as necessary :)
  120. #
  121. DERIVED_WEB_FILES:=$(WEB_QUESTIONS_HTML) $(WEB_ANSWERS_HTML)
  122. DERIVED_PRINT_FILES:=$(PRINT_QUESTIONS_TEX) $(PRINT_ANSWERS_TEX) \
  123. $(PRINT_QUESTIONS_PDF_1UP) $(PRINT_ANSWERS_PDF_1UP) \
  124. $(PRINT_QUESTIONS_PDF_2UP) $(PRINT_ANSWERS_PDF_2UP)
  125.  
  126.  
  127. #
  128. # List of XSL stylesheets. If any of these change, we need to rebuild
  129. # everything.
  130. #
  131. # We can't use the resolver approach under Windows because of the DOS
  132. # pathnames. The style sheets come out of the resolver with paths like
  133. # C:\bar\foo\..., and make interprets the colon as an extra dependency
  134. # delimiter (tested and behaviour verified). Of course, this works fine on
  135. # any platform with sensible path standards. Quoting the value doesn't
  136. # help, unfortunately. Bugger :(
  137. #
  138. #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-)
  139. 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
  140.  
  141.  
  142. ################################################################################
  143. #
  144. # Extract the list of included filenames from the source template. Hooray
  145. # for the shell function and Perl! Include file paths are found within the
  146. # href attributes of XML Include elements (<xi:include href="..." />).
  147. # All paths are relative to $(PAPER_ROOT). We don't use
  148. # $(PAPER_ROOT)/$(SECTION), because some of the include directories may be
  149. # in relatively arbitrary locations.
  150. #
  151. CONTENT_SRC:=$(shell $(PERL) -ne 'print "$(PAPER_ROOT)/$$2\n" if m{<xi:include .*href="(\.\./)*([^"]+)"};' $(SOURCE_XML))
  152.  
  153.  
  154. ################################################################################
  155. #
  156. # Directory to install files into on web server.
  157. #
  158. INSTALL_DIRECTORY:=$(HANDBOOK_INSTALL_ROOT)/$(SUBJECT_CODE)$(PAPER_NUMBER)/$(SECTION)/$(BASE_NAME)
  159.  
  160.  
  161. ################################################################################
  162. #
  163. # Files to be installed on web server.
  164. #
  165. QUESTION_INSTALL_FILES:=$(WEB_QUESTIONS_HTML) $(PRINT_QUESTIONS_PDF_1UP) \
  166. $(PRINT_QUESTIONS_PDF_2UP) $(wildcard *.png)
  167.  
  168. ANSWER_INSTALL_FILES:=$(WEB_ANSWERS_HTML) $(PRINT_ANSWERS_PDF_1UP) \
  169. $(PRINT_ANSWERS_PDF_2UP) $(wildcard *.png)
  170.  
  171.  
  172. ################################################################################
  173. #
  174. # Lists of files for cleaning up. Add to these (using +=) as necessary in
  175. # derived makefiles. Note that ALL_CLEAN_FILES comprises files that need
  176. # to be deleted _in addition_ to those listed in WEB_CLEAN_FILES and
  177. # PRINT_CLEAN_FILES (that is, it's the list of additional files for the
  178. # "clean" target, which depends on "web-clean" and "print-clean" anyway).
  179. #
  180. WEB_CLEAN_FILES:=$(DERIVED_WEB_FILES) *-web*.png
  181. PRINT_CLEAN_FILES:=$(DERIVED_PRINT_FILES) *-print*.png *.pdf
  182. ALL_CLEAN_FILES:=$(DERIVED_XML)
  183.  
  184.  
  185. ################################################################################
  186. #
  187. # List of possible targets. If you need to add to this for a specific
  188. # case, use TARGETS+=xxx in the actual makefile.
  189. #
  190. TARGETS:=all content targets debug install-questions install-answers \
  191. web web-questions web-answers \
  192. print print-questions print-answers \
  193. questions answers \
  194. clean web-clean print-clean
  195.  
  196. .PHONY: $(TARGETS)
  197.  
  198.  
  199. ################################################################################
  200. #
  201. # Build everything.
  202. #
  203. all: web print
  204.  
  205.  
  206. ################################################################################
  207. #
  208. # Build questions or answers only.
  209. #
  210. questions: web-questions print-questions
  211.  
  212. answers: web-answers print-answers
  213.  
  214.  
  215. ################################################################################
  216. #
  217. # Build web version only.
  218. #
  219. web: web-questions web-answers
  220.  
  221. web-questions: content $(WEB_QUESTIONS_HTML)
  222.  
  223. $(WEB_QUESTIONS_HTML): $(DERIVED_XML)
  224. @$(ANNOUNCE) "Building $@ from $<"
  225. $(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,'no'),$(call xslt_parameter,showanswers,'no'),$(call xslt_parameter,base-path,'.'),$(call xslt_parameter,image-format,'png')) > $@
  226.  
  227. web-answers: content $(WEB_ANSWERS_HTML)
  228.  
  229. $(WEB_ANSWERS_HTML): $(DERIVED_XML)
  230. @$(ANNOUNCE) "Building $@ from $<"
  231. $(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,'no'),$(call xslt_parameter,showanswers,'yes'),$(call xslt_parameter,base-path,'.'),$(call xslt_parameter,image-format,'png')) > $@
  232.  
  233.  
  234. ################################################################################
  235. #
  236. # Build print version only. We add code to the LaTeX source to mark the
  237. # first and last pages of the document, so that an individual PDF for this
  238. # document can be generated later. \markfirstpage and \marklastpage are
  239. # macros defined in handbook_template.tex that write the current physical
  240. # page number to the .aux file.
  241. #
  242. print: print-questions print-answers
  243.  
  244. print-questions: content $(PRINT_QUESTIONS_TEX)
  245.  
  246. $(PRINT_QUESTIONS_TEX): $(DERIVED_XML)
  247. @$(ANNOUNCE) "Building $@ from $<"
  248. @$(ECHO) "\\markfirstpage{$(SECTION)/$(BASE_NAME)/$(@:.tex=.pdf)}" > $@
  249. $(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,'no'),$(call xslt_parameter,showanswers,'no'),$(call xslt_parameter,base-path,'sections/$(SECTION)/$(BASE_NAME)'),$(call xslt_parameter,image-format,'pdf')) >> $@
  250. @$(ECHO) "\\marklastpage{$(SECTION)/$(BASE_NAME)/$(@:.tex=.pdf)}" >> $@
  251.  
  252. %-questions.pdf: %-questions.tex
  253. @$(ANNOUNCE) "Generating $@"
  254. @$(if $(wildcard $(HANDBOOK_ROOT)/handbook.pdf),,$(error $(HANDBOOK_ROOT)/handbook.pdf is missing))
  255. @gs -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=$@ \
  256. -dFirstPage=$(shell $(GREP) '$@.1up.first' $(HANDBOOK_ROOT)/handbook.aux | $(CUT) -d= -f2) \
  257. -dLastPage=$(shell $(GREP) '$@.1up.last' $(HANDBOOK_ROOT)/handbook.aux | $(CUT) -d= -f2) $(HANDBOOK_ROOT)/handbook.pdf
  258.  
  259. %-questions-2up.pdf: %-questions.tex
  260. @$(ANNOUNCE) "Generating $@"
  261. @$(if $(wildcard $(HANDBOOK_ROOT)/handbook-2up.pdf),,$(error $(HANDBOOK_ROOT)/handbook-2up.pdf is missing))
  262. @gs -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=$@ \
  263. -dFirstPage=$(shell $(GREP) '$(@:-2up.pdf=.pdf).2up.first' $(HANDBOOK_ROOT)/handbook.aux | $(CUT) -d= -f2) \
  264. -dLastPage=$(shell $(GREP) '$(@:-2up.pdf=.pdf).2up.last' $(HANDBOOK_ROOT)/handbook.aux | $(CUT) -d= -f2) $(HANDBOOK_ROOT)/handbook-2up.pdf
  265.  
  266. print-answers: content $(PRINT_ANSWERS_TEX)
  267.  
  268. $(PRINT_ANSWERS_TEX): $(DERIVED_XML)
  269. @$(ANNOUNCE) "Building $@ from $<"
  270. @$(ECHO) "\\markfirstpage{$(SECTION)/$(BASE_NAME)/$(@:.tex=.pdf)}" > $@
  271. $(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,'no'),$(call xslt_parameter,showanswers,'yes'),$(call xslt_parameter,base-path,'sections/$(SECTION)/$(BASE_NAME)'),$(call xslt_parameter,image-format,'pdf')) >> $@
  272. @$(ECHO) "\\marklastpage{$(SECTION)/$(BASE_NAME)/$(@:.tex=.pdf)}" >> $@
  273.  
  274. %-answers.pdf: %-answers.tex
  275. @$(ANNOUNCE) "Generating $@"
  276. @$(if $(wildcard $(HANDBOOK_ROOT)/handbook-answers.pdf),,$(error $(HANDBOOK_ROOT)/handbook-answers.pdf is missing))
  277. @gs -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=$@ \
  278. -dFirstPage=$(shell $(GREP) '$@.1up.first' $(HANDBOOK_ROOT)/handbook-answers.aux | $(CUT) -d= -f2) \
  279. -dLastPage=$(shell $(GREP) '$@.1up.last' $(HANDBOOK_ROOT)/handbook-answers.aux | $(CUT) -d= -f2) $(HANDBOOK_ROOT)/handbook-answers.pdf
  280.  
  281. %-answers-2up.pdf: %-answers.tex
  282. @$(ANNOUNCE) "Generating $@"
  283. @$(if $(wildcard $(HANDBOOK_ROOT)/handbook-answers-2up.pdf),,$(error $(HANDBOOK_ROOT)/handbook-answers-2up.pdf is missing))
  284. @gs -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=$@ \
  285. -dFirstPage=$(shell $(GREP) '$(@:-2up.pdf=.pdf).2up.first' $(HANDBOOK_ROOT)/handbook-answers.aux | $(CUT) -d= -f2) \
  286. -dLastPage=$(shell $(GREP) '$(@:-2up.pdf=.pdf).2up.last' $(HANDBOOK_ROOT)/handbook-answers.aux | $(CUT) -d= -f2) $(HANDBOOK_ROOT)/handbook-answers-2up.pdf
  287.  
  288.  
  289. ################################################################################
  290. #
  291. # Generate the derived XML source from the original XML template.
  292. # This is done by simply running the original source through xmllint
  293. # with the --xinclude option to process all the xi:include elements.
  294. # The result of this could have just been piped into the XSLT processor,
  295. # except that (a) not all of the processors support input from stdin,
  296. # and (b) combining both xmllint and XSLT processing into one command
  297. # means that make won't stop if there's any errors from xmllint.
  298. #
  299. # Sed is used to add a comment to the derived XML file, warning that this
  300. # is generated and shouldn't be edited. Sed was used because the <?xml?>
  301. # processing instruction MUST be on the first line. The implication here
  302. # is that all input source files have an <?xml?> processing instruction
  303. # (which they should anyway).
  304. #
  305. $(DERIVED_XML): $(SOURCE_XML) $(XSLT_STYLESHEETS)
  306. @$(ANNOUNCE) "Generating $@"
  307. @$(XMLLINT) --xinclude $< >$@
  308. @$(SED) -i -e '1a <!-- THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT! -->' $@
  309.  
  310. ################################################################################
  311. #
  312. # If any of the content files change, touch the XML template to
  313. # ensure that the document gets fully rebuilt.
  314. #
  315. $(SOURCE_XML): $(CONTENT_SRC)
  316. @$(TOUCH) $@
  317.  
  318.  
  319. ################################################################################
  320. #
  321. # Build the individual content files, etc., as necessary. Note above that
  322. # all the primary targets depend on the "content" target, _before_
  323. # anything else. This ensures that the content gets rebuilt (if necessary)
  324. # before anything else happens.
  325. #
  326. # This may seem redundant, given that SOURCE_XML depends on CONTENT_SRC in
  327. # the rule above. However, this rule only works if we change one of the
  328. # actual content files. What if instead, we change a graphic associated
  329. # with one of the content files, without changing the content file itself?
  330. # In this case, make assumes that nothing needs to be done, because the
  331. # content file is older than the target, and this makefile knows nothing
  332. # about any dependencies that the content file might have (that's dealt
  333. # with by the makefile in the appropriate content directory). This is the
  334. # main downside of having independent makefiles.
  335. #
  336. # So, the slightly convoluted workaround using the empty "content" target
  337. # ensures that the content files will always be checked, regardless of
  338. # whether they've changed. If any of their prerequisites for a particular
  339. # content file change, then the content file itself will be touched, thus
  340. # activating the SOURCE_XML rule above. This process is particularly
  341. # important to ensure that associated graphics get rebuilt when they
  342. # change.
  343. #
  344. # All that aside, however, the _real_ trick is to ensure that this rule is
  345. # only executed once. If we do a "make", this rule would nominally get
  346. # executed four times (once for each of the targets that depend on
  347. # "content"). The first time through the rule, therefore, we create a
  348. # marker file called "content-checked". If this file exists, the rule
  349. # isn't executed. These marker files are cleaned up by a one-off find
  350. # command when the makefile is first run (see the include file
  351. # one-time-init.make).
  352. #
  353. # Note: using the wildcard function to test for the existence of the
  354. # marker file doesn't work when the makefile is run standalone, because
  355. # the function result is expanded at the time the makefile is _loaded_,
  356. # _before_ the one-time initialisation has a change to kick in and delete
  357. # the file. This has the rather bizarre side-effect of the makefile only
  358. # re-checking the content on every second run, and means that we can't use
  359. # make conditionals to control rule execution. The solution is to prefix
  360. # every command in the rule with "test ! -f" to check whether the marker
  361. # file exists.
  362. #
  363. # Ack! The tribulations of not using a monolithic makefile...
  364. #
  365. content:
  366. # Of course, there's little point in doing anything if there's no content!
  367. ifneq ($(strip $(CONTENT_SRC)),)
  368. @if $(TEST) ! -f content-checked; then \
  369. $(ANNOUNCE) "Checking content for $(BASE_NAME)"; \
  370. fi
  371. # Sanity check: do the content files referenced from the original source
  372. # actually exist? The "$(TRUE)" is included because there needs to
  373. # be something in the body of the if --- you can't just leave it empty. We
  374. # can use the wildcard function here because these files should already
  375. # exist --- if they don't, then by definition the filename is wrong!
  376. @if $(TEST) ! -f content-checked; then \
  377. $(foreach f,$(CONTENT_SRC),$(if $(wildcard $f),,$(error Content file $f referenced from $(SOURCE_XML) does not exist)) $(TRUE);) \
  378. fi
  379. # Remake each individual content file.
  380. @if $(TEST) ! -f content-checked; then \
  381. $(foreach f,$(CONTENT_SRC),if $(MAKE) -C $(dir $f) $(notdir $f) BUILD_DIR=$(CURDIR); then $(TRUE); else exit 1; fi;) \
  382. fi
  383. # Create the marker file so that this rule doesn't get executed again.
  384. @if $(TEST) ! -f content-checked; then \
  385. $(TOUCH) content-checked; \
  386. fi
  387. endif
  388.  
  389.  
  390. ################################################################################
  391. #
  392. # Deploy the appropriate files into a shared folder, which is then synchronised
  393. # with Blackboard. This relies on the environment variable HANDBOOK_INSTALL_ROOT
  394. # being defined, and (assuming that this variable points to a directory on the
  395. # network) the appropriate share has been mounted.
  396. #
  397. # This checks each file in the build directory against the corresponding
  398. # file in the install directory. The local file is only copied to the
  399. # install directory if it is newer, or the remote file doesn't exist.
  400. #
  401. # I was going to do the testing using a target rule that dealt with
  402. # each file individually, but for some weird reason it would ignore any
  403. # additional files appended to the *_INSTALL_FILES variables. So I've done
  404. # it with a foreach instead, which _does_ work. (Ick, although ironically
  405. # the code is shorter.)
  406. #
  407. # !!! How do we get it to also install any extra files that we require
  408. # for a particular content file (e.g., the SQL code for Tutorial 3)? !!!
  409. #
  410. install-questions: questions
  411. @$(TEST) -d $(HANDBOOK_INSTALL_ROOT)
  412. @$(MKDIR_P) $(INSTALL_DIRECTORY)
  413. @$(foreach f,$(QUESTION_INSTALL_FILES),if $(TEST) ! -f $(INSTALL_DIRECTORY)/$(f) -o $(f) -nt $(INSTALL_DIRECTORY)/$(f); then $(ECHO) "Deploying $(f)"; $(CP) $(f) $(INSTALL_DIRECTORY); fi;)
  414.  
  415. install-answers: answers
  416. @$(TEST) -d $(HANDBOOK_INSTALL_ROOT)
  417. @$(MKDIR_P) $(INSTALL_DIRECTORY)
  418. @$(foreach f,$(ANSWER_INSTALL_FILES),if $(TEST) ! -f $(INSTALL_DIRECTORY)/$(f) -o $(f) -nt $(INSTALL_DIRECTORY)/$(f); then $(ECHO) "Deploying $(f)"; $(CP) $(f) $(INSTALL_DIRECTORY); fi;)
  419.  
  420.  
  421. ################################################################################
  422. #
  423. # Clean up.
  424. #
  425. clean: web-clean print-clean
  426. ifneq ($(strip $(ALL_CLEAN_FILES)),)
  427. -$(RM) -f $(ALL_CLEAN_FILES)
  428. endif
  429.  
  430.  
  431. web-clean:
  432. ifneq ($(strip $(WEB_CLEAN_FILES)),)
  433. -$(RM) -f $(WEB_CLEAN_FILES)
  434. endif
  435.  
  436.  
  437. print-clean:
  438. ifneq ($(strip $(PRINT_CLEAN_FILES)),)
  439. -$(RM) -f $(PRINT_CLEAN_FILES)
  440. endif
  441.  
  442.  
  443. ################################################################################
  444. #
  445. # Debugging information, mostly lists of the generated variables.
  446. #
  447. debug:
  448. @$(ANNOUNCE) Externally defined variables
  449. @$(ECHO) "TEACHING_SHARED = [$(TEACHING_SHARED)]"
  450. @$(ECHO) "ALL_PAPERS_ROOT = [$(ALL_PAPERS_ROOT)]"
  451. @$(ECHO) "HANDBOOK_INSTALL_ROOT = [$(HANDBOOK_INSTALL_ROOT)]"
  452. @$(ECHO) "NOINIT = [$(NOINIT)]"
  453. @$(ANNOUNCE) Internally defined variables
  454. @$(ECHO) "GLOBAL_HANDBOOK_INCLUDE = [$(GLOBAL_HANDBOOK_INCLUDE)]"
  455. @$(ECHO) "LOCAL_HANDBOOK_INCLUDE = [$(LOCAL_HANDBOOK_INCLUDE)]"
  456. @$(ECHO) "SUBJECT_CODE = [$(SUBJECT_CODE)]"
  457. @$(ECHO) "PAPER_NUMBER = [$(PAPER_NUMBER)]"
  458. @$(ECHO) "PAPER_YEAR = [$(PAPER_YEAR)]"
  459. @$(ECHO) "PAPER_PERIOD = [$(PAPER_PERIOD)]"
  460. @$(ECHO) "PAPER_ROOT = [$(PAPER_ROOT)]"
  461. @$(ECHO) "HANDBOOK_ROOT = [$(HANDBOOK_ROOT)]"
  462. @$(ECHO) "SECTION = [$(SECTION)]"
  463. @$(ECHO) "BASE_NAME = [$(BASE_NAME)]"
  464. @$(ECHO) "SOURCE_XML = [$(SOURCE_XML)]"
  465. @$(ECHO) "DERIVED_XML = [$(DERIVED_XML)]"
  466. @$(ECHO) "WEB_QUESTIONS_HTML = [$(WEB_QUESTIONS_HTML)]"
  467. @$(ECHO) "WEB_ANSWERS_HTML = [$(WEB_ANSWERS_HTML)]"
  468. @$(ECHO) "PRINT_QUESTIONS_TEX = [$(PRINT_QUESTIONS_TEX)]"
  469. @$(ECHO) "PRINT_ANSWERS_TEX = [$(PRINT_ANSWERS_TEX)]"
  470. @$(ECHO) "PRINT_QUESTIONS_PDF_1UP = [$(PRINT_QUESTIONS_PDF_1UP)]"
  471. @$(ECHO) "PRINT_ANSWERS_PDF_1UP = [$(PRINT_ANSWERS_PDF_1UP)]"
  472. @$(ECHO) "PRINT_QUESTIONS_PDF_2UP = [$(PRINT_QUESTIONS_PDF_2UP)]"
  473. @$(ECHO) "PRINT_ANSWERS_PDF_2UP = [$(PRINT_ANSWERS_PDF_2UP)]"
  474. @$(ECHO) "DERIVED_WEB_FILES = [$(DERIVED_WEB_FILES)]"
  475. @$(ECHO) "DERIVED_PRINT_FILES = [$(DERIVED_PRINT_FILES)]"
  476. @$(ECHO) "XSLT_STYLESHEETS = [$(XSLT_STYLESHEETS)]"
  477. @$(ECHO) "CONTENT_SRC = [$(CONTENT_SRC)]"
  478. @$(ECHO) "INSTALL_DIRECTORY = [$(INSTALL_DIRECTORY)]"
  479. @$(ECHO) "QUESTION_INSTALL_FILES = [$(QUESTION_INSTALL_FILES)]"
  480. @$(ECHO) "ANSWER_INSTALL_FILES = [$(ANSWER_INSTALL_FILES)]"
  481. @$(ECHO) "WEB_CLEAN_FILES = [$(WEB_CLEAN_FILES)]"
  482. @$(ECHO) "PRINT_CLEAN_FILES = [$(PRINT_CLEAN_FILES)]"
  483. @$(ECHO) "ALL_CLEAN_FILES = [$(ALL_CLEAN_FILES)]"
  484.  
  485.  
  486. ################################################################################
  487. #
  488. # Print out the list of targets. Handy for when you forget!
  489. #
  490. targets:
  491. @$(ECHO) $(TARGETS)