chiark / gitweb /
preview png, actually make it a png
[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
39 i=mv -f $@.tmp $@
40 o= >$@.tmp && $i
41
42 export PERL_HASH_SEED=1
43
44 # PLAG_DEBUG   ?= $(PLAG)     # effectively
45 # PLAG_RELEASE ?= $(PLAG)     # ie caller may set these
46 PLAG_DIR     ?= ../plag-mangler
47
48 USE_PLAG_DEBUG   := $(shell ./find-plag \
49  debug:release "$(PLAG_DIR)" "$(PLAG_DEBUG)" "$(PLAG_RELEASE)" "$(PLAG)")
50 USE_PLAG_RELEASE := $(shell ./find-plag \
51  release:debug "$(PLAG_DIR)" "$(PLAG_RELEASE)" "$(PLAG_DEBUG)" "$(PLAG)")
52
53 # with
54 #  plag-mangler   3a1eae4d6395f7d862cf66d0e4a1008d1bedc6e7
55 #  rc-dlist-deque 3e19e16dde436fc1ac03534bf502588d17b3faeb
56 #  c_vec          3394762a6221c44f8e22b222ce5547f6534129ea
57 #  rust-nlopt     d6781621e72bb7a78da56689ab5bb27befafec6a
58 #  nlopt (hack)   3068d8b694a6047c4f374b7267a54fdb3fae1f69 2.3+252-g8b3cb5a-1
59 #  crates from Debian buster:
60 #    libc   0.2.43-1
61 #    arrayvec 0.4.8-1
62 #  also relevant
63 #    libboost-dev:amd64       1.67.0.1
64 #    libboost1.67-dev:amd64   1.67.0-11
65
66 PS2PDF ?= ps2pdf
67 PS2PDF_FLAGS ?=
68
69 export PERL_HASH_SEED=1
70 export PERL_PERTURB_KEYS=0
71
72 default: all
73
74 # board-pMAXPAPER-bPAGE.pdf
75 #   where MAXPAPER is a3 for one a4 and one a3 page, PAGEs are B, MT
76 #                     a4 for three a4 pages, PAGEs are B, M, T
77 #                     a1 for one a1 page (with much whitespace), page is P
78 #                     a1m like a1 but assumes pasting onto 4 x a4 boards
79 #
80 # boundings-* (one per MAXPAPER) shows various regions
81 #   assuming 5.5mm unprintable border, see $max_printeredge
82
83 BOARDFILES=                                             \
84         $(addprefix maxprintable-,      a3)             \
85         $(addprefix minprintable-,      a3)             \
86         $(addprefix boundings-, pa3 pa4 pa1-bPageP pa1m pa1m-bPageP     ) \
87         $(addprefix board-,     pa3-bPageB pa3-bPageMT                  \
88                                 pa4-bPageB pa4-bPageM pa4-bPageT        \
89                                 pa1-bPageP pa1m-bPageP                  ) \
90         $(addprefix a4-test-,           b m t a1m)      \
91         layout-test-preview                             \
92         $(addprefix layout-test-,       b m t a1m)
93
94
95 all:            all-ps all-pdf all-preview
96
97 PSS=$(addsuffix .ps,  $(BOARDFILES))
98 PDFS=$(addsuffix .pdf, $(BOARDFILES))
99 PREVIEWS=maxprintable-a3-preview.png
100
101 all-ps:         $(PSS)
102 all-pdf:        $(PDFS)
103 all-preview:    $(PREVIEWS)
104
105 %.pdf: %.ps Makefile
106         $(PS2PDF) $(PS2PDF_FLAGS) $< $@.tmp && $i
107
108 cmyk.pdf: PS2PDF_FLAGS += -dAutoRotatePages=/None
109
110 map.plag: generate-plag input-graph Parse.pm 
111         ./$< input-graph $o
112
113 www=ianmdlvl@chiark:public-html/pandemic-rising-tide
114
115 html: $(PDFS) $(PREVIEWS) README map.plag
116         rm -rf $@ $@.tmp; mkdir $@.tmp
117         cp $^ $@.tmp/ && $i
118
119 to-www: html
120         rsync -aH --delete html/. $(www)/.
121
122 # create opt.plag.reuse to shortcut this
123 opt.plag: maybe-rerun-optim map.plag $(USE_PLAG_RELEASE) Makefile
124         ./$(filter-out Makefile, $^) $@ .opt.plag.sums \
125                 R                                       \
126                 DUAL                                    \
127                 OUTER-F2V OUTER-SPLIT                   \
128                 B T OUTER-F2V OUTER-F12VA               \
129                 PCO CP RAE                              \
130                 D 0 NLOPT                               \
131                 W $@.tmp
132
133 faces.plag: opt.plag $(USE_PLAG_DEBUG) Makefile
134         $(USE_PLAG_DEBUG) RF $< W-FACES $@.tmp && $i
135
136 BOARDDEPS= generate-board faces.plag input-graph misc-data.pl Parse.pm
137
138 maxprintable-%.ps: $(BOARDDEPS)
139         ./generate-board -Xp$* faces.plag input-graph $o
140
141 minprintable-%.ps: $(BOARDDEPS)
142         ./generate-board -Xp$*,bPrintableAll faces.plag input-graph $o
143
144 %-preview.png: %.pdf Makefile
145         gm convert -geometry 50% $< png:$@.tmp && $i
146
147 boundings-%.ps: $(BOARDDEPS)
148         ./generate-board -XB$* faces.plag input-graph $o
149
150 board-%.ps: $(BOARDDEPS)
151         ./generate-board -X$* faces.plag input-graph $o
152
153 layout-test-a1m.ps: $(BOARDDEPS) layout-test-prefix-a1.ps
154         ./generate-board -XWB,pa1m-bPageP faces.plag input-graph >$@.tmp.1
155         cat layout-test-prefix-a1.ps $@.tmp.1 $o
156
157 a4-test-a1m.ps: $(BOARDDEPS) layout-test-prefix-a1.ps
158         ./generate-board -XB,pa1m-bPageP faces.plag input-graph >$@.tmp.1
159         cat layout-test-prefix-a1.ps $@.tmp.1 $o
160
161 layout-test-preview.ps: $(BOARDDEPS) 
162         ./generate-board -XW faces.plag input-graph $o
163
164 layout-test-%.ps: layout-test-prefix-%.ps layout-test-preview.ps
165         cat $^ $o
166
167 a4-test-%.ps: layout-test-prefix-%.ps maxprintable-a3.ps
168         cat $^ $o
169
170 #map.ps: map.dot
171 #       neato -Tps $^ $o