chiark / gitweb /
Makefile: shrink preview of pdf
[pandemic-rising-tide.git] / Makefile
1 # Makefile - build system for new board layouts for
2 #   for games very like Pandemic Rising Tide
3 #
4 # Copyright (C) 2019 Ian Jackson
5 #
6 # This program is dual licensed, GPv3+ or CC-BY-SA 4.0+.
7 # Only to the Pandemic Rising Tide folks, it is permissively licensed.
8 #
9 #   This program is free software.
10 #
11 #   You can redistribute it and/or modify it under the terms of the
12 #   GNU General Public License as published by the Free Software
13 #   Foundation, either version 3 of the License, or (at your option)
14 #   any later version; or (at your option), under the terms of the
15 #   Creative Commons Attribution-ShareAlike International License,
16 #   version 4.0 of that License, or (at your option), any later
17 #   version.
18 #
19 #   This program is distributed in the hope that it will be useful,
20 #   but WITHOUT ANY WARRANTY; without even the implied warranty of
21 #   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
22 #   General Public License Creative Commons Attribution-ShareAlike
23 #   License or the for more details.
24 #
25 #   You should have received a copy of these licenses along with this
26 #   program.  If not, see <https://www.gnu.org/licenses/> and
27 #   <https://creativecommons.org/licenses/>.
28 #
29 # Pandemic and Pandemic Rising Tide are (I think) trademarks of Z-Man
30 # games and I use them without permission.
31
32 # For the avoidance of doubt, I do not consider this program to be a
33 # derivative work of the game Pandemic Rising Tide.  However, it is
34 # not very useful without a pair of game description files and the
35 # only nontrivial game description files I know of are indeed such
36 # derivatives.
37
38 SHELL=/bin/bash
39
40 i=mv -f $@.tmp $@
41 o= >$@.tmp && $i
42
43 export PERL_HASH_SEED=1
44
45 # PLAG_DEBUG   ?= $(PLAG)     # effectively
46 # PLAG_RELEASE ?= $(PLAG)     # ie caller may set these
47 PLAG_DIR     ?= ../plag-mangler
48
49 USE_PLAG_DEBUG   := $(shell ./find-plag \
50  debug:release "$(PLAG_DIR)" "$(PLAG_DEBUG)" "$(PLAG_RELEASE)" "$(PLAG)")
51 USE_PLAG_RELEASE := $(shell ./find-plag \
52  release:debug "$(PLAG_DIR)" "$(PLAG_RELEASE)" "$(PLAG_DEBUG)" "$(PLAG)")
53
54 # with
55 #  plag-mangler   3a1eae4d6395f7d862cf66d0e4a1008d1bedc6e7
56 #  rc-dlist-deque 3e19e16dde436fc1ac03534bf502588d17b3faeb
57 #  c_vec          3394762a6221c44f8e22b222ce5547f6534129ea
58 #  rust-nlopt     d6781621e72bb7a78da56689ab5bb27befafec6a
59 #  nlopt (hack)   3068d8b694a6047c4f374b7267a54fdb3fae1f69 2.3+252-g8b3cb5a-1
60 #  crates from Debian buster:
61 #    libc   0.2.43-1
62 #    arrayvec 0.4.8-1
63 #  also relevant
64 #    libboost-dev:amd64       1.67.0.1
65 #    libboost1.67-dev:amd64   1.67.0-11
66
67 PS2PDF ?= ps2pdf
68 PS2PDF_FLAGS ?=
69
70 export PERL_HASH_SEED=1
71 export PERL_PERTURB_KEYS=0
72
73 default: all
74
75 # board-pMAXPAPER-bPAGE.pdf
76 #   where MAXPAPER is a3 for one a4 and one a3 page, PAGEs are B, MT
77 #                     a4 for three a4 pages, PAGEs are B, M, T
78 #                     a1 for one a1 page (with much whitespace), page is P
79 #                     a1m like a1 but assumes pasting onto 4 x a4 boards
80 #
81 # boundings-* (one per MAXPAPER) shows various regions
82 #   assuming 5.5mm unprintable border, see $max_printeredge
83
84 BOARDFILES=                                             \
85         $(addprefix maxprintable-,      a3)             \
86         $(addprefix minprintable-,      a3)             \
87         $(addprefix boundings-, pa3 pa4 pa1-bPageP pa1m pa1m-bPageP     ) \
88         $(addprefix board-,     pa3-bPageB pa3-bPageMT                  \
89                                 pa4-bPageB pa4-bPageM pa4-bPageT        \
90                                 pa1-bPageP pa1m-bPageP                  ) \
91         $(addprefix a4-test-,           b m t a1m)      \
92         layout-test-preview                             \
93         $(addprefix layout-test-,       b m t a1m)
94
95
96 all:            all-ps all-pdf all-preview
97
98 PSS=$(addsuffix .ps,  $(BOARDFILES))
99 PDFS=$(addsuffix .pdf, $(BOARDFILES))
100 PREVIEWS=maxprintable-a3-preview.png
101 TEXTFILES=README map.plag
102
103 all-ps:         $(PSS)
104 all-pdf:        $(PDFS)
105 all-preview:    $(PREVIEWS)
106
107 %.pdf: %.ps Makefile
108         $(PS2PDF) $(PS2PDF_FLAGS) $< $@.tmp && $i
109
110 cmyk.pdf: PS2PDF_FLAGS += -dAutoRotatePages=/None
111
112 map.plag: generate-plag input-graph Parse.pm 
113         ./$< input-graph $o
114
115 www=ianmdlvl@chiark:public-html/pandemic-rising-tide
116
117 html: $(PDFS) $(PREVIEWS) $(TEXTFILES)
118         rm -rf $@ $@.tmp; mkdir $@.tmp
119         cp $^ $@.tmp/
120         set -e; for f in $(TEXTFILES); do mv $@.tmp/$$f{,.txt}; done
121         $i
122
123 to-www: html
124         git-push
125         rsync -aH --delete html/. $(www)/.
126
127 # create opt.plag.reuse to shortcut this
128 opt.plag: maybe-rerun-optim map.plag $(USE_PLAG_RELEASE) Makefile
129         ./$(filter-out Makefile, $^) $@ .opt.plag.sums \
130                 R                                       \
131                 DUAL                                    \
132                 OUTER-F2V OUTER-SPLIT                   \
133                 B T OUTER-F2V OUTER-F12VA               \
134                 PCO CP RAE                              \
135                 D 0 NLOPT                               \
136                 W $@.tmp
137
138 faces.plag: opt.plag $(USE_PLAG_DEBUG) Makefile
139         $(USE_PLAG_DEBUG) RF $< W-FACES $@.tmp && $i
140
141 BOARDDEPS= generate-board faces.plag input-graph misc-data.pl Parse.pm
142
143 maxprintable-%.ps: $(BOARDDEPS)
144         ./generate-board -Xp$* faces.plag input-graph $o
145
146 minprintable-%.ps: $(BOARDDEPS)
147         ./generate-board -Xp$*,bPrintableAll faces.plag input-graph $o
148
149 %-preview.png: %.pdf Makefile
150         gm convert -geometry 20% $< png:$@.tmp && $i
151
152 boundings-%.ps: $(BOARDDEPS)
153         ./generate-board -XB$* faces.plag input-graph $o
154
155 board-%.ps: $(BOARDDEPS)
156         ./generate-board -X$* faces.plag input-graph $o
157
158 layout-test-a1m.ps: $(BOARDDEPS) layout-test-prefix-a1.ps
159         ./generate-board -XWB,pa1m-bPageP faces.plag input-graph >$@.tmp.1
160         cat layout-test-prefix-a1.ps $@.tmp.1 $o
161
162 a4-test-a1m.ps: $(BOARDDEPS) layout-test-prefix-a1.ps
163         ./generate-board -XB,pa1m-bPageP faces.plag input-graph >$@.tmp.1
164         cat layout-test-prefix-a1.ps $@.tmp.1 $o
165
166 layout-test-preview.ps: $(BOARDDEPS) 
167         ./generate-board -XW faces.plag input-graph $o
168
169 layout-test-%.ps: layout-test-prefix-%.ps layout-test-preview.ps
170         cat $^ $o
171
172 a4-test-%.ps: layout-test-prefix-%.ps maxprintable-a3.ps
173         cat $^ $o
174
175 #map.ps: map.dot
176 #       neato -Tps $^ $o