blob: 20fd6dd07ceea3291a215d08f4cdc8672c9599ad (
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
|
#!/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
'
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"
dir="$CONTENT_PREFIX/$lang"
else
filter='^$'
dir="$CONTENT_PREFIX/$lang/$c"
fi
mds() {
find "$dir"/*.md 2>/dev/null
}
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.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
continue
fi
mds | sed 's/^\(.*\)\.md$/\1.xmlentry: \1.htmlbody/'
echo "$CONTENT_PREFIX/$lang/$c/index.categories: \$($c.$lang.categoryentry)"
echo "$CONTENT_PREFIX/$lang/$c/index.html: \$($c.$lang.indexentry) $CONTENT_PREFIX/$lang/$c/index.categories"
echo "$CONTENT_PREFIX/$lang/$c/feed.xml: \$($c.$lang.xmlentry) $CONTENT_PREFIX/$lang/$c/index.categories"
echo "$CONTENT_PREFIX/$lang/$c/index.extrahtml: $CONTENT_PREFIX/$lang/$c/index.html"
echo "$CONTENT_PREFIX/$lang/$c/index.extrafeeds: $CONTENT_PREFIX/$lang/$c/feed.xml"
printf '\n\n'
done
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 |
sed "s|^\(.*\)\$|$CONTENT_PREFIX/$lang/\1/index.categories|" |
varlist "all-generated.$lang.categories"
collections |
sed "s|^\(.*\)\$|$CONTENT_PREFIX/$lang/\1/index.extrahtml|" |
varlist "all-generated.$lang.extrahtml"
collections |
sed "s|^\(.*\)\$|$CONTENT_PREFIX/$lang/\1/index.extrafeeds|" |
varlist "all-generated.$lang.extrafeeds"
collections |
sed "s|^\(.*\)\$|$CONTENT_PREFIX/$lang/\1/index.html|" |
varlist "all-generated.$lang.index"
collections |
sed "s|^\(.*\)\$|$CONTENT_PREFIX/$lang/\1/feed.xml|" |
varlist "all-generated.$lang.xml"
extensions '.categories' '.extrahtml' '.extrafeeds' '.index' '.xml' |
sed "s|^\(.*\)\$|\$(all-generated.$lang\1)|" |
varlist "all-generated.$lang"
printf '\n'
done
for e in $(extensions '.categories' '.extrahtml' '.extrafeeds' '.index' '.xml'); do
langs |
sed "s|^\(.*\)\$|\$(all-generated.\1$e)|" |
varlist "all-generated$e"
done
# 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$' |
varlist 'static-content'
|