Newer
Older
Handbook / makefile-templates / Makefile.document
  1. ################################################################################
  2. #
  3. # Template makefile for building a particular document within a section of
  4. # the handbook (e.g., Tutorials 5). Place a copy of this file in the
  5. # directory for each document, and modify as appropriate. The default
  6. # makefile checks (and rebuilds if necessary) all of the content files for
  7. # the current document, using recursive make calls to each content file.
  8. # Most of the work is done by the include files, and should cater for
  9. # almost all cases. However, if custom rules are needed for a section,
  10. # they can be appended to the end of the document's makefile.
  11. #
  12. ################################################################################
  13.  
  14.  
  15. SHELL=/bin/sh
  16.  
  17.  
  18. ################################################################################
  19. #
  20. # Get path to current Makefile so we can set up self-deleting temporary
  21. # directory. Note that this MUST happen before the first include!
  22. #
  23. MAKEFILE:=$(CURDIR)/$(lastword $(MAKEFILE_LIST))
  24.  
  25.  
  26. ################################################################################
  27. #
  28. # Required Environment Variables
  29. #
  30. # TEACHING_SHARED
  31. # This variable specifies the path to the top level of the teaching
  32. # shared directory hierarchy (e.g., /path/to/Teaching/Shared).
  33. #
  34. 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))
  35. #
  36. # ALL_PAPERS_ROOT
  37. # This variable specifies the path to the top level directory for all
  38. # papers taught, i.e., the directory that contains the individual paper
  39. # directory hierarchies. For example, /path/to/Teaching/2005.
  40. #
  41. ALL_PAPERS_ROOT?=$(error The required environment variable ALL_PAPERS_ROOT has not been defined. It should point to the root level of the current teaching directory hierarchy (e.g., /path/to/Teaching/2005))
  42. #
  43. # HANDBOOK_INSTALL_ROOT
  44. # This variable specifies the path to the top level directory on the web
  45. # server, under which the files for this paper will be installed (that is,
  46. # the directory that contains the individual paper directory hierarchies).
  47. # For example, \\INFO-NTS-12\DBCourses$ (this may require munging).
  48. #
  49. HANDBOOK_INSTALL_ROOT?=$(error The required environment variable HANDBOOK_INSTALL_ROOT has not been defined. It should point to the root level of the directory hierarchy on the web server (e.g., \\INFO-NTS-12\DBCourses$))
  50.  
  51.  
  52. ################################################################################
  53. #
  54. # Set up paths to makefile include directories.
  55. #
  56. # GLOBAL_HANDBOOK_INCLUDE is the global include directory in the "Shared"
  57. # hierarchy, and is defined relative to the root of that hierarchy.
  58. #
  59. # LOCAL_HANDBOOK_INCLUDE is the local include directory for this
  60. # particular paper, and is defined relative to the current execution
  61. # directory. We are assuming a fixed directory structure here! We can't
  62. # really do this as an environment variable because the full path will be
  63. # different for each paper, and we can't use the variables from
  64. # paper_variables.make to set the path, because that file is in the
  65. # include directory! <head spins> We will, however, allow for the
  66. # possibility of someone wanting to define this as an environment variable
  67. # by making it a conditional assignment.
  68. #
  69. GLOBAL_HANDBOOK_INCLUDE?=$(TEACHING_SHARED)/Authoring/Handbook/make-includes
  70.  
  71. export LOCAL_HANDBOOK_INCLUDE?=$(shell cd ../../..; pwd)/make-includes
  72.  
  73.  
  74. ################################################################################
  75. #
  76. # Include local system-specific configuration.
  77. #
  78. include $(GLOBAL_HANDBOOK_INCLUDE)/local_configuration.make
  79.  
  80.  
  81. ################################################################################
  82. #
  83. # Set up global, self-deleting temporary directory. The first time through,
  84. # TEMPDIR will be undefined, so the first part of the if will create the
  85. # variable, then recursively call the makefile again with the appropriate
  86. # targets, passing the temporary directory as an argument.
  87. #
  88. ifndef TEMPDIR
  89.  
  90. .PHONY: all
  91.  
  92. all:
  93. @TEMPDIR=$(shell $(MKTEMP) -d); \
  94. trap 'rm -rf "$$TEMPDIR"' EXIT; \
  95. $(MAKE) -f $(MAKEFILE) --no-print-directory TEMPDIR=$$TEMPDIR all
  96.  
  97. %:
  98. @TEMPDIR=$(shell $(MKTEMP) -d); \
  99. trap 'rm -rf "$$TEMPDIR"' EXIT; \
  100. $(MAKE) -f $(MAKEFILE) --no-print-directory TEMPDIR=$$TEMPDIR $@
  101.  
  102.  
  103. ################################################################################
  104. #
  105. # Normal makefile follows.
  106. #
  107. else
  108.  
  109.  
  110. ################################################################################
  111. #
  112. # Include standard variables and rules for building a document.
  113. #
  114. include $(GLOBAL_HANDBOOK_INCLUDE)/build_document_rules.make
  115.  
  116.  
  117. ################################################################################
  118. #
  119. # Add custom rules below here, as necessary, BEFORE the endif. Add files to be
  120. # deleted to the variables below, as appropriate.
  121. #
  122. # WEB_CLEAN_FILES+=
  123. # PRINT_CLEAN_FILES+=
  124. # ALL_CLEAN_FILES+=
  125.  
  126.  
  127. endif