blob: 3956844fa3d5580a36541e5f41463da9cf273ded (
about) (
plain) (
blame)
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
|
#!/bin/sh
set -eu
usage() {
cat <<-'EOF'
Usage:
makemake
makemake -h
EOF
}
help() {
cat <<-'EOF'
Options:
-h, --help show this message
Generate make(1) code for later evaluation by make(1). What
this scripts does is fill the gap where make(1) can't handle
globs and dynamic dependencies, and uses some ad-hoc scripts
to generate those.
EOF
}
for flag in "$@"; do
case "$flag" in
--)
break
;;
--help)
usage
help
exit
;;
*)
;;
esac
done
while getopts 'h' flag; do
case "$flag" in
h)
usage
help
exit
;;
*)
usage >&2
exit 2
;;
esac
done
shift $((OPTIND - 1))
varlist() {
printf '%s = \\\n' "$1"
sed \
-e 's/^/ /' \
-e 's/$/ \\/'
printf '\n'
}
EXTENSIONS='
.conf
.content
.html
.snippets
.htmlbody
.mapentry
'
COLL_EXTENSIONS='
.categoryentry
.indexentry
.xmlentry
'
page_ext_filter="^($(echo "$COLL_EXTENSIONS" |
tr ' ' '\n' |
grep . |
paste -sd'|'
))\$"
extensions() {
echo "$EXTENSIONS" "$COLL_EXTENSIONS" "$@" |
tr ' ' '\n' |
grep .
}
printf '.POSIX:\n\n\n'
for lang in $(langs); do
for c in pages $(collections); do
if [ "$c" = 'pages' ]; then
filter="$page_ext_filter"
src='page'
coll_path=''
else
filter='^$'
src='md'
coll_path="$(coll2path "$lang" "$c")"
fi
mds() {
git ls-files "$CONTENT_PREFIX/$lang/$coll_path"*."$src" |
sed 's|\.page$|.md|'
}
exts() {
extensions | grep -Ev "$filter"
}
mds | varlist "$c.$lang.md"
exts | sed "s|^\(.*\)\$|$c.$lang\1 = \$($c.$lang.md:.md=\1)|"
exts | sed "s|^\(.*\)\$|\$($c.$lang\1)|" | varlist "$c.$lang"
mds | sed 's/^\(.*\)\.md$/\1.mapentry \1.conf \1.content: \1.md/'
mds | sed 's/^\(.*\)\.md$/\1.categoryentry \1.indexentry \1.html: \1.conf \1.content/'
mds | sed 's/^\(.*\)\.md$/\1.snippets \1.htmlbody: \1.html/'
if [ "$c" = 'pages' ]; then
mds | sed 's|\.md$|\.page|' | varlist "pages.$lang.page"
mds | sed "s|^\(.*\).md$|\1.md: \1.page|"
continue
fi
mds | sed 's/^\(.*\)\.md$/\1.xmlentry: \1.htmlbody/'
echo "$CONTENT_PREFIX/$lang/${coll_path}index.categories: \$($c.$lang.categoryentry)"
echo "$CONTENT_PREFIX/$lang/${coll_path}index.html: \$($c.$lang.indexentry) $CONTENT_PREFIX/$lang/${coll_path}index.categories"
echo "$CONTENT_PREFIX/$lang/${coll_path}feed.xml: \$($c.$lang.xmlentry) $CONTENT_PREFIX/$lang/${coll_path}index.categories"
echo "$CONTENT_PREFIX/$lang/${coll_path}index.extrahtml: $CONTENT_PREFIX/$lang/${coll_path}index.html"
echo "$CONTENT_PREFIX/$lang/${coll_path}index.extrafeeds: $CONTENT_PREFIX/$lang/${coll_path}feed.xml"
echo "$CONTENT_PREFIX/$lang/${coll_path}index.series: \$($c.$lang.conf)"
echo "\$($c.$lang.html): $CONTENT_PREFIX/$lang/${coll_path}index.series"
printf '\n\n'
done
coll_path="$(coll2path "$lang" slide)"
git ls-files "$CONTENT_PREFIX/$lang/$coll_path"*.slides |
varlist "slide.$lang.slides"
git ls-files "$CONTENT_PREFIX/$lang/$coll_path"*.slides |
sed 's/^\(.*\)\.slides$/\1.pdf: \1.ps/'
printf '\n\n'
echo "slide.$lang.pdf = \$(slide.$lang.slides:.slides=.pdf)"
echo "all-generated.$lang.slides = \$(slide.$lang.slides)"
echo "all-generated.$lang.pdf = \$(slide.$lang.pdf)"
for e in $(extensions); do
{
if ! printf '%s\n' "$e" | grep -qE "$page_ext_filter"; then
echo pages
fi
collections
} |
sed "s|^\(.*\)\$|\$(\1.$lang$e)|" |
varlist "all-generated.$lang$e"
done
collections |
xargs -I% coll2path "$lang" % |
sed "s|^\(.*\)\$|$CONTENT_PREFIX/$lang/\1index.series|" |
varlist "all-generated.$lang.series"
collections |
xargs -I% coll2path "$lang" % |
sed "s|^\(.*\)\$|$CONTENT_PREFIX/$lang/\1index.categories|" |
varlist "all-generated.$lang.categories"
collections |
xargs -I% coll2path "$lang" % |
sed "s|^\(.*\)\$|$CONTENT_PREFIX/$lang/\1index.extrahtml|" |
varlist "all-generated.$lang.extrahtml"
collections |
xargs -I% coll2path "$lang" % |
sed "s|^\(.*\)\$|$CONTENT_PREFIX/$lang/\1index.extrafeeds|" |
varlist "all-generated.$lang.extrafeeds"
collections |
xargs -I% coll2path "$lang" % |
sed "s|^\(.*\)\$|$CONTENT_PREFIX/$lang/\1index.html|" |
varlist "all-generated.$lang.index"
collections |
xargs -I% coll2path "$lang" % |
sed "s|^\(.*\)\$|$CONTENT_PREFIX/$lang/\1feed.xml|" |
varlist "all-generated.$lang.xml"
extensions '.series' '.categories' '.extrahtml' '.extrafeeds' '.index' '.xml' '.pdf' |
sed "s|^\(.*\)\$|\$(all-generated.$lang\1)|" |
varlist "all-generated.$lang"
printf '\n'
done
git ls-files |
grep '\.uncolored' |
varlist 'svgs.uncolored'
# shellcheck disable=2016
printf 'svgs = $(svgs.uncolored:.uncolored=)\n\n'
{
git ls-files |
grep '\.page' |
sed "s|^$CONTENT_PREFIX\(.*\)\.page|\1.md|"
git ls-files |
grep '\.uncolored' |
sed "s|^$CONTENT_PREFIX\(.*\)\.uncolored|\1|"
} > "$CONTENT_PREFIX"/.gitignore
for e in $(extensions '.series' '.categories' '.extrahtml' '.extrafeeds' '.index' '.xml' '.pdf'); do
langs |
sed "s|^\(.*\)\$|\$(all-generated.\1$e)|" |
varlist "all-generated$e"
done
# shellcheck disable=2016
langs |
sed 's|^\(.*\)$|$(pages.\1.md)|' |
varlist 'pages-mds'
# shellcheck disable=2016
langs |
sed 's|^\(.*\)$|$(all-generated.\1)|' |
varlist 'all-generated'
git ls-files src/ |
grep -v ^"$CONTENT_PREFIX"/ |
varlist 'non-content'
git ls-files "$CONTENT_PREFIX"/ |
grep -v '\.md$' |
grep -v '\.page$' |
grep -v '\.uncolored$' |
grep -v '\.slides$' |
grep -v '\.ps$' |
varlist 'static-content'
|