blob: c5a63d9c374fb62a73c6f759ec1ef6c562341655 (
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
|
pages = $(if $(TITLE),64lines.txt title.txt break)
pages += way-to-be-great.txt space lost-pen.txt space authenticated-counterfeit.txt break
pages += bitcoin.txt space monad-tutorial.txt break
pages += why.txt space con-job.txt break
pages += argument.txt space medium.txt break
pages += introduction.txt $(if $(FINALE),finale.txt) break
pages += human-communication.txt
output_name = poetrybook
pdf_viewer = evince
.DEFAULT_GOAL = view
output_txt = $(output_name).txt
output_pdf = $(output_name).pdf
SIDES = two-sided-short-edge
LP = lp
LP += $(if $(SIDES), -o sides=$(SIDES))
LPDF = lpdf
NUMBER_UP = 2
LEFT_MARGIN = 100
TOP_MARGIN = 20
MARGIN_ARGS = left=$(LEFT_MARGIN) top=$(TOP_MARGIN)
SCALING = none
LPDF += $(if $(PAGES), -P $(PAGES))
LPDF += $(addprefix -o page-, $(MARGIN_ARGS))
LPDF += $(if $(SCALING),-o print-scaling=$(SCALING))
LPDF += $(if $(NUMBER_UP),-o number-up=$(NUMBER_UP))
LPDF += $(if $(SIDES),-o sides=$(SIDES))
define concatenate_with_terminator
@($(foreach f,$(+), cat < $(f) && printf $(1);)) > $@.tmp
@$(done)
endef
dirs = build
$(dirs):
@mkdir -p $@
done = mv -T -- $@.tmp $@
.INTERMEDIATE: build/$(output_txt)
build/break: | build
printf \\f > $@
build/space: | build
printf \\n\\n\\n > $@
build/$(output_txt): $(addprefix build/,$(pages)) | build
cat $+ > $@.tmp
$(done)
%.pdf: %.txt
$(LPDF) $< > $@.tmp
$(done)
build/%: % | build
cp --reflink -T -- $< $@
clean:
-rm -rf build
.PHONY: view print viewall printall realview realprint
view: clean realview
print: clean realprint
realview: build/$(output_pdf)
-$(pdf_viewer) $< &
realprint: build/$(output_pdf)
$(LP) $^
.PHONY: install
install:
apt install --no-upgrade printer-driver-cups-pdf evince
|