Debian Codegraph @

texmf-dist/source/generic/memoize/Makefile.package

raw
1 # This Makefile must be included at the end of the including file.
2
3 latex = $(COMMON:%=%.sty) $(LATEX)
4 plain = $(COMMON:%=%.tex) $(PLAIN)
5 context = $(COMMON:%=t-%.tex) $(CONTEXT)
6
7 TEX = $(latex) $(plain) $(context) $(GENERIC)
8
9 RUNTIME = $(TEX) $(SCRIPTS) $(MAN)
10
11 ALL = $(RUNTIME) $(SOURCE) $(DOC) \
12 $(README) $(INSTALL) $(CHANGELOG) $(LICENCE) $(MAKEFILE)
13
14 ctan/$(PACKAGE).zip: $(ALL)
15
16 CTAN-DIR = ctan/$(PACKAGE)
17 CTAN-DOC-DIR = ctan/$(PACKAGE)/doc
18
19 format-dir = $(subst context,context/third,$(FORMAT))
20
21 TDS-DIR = texmf/$(PACKAGE).tds
22 TDS-SCRIPTS-DIR = $(TDS-DIR)/scripts/$(PACKAGE)
23 TDS-DOC-DIR = $(TDS-DIR)/doc/$(format-dir)/$(PACKAGE)
24 TDS-SOURCE-DIR = $(TDS-DIR)/source/$(format-dir)/$(PACKAGE)
25 TDS-MAN-DIR = $(TDS-DIR)/doc/man/man
26 TDS-ALL-DIRS = $(TDS-SCRIPTS-DIR) $(TDS-SOURCE-DIR) $(TDS-DOC-DIR) \
27 $(TDS-DIR)/tex/{latex,plain,generic}/$(PACKAGE) \
28 $(TDS-DIR)/tex/context/third/$(PACKAGE) \
29 $(TDS-MAN-DIR){1,2,3,4,5,6,7,8,9}
30
31 readme?md = README$(findstring .md, $(suffix $(README)))
32 install?md = INSTALL$(findstring .md, $(suffix $(INSTALL)))
33 changelog?md = CHANGELOG$(findstring .md, $(suffix $(CHANGELOG)))
34 licence?md = LICENCE$(findstring .md, $(suffix $(LICENCE)))
35
36 man1 = $(filter %.1,$(MAN))
37 man2 = $(filter %.2,$(MAN))
38 man3 = $(filter %.3,$(MAN))
39 man4 = $(filter %.4,$(MAN))
40 man5 = $(filter %.5,$(MAN))
41 man6 = $(filter %.6,$(MAN))
42 man7 = $(filter %.7,$(MAN))
43 man8 = $(filter %.8,$(MAN))
44 man9 = $(filter %.9,$(MAN))
45
46 define MAKE-CTAN
47 $(CTAN-BEGIN)
48 $(CTAN-END)
49 endef
50
51 define CTAN-BEGIN
52 rm -rf $(CTAN-DIR) ctan/$(PACKAGE).zip
53 mkdir -p $(CTAN-DIR) $(CTAN-DOC-DIR)
54 $(call cp,$(SOURCE) $(SCRIPTS) $(CTAN),$(CTAN-DIR))
55 $(call cp,$(README),$(CTAN-DIR)/$(readme?md))
56 $(call cp,$(INSTALL),$(CTAN-DIR)/$(install?md))
57 $(call cp,$(CHANGELOG),$(CTAN-DIR)/$(changelog?md))
58 $(call cp,$(LICENCE),$(CTAN-DIR)/$(licence?md))
59 $(call cp,$(MAKEFILE),$(CTAN-DIR))
60 $(call cp,$(DOC),$(CTAN-DOC-DIR))
61 endef
62
63 define CTAN-END
64 if [[ -d $(TDS-DIR) ]] ; then \
65 cd $(TDS-DIR) && \
66 zip -r $(PACKAGE).tds.zip * ; \
67 fi
68 if [[ -a $(TDS-DIR)/$(PACKAGE).tds.zip ]] ; then \
69 mv $(TDS-DIR)/$(PACKAGE).tds.zip ctan ; \
70 fi
71 rmdir -p --ignore-fail-on-non-empty `find $(CTAN-DIR) -type d`
72 cd ctan && zip -r $(PACKAGE).zip $(PACKAGE) $(PACKAGE).tds.zip
73 cp ctan/$(PACKAGE).zip ctan/$(PACKAGE)-$(YEAR)-$(MONTH)-$(DAY)-v$(VERSION).zip
74 endef
75
76 define MAKE-TDS
77 $(TDS-BEGIN)
78 $(TDS-END)
79 endef
80
81 define TDS-BEGIN
82 rm -rf $(TDS-DIR)
83 $(TDS-MKDIR)
84 $(TDS-CP)
85 endef
86 define TDS-MKDIR
87 mkdir -p $(TDS-ALL-DIRS)
88 endef
89 define TDS-CP
90 $(call cp,$(latex),$(TDS-DIR)/tex/latex/$(PACKAGE))
91 $(call cp,$(plain),$(TDS-DIR)/tex/plain/$(PACKAGE))
92 $(call cp,$(context),$(TDS-DIR)/tex/context/third/$(PACKAGE))
93 $(call cp,$(GENERIC),$(TDS-DIR)/tex/generic/$(PACKAGE))
94 $(call cp,$(SCRIPTS),$(TDS-SCRIPTS-DIR))
95 $(call cp,$(SOURCE),$(TDS-SOURCE-DIR))
96 $(call cp,$(MAKEFILE),$(TDS-SOURCE-DIR))
97 $(call cp,$(DOC),$(TDS-DOC-DIR))
98 $(call cp,$(README),$(TDS-DOC-DIR)/$(readme?md))
99 $(call cp,$(INSTALL),$(TDS-DOC-DIR)/$(install?md))
100 $(call cp,$(CHANGELOG),$(TDS-DOC-DIR)/$(changelog?md))
101 $(call cp,$(LICENCE),$(TDS-DOC-DIR)/$(licence?md))
102 $(call cp,$(man1),$(TDS-MAN-DIR)1)
103 $(call cp,$(man2),$(TDS-MAN-DIR)2)
104 $(call cp,$(man3),$(TDS-MAN-DIR)3)
105 $(call cp,$(man4),$(TDS-MAN-DIR)4)
106 $(call cp,$(man5),$(TDS-MAN-DIR)5)
107 $(call cp,$(man6),$(TDS-MAN-DIR)6)
108 $(call cp,$(man7),$(TDS-MAN-DIR)7)
109 $(call cp,$(man8),$(TDS-MAN-DIR)8)
110 $(call cp,$(man9),$(TDS-MAN-DIR)9)
111 endef
112
113 define TDS-END
114 $(TDS-FILES)
115 $(TDS-PRUNE)
116 endef
117 define TDS-FILES
118 cd $(TDS-DIR) ; find . -type f | sed 's!^\./!!' \
119 > doc/$(format-dir)/$(PACKAGE)/FILES
120 endef
121 define TDS-PRUNE
122 rmdir -p --ignore-fail-on-non-empty `find $(TDS-DIR) -type d`
123 endef
124
125 %.1: %.1.md
126 pandoc $< -s -t man -o $@
127 %.2: %.2.md
128 pandoc $< -s -t man -o $@
129 %.3: %.3.md
130 pandoc $< -s -t man -o $@
131 %.4: %.4.md
132 pandoc $< -s -t man -o $@
133 %.5: %.5.md
134 pandoc $< -s -t man -o $@
135 %.6: %.6.md
136 pandoc $< -s -t man -o $@
137 %.7: %.7.md
138 pandoc $< -s -t man -o $@
139 %.8: %.8.md
140 pandoc $< -s -t man -o $@
141 %.9: %.9.md
142 pandoc $< -s -t man -o $@
143
144 .PHONY: runtimes link-runtimes install-runtimes uninstall-runtimes version
145 .IGNORE: uninstall-runtimes
146
147 cp=$(intcmp $(words $(1)),0,,,cp $(1) $(2))
148
149 runtimes: $(RUNTIME)
150
151 TEXMFHOME=$(shell kpsewhich -var-value TEXMFHOME)
152
153 link-runtimes:
154 $(eval TDS-DIR=$(TEXMFHOME))
155 $(eval cp=$$(intcmp $$(words $$(1)),0,,,ln -srf $$(1) $$(2)))
156 $(TDS-MKDIR)
157 $(TDS-CP)
158 $(TDS-PRUNE)
159 texconfig rehash
160
161 install-runtimes:
162 $(eval TDS-DIR=$(TEXMFHOME))
163 $(TDS-MKDIR)
164 $(TDS-CP)
165 $(TDS-PRUNE)
166 texconfig rehash
167
168 uninstall-runtimes:
169 $(eval TDS-DIR=$(TEXMFHOME))
170 $(eval cp=$$(intcmp $$(words $$(1)),0,,,\
171 if [[ -d $$(2) ]] ; then rm -f $$(foreach f,$$(1),$$(2)/$$(notdir $$(f))) ; \
172 else rm -f $$(2) ; fi \
173 ))
174 $(TDS-CP)
175 $(TDS-PRUNE)
176 texconfig rehash
177
178
179 # $1 = source file, $2 = package name
180 VERSION-LATEX = $(YEAR)/$(MONTH)/$(DAY) v$(VERSION)
181 define EDIT-VERSION-LATEX
182 sed -Ei 's!\\ProvidesPackage\{$(2)\}\[[0-9]{4}/[0-9]{1,2}/[0-9]{1,2} v[-0-9.a-z]* !\\ProvidesPackage{$(2)}[$(VERSION-LATEX) !' $(1)
183 endef
184
185 # $1 = source file
186 # This assumes that all the \modules in the file have the same date and version.
187 VERSION-CONTEXT = $(VERSION)
188 DATE-CONTEXT = $(YEAR)-$(MONTH)-$(DAY)
189 define EDIT-VERSION-CONTEXT
190 sed -Ei 's!(%D *version=)[-0-9.a-z]*,!\1$(VERSION-CONTEXT),!;s!(%D *date=)[-0-9]*,!\1$(DATE-CONTEXT),!' $(1)
191 endef
192
193 # $1 = source .pl file, $2 = version
194 VERSION-PERL = $(YEAR)/$(MONTH)/$(DAY) v$(VERSION)
195 define EDIT-VERSION-PERL
196 sed -i "s!^my \$$VERSION = .*!my \$$VERSION = '$(VERSION-PERL)';!" $(1)
197 endef
198
199 # $1 = source .py file, $2 = version
200 VERSION-PYTHON = $(YEAR)/$(MONTH)/$(DAY) v$(VERSION)
201 define EDIT-VERSION-PYTHON
202 sed -i "s!^__version__ = .*!__version__ = '$(VERSION-PYTHON)'!" $(1)
203 endef
204
205 # $1 = source file
206 VERSION-MAN = $(VERSION)
207 DATE-MAN = $(shell LANG=en date -d '$(YEAR)-$(MONTH)-$(DAY)' +"%B %d, %Y")
208 # This assumes that the source filename is file.<N>.md, because it strips away two suffixes.
209 define EDIT-VERSION-MAN
210 sed -i '/^date:/c date: $(DATE-MAN)' $(1)
211 sed -i '/^footer:/c footer: $(basename $(basename $(notdir $(1)))) $(VERSION-MAN)' $(1)
212 endef
213
214 # $1 = source file, $2 = package name
215 VERSION-PLAIN = $(VERSION-LATEX)
216 define EDIT-VERSION-PLAIN
217 sed -Ei 's!^(%<[^\>]*>% Package $(2) ).*!\1$(VERSION-PLAIN)!' $(1)
218 endef
219
220 # Change the date of the latest release (identified by the version) of the package.
221 define EDIT-DATE-CHANGELOG
222 sed -Ei 's!^(#+|Manual: Memoize) [0-9]{4}/[0-9]{1,2}/[0-9]{1,2} +v$(VERSION)!\1 $(YEAR)/$(MONTH)/$(DAY) v$(VERSION)!' $(1)
223 endef
224