| 1 |
|
| 2 |
# |
| 3 |
# Common useful definitions |
| 4 |
# |
| 5 |
LATEX = latex |
| 6 |
|
| 7 |
PDFLATEXNAME = pdflatex |
| 8 |
|
| 9 |
PDFLATEX = TEXINPUTS="$$TEXINPUTS:../phfnote" $(PDFLATEXNAME) |
| 10 |
PDFLATEXOPTS = -interaction=batchmode |
| 11 |
PDFLATEXOPTSLAST = -interaction=batchmode --synctex=1 |
| 12 |
|
| 13 |
MAKEINDEX = makeindex |
| 14 |
|
| 15 |
|
| 16 |
# |
| 17 |
# Set default PREFIX. This can be overridden with 'make install PREFIX=/installation/directory' |
| 18 |
# |
| 19 |
DEFAULT_PREFIX := $(shell kpsewhich -var-value TEXMFHOME) |
| 20 |
PREFIX ?= $(DEFAULT_PREFIX) |
| 21 |
|
| 22 |
|
| 23 |
# |
| 24 |
# package should be set in variable PKG |
| 25 |
# |
| 26 |
PKGREADME = README.md |
| 27 |
|
| 28 |
# |
| 29 |
# packages may specify additional files in the distribution with this variable |
| 30 |
# (by default empty) |
| 31 |
# |
| 32 |
DIST_ADDITIONAL_FILES ?= |
| 33 |
|
| 34 |
# |
| 35 |
# Additional files automatically generated by the .ins file, such as .def files |
| 36 |
# (by default empty) |
| 37 |
# |
| 38 |
ADDITIONAL_GENERATED_FILES ?= |
| 39 |
|
| 40 |
|
| 41 |
# By default, the generated style file is a '.sty' latex package. If it's a |
| 42 |
# '.cls' class file instead, the local Makefile will redefine this to 'cls'. |
| 43 |
PKGSTYEXT ?= sty |
| 44 |
|
| 45 |
PKGDTX = $(PKG).dtx |
| 46 |
PKGSTY = $(PKG).$(PKGSTYEXT) |
| 47 |
PKGINS = $(PKG).ins |
| 48 |
PKGPDF = $(PKG).pdf |
| 49 |
PKGTDSZIP = $(PKG).tds.zip |
| 50 |
PKGZIP = $(PKG).zip |
| 51 |
|
| 52 |
|
| 53 |
.PHONY: help sty cls pdf install install_sty install_cls install_doc tdszip dist clean cleanall cleansty cleancls cleanaux cleanpdf cleantdszip cleandist |
| 54 |
|
| 55 |
|
| 56 |
help: |
| 57 |
@echo "Targets for $(PKG):" |
| 58 |
@echo "make $(PKGSTYEXT) -- generate LaTeX package file $(PKG).$(PKGSTYEXT)" |
| 59 |
@echo "make pdf -- generate pdf documentation" |
| 60 |
@echo "make install -- install style and documentation files to $(DEFAULT_PREFIX)" |
| 61 |
@echo "make install PREFIX=[specify texmf directory destination]" |
| 62 |
@echo "make $(PKG).tds.zip -- create TDS.ZIP package for distribution" |
| 63 |
@echo "make dist -- create distribution ZIP, ready for upload to CTAN" |
| 64 |
@echo "make clean -- remove LaTeX auxiliary files" |
| 65 |
@echo "make clean$(PKGSTYEXT) -- remove generated style file" |
| 66 |
@echo "make cleanpdf -- remove generated pdf documentation" |
| 67 |
@echo "make cleanall -- remove all generated files, incl. distribution zip" |
| 68 |
|
| 69 |
|
| 70 |
clean: cleanaux |
| 71 |
|
| 72 |
cleanall: cleansty cleanaux cleanpdf cleantdszip cleandist |
| 73 |
|
| 74 |
# ------------------------------------------------ |
| 75 |
# make sty |
| 76 |
# ------------------------------------------------ |
| 77 |
|
| 78 |
sty: $(PKGSTY) |
| 79 |
|
| 80 |
# synonym of `sty` in case of LaTeX classes, we use same commands etc. |
| 81 |
cls: $(PKGSTY) |
| 82 |
|
| 83 |
$(PKGSTY): $(PKGINS) $(PKGDTX) |
| 84 |
$(LATEX) $< |
| 85 |
|
| 86 |
cleansty: |
| 87 |
@rm -f $(PKGSTY) $(ADDITIONAL_GENERATED_FILES) |
| 88 |
|
| 89 |
cleancls: cleansty |
| 90 |
|
| 91 |
|
| 92 |
# ------------------------------------------------ |
| 93 |
# make pdf |
| 94 |
# ------------------------------------------------ |
| 95 |
|
| 96 |
pdf: $(PKG).pdf |
| 97 |
|
| 98 |
# |
| 99 |
# fake index & glossary so they get a TOC entry from the beginning, and so the page |
| 100 |
# numbers in the index are correct. |
| 101 |
# |
| 102 |
$(PKG).aux $(PKG).idx $(PKG).glo: $(PKGDTX) $(PKGSTY) |
| 103 |
DTX=$< ; echo '\\begin{theindex}\\item index here \\end{theindex}' >$${DTX%.dtx}.ind |
| 104 |
DTX=$< ; echo '\\begin{theglossary}\\item changes here\\end{theglossary}' >$${DTX%.dtx}.gls |
| 105 |
$(PDFLATEX) $(PDFLATEXOPTS) $< |
| 106 |
$(PDFLATEX) $(PDFLATEXOPTS) $< |
| 107 |
$(PDFLATEX) $(PDFLATEXOPTS) $< |
| 108 |
|
| 109 |
$(PKG).ind: $(PKG).idx |
| 110 |
$(MAKEINDEX) -s gind.ist -o $@ $< |
| 111 |
|
| 112 |
$(PKG).gls: $(PKG).glo |
| 113 |
$(MAKEINDEX) -s gglo.ist -o $@ $< |
| 114 |
|
| 115 |
# final steps of making the PKG.pdf doc file. At the end, touch the ind and gls files so |
| 116 |
# that they don't look out-of-date (because the idx and glo files were overwritten again) |
| 117 |
$(PKGPDF): $(PKGDTX) $(PKG).aux $(PKG).ind $(PKG).gls |
| 118 |
$(PDFLATEX) $(PDFLATEXOPTS) $< |
| 119 |
$(PDFLATEX) $(PDFLATEXOPTS) $< |
| 120 |
$(PDFLATEX) $(PDFLATEXOPTSLAST) $< |
| 121 |
touch $(PKG).ind $(PKG).gls $(PKG).pdf |
| 122 |
|
| 123 |
|
| 124 |
cleanaux: |
| 125 |
@rm -f *.aux *.log *.toc *.glo *.gls *.ind *.idx *.ilg *.out *.bbl *.blg *.synctex.gz *.hd |
| 126 |
|
| 127 |
cleanpdf: |
| 128 |
@rm -f $(PKGPDF) |
| 129 |
|
| 130 |
# ------------------------------------------------ |
| 131 |
# 'make install' partial installation targets |
| 132 |
# ------------------------------------------------ |
| 133 |
|
| 134 |
# |
| 135 |
# The install target itself is defined per-package, in case packages want to install more |
| 136 |
# files (such as bibtex styles) |
| 137 |
# |
| 138 |
|
| 139 |
install_sty: $(PKGSTY) |
| 140 |
mkdir -p $(DESTDIR)$(PREFIX)/tex/latex/$(PKG) |
| 141 |
cp $(PKGSTY) $(ADDITIONAL_GENERATED_FILES) $(DESTDIR)$(PREFIX)/tex/latex/$(PKG) |
| 142 |
|
| 143 |
install_cls: install_sty |
| 144 |
|
| 145 |
install_doc: $(PKGPDF) |
| 146 |
mkdir -p $(DESTDIR)$(PREFIX)/doc/latex/$(PKG) |
| 147 |
cp $(PKGPDF) $(PKGREADME) $(DESTDIR)$(PREFIX)/doc/latex/$(PKG) |
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
# ------------------------------------------------ |
| 152 |
# make tdszip |
| 153 |
# ------------------------------------------------ |
| 154 |
|
| 155 |
TDSTMPDIR = $(CURDIR)/_install_tds_zip.make.tmp |
| 156 |
|
| 157 |
tdszip: $(PKGTDSZIP) |
| 158 |
|
| 159 |
$(PKGTDSZIP): $(PKGSTY) $(PKGPDF) |
| 160 |
mkdir $(TDSTMPDIR) |
| 161 |
$(MAKE) install PREFIX=$(TDSTMPDIR) |
| 162 |
cd $(TDSTMPDIR) && zip -r $(CURDIR)/$(PKGTDSZIP) * |
| 163 |
rm -rf $(TDSTMPDIR) |
| 164 |
|
| 165 |
cleantdszip: |
| 166 |
@rm -f $(PKGTDSZIP) |
| 167 |
|
| 168 |
|
| 169 |
# ------------------------------------------------ |
| 170 |
# make dist |
| 171 |
# ------------------------------------------------ |
| 172 |
|
| 173 |
DISTTMPDIR = $(CURDIR)/_install_dist_zip.make.tmp |
| 174 |
|
| 175 |
dist: $(PKGZIP) |
| 176 |
|
| 177 |
# feedback from CTAN upload manager: prefer not to provide tds.zip in CTAN upload |
| 178 |
$(PKGZIP): #$(PKGTDSZIP) |
| 179 |
rm -rf $(DISTTMPDIR) |
| 180 |
mkdir -p $(DISTTMPDIR)/$(PKG) |
| 181 |
# cp $(PKGTDSZIP) $(DISTTMPDIR) |
| 182 |
cp $(PKGDTX) $(PKGINS) $(PKGPDF) $(PKGREADME) Makefile pkg.mk $(DIST_ADDITIONAL_FILES) $(DISTTMPDIR)/$(PKG) |
| 183 |
# cd $(DISTTMPDIR) && zip -r $(CURDIR)/$(PKGZIP) $(PKG) $(PKGTDSZIP) |
| 184 |
cd $(DISTTMPDIR) && zip -r $(CURDIR)/$(PKGZIP) $(PKG) |
| 185 |
rm -rf $(DISTTMPDIR) |
| 186 |
|
| 187 |
cleandist: |
| 188 |
@rm -f $(PKGZIP) |