aboutsummaryrefslogtreecommitdiff
path: root/mkdeps.sh
blob: 505ccffbe17498fd3c6ded9547586b429ec2f4d8 (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
#!/bin/sh
set -eu

export LANG=POSIX.UTF-8


normalize() {
	xargs realpath |
		awk -vPWD="$PWD/" '{ print substr($0, length(PWD) + 1) }' |
		sort
}

pages() {
	find src/pages/*/*.adoc -type f                  | normalize
}

articles() {
	find src/collections/*/*/ -type f -name '*.adoc' | normalize
}

listings() {
	find src/collections/*/index.adoc                | normalize
}

extras() {
	find src/content/ -type f \
		-name '*.flac' -or \
		-name '*.webm' -or \
		-name '*.tar.gz'
}

files() {
	pages
	articles
	listings
}


pages                                       | varlist    'pages.adoc'
articles                                    | varlist 'articles.adoc'
listings                                    | varlist 'listings.adoc'
listings | sed 's|/index\.adoc$|/feed.xml|' | varlist 'feeds.xml'
find src/content/img/ -name '*.svg'         | varlist 'images.svg'
extras                                      | varlist 'sources.extras'


files    | sed 's/^\(.*\)\.adoc$/\1.htmlbody\t\1.snippets\t\1.conf:\t\1.adoc/'
files    | sed 's/^\(.*\)\.adoc$/\1.html:\t\1.conf\t\1.htmlbody/'
printf '\n'

articles | sed 's/^\(.*\)\.adoc$/\1.feedentry:\t\1.conf\t\1.htmlbody/'
articles | sed 's/^\(.*\)\.adoc$/\1.sortdata:\t\1.conf/'
printf '\n'

listings | sed 's/^\(.*\)\.adoc$/\1.htmlheader\t\1.htmlfooter:\t\1.conf/'
listings | sed 's/^\(.*\)\.adoc$/\1.htmllisting:\t\1.htmldeps/'
listings | sed 's/^\(.*\)\.adoc$/\1.html:\t\1.htmlheader\t\1.htmlfooter/'
listings | sed 's/^\(.*\)\.adoc$/\1.html:\t\1.htmllisting\t\1.htmlbody/'

for colllink in src/collections/*; do
	c="$(printf '%s' "$colllink" | normalize)"

	printf '\n\n'
	name="$(basename "$c")"
	find "$c"/*/ -type f -name '*.adoc' | varlist "articles.$name.adoc"
	printf 'articles.%s.%s = $(articles.%s.adoc:.adoc=.%s)\n' \
		"$name" 'sortdata  ' "$name" 'sortdata'
	printf 'articles.%s.%s = $(articles.%s.adoc:.adoc=.%s)\n' \
		"$name" 'indexentry' "$name" 'indexentry'
	printf 'articles.%s.%s = $(articles.%s.adoc:.adoc=.%s)\n' \
		"$name" 'feedentry ' "$name" 'feedentry'


	printf '%s/index.htmldeps: $(articles.%s.indexentry)\n' "$c" "$name"
	printf '%s/feed.xmldeps:   $(articles.%s.feedentry)\n'  "$c" "$name"

	printf '%s/index.htmldeps %s/feed.xmldeps: $(articles.%s.sortdata)\n' \
		"$c" "$c" "$name"
	printf '\tfind $(articles.%s.sortdata) > $@\n\n' "$name"
	printf '%s/feed.xml:\t%s/feed.xmldeps\n' "$c" "$c"
done