yhdev/Makefile
Yorhel 6242b2ee9c Rewrite to static site
With a complete reorganisation of the directory structure and most of
the content converted to pandoc-flavoured markdown.

Some TODO's left before this can go live:
- Main page
- Atom feeds
- Bug tracker
2019-03-23 11:56:53 +01:00

139 lines
6.2 KiB
Makefile

# List of all input files. Each file is converted into a .html file at the same path.
#
# The format of each line is: $path $URL $title
#
# If no $URL is given or the $URL is '-', then the input file is assumed to be
# in dat/, otherwise it will be fetched from $URL.
#
# A $title should be given for .pod and .log files, it is ignored for .md files
# because those already have a title embedded in the file.
#
# Supported file types:
# .md: Converted directly into .html with pandoc.
# .pod: Perl's Plain Old Documentation, converted through HTML into a .md
# file which is then converted into .html again with the proper template.
# .log: A ChangeLog-formatted file, converted through .md into .html.
PAGES=\
"doc.md"\
"doc/commvis.md"\
"doc/dcstats.md"\
"doc/easyipc.md"\
"doc/funcweb.md"\
"doc/sqlaccess.md"\
"dump.md"\
"dump/awshrink.md"\
"dump/btrfssize.md"\
"dump/demo.md"\
"dump/grenamr.md"\
"dump/insbench.md"\
"dump/nccolour.md"\
"globster.md"\
"globster/api.pod https://g.blicky.net/globster.git/plain/doc/api.pod The Globster D-Bus API"\
"globster/ctl.pod https://g.blicky.net/globster.git/plain/doc/globsterctl.pod The globsterctl(1) Man Page"\
"globster/daemon.pod https://g.blicky.net/globster.git/plain/doc/globster.pod The globster(1) Man Page"\
"globster/launch.pod https://g.blicky.net/globster.git/plain/doc/globster-launch.pod The globster-launch(1) Man Page"\
"ncdc.md"\
"ncdc/changes.log https://g.blicky.net/ncdc.git/plain/ChangeLog Ncdc Release History"\
"ncdc/faq.md"\
"ncdc/install.md"\
"ncdc/man.pod - Ncdc Manual"\
"ncdc/scr.md"\
"ncdu.md"\
"ncdu/changes.log https://g.blicky.net/ncdu.git/plain/ChangeLog Ncdu Release History"\
"ncdu/jsonfmt.md"\
"ncdu/man.pod https://g.blicky.net/ncdu.git/plain/doc/ncdu.pod Ncdu Manual"\
"ncdu/scr.md"\
"nginx-confgen.md"\
"nginx-confgen/changes.log https://g.blicky.net/nginx-confgen.git/plain/ChangeLog Nginx-confgen Release History"\
"nginx-confgen/man.pod https://g.blicky.net/nginx-confgen.git/plain/nginx-confgen.pod The nginx-confgen(1) Man Page"\
"tuwf.md"\
"tuwf/changes.log https://g.blicky.net/tuwf.git/plain/ChangeLog TUWF Release History"\
"tuwf/man.pod https://g.blicky.net/tuwf.git/plain/lib/TUWF.pod TUWF Documentation"\
"tuwf/man/db.pod https://g.blicky.net/tuwf.git/plain/lib/TUWF/DB.pod TUWF::DB Documentation"\
"tuwf/man/intro.pod https://g.blicky.net/tuwf.git/plain/lib/TUWF/Intro.pod TUWF::Intro Documentation"\
"tuwf/man/misc.pod https://g.blicky.net/tuwf.git/plain/lib/TUWF/Misc.pod TUWF::Misc Documentation"\
"tuwf/man/request.pod https://g.blicky.net/tuwf.git/plain/lib/TUWF/Request.pod TUWF::Request Documentation"\
"tuwf/man/response.pod https://g.blicky.net/tuwf.git/plain/lib/TUWF/Response.pod TUWF::Response Documentation"\
"tuwf/man/validate.pod https://g.blicky.net/tuwf.git/plain/lib/TUWF/Validate.pod TUWF::Validate Documentation"\
"tuwf/man/xml.pod https://g.blicky.net/tuwf.git/plain/lib/TUWF/XML.pod TUWF::XML Documentation"\
"ylib.pod https://g.blicky.net/ylib.git/plain/README.pod Ylib"\
"yxml.md"\
"yxml/man.md"
# Files we need to download
FETCH := $(shell for i in ${PAGES}; do echo "$$i" | grep -Eo '^[^ ]+ +[^-][^ ]+' | sed -E 's/^([^ ]+).*/dat\/\1/'; done)
# List of generated .html files
HTML_OUT := $(shell for i in ${PAGES}; do echo "$$i" | sed -E 's/^([^ ]+)\.[^\. ]+.*$$/pub\/\1.html/'; done)
# List of .md files generated from .pod files
POD_MD := $(shell for i in ${PAGES}; do echo "$$i" | grep -Eo '^[^ ]+\.pod' | sed -E 's/(.+)\.pod$$/dat\/\1.md/'; done)
# List of .md files generated from .log files
CHANGES_MD := $(shell for i in ${PAGES}; do echo "$$i" | grep -Eo '^[^ ]+\.log' | sed -E 's/(.+)\.log$$/dat\/\1.md/'; done)
# All fetched & generated files
CLEAN := ${FETCH} ${POD_MD} ${CHANGES_MD} ${HTML_OUT}
.PHONY: all clean
all: .gitignore ${HTML_OUT}
${FETCH}: dat/%:
@echo "FETCH $*"
@mkdir -p $$(dirname "$@")
@curl -s ${shell for i in ${PAGES}; do case "$$i" in "$* "*) echo "$$i" | awk '{print$$2}';; esac; done} -o "$@"
# There is a 'pod2markdown' program, but going through HTML with a little bit
# of Perl magic tends to give better results, if only because definition lists
# are properly converted this way and I have more control over links.
${POD_MD}: dat/%.md: dat/%.pod mkpod.pl
@echo "POD $*"
@cat "$<" | ./mkpod.pl |\
pandoc -f html -t markdown -s -o "$@" \
--metadata title="${shell for i in ${PAGES}; do case "$$i" in "$*.pod "*) echo "$$i" | sed -E 's/[^ ]+ +[^ ]+ +//';; esac; done}"
@rm -f pod2htmd.tmp pod2html.tmp
${CHANGES_MD}: dat/%.md: dat/%.log mkchangelog.pl
@echo "MD $*"
@./mkchangelog.pl "$*" "${shell for i in ${PAGES}; do case "$$i" in "$*.log "*) echo "$$i" | sed -E 's/[^ ]+ +[^ ]+ +//';; esac; done}" <"$<" >"$@"
${HTML_OUT}: pub/%.html: dat/%.md template.html
@echo "HTML $*"
@mkdir -p $$(dirname "$@")
@cat "$<" |\
perl -pe 's{\[dllink ([^ \]]+)\]}{<a href="/download/$$1">$$1</a><b class="sig"><a href="/download/$$1.asc">pgp</a>-<a href="/download/$$1.sha1">sha1</a>-<a href="/download/$$1.md5">md5</a></b>}' |\
pandoc -f markdown -t html5 --template template.html \
--metadata path1=$$(echo "$*" | sed 's/\/.*//') \
--metadata path2=$$(echo "$*" | sed 's/\//-/' | sed 's/\/.*//') \
--metadata path3=$$(echo "$*" | sed 's/\//-/g') \
--variable menu-$$(case "$*" in\
globster*) echo "globster";;\
ncdc*) echo "ncdc";;\
ncdu*) echo "ncdu";;\
nginx-confgen*) echo "nginx-confgen";;\
tuwf*) echo "tuwf";;\
yxml*) echo "yxml";;\
*) echo "main";;\
esac)\
-o "$@"
.gitignore: Makefile
@echo "GIT"
@echo '*.zip' >$@
@echo '*.gz' >>$@
@echo '*.pdf' >>$@
@for i in ${CLEAN}; do echo "$$i"; done | sort >>$@
clean:
rm -rf ${CLEAN}
find dat pub -type d -empty -print -delete