summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/wargame/source/Makefile
blob: 8320c42419a6a6eafd2a91c0a6d3cc5ce631ae9a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
#
#
#
NAME		:= wargame
VERSION		:= 0.6
LATEX_FLAGS	:= -interaction=nonstopmode 	\
		   -file-line-error		\
		   --synctex=15			\
		   -shell-escape
LATEX		:= pdflatex  
MAKEINDEX	:= makeindex
SED		:= sed
CTANOMAT	:= ctan-o-mat
CTANOMAT_FLAGS	:= -n
SOURCES		:= wargame.ins				\
		   wargame.dtx				\
		   package.dtx				\
		   util/core.dtx			\
		   util/misc.dtx			\
		   util/compound.dtx			\
		   util/bb.dtx				\
		   util/tikz.dtx			\
		   util/randomid.dtx			\
		   util/icons.dtx			\
		   util/export.dtx			\
		   chit/shape.dtx			\
		   chit/misc.dtx			\
		   chit/modifiers.dtx			\
		   chit/stack.dtx			\
		   chit/oob.dtx				\
		   chit/table.dtx			\
		   chit/battle.dtx			\
		   chit/dice.dtx			\
		   chit/elements.dtx			\
		   chit/core.dtx			\
		   hex/shape.dtx			\
		   hex/tile.dtx				\
		   hex/ridges.dtx			\
		   hex/towns.dtx			\
		   hex/terrain.dtx			\
		   hex/paths.dtx			\
		   hex/core.dtx				\
		   hex/labels.dtx			\
		   hex/extra.dtx			\
		   hex/terrain/woods.dtx		\
		   hex/terrain/town.dtx			\
		   hex/terrain/tree.dtx			\
		   hex/terrain/beach.dtx		\
		   hex/terrain/mountain.dtx		\
		   hex/terrain/light_woods.dtx		\
		   hex/terrain/mountains.dtx		\
		   hex/terrain/village.dtx		\
		   hex/terrain/city.dtx			\
		   hex/terrain/swamp.dtx		\
		   hex/terrain/rough.dtx		\
		   hex/board.dtx			\
		   hex/coord.dtx			\
		   hex/split.dtx			\
		   natoapp6c/shape.dtx			\
		   natoapp6c/symbols.dtx		\
		   natoapp6c/list.dtx			\
		   natoapp6c/compat/seasurface.dtx	\
		   natoapp6c/compat/activity.dtx	\
		   natoapp6c/compat/subsurface.dtx	\
		   natoapp6c/compat/missile.dtx		\
		   natoapp6c/compat/air.dtx		\
		   natoapp6c/compat/seamine.dtx		\
		   natoapp6c/compat/land.dtx		\
		   natoapp6c/compat/equipment.dtx	\
		   natoapp6c/compat/installation.dtx	\
		   natoapp6c/compat/space.dtx		\
		   natoapp6c/frames/hostile.dtx		\
		   natoapp6c/frames/base.dtx		\
		   natoapp6c/frames/friendly.dtx	\
		   natoapp6c/frames/neutral.dtx		\
		   natoapp6c/frames/unknown.dtx		\
		   natoapp6c/weaponry.dtx		\
		   natoapp6c/core.dtx			\
		   natoapp6c/text.dtx			\
		   natoapp6c/echelon.dtx		\
		   natoapp6c/util.dtx			\
		   tests/map.dtx			\
		   tests/chits.dtx			
SCRIPTS		:= utils/wgsvg2tikz.py utils/wgexport.py

DESTDIR		:= $(HOME)/texmf/
instdir		:= tex/latex/$(NAME)
docdir		:= doc/latex/$(NAME)
srcdir		:= source/latex/$(NAME)
ctandir		:= ctan
distsdir	:= $(NAME)-$(VERSION)

TILES		:= beach	\
		   city		\
		   light_woods	\
		   mountains	\
		   rough	\
		   swamp	\
		   town		\
		   village	\
		   woods
TILES_PDF	:= $(TILES:%=wargame.%.pdf)
TILES_TEX	:= $(TILES:%=wargame.%.tex)
TABLES		:= air		\
		   missile	\
		   land		\
		   equipment	\
		   installation	\
		   seasurface	\
		   subsurface	\
		   seamine	\
		   space	\
		   activity
PKG_FILES	:= wargame.sty					\
		   tikzlibrarywargame.util.code.tex		\
		   tikzlibrarywargame.hex.code.tex		\
		   tikzlibrarywargame.natoapp6c.code.tex	\
		   tikzlibrarywargame.chit.code.tex		\
		   wgexport.cls					\
		   $(TILES_PDF)				

DOC_FILES	:= wargame.pdf symbols.pdf compat.pdf

ifdef VERBOSE	
MUTE		:=
REDIR		:=
LATEX_FLAGS	:= 
else
MUTE		:= @
REDIR		:= > /dev/null 2>&1 
endif
ifdef CI_COMMIT_REF_NAME
VERSION		:= $(CI_COMMIT_REF_NAME)
else
ifdef 		:= $(CI_JOB_ID)
endif

%.pdf:%.tex
	@echo "LATEX $< -> $@"
	$(MUTE)$(LATEX) $(LATEX_FLAGS) $<  $(REDIR)

%.aux:%.tex
	@echo "LATEX $< -> $@"
	$(MUTE)$(LATEX) $(LATEX_FLAGS) $<  $(REDIR)

%.idx:%.dtx
	@echo "LATEX $< -> $@"
	$(MUTE)$(LATEX) $(LATEX_FLAGS) $<  $(REDIR)

%.aux:%.idx
	@echo "LATEX $*.dtx -> $@ (via $<)"
	$(MUTE)$(LATEX) $(LATEX_FLAGS) $*.dtx  $(REDIR)
	$(MUTE)touch $< $@

%.pdf:%.aux %.ind
	@echo "LATEX $*.dtx -> $@ (via $<)"
	$(MUTE)$(LATEX) $(LATEX_FLAGS) $*.dtx  $(REDIR)
	$(MUTE)touch $^ $@

%.pdf:%.aux %.tex
	@echo "LATEX $*.tex -> $@ (via $<)"
	$(MUTE)$(LATEX) $(LATEX_FLAGS) $*.tex  $(REDIR)


%.ind:%.idx
	@echo "INDEX $< -> $@ $<"
	$(MUTE)$(MAKEINDEX) -s gind -o $@ $<  $(REDIR)
	$(MUTE)touch $^ $@

%.gls:%.glo
	@echo "GLOSSAY $< -> $@"
	$(MUTE)$(MAKEINDEX) -s gglo -o $@ $<  $(REDIR)
	$(MUTE)touch $^ $@

all:		wargame.pdf

package:	$(PKG_FILES)

everything:	all symbols.pdf compat.pdf tests/test.pdf

tutorial: tutorial/game.pdf
tutorial/game.pdf: all
	@echo "MAKE -C tutorial Game.vmod"
	$(MUTE)$(MAKE) -C tutorial Game.vmod

clean:
	@echo "CLEAN"
	$(MUTE)rm -f  *~ *.log* *.aux *.toc *.lof *.lot *.out *.ilg *.idx *.ind
	$(MUTE)rm -f  cmp_*.tex *.synctex* *.hd
	$(MUTE)rm -f  symbols.tex compat.tex testmap.tex testchits.tex 
	$(MUTE)rm -f  wargame.sty wgdoc.sty logo.png logo.pdf
	$(MUTE)rm -f  symbols.pdf compat.pdf test.pdf wargame.pdf
	$(MUTE)rm -f  tikzlibrarywargame.util.code.tex
	$(MUTE)rm -f  tikzlibrarywargame.hex.code.tex
	$(MUTE)rm -f  tikzlibrarywargame.natoapp6c.code.tex
	$(MUTE)rm -f  tikzlibrarywargame.chit.code.tex
	$(MUTE)rm -f  wgexport.cls mksvg.pdf README.md.version
	$(MUTE)rm -f  $(TILES_TEX) $(TILES_PDF)
	$(MUTE)rm -rf public texmf
	$(MUTE)rm -rf $(distsdir)
	$(MUTE)rm -f  $(distsdir).tar.gz
	$(MUTE)rm -f  $(distsdir).zip
	$(MUTE)rm -f  $(NAME).tar.gz
	$(MUTE)rm -rf __pycache__
	$(MUTE)rm -rf $(ctandir) tmp
	$(MUTE)rm -f  ctan.tex $(NAME).ctan.tar.gz
	$(MUTE)$(MAKE) -C tutorial clean 



wargame.sty 				\
testmap.tex 				\
testchits.tex 				\
wgdoc.sty 				\
compat.tex 				\
symbols.tex 				\
tikzlibrarywargame.hex.code.tex		\
tikzlibrarywargame.natoapp6c.code.tex	\
tikzlibrarywargame.chit.code.tex	\
wgexport.cls				\
$(TILES_TEX)		\
$(TABLES:%=cmp_%.tex): $(SOURCES)
	@echo "DOCSTRIP $<"
	$(MUTE)$(LATEX) $< $(REDIR)

wargame.idx:	wargame.dtx wargame.sty $(TILES_PDF)
wargame.pdf:	wargame.aux wargame.ind
fast:		wargame.idx
symbols.aux:	symbols.tex wargame.sty
symbols.pdf:	symbols.aux
compat.aux:	compat.tex $(TABLES:%=cmp_%.tex) wargame.sty
compat.pdf:	compat.aux
test.aux:	test.tex wargame.sty

beach.pdf:	beach.tex
city.pdf:	city.tex
light_woods.pdf:light_woods.tex
mountains.pdf:	mountains.tex
rough.pdf:	rough.tex
swamp.pdf:	swamp.tex
town.pdf:	town.tex
village.pdf:	village.tex
woods.pdf:	woods.tex

install-devel: all 
	(cd $(dir $(DESTDIR)/$(instdir)) && \
		rm -f $(notdir $(instdir)) && \
		ln -fs $(PWD) $(notdir $(instdir)))

install:$(PKG_FILES) $(DOC_FILES) $(SCRIPTS)
	@echo "Installing DESTDIR=$(DESTDIR)"
	$(MUTE)mkdir -p $(DESTDIR)$(instdir)
	$(MUTE)mkdir -p $(DESTDIR)$(docdir)
	$(MUTE)cp $(PKG_FILES) $(DESTDIR)$(instdir)
	$(MUTE)cp $(DOC_FILES) $(DESTDIR)$(docdir)
	$(MUTE)cp $(SCRIPTS)   $(DESTDIR)$(instdir)

uninstall:
	rm -rf $(DESTDIR)$(instdir)
	rm -rf $(DESTDIR)$(docdir)

distdir:$(SOURCES) $(SCRIPTS) Makefile tests/test.tex
	$(MUTE)rm -rf $(distsdir)
	$(MUTE)mkdir -p $(distsdir)
	$(foreach s, $^, 	\
		mkdir -p $(distsdir)/$(shell dirname $(s)); \
		cp $(s) $(distsdir)/$(s);)

distcheck:distdir
	$(MAKE) $(MAKEFLAGS) -C $(distsdir) everything

dist:distdir
	zip -r $(distsdir).zip $(distsdir)

bindist:	DESTDIR:=$(distsdir)/
bindist:install
	zip -r $(distsdir).zip $(distsdir)


logo.png:logo.pdf
	pdftocairo -transp -png $<
	mv logo-1.png logo.png

README.md.version:README.md
	@echo "Versioned README.md $(VERSION)"
	$(MUTE)$(SED) 's/^# \(.*\)/# \1\n## Version $(VERSION)/' \
		< $< | pandoc --to markdown > $@

ctandir: all tutorial/game.pdf README.md.version
	@echo "Preparing CTAN directory"
	$(MUTE)$(MAKE) install DESTDIR:=tmp/ 
	$(MUTE)mkdir -p tmp/$(docdir)/tutorial
	$(MUTE)cp $(foreach i, game.tex game.sty export.tex patch.py \
	                README.md Makefile game.pdf,\
		tutorial/$(i)) tmp/$(docdir)/tutorial
	$(MUTE)cp README.md.version tmp/$(docdir)/README.md
	$(MUTE)$(MAKE) distdir distsdir:=tmp/$(srcdir) $(REDIR)
	$(MUTE)mkdir -p $(ctandir)/$(NAME)
	$(MUTE)cp tmp/$(docdir)/README.md $(ctandir)/$(NAME)/
	$(MUTE)(cd tmp && zip -q -r ../$(ctandir)/$(NAME).tds.zip *)
	$(MUTE)rm tmp/$(docdir)/README.md
	$(MUTE)(cd tmp && cp -a $(docdir) ../$(ctandir)/$(NAME)/doc)
	$(MUTE)(cd tmp && cp -a $(srcdir) ../$(ctandir)/$(NAME)/source)
	$(MUTE) rm -rf tmp

ctan.tex:ctan.tex.in 
	@echo "SED	$< -> $@"
	$(MUTE)$(SED)   -e 's/@NAME@/$(NAME)/g' \
			-e 's/@VERSION@/$(VERSION)/' \
		< $< > $@

ctandist: $(NAME).ctan.tar.gz
$(NAME).ctan.tar.gz:	ctandir
	@echo "TAR	$@"
	$(MUTE)rm -f $@
	$(MUTE)(cd $(ctandir) && tar -czf ../$(NAME).ctan.tar.gz *)
	$(MUTE)rm -rf $(ctandir) tmp


ctan-upload:ctan.tex $(NAME).ctan.tar.gz  
	@echo "CTAN	$< -> CTAN ($(CTANOMAT_FLAGS))"
	$(MUTE)$(CTANOMAT) $(CTANOMAT_FLAGS) -c $<


docker:
	docker run --user root --group-add users -e GRANT_SUDO=yes -it --rm \
		-v $(PWD):/root/$(notdir $(PWD)) texlive/texlive \
		/bin/bash

docker-prep:
	apt update
	apt install -y poppler-utils python3-pil pandoc zip \
		libwww-mechanize-perl libfile-copy-recursive-perl
	pwd 
	ls
	make clean

docker-artifacts: DESTDIR=$(PWD)/public/
docker-artifacts: install tutorial/game.pdf
	cp tutorial/game.pdf  $(DESTDIR)$(docdir)/tutorial.pdf
	cp tutorial/Game.vmod $(DESTDIR)$(docdir)/Game.vmod


#
# EOF
#