chiark / gitweb /
66494c02f2c601017c65379ca47b77e27158f87b
[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 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 o=>$@.new && mv -f $@.new $@
31 use_rsvg=rsvg-convert -f png -o $@.tmp.png $<
32 shell_pipe=set -o pipefail; set -e;
33 make_pnm = pnmdepth 255 | pnmnoraw $o
34
35 pumpkin-books.ps: pumpkin-books.ps.pl bag.pgm pot.pgm droplet.ppm
36         ./$< $(BOOKS) $o
37
38 pumpkin-books.pdf: pumpkin-books.ps
39         gs -q -dNOPAUSE -dBATCH -dPDFSETTINGS=/prepress \
40                 -sDEVICE=pdfwrite -sOutputFile=$@ $<
41
42 bag.pgm: Sack_-_Sac_-_Zak_brown.svg Makefile
43         $(use_rsvg)
44         $(shell_pipe)                                   \
45         pngtopnm <$@.tmp.png -mix -background 'white'   \
46         | ppmtopgm                                      \
47         | $(make_pnm)
48
49 pot.pgm: 146_Kaldrono.svg Makefile
50         $(use_rsvg)
51         $(shell_pipe)                                   \
52         pngtopnm <$@.tmp.png                            \
53         | ppmtopgm                                      \
54         | pnminvert                                     \
55         | $(make_pnm)
56
57 droplet.ppm: droplet.svg Makefile
58         $(use_rsvg)
59         $(shell_pipe)                                   \
60         pngtopnm <$@.tmp.png -mix -background 'white'   \
61         | pnmdepth 255                                  \
62         | $(make_pnm)
63
64 $(addsuffix .ps, $(BOOK_STEMS)): pumpkin-books.ps
65
66 book-%.pdf: book-%.eps
67         rm -f $@; ps2pdf $<
68
69 book-%.eps: book-%.ps
70         rm -f $@; ps2eps $<
71
72 book-%.png: book-%.eps Makefile
73         gm convert -density 100x100 $< $@
74
75 .PRECIOUS: book-%.eps
76
77 PUBLISH_FILES= \
78         $(patsubst %.md,%.md.txt, $(PUBLISH)) \
79         $(patsubst %.md,%.md.html, $(filter $(PUBLISH)) \
80
81 index.html: gen-index README.html
82         ./$^ $(BOOK_STEMS) $o
83
84 %.md.txt: %.md
85         cat $< $o
86
87 %.md.html: %.md Makefile massage-html
88         pandoc -s -Mtitle='Fm4YNbKyBNiS7TNu' $< >$@.tmp
89         ./massage-html $< $@.tmp $o
90
91 %.md.pdf: %.md Makefile
92         perl -pe '$$_ = uc if $$.==1' <$< >$@.tmp
93         pandoc --pdf-engine=wkhtmltopdf -o $@ $@.tmp
94
95 pubssh=c
96 pubpath=games-rules/quacks
97 puburl=https://www.chiark.greenend.org.uk/~ijackson/
98
99 publish: $(PUBLISH)
100         git push origin
101         rsync $^ $(pubssh):public-html/$(pubpath)/.
102         @echo $(puburl)$(pubpath)/README.html