chiark / gitweb /
overflow-tube: Add cover up instruction (introduce var)
[quacks.git] / Makefile
1 # Books of Pumpkins, etc.  Extensions to Quacks of Quedlinburg
2 #  SPDX-License-Identifier: GPL-3.0-or-later OR CC-BY-SA-4.0
3 # Copyright 2020-2021 Ian Jackson
4
5 PUBLISH_MD += pumpkin-books house-rules
6 PUBLISH += pumpkin-books.pdf overflow-tube.pdf index.html
7 PUBLISH += LICENCE.txt GPL-3.txt CC-BY-SA-4.0.txt
8 PUBLISH += $(addsuffix .md.txt,  $(PUBLISH_MD))
9 PUBLISH += $(addsuffix .md.html, $(PUBLISH_MD))
10 PUBLISH += $(addsuffix .md.pdf,  $(PUBLISH_MD))
11
12 SHELL=bash
13
14 BOOKS+=         red
15 BOOKS+=         green
16 BOOKS+=         purple
17 BOOKS+=         blue
18 BOOKS+=         lotus
19 BOOKS+=         yellow
20 BOOKS+=         black-pair/black-more
21
22 BOOK_STEMS := $(addprefix book-,$(subst /, ,$(BOOKS)))
23 PUBLISH += $(addsuffix .pdf, $(BOOK_STEMS))
24 PUBLISH += $(addsuffix .png, $(BOOK_STEMS))
25
26 all:    $(PUBLISH)
27
28 # Don't print the ps, printers (eg ours!) don't always have the fonts
29
30 i=mv -f $@.new $@
31 o=>$@.new && $i
32 use_rsvg=rsvg-convert -f png -o $@.tmp.png $<
33 shell_pipe=set -o pipefail; set -e;
34 make_pnm = pnmdepth 255 | pnmnoraw $o
35
36 %.ps: %.ps.pl bag.pgm pot.pgm droplet.ppm
37         ./$< $(BOOKS) $o
38
39 %.pdf: %.ps
40         gs -q -dNOPAUSE -dBATCH -dPDFSETTINGS=/prepress \
41                 -sDEVICE=pdfwrite -sOutputFile=$@ $<
42
43 bag.pgm: Sack_-_Sac_-_Zak_brown.svg Makefile
44         $(use_rsvg)
45         $(shell_pipe)                                   \
46         pngtopnm <$@.tmp.png -mix -background 'white'   \
47         | ppmtopgm                                      \
48         | $(make_pnm)
49
50 pot.pgm: 146_Kaldrono.svg Makefile
51         $(use_rsvg)
52         $(shell_pipe)                                   \
53         pngtopnm <$@.tmp.png                            \
54         | ppmtopgm                                      \
55         | pnminvert                                     \
56         | $(make_pnm)
57
58 droplet.ppm: droplet.svg Makefile
59         $(use_rsvg)
60         $(shell_pipe)                                   \
61         pngtopnm <$@.tmp.png -mix -background 'white'   \
62         | pnmdepth 255                                  \
63         | $(make_pnm)
64
65 $(addsuffix .ps, $(BOOK_STEMS)): pumpkin-books.ps
66         @:
67
68 book-%.pdf: book-%.eps
69         rm -f $@.new; ps2pdf $< $@.new && $i
70
71 book-%.eps: book-%.ps
72         ps2eps <$< $o
73
74 book-%.png: book-%.eps Makefile
75         gm convert -density 100x100 $< $@
76
77 .PRECIOUS: book-%.eps
78
79 PUBLISH_FILES= \
80         $(patsubst %.md,%.md.txt, $(PUBLISH)) \
81         $(patsubst %.md,%.md.html, $(filter $(PUBLISH)) \
82
83 index.html: gen-index README.html
84         ./$^ $(BOOK_STEMS) $o
85
86 %.md.txt: %.md
87         cat $< $o
88
89 %.md.html: %.md Makefile massage-html
90         pandoc -s -Mtitle='Fm4YNbKyBNiS7TNu' $< >$@.tmp
91         ./massage-html $< $@.tmp $o
92
93 %.md.pdf: %.md Makefile
94         perl -pe '$$_ = uc if $$.==1' <$< >$@.tmp
95         pandoc --pdf-engine=wkhtmltopdf -o $@ $@.tmp
96
97 pubssh=c
98 pubpath=games-rules/quacks
99 puburl=https://www.chiark.greenend.org.uk/~ijackson/
100
101 publish: $(PUBLISH)
102         git push origin
103         rsync $^ $(pubssh):public-html/$(pubpath)/.
104         @echo $(puburl)$(pubpath)/README.html