#!/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