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
- Generalised section inclusion mechanism.
master
1 parent
6f26112
commit
37ddedaf4dfb53d34ea1c7ce894ddb617c9f95ab
nstanger
authored
on 21 Jan 2005
Patch
Showing
1 changed file
makefile-templates/Makefile.handbook
Ignore Space
Show notes
View
makefile-templates/Makefile.handbook
################################################################################ # # File: $Id$ # # Makefile for DBCOURSES handbooks. Revamped completely from old # monolithic version to a "many-makefiles" model. Each major sub-unit of # the handbook has its own makefile, and is called recursively from here. # This makes management of the whole process a bit more complex, but a lot # more flexible. It's now possible, for example, to build many of the # files for a single tutorial by going into that tutorial's directory and # running a make there. The old scheme was also wont to rebuild lots of # extraneous stuff when only one file changed (especially with graphics). # This does not appear to be (and should not) be a problem with the new # scheme. # ################################################################################ SHELL=/bin/sh ################################################################################ # # Required Environment Variables # # TEACHING_SHARED # This variable specifies the path to the top level of the teaching # shared directory hierarchy (e.g., /path/to/Teaching/Shared). # TEACHING_SHARED?=$(error The required environment variable TEACHING_SHARED has not been defined. It should point to the root level of the shared teaching directory (e.g., /path/to/Teaching/Shared)) # # ALL_PAPERS_ROOT # This variable specifies the path to the top level directory for all # papers taught, i.e., the directory that contains the individual paper # directory hierarchies. For example, /path/to/Teaching/2005. # 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)) # # HANDBOOK_INSTALL_ROOT # This variable specifies the path to the top level directory on the web # server, under which the files for this paper will be installed (that is, # the directory that contains the individual paper directory hierarchies). # For example, \\INFO-NTS-12\DBCourses$ (this may require munging). # 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$)) ################################################################################ # # Set up paths to makefile include directories. # # GLOBAL_HANDBOOK_INCLUDE is the global include directory in the "Shared" # hierarchy, and is defined relative to the root of that hierarchy. # # LOCAL_HANDBOOK_INCLUDE is the local include directory for this # particular paper, and is defined relative to the current execution # directory. We are assuming a fixed directory structure here! We can't # really do this as an environment variable because the full path will be # different for each paper, and we can't use the variables from # paper_variables.make to set the path, because that file is in the # include directory! <head spins> We will, however, allow for the # possibility of someone wanting to define this as an environment variable # by making it a conditional assignment. # GLOBAL_HANDBOOK_INCLUDE?=$(TEACHING_SHARED)/Authoring/Handbook/make-includes export LOCAL_HANDBOOK_INCLUDE?=$(shell pwd)/make-includes ################################################################################ # # Include variables defining the current paper. # include $(LOCAL_HANDBOOK_INCLUDE)/paper_variables.make ################################################################################ # # Directories for the major sections. Add to as necessary. Sections should # be listed in the order that they will appear in the handbook. Remember to # exclude CVS directories (doh!). # SECTION_DIRS:=$(shell find sections -type d -not -name CVS -mindepth 1 -maxdepth 1) ################################################################################ # # Run one-time initialisation stuff. # # Delete the marker file that indicates that we've already initialised the # sub-sections by removing their "content checked" marker files. There's # only one of these, so it's much easier to deal with :) # # Note: NOINIT should _not_ be exported to this sub-make, to ensure that # the sub-makefile's one-time initialisation is executed. # CLEANUP_MARKER_FILES:=$(foreach d,$(SECTION_DIRS),$(shell $(MAKE) -C $d init-clean)) ################################################################################ # # Lists of LaTeX files to be \input into the master LaTeX document. Just # build a single list for everything; we can extract the sections we want # at the time using make's filter function, as the sections have distinct # names. These are statically defined rather than using a find command, # because the files may not exist at the time the find command is # executed. This Would Be Non-Useful. # QUESTION_TEX_INPUTS:=$(foreach d,$(SECTION_DIRS),$d/question-manifest.tex) ANSWER_TEX_INPUTS:=$(foreach d,$(SECTION_DIRS),$d/answer-manifest.tex) LATEX_INCLUDES:=$(shell find latex-includes -name "*.tex") ################################################################################ # # Directory to install files into on web server. # INSTALL_DIRECTORY:=$(HANDBOOK_INSTALL_ROOT)/$(SUBJECT_CODE)$(PAPER_NUMBER)/www/Handbook ################################################################################ # # Files to be installed on web server. # INSTALL_FILES:=handbook.pdf handbook-2up.pdf \ handbook-answers.pdf handbook-answers-2up.pdf $(wildcard *.png) ################################################################################ # # Lists of files for cleaning up. # WEB_CLEAN_FILES:=*.png PRINT_CLEAN_FILES:=handbook.tex handbook-answers.tex \ *.pdf *.ps *.dvi *.aux *.log *.toc *.idx *.ind *.tex~ *.out ALL_CLEAN_FILES:=$(WEB_CLEAN_FILES) $(PRINT_CLEAN_FILES) ################################################################################ # # List of possible targets. # TARGETS:=all targets debug install \ web web-questions web-answers \ print print-questions print-answers \ questions answers \ section-questions section-answers \ question-pdfs answer-pdfs \ clean web-clean print-clean .PHONY: $(TARGETS) ################################################################################ # # Build everything. # all: web print ################################################################################ # # Build questions/answers only. # questions: web-questions print-questions answers: web-answers print-answers ################################################################################ # # Build web version only. NOINIT and SECTION should be exported to all # these sub-makes. # web: general-graphics web-questions web-answers web-questions: @$(foreach d,$(SECTION_DIRS),$(MAKE) -C $d web-questions NOINIT=x SECTION=$(notdir $(d));) web-answers: @$(foreach d,$(SECTION_DIRS),$(MAKE) -C $d web-answers NOINIT=x SECTION=$(notdir $(d));) ################################################################################ # # Build print version only. NOINIT and SECTION should be exported to all # these sub-makes. # print: general-graphics print-questions print-answers print-questions: section-questions handbook.pdf handbook-2up.pdf question-pdfs section-questions: @$(foreach d,$(SECTION_DIRS),$(MAKE) -C $d print-questions NOINIT=x SECTION=$(notdir $(d));) handbook.tex: handbook_template.tex $(QUESTION_TEX_INPUTS) $(LOCAL_HANDBOOK_INCLUDE)/questions.patterns $(LATEX_INCLUDES) @announce "Generating $@" @perl -p -e "s|\<\@SHOWANSWERS\@\>||;" \ $(foreach sect,$(SECTION_DIRS),-e "s|\<\@SECTION\[$(notdir $(sect))\]\@\>|\\\\input{$(basename $(filter $(sect)/%,$(QUESTION_TEX_INPUTS)))}|;") $< > $@ question-pdfs: @$(foreach d,$(SECTION_DIRS),$(MAKE) -C $d question-pdfs NOINIT=x SECTION=$(notdir $(d));) # # Answers # print-answers: section-answers handbook-answers.pdf handbook-answers-2up.pdf answer-pdfs section-answers: @$(foreach d,$(SECTION_DIRS),$(MAKE) -C $d print-answers NOINIT=x SECTION=$(notdir $(d));) handbook-answers.tex: handbook_template.tex $(ANSWER_TEX_INPUTS) $(LOCAL_HANDBOOK_INCLUDE)/answers.patterns $(LATEX_INCLUDES) @announce "Generating $@" @perl -p -e "s|\<\@SHOWANSWERS\@\>|\\\\showanswers|;" \ $(foreach sect,$(SECTION_DIRS),-e "s|\<\@SECTION\[$(notdir $(sect))\]\@\>|\\\\input{$(basename $(filter $(sect)/%,$(QUESTION_TEX_INPUTS)))}|;") $< > $@ answer-pdfs: @$(foreach d,$(SECTION_DIRS),$(MAKE) -C $d answer-pdfs NOINIT=x SECTION=$(notdir $(d));) # # Generic rules for print version. # %.pdf: %.tex @announce "pdflatex $< (pass 1)" pdflatex $< @announce "pdflatex $< (pass 2)" pdflatex $< %-2up.pdf: %.pdf @announce "Generating $@" pdfnup --nup 2x1 --outfile $@ $< ################################################################################ # # Build any general graphics that are used throughout the handbook. This uses # the standard makefile for a content directory, but the only files in this # directory are graphics files. # general-graphics: @$(MAKE) -C graphics general-graphics BUILD_DIR=$(CURDIR) ################################################################################ # # Install the appropriate files on the web server. This relies on the # environment variable HANDBOOK_INSTALL_DIRECTORY being defined, and # (assuming that this variable points to a directory on the network) the # appropriate share has been mounted. # install: $(INSTALL_FILES) @announce "Copying files to web server --- make sure that you have the share mounted!" @test -d $(HANDBOOK_INSTALL_ROOT) ifneq ($(strip $(SECTION_DIRS)),) @$(foreach d,$(SECTION_DIRS),$(MAKE) -C $d install NOINIT=x SECTION=$(notdir $(d));) endif ifneq ($(strip $(INSTALL_FILES)),) @announce "Installing miscellaneous handbook files" cp $(INSTALL_FILES) $(INSTALL_DIRECTORY) endif ################################################################################ # # Clean up all generated files. # "web-clean" and "print-clean" only clean up files for the web and print # versions, respectively. Note that "clean" isn't dependent on either # "web-clean" or "print-clean", to ensure that the correct target is # used when calling the sub-makefile. # clean: @$(foreach d,$(SECTION_DIRS),$(MAKE) -C $d $@;) ifneq ($(strip $(ALL_CLEAN_FILES)),) -rm -f $(ALL_CLEAN_FILES) endif web-clean: @$(foreach d,$(SECTION_DIRS),$(MAKE) -C $d $@;) ifneq ($(strip $(WEB_CLEAN_FILES)),) -rm -f $(WEB_CLEAN_FILES) endif print-clean: @$(foreach d,$(SECTION_DIRS),$(MAKE) -C $d $@;) ifneq ($(strip $(PRINT_CLEAN_FILES)),) -rm -f $(PRINT_CLEAN_FILES) endif ################################################################################ # # Debugging information, mostly lists of the generated variables. # debug: @announce Externally defined variables @echo "TEACHING_SHARED = [$(TEACHING_SHARED)]" @echo "HANDBOOK_INSTALL_ROOT = [$(HANDBOOK_INSTALL_ROOT)]" @announce Internally defined variables @echo "GLOBAL_HANDBOOK_INCLUDE = [$(GLOBAL_HANDBOOK_INCLUDE)]" @echo "LOCAL_HANDBOOK_INCLUDE = [$(LOCAL_HANDBOOK_INCLUDE)]" @echo "SECTION_DIRS = [$(SECTION_DIRS)]" @echo "QUESTION_TEX_INPUTS = [$(QUESTION_TEX_INPUTS)]" @echo "ANSWER_TEX_INPUTS = [$(ANSWER_TEX_INPUTS)]" @echo "LATEX_INCLUDES = [$(LATEX_INCLUDES)]" @echo "INSTALL_DIRECTORY = [$(INSTALL_DIRECTORY)]" @echo "INSTALL_FILES = [$(INSTALL_FILES)]" @echo "WEB_CLEAN_FILES = [$(WEB_CLEAN_FILES)]" @echo "PRINT_CLEAN_FILES = [$(PRINT_CLEAN_FILES)]" @echo "ALL_CLEAN_FILES = [$(ALL_CLEAN_FILES)]" ################################################################################ # # Print out the list of targets. Handy for when you forget! # targets: @echo $(TARGETS)
################################################################################ # # File: $Id$ # # Makefile for DBCOURSES handbooks. Revamped completely from old # monolithic version to a "many-makefiles" model. Each major sub-unit of # the handbook has its own makefile, and is called recursively from here. # This makes management of the whole process a bit more complex, but a lot # more flexible. It's now possible, for example, to build many of the # files for a single tutorial by going into that tutorial's directory and # running a make there. The old scheme was also wont to rebuild lots of # extraneous stuff when only one file changed (especially with graphics). # This does not appear to be (and should not) be a problem with the new # scheme. # ################################################################################ SHELL=/bin/sh ################################################################################ # # Required Environment Variables # # TEACHING_SHARED # This variable specifies the path to the top level of the teaching # shared directory hierarchy (e.g., /path/to/Teaching/Shared). # TEACHING_SHARED?=$(error The required environment variable TEACHING_SHARED has not been defined. It should point to the root level of the shared teaching directory (e.g., /path/to/Teaching/Shared)) # # ALL_PAPERS_ROOT # This variable specifies the path to the top level directory for all # papers taught, i.e., the directory that contains the individual paper # directory hierarchies. For example, /path/to/Teaching/2005. # 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)) # # HANDBOOK_INSTALL_ROOT # This variable specifies the path to the top level directory on the web # server, under which the files for this paper will be installed (that is, # the directory that contains the individual paper directory hierarchies). # For example, \\INFO-NTS-12\DBCourses$ (this may require munging). # 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$)) ################################################################################ # # Set up paths to makefile include directories. # # GLOBAL_HANDBOOK_INCLUDE is the global include directory in the "Shared" # hierarchy, and is defined relative to the root of that hierarchy. # # LOCAL_HANDBOOK_INCLUDE is the local include directory for this # particular paper, and is defined relative to the current execution # directory. We are assuming a fixed directory structure here! We can't # really do this as an environment variable because the full path will be # different for each paper, and we can't use the variables from # paper_variables.make to set the path, because that file is in the # include directory! <head spins> We will, however, allow for the # possibility of someone wanting to define this as an environment variable # by making it a conditional assignment. # GLOBAL_HANDBOOK_INCLUDE?=$(TEACHING_SHARED)/Authoring/Handbook/make-includes export LOCAL_HANDBOOK_INCLUDE?=$(shell pwd)/make-includes ################################################################################ # # Include variables defining the current paper. # include $(LOCAL_HANDBOOK_INCLUDE)/paper_variables.make ################################################################################ # # Directories for the major sections. Add to as necessary. Sections should # be listed in the order that they will appear in the handbook. Remember to # exclude CVS directories (doh!). # SECTION_DIRS:=$(shell find Sections -type d -not -name CVS -mindepth 1 -maxdepth 1) ################################################################################ # # Run one-time initialisation stuff. # # Delete the marker file that indicates that we've already initialised the # sub-sections by removing their "content checked" marker files. There's # only one of these, so it's much easier to deal with :) # # Note: NOINIT should _not_ be exported to this sub-make, to ensure that # the sub-makefile's one-time initialisation is executed. # CLEANUP_MARKER_FILES:=$(foreach d,$(SECTION_DIRS),$(shell $(MAKE) -C $d init-clean)) ################################################################################ # # Lists of LaTeX files to be \input into the master LaTeX document. Just # build a single list for everything; we can extract the sections we want # at the time using make's filter function, as the sections have distinct # names. These are statically defined rather than using a find command, # because the files may not exist at the time the find command is # executed. This Would Be Non-Useful. # QUESTION_TEX_INPUTS:=$(foreach d,$(SECTION_DIRS),$d/question-manifest.tex) ANSWER_TEX_INPUTS:=$(foreach d,$(SECTION_DIRS),$d/answer-manifest.tex) LATEX_INCLUDES:=$(shell find latex-includes -name "*.tex") ################################################################################ # # Directory to install files into on web server. # INSTALL_DIRECTORY:=$(HANDBOOK_INSTALL_ROOT)/$(SUBJECT_CODE)$(PAPER_NUMBER)/www/Handbook ################################################################################ # # Files to be installed on web server. # INSTALL_FILES:=handbook.pdf handbook-2up.pdf \ handbook-answers.pdf handbook-answers-2up.pdf $(wildcard *.png) ################################################################################ # # Lists of files for cleaning up. # WEB_CLEAN_FILES:=*.png PRINT_CLEAN_FILES:=handbook.tex handbook-answers.tex \ *.pdf *.ps *.dvi *.aux *.log *.toc *.idx *.ind *.tex~ *.out ALL_CLEAN_FILES:=$(WEB_CLEAN_FILES) $(PRINT_CLEAN_FILES) ################################################################################ # # List of possible targets. # TARGETS:=all targets debug install \ web web-questions web-answers \ print print-questions print-answers \ questions answers \ section-questions section-answers \ question-pdfs answer-pdfs \ clean web-clean print-clean .PHONY: $(TARGETS) ################################################################################ # # Build everything. # all: web print ################################################################################ # # Build questions/answers only. # questions: web-questions print-questions answers: web-answers print-answers ################################################################################ # # Build web version only. NOINIT and SECTION should be exported to all # these sub-makes. # web: general-graphics web-questions web-answers web-questions: @$(foreach d,$(SECTION_DIRS),$(MAKE) -C $d web-questions NOINIT=x SECTION=$(notdir $(d));) web-answers: @$(foreach d,$(SECTION_DIRS),$(MAKE) -C $d web-answers NOINIT=x SECTION=$(notdir $(d));) ################################################################################ # # Build print version only. NOINIT and SECTION should be exported to all # these sub-makes. # print: general-graphics print-questions print-answers print-questions: section-questions handbook.pdf handbook-2up.pdf question-pdfs section-questions: @$(foreach d,$(SECTION_DIRS),$(MAKE) -C $d print-questions NOINIT=x SECTION=$(notdir $(d));) handbook.tex: handbook_template.tex $(QUESTION_TEX_INPUTS) $(LOCAL_HANDBOOK_INCLUDE)/questions.patterns $(LATEX_INCLUDES) @announce "Generating $@" @perl -p -e "s|\<\@SHOWANSWERS\@\>||;" \ -e "s|\<\@INCLUDELABS\@\>|\\\\input{$(basename $(filter Sections/Labs/%,$(QUESTION_TEX_INPUTS)))}|;" \ -e "s|\<\@INCLUDETUTS\@\>|\\\\input{$(basename $(filter Sections/Tutorials/%,$(QUESTION_TEX_INPUTS)))}|;" $< > $@ question-pdfs: @$(foreach d,$(SECTION_DIRS),$(MAKE) -C $d question-pdfs NOINIT=x SECTION=$(notdir $(d));) # # Answers # print-answers: section-answers handbook-answers.pdf handbook-answers-2up.pdf answer-pdfs section-answers: @$(foreach d,$(SECTION_DIRS),$(MAKE) -C $d print-answers NOINIT=x SECTION=$(notdir $(d));) handbook-answers.tex: handbook_template.tex $(ANSWER_TEX_INPUTS) $(LOCAL_HANDBOOK_INCLUDE)/answers.patterns $(LATEX_INCLUDES) @announce "Generating $@" @perl -p -e "s|\<\@SHOWANSWERS\@\>|\\\\showanswers|;" \ -e "s|\<\@INCLUDELABS\@\>|\\\\input{$(basename $(filter Sections/Labs/%,$(ANSWER_TEX_INPUTS)))}|;" \ -e "s|\<\@INCLUDETUTS\@\>|\\\\input{$(basename $(filter Sections/Tutorials/%,$(ANSWER_TEX_INPUTS)))}|;" $< > $@ answer-pdfs: @$(foreach d,$(SECTION_DIRS),$(MAKE) -C $d answer-pdfs NOINIT=x SECTION=$(notdir $(d));) # # Generic rules for print version. # %.pdf: %.tex @announce "pdflatex $< (pass 1)" pdflatex $< @announce "pdflatex $< (pass 2)" pdflatex $< %-2up.pdf: %.pdf @announce "Generating $@" pdfnup --nup 2x1 --outfile $@ $< ################################################################################ # # Build any general graphics that are used throughout the handbook. This uses # the standard makefile for a content directory, but the only files in this # directory are graphics files. # general-graphics: @$(MAKE) -C graphics general-graphics BUILD_DIR=$(CURDIR) ################################################################################ # # Install the appropriate files on the web server. This relies on the # environment variable HANDBOOK_INSTALL_DIRECTORY being defined, and # (assuming that this variable points to a directory on the network) the # appropriate share has been mounted. # install: @announce "Copying files to web server --- make sure that you have the share mounted!" @test -d $(HANDBOOK_INSTALL_ROOT) @$(foreach d,$(SECTION_DIRS),$(MAKE) -C $d install NOINIT=x SECTION=$(notdir $(d));) ifneq ($(strip $(INSTALL_FILES)),) @announce "Installing miscellaneous handbook files" cp $(INSTALL_FILES) $(INSTALL_DIRECTORY) endif ################################################################################ # # Clean up all generated files. # "web-clean" and "print-clean" only clean up files for the web and print # versions, respectively. Note that "clean" isn't dependent on either # "web-clean" or "print-clean", to ensure that the correct target is # used when calling the sub-makefile. # clean: @$(foreach d,$(SECTION_DIRS),$(MAKE) -C $d $@;) ifneq ($(strip $(ALL_CLEAN_FILES)),) -rm -f $(ALL_CLEAN_FILES) endif web-clean: @$(foreach d,$(SECTION_DIRS),$(MAKE) -C $d $@;) ifneq ($(strip $(WEB_CLEAN_FILES)),) -rm -f $(WEB_CLEAN_FILES) endif print-clean: @$(foreach d,$(SECTION_DIRS),$(MAKE) -C $d $@;) ifneq ($(strip $(PRINT_CLEAN_FILES)),) -rm -f $(PRINT_CLEAN_FILES) endif ################################################################################ # # Debugging information, mostly lists of the generated variables. # debug: @announce Externally defined variables @echo "TEACHING_SHARED = [$(TEACHING_SHARED)]" @echo "HANDBOOK_INSTALL_ROOT = [$(HANDBOOK_INSTALL_ROOT)]" @announce Internally defined variables @echo "GLOBAL_HANDBOOK_INCLUDE = [$(GLOBAL_HANDBOOK_INCLUDE)]" @echo "LOCAL_HANDBOOK_INCLUDE = [$(LOCAL_HANDBOOK_INCLUDE)]" @echo "SECTION_DIRS = [$(SECTION_DIRS)]" @echo "QUESTION_TEX_INPUTS = [$(QUESTION_TEX_INPUTS)]" @echo "ANSWER_TEX_INPUTS = [$(ANSWER_TEX_INPUTS)]" @echo "LATEX_INCLUDES = [$(LATEX_INCLUDES)]" @echo "INSTALL_DIRECTORY = [$(INSTALL_DIRECTORY)]" @echo "INSTALL_FILES = [$(INSTALL_FILES)]" @echo "WEB_CLEAN_FILES = [$(WEB_CLEAN_FILES)]" @echo "PRINT_CLEAN_FILES = [$(PRINT_CLEAN_FILES)]" @echo "ALL_CLEAN_FILES = [$(ALL_CLEAN_FILES)]" ################################################################################ # # Print out the list of targets. Handy for when you forget! # targets: @echo $(TARGETS)
Show line notes below