summaryrefslogtreecommitdiff
path: root/macros/generic/memoize/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'macros/generic/memoize/Makefile')
-rw-r--r--macros/generic/memoize/Makefile139
1 files changed, 139 insertions, 0 deletions
diff --git a/macros/generic/memoize/Makefile b/macros/generic/memoize/Makefile
new file mode 100644
index 0000000000..7edbd7ba34
--- /dev/null
+++ b/macros/generic/memoize/Makefile
@@ -0,0 +1,139 @@
+# Prepare the CTAN submission for all three packages.
+
+PACKAGES = memoize advice collargs
+
+all: ctan/memoize.zip
+ $(MAKE) -f Makefile.advice ctan/advice.zip
+ $(MAKE) -f Makefile.collargs ctan/collargs.zip
+
+# Prepare the CTAN submission.
+
+PACKAGE = memoize
+VERSION = 1.0.0
+YEAR = 2023
+MONTH = 10
+DAY = 10
+
+FORMAT = generic
+
+COMMON = memoize nomemoize memoizable
+PLAIN = memoize-extract-one.tex
+SOURCE = memoize.edtx memoize.ins # $(makefiles)
+
+SCRIPTS := memoize-extract memoize-clean
+man-src := $(SCRIPTS:%=doc/%.1.md)
+MAN := $(SCRIPTS:%=%.1) $(SCRIPTS:%=%.pl.1) $(SCRIPTS:%=%.py.1)
+MAN := $(MAN:%=doc/%)
+SCRIPTS := $(SCRIPTS:%=%.pl) $(SCRIPTS:%=%.py)
+
+%.pl.1: %.1
+ echo .so man1/$*.1 > $@ # link to .1 man page
+%.py.1: %.1
+ echo .so man1/$*.1 > $@ # link to .1 man page
+
+.PHONY: runtime
+runtime: $(RUNTIME)
+
+README = doc/README.memoize.md
+INSTALL = INSTALL.md
+MAKEFILE = Makefile
+LICENCE = LICENCE
+
+makefiles = Makefile.package Makefile.runtimes Makefile.advice Makefile.collargs
+
+codedoc-source = memoize-code.tex \
+ memoize-code.sty memoize-doc-common.sty
+
+manual-source = memoize.tex \
+ memoize-doc.sty memoize-doc-common.sty yadoc.sty \
+ memoize.mst
+
+PDF = memoize.pdf memoize-code.pdf
+
+codedoc-source := $(codedoc-source:%=doc/%)
+manual-source := $(manual-source:%=doc/%)
+pdf := $(PDF:%=doc/%)
+DOC = $(sort $(codedoc-source) $(manual-source)) $(pdf) $(man-src)
+
+examples-src := Makefile ins.begin ins.mid ins.end
+examples-src := $(examples-src:%=doc/examples/%)
+#examples-src += $(shell git ls-files | grep ^doc/examples/.*dtx$)
+examples-src += $(shell find doc/examples -name '*.dtx')
+
+# doc/attachments.lst is produced by compiling memoize.tex (without memoization).
+# doc-examples will hold soft links to the relevant generated example files.
+doc-examples := $(shell sed 's/^.* \(.*\) ##.*$$/\1/' doc/attachments.lst)
+doc-examples := $(doc-examples:%=doc/examples/%)
+
+ctan/$(PACKAGE).zip:
+ $(TDS-BEGIN)
+# Check for duplicate filenames:
+ echo $(doc-examples) | tr ' ' '\n' | uniq -d | ifne false
+ cd doc && zip ../$(TDS-DOC-DIR)/examples-src.zip $(examples-src:doc/%=%)
+# For each line ($1 $2) in attachments.lst, link $1 to $2 ...
+ cd doc/examples && sed 's!^examples/!ln -sfr !' ../attachments.lst | sh
+# ... and zip those links.
+ cd doc && zip -r ../$(TDS-DOC-DIR)/examples.zip $(doc-examples:doc/%=%)
+ $(TDS-END)
+ $(CTAN-BEGIN)
+ ln -sr $(TDS-DOC-DIR)/examples-src.zip $(CTAN-DIR)/doc
+ ln -sr $(TDS-DOC-DIR)/examples.zip $(CTAN-DIR)/doc
+ $(CTAN-END)
+
+
+
+doc/memoize-code.pdf: $(SOURCE) $(codedoc-source)
+
+doc/memoize.pdf: $(manual-source) $(examples-src)
+
+%.pdf: %.tex
+ latexmk -cd -lualatex -bibtex- $< && touch $@
+
+
+
+# Maintanence
+
+test.tex = $(wildcard test*.tex)
+
+.PHONY: all runtime force clean versions-show
+
+.PRECIOUS: %.1
+
+clean: # clean this directory
+ memoize-clean.py -a $(test.tex:%.tex=-p %.) $(test.tex:%.tex=-p %.memo.dir/)
+ latexmk -C -f $(test.tex) _region_
+
+version:
+ $(MAKE) -f Makefile.collargs version
+ $(MAKE) -f Makefile.advice version
+ $(call EDIT-VERSION-LATEX,memoize.edtx,memoize)
+ $(call EDIT-VERSION-LATEX,memoize.edtx,nomemoize)
+ $(call EDIT-VERSION-LATEX,memoize.edtx,memoizable)
+ $(call EDIT-VERSION-CONTEXT,memoize.edtx)
+ $(call EDIT-VERSION-PLAIN,memoize.edtx,memoize)
+ $(call EDIT-VERSION-PLAIN,memoize.edtx,nomemoize)
+ $(call EDIT-VERSION-PLAIN,memoize.edtx,memoizable)
+ $(call EDIT-VERSION-PERL,memoize-extract.pl)
+ $(call EDIT-VERSION-PERL,memoize-clean.pl)
+ $(call EDIT-VERSION-PYTHON,memoize-extract.py)
+ $(call EDIT-VERSION-PYTHON,memoize-clean.py)
+ $(call EDIT-VERSION-MAN,doc/memoize-extract.1.md)
+ $(call EDIT-VERSION-MAN,doc/memoize-clean.1.md)
+# Change the date of the latest release (identified by the version).
+ sed -Ei 's!^\\item\[\\githubrelease\{[0-9]{4}/[0-9]{2}/[0-9]{2}\}\{v$(VERSION)\}\] *$$!\\item\[\\githubrelease\{$(YEAR)/$(MONTH)/$(DAY)\}\{v$(VERSION)\}\]!' doc/memoize.tex
+
+define COLOR_VERSION
+grep -E --color '[0-9]{4}[/-][0-9]{2}[/-][0-9]{2}|v?[0-9]\.[0-9]\.[0-9]|(January|February|March|April|May|June|July|August|September|October|November|December) [0-9]+, [0-9]{4}'
+endef
+
+versions-show:
+ @grep -E '%<latex>\\ProvidesPackage|^%<context>%D\s*(version|date)=' $(PACKAGES:%=%.edtx) | ${COLOR_VERSION}
+ @grep __version__ *.py | ${COLOR_VERSION}
+ @grep VERSION *.pl | ${COLOR_VERSION}
+ @grep -E '^(footer|date):' doc/memoize-*.md | ${COLOR_VERSION}
+ @grep -E 'githubrelease' doc/memoize.tex | ${COLOR_VERSION}
+
+include Makefile.package
+include Makefile.runtimes
+
+VERSION-MAN = of Memoize v$(VERSION)