| 1 |
# makefile |
| 2 |
# |
| 3 |
# 2019 Nov 01 |
| 4 |
# |
| 5 |
# Macro definitions |
| 6 |
# |
| 7 |
# - parameters: |
| 8 |
ROOT_NAME = halloweenmath |
| 9 |
# (the following need not be redefined, although it can be) |
| 10 |
BUNDLE_NAME = $(ROOT_NAME) package |
| 11 |
# |
| 12 |
# - all the rest: |
| 13 |
DTX_NAME = $(ROOT_NAME).dtx |
| 14 |
INS_NAME = $(ROOT_NAME).ins |
| 15 |
LOG_FILE = $(ROOT_NAME).log |
| 16 |
DOC_AUX_FIL = $(LOG_FILE) $(ROOT_NAME).aux \ |
| 17 |
$(ROOT_NAME).glo $(ROOT_NAME).gls \ |
| 18 |
$(ROOT_NAME).idx $(ROOT_NAME).ind \ |
| 19 |
$(ROOT_NAME).ilg $(ROOT_NAME).glg \ |
| 20 |
$(ROOT_NAME).toc $(ROOT_NAME).lof \ |
| 21 |
$(ROOT_NAME).hd $(ROOT_NAME).out |
| 22 |
DOCUM_FILE = $(ROOT_NAME).pdf |
| 23 |
CODE_FILES = $(ROOT_NAME).sty |
| 24 |
# |
| 25 |
LATEX = pdflatex |
| 26 |
MAKEINDEX = makeindex |
| 27 |
REMOVE = -rm |
| 28 |
|
| 29 |
# |
| 30 |
define GEN_FAKE_INDEX |
| 31 |
@echo '\\begin{theindex}' > $(ROOT_NAME).ind |
| 32 |
@echo '\\end{theindex}' >> $(ROOT_NAME).ind |
| 33 |
@echo "Generating fake .ind file." |
| 34 |
endef |
| 35 |
# |
| 36 |
define GEN_FAKE_GLOSSARY |
| 37 |
@echo '\\begin{theglossary}' > $(ROOT_NAME).gls |
| 38 |
@echo '\\end{theglossary}' >> $(ROOT_NAME).gls |
| 39 |
@echo "Generating fake .gls file." |
| 40 |
endef |
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
.PHONY: default |
| 45 |
.PHONY: code doc |
| 46 |
.PHONY: clean cleandoc cleanaux cleancode cleanlog cleanall |
| 47 |
.PHONY: help |
| 48 |
|
| 49 |
# Default target |
| 50 |
default: doc code |
| 51 |
|
| 52 |
# Generating the code |
| 53 |
################################################################ |
| 54 |
# # |
| 55 |
# PLEASE NOTE THAT THE INSTALLER SCRIPT IS EXECUTED WITH # |
| 56 |
# openout_any=r # |
| 57 |
# # |
| 58 |
################################################################ |
| 59 |
code: |
| 60 |
openout_any=r tex $(INS_NAME) |
| 61 |
|
| 62 |
# Generating the documentation |
| 63 |
doc: $(DOCUM_FILE) |
| 64 |
|
| 65 |
$(DOCUM_FILE): $(DTX_NAME) |
| 66 |
# Hack for getting index and glossary in the toc since first run: |
| 67 |
$(GEN_FAKE_INDEX) |
| 68 |
$(GEN_FAKE_GLOSSARY) |
| 69 |
# We know how many runs are needed: |
| 70 |
$(LATEX) $(DTX_NAME) |
| 71 |
$(LATEX) $(DTX_NAME) |
| 72 |
$(MAKEINDEX) -s gind.ist -t $(ROOT_NAME).ilg -o $(ROOT_NAME).ind \ |
| 73 |
$(ROOT_NAME).idx |
| 74 |
$(MAKEINDEX) -s gglo.ist -t $(ROOT_NAME).glg -o $(ROOT_NAME).gls \ |
| 75 |
$(ROOT_NAME).glo |
| 76 |
$(LATEX) $(DTX_NAME) |
| 77 |
$(LATEX) $(DTX_NAME) |
| 78 |
# Hyperlinks in the indexes seem not to work properly without the |
| 79 |
# following additional run: |
| 80 |
$(MAKEINDEX) -s gind.ist -t $(ROOT_NAME).ilg -o $(ROOT_NAME).ind \ |
| 81 |
$(ROOT_NAME).idx |
| 82 |
$(MAKEINDEX) -s gglo.ist -t $(ROOT_NAME).glg -o $(ROOT_NAME).gls \ |
| 83 |
$(ROOT_NAME).glo |
| 84 |
$(LATEX) $(DTX_NAME) |
| 85 |
|
| 86 |
# Cleaning up: command "make clean" defaults to "make cleanall" |
| 87 |
clean: cleanall |
| 88 |
|
| 89 |
# Cleaning the code files |
| 90 |
cleancode: |
| 91 |
$(REMOVE) $(CODE_FILES) |
| 92 |
|
| 93 |
# Cleaning the documentation files |
| 94 |
cleandoc: cleanaux |
| 95 |
$(REMOVE) $(DOCUM_FILE) |
| 96 |
|
| 97 |
# Cleaning just the auxiliary files used in producing the documentation |
| 98 |
cleanaux: |
| 99 |
$(REMOVE) $(DOC_AUX_FIL) |
| 100 |
|
| 101 |
# Cleaning only the transcript file (e.g., after "make code") |
| 102 |
cleanlog: |
| 103 |
$(REMOVE) $(LOG_FILE) |
| 104 |
|
| 105 |
# Cleaning up all the generated files |
| 106 |
cleanall: cleancode cleandoc |
| 107 |
|
| 108 |
# Giving help |
| 109 |
help: |
| 110 |
@echo "Here is a list of the available commands:" |
| 111 |
@echo |
| 112 |
@echo " make" |
| 113 |
@echo " Generate both the code and the documentation (see below)." |
| 114 |
@echo |
| 115 |
@echo " make code" |
| 116 |
@echo " Generate all the LaTeX \"executables\" (e.g., \`.sty' files)" |
| 117 |
@echo " of the $(BUNDLE_NAME);" |
| 118 |
@echo " these files go into the LaTeX input directories." |
| 119 |
@echo |
| 120 |
@echo " make doc" |
| 121 |
@echo " Generate the documentation (in PDF); the resulting PDF file" |
| 122 |
@echo " goes into the LaTeX documentation directories (the auxiliary" |
| 123 |
@echo " files may be discarded)." |
| 124 |
@echo |
| 125 |
@echo " make clean" |
| 126 |
@echo " make cleanall" |
| 127 |
@echo " These two commands are synonyms; they remove all of the" |
| 128 |
@echo " generated files (both code and documentation)." |
| 129 |
@echo |
| 130 |
@echo " make cleancode" |
| 131 |
@echo " Remove the LaTeX source files (the \"code files\")." |
| 132 |
@echo |
| 133 |
@echo " make cleandoc" |
| 134 |
@echo " Remove the documentation, together with all the auxiliary" |
| 135 |
@echo " files used to generate it." |
| 136 |
@echo |
| 137 |
@echo " make cleanaux" |
| 138 |
@echo " Remove only the auxiliary files used to generate the" |
| 139 |
@echo " documentation." |
| 140 |
@echo |
| 141 |
@echo " make cleanlog" |
| 142 |
@echo " Remove just the transcript file (e.g., after \"make doc\")." |
| 143 |
@echo |
| 144 |
@echo " make help" |
| 145 |
@echo " Print this help message." |
| 146 |
@echo |
| 147 |
|