-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
142 lines (124 loc) · 3.12 KB
/
Makefile
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
LANG=en
MKOBJDIRS=auto
OBJDIR= obj
SCRDIR = ./
DICT=dict
OUTPUT_DICT=aspell-dict
SOURCES = \
ion-rfc.nroff \
ion-rfc-00-preamble.nroff \
ion-rfc-00-toc.nroff \
ion-rfc-01-introduction.nroff \
ion-rfc-02-data-model.nroff \
ion-rfc-03-text-encoding.nroff \
ion-rfc-04-binary-encoding.nroff \
ion-rfc-05-symbols.nroff \
ion-rfc-06-stringclob.nroff \
ion-rfc-07-real-numbers.nroff \
ion-rfc-08-compression.nroff \
ion-rfc-09-security-considerations.nroff \
ion-rfc-10-iana-considerations.nroff \
ion-rfc-appendix.nroff \
ion-rfc-references.nroff
SPELL_OUTPUT = \
ion-rfc.sc \
ion-rfc-00-preamble.sc \
ion-rfc-00-toc.sc \
ion-rfc-01-introduction.sc \
ion-rfc-02-data-model.sc \
ion-rfc-03-text-encoding.sc \
ion-rfc-04-binary-encoding.sc \
ion-rfc-05-symbols.sc \
ion-rfc-06-stringclob.sc \
ion-rfc-07-real-numbers.sc \
ion-rfc-08-compression.sc \
ion-rfc-09-security-considerations.sc \
ion-rfc-10-iana-considerations.sc \
ion-rfc-appendix.sc \
ion-rfc-references.sc
OUTPUT = rfc-ion.txt
TOC = toc.input
#
# Macros
#
print_target = \
@printf "\033[0;32m$@\033[0m\n" ;
.PHONY: all
all: $(OUTPUT) verify
$(call print_target)
verify: check-spelling
$(call print_target)
$(OUTPUT): $(SOURCES) toc.input
$(call print_target)
nroff -ms $(SOURCES) | \
sed 's/FORMFEED\(\[Page[ ]*[0-9]*\]\)[ ]*/ \1\
\
/' \
> $@
toc.input: $(SOURCES)
$(call print_target)
@touch toc.input
# run once to generate a placeholder TOC
# which will block correctly, but include
# wrong page numbers
@nroff -ms $(SOURCES) 2>&1 >/dev/null | \
sed 's/^_/ /' | \
grep -v ': warning: ' | \
sed 's/^/ /' | \
tee $@
# do it again with correct line numbers
nroff -ms $(SOURCES) 2>&1 >/dev/null | \
sed 's/^_/ /' | \
grep -v ': warning: ' | \
sed 's/^/ /' | \
tee $@
check-spelling: $(SPELL_OUTPUT)
$(call print_target)
.SUFFIXES: .sc
%.sc: %.nroff $(OUTPUT_DICT)
$(call print_target)
cat $< | \
aspell list \
--mode nroff \
--lang="$(LANG)" \
--extra-dicts="./$(OUTPUT_DICT)" \
-a | \
sort -u | \
tee $@ | \
xargs -n 1 printf "\\033[0;31m$< >>>\033[0m %s\n"
$(OUTPUT_DICT): $(DICT)
$(call print_target)
aspell --lang="$(LANG)" create master "./$@" < $^
rfc-ion.pdf: $(OUTPUT)
cat $(OUTPUT) | \
awk ' \
{ gsub(/\r/, ""); } \
{ gsub(/[ \t]+$$/, ""); } \
/\[?[Pp]age [0-9ivx]+\]?[ \t]*$$/{ pageend=1; print; next; } \
/^[ \t]*\f/ { formfeed=1; print; next; } \
/^ *Internet.Draft.+[0-9]+ *$$/ { newpage=1; } \
/^ *INTERNET.DRAFT.+[0-9]+ *$$/ { newpage=1; } \
/^RFC.+[0-9]+$$/ { newpage=1; } \
/^draft-[-a-z0-9_.]+.*[0-9][0-9][0-9][0-9]$$/ { \
newpage=1; \
} \
/^[ \t]*$$/ { \
if (pageend && !newpage) next; \
} \
{ \
if ( pageend && newpage && !formfeed ) { print "\f"; } \
pageend=0; formfeed=0; newpage=0; \
print \
} \
' | \
enscript --margins 76::76: -B -q -p - | \
ps2pdf - $@
pdf: rfc-ion.pdf
clean:
$(call print_target)
echo `pwd`
rm -f toc.input
rm -f $(OUTPUT)
rm -f $(OUTPUT_DICT)
rm -f $(SPELL_OUTPUT)
rm -f rfc-ion.pdf