Mike Gerwitz

Activist for User Freedom

aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Gerwitz <mtg@gnu.org>2019-01-08 00:11:20 -0500
committerMike Gerwitz <mtg@gnu.org>2019-01-11 23:46:13 -0500
commitb182ea79b3a7ac07f673870edab1bd3d6074c618 (patch)
tree3ce02ad905ace0498829d52b4b223790b9d63266 /Makefile
parent643a9858f125e2fc2c4557a9c0d706b72c09259a (diff)
downloadthoughts-b182ea79b3a7ac07f673870edab1bd3d6074c618.tar.gz
thoughts-b182ea79b3a7ac07f673870edab1bd3d6074c618.tar.bz2
thoughts-b182ea79b3a7ac07f673870edab1bd3d6074c618.zip
Majority of work on generation of new static site
I didn't originally intend for all of this to be in a single commit. But here we are. I don't have the time to split these up more cleanly; this project is taking more time than I originally hoped that it would. This is a new static site generator. More information to follow in the near future (hopefully in the form of an article), but repo2html is now removed. See code comments for additional information; I tried to make it suitable as a learning resource for others. It is essentially a set of shell scripts with a fairly robust build for incremental generation. The site has changed drastically, reflecting that its purpose has changed over the years: it is now intended for publishing quality works (or at least I hope), not just a braindump. This retains most of the text of the original pages verbatim, with the exception of the About page. Other pages may have their text modified in commits that follow. Enhancements to follow in future commits.
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile201
1 files changed, 115 insertions, 86 deletions
diff --git a/Makefile b/Makefile
index 9a8dad4..20a9475 100644
--- a/Makefile
+++ b/Makefile
@@ -1,107 +1,136 @@
# Builds thoughts (well, not quite like that)
#
-# Copyright (C) 2013 Mike Gerwitz
+# Copyright (C) 2013, 2018, 2019 Mike Gerwitz
#
-# This program is free software: you can redistribute it and/or modify
+# This program is free software: you can rewww-ribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
-# This program is distributed in the hope that it will be useful,
+# This program is www-ributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-# #
-
-pages := $(patsubst %.pg, %.html, \
- $(shell find docs/ -name '*.pg'))
-pages_md := $(patsubst %.md, %.html, \
- $(shell find docs/ -name '*.md'))
-articles := $(patsubst %.txt, %.html, \
- $(shell find docs/ -maxdepth 2 -name '*.txt' | grep -Fv /gh/))
-# articles in TeX with an inappropriate var name
-texticles=$(patsubst %/, %.html, $(dir $(shell find docs/ -name 'Makefile')))
-www_root := www-root/
-url_root := https://mikegerwitz.com
-repo_url := https://mikegerwitz.com/projects/thoughts
-repo_commit_url := '$(repo_url)/commit/?id=%s'
-
-# configured repo2html command
-repo2html := repo2html \
- -t 'Mike Gerwitz' \
- -d 'Free Software Hacker+Activist' \
- -c 'Mike Gerwitz' \
- -l 'This content is licensed under the Creative Commons Attribution-ShareAlike 4.0 International License.' \
- -C '/style.css' \
- -f 'tools/thoughts-fmt' \
- -F .listfilter \
- -T '$(PWD)/tpl' \
- -u '$(repo_url)' \
- -U '$(repo_commit_url)' \
- -E ''
-
-.PHONY: default clean pages articles thoughts docs
+#
+# This project is a static site generator. This Makefile was written to
+# have deep knowledge of every aspect of the site so that it can be
+# incrementally built, and so that all relevant portions will be properly
+# rebuilt any time something changes.
+#
+# Source files are automatically identified through either wildcards or
+# Makefile generation with one important exception: things in src/. The
+# reason is that src/ contains a number of things we don't want published,
+# and the distinction is too messy to codify. Of course, another option is
+# to clean that up, but I don't mind being explicit for now.
+##
+
+.DELETE_ON_ERROR:
+
+postsrc := $(wildcard post/*.md)
+pmeta := $(postsrc:.md=.meta)
+phtml := $(postsrc:.md=.html)
+pmk := $(pmeta:.meta=.mk)
+
+www-root = www-root
+
+# articles in TeX
+texticles = $(wildcard papers/*/)
+www-paper = $(patsubst papers/%/, $(www-root)/papers/%.pdf, $(texticles)) \
+ $(patsubst papers/%/, $(www-root)/papers/%.dvi, $(texticles))
+
+images = $(wildcard images/*.*) $(wildcard images/tp/*.*)
+www-images = $(patsubst images/%, $(www-root)/images/%, $(images))
+
+cssfonts := $(shell build-aux/lsfonts)
+www-fonts := $(patsubst fonts/%, $(www-root)/fonts/%, $(cssfonts))
+
+# Manually maintain both for simplicity and to ensure something does not get
+# unintentionally published.
+srcpages = src/index.html src/about.html src/papers.html src/posts.html \
+ src/talks.html src/404.html src/about/inside.html \
+ src/about/githubbub.html \
+ src/about/resume.html $(wildcard src/about/resume/*)
+www-pages = $(patsubst src/%, $(www-root)/%, $(srcpages))
+
+www-files = $(www-pages) $(www-root)/style.css $(www-root)/rss.xml $(www-paper) \
+ $(www-images) $(www-fonts)
+
+RSS_N=10
+export WWW_URL
+
+
+.PHONY: default clean webroot
default: www-root
-thoughts:
- mkdir -p "$(www_root)"
- $(repo2html) \
- -R 40 \
- -o "$(www_root)" \
- '$(url_root)' \
- > "$(www_root)/index.html"
-
-# all .txt articles will be compiled with asciidoc, then post-processed with the
-# mgify script
-%.html: %.txt
- asciidoc -fasciidoc.conf -v \
- -a stylesdir= \
- -a themedir=$(PWD)/ \
- $<
- ./tools/mgify "$@"
-
-# "pages"
-%.html: %.pg docs/papers/.list tpl/.config
- $(repo2html) -icontent -ftools/extfmt <$< >$@
-%.html: %.md tpl/.config
- $(repo2html) -icontent -ftools/mdfmt <$< >$@
-
-# TeX papers are expected to have their own makefiles as well as an abstract.tex
-%.html: %/abstract.tex
- $(MAKE) -C '$(dir $<)' pdf dvi
- url_root='$(url_root)' ./tools/texdoc '$(dir $<)' | $(repo2html) -icontent -ftools/extfmt >$@
+%.meta: %.html src/post2meta src/post2html
+ src/post2meta $< > $@
+src/talks.html: src/talks.rec
+src/papers.html: src/papers.rec
+%.html %.xml: %.sh post/list src/mkheader src/header.tpl.htm src/footer.tpl.htm $(phtml)
+ $< > $@
+%.html: %.md src/post2html src/mkheader src/h12title src/header.tpl.htm src/footer.tpl.htm src/pandoc.tpl
+ src/post2html $< > $@
+%.html: %.htm src/mkheader src/h12title src/header.tpl.htm src/footer.tpl.htm
+ src/mkheader about @__PAGE_TITLE__@ \
+ | cat - $< src/footer.tpl.htm \
+ | src/h12title @__PAGE_TITLE__@ \
+ > $@
+
+# special outputs
+src/rss.xml: src/rss.sh post/list $(phtml)
+ head -n$(RSS_N) post/list | xargs $< > $@
+
+posts: $(pmeta) $(phtml)
+post/list: $(pmeta)
+ ls post/*.meta | sort -rn > $@
+
+# Rules for generating the final webroot from the posts are themselves
+# generated. This also appends dependencies to www-posts.
+.PHONY: www-posts
+post/%.mk: post/%.meta build-aux/mkmk
+ build-aux/mkmk $(www-root) $< > $@
+
+# Note the conditional include only for webroot. This is needed for two
+# reasons:
+# 1. To avoid including them on `clean' (see GNU Make manual, which is
+# where this snippet originated from); and
+# 2. Because otherwise including the makefiles causes every pmete to be
+# built, which is unnecessary for all but `webroot'.
+#
+# The alternative (and perhaps more proper means) to #2 would be to run mkmk
+# as part of the meta target. This was originally done until a solution to
+# `clean' was needed; this handles both situations well.
+ifeq ($(MAKECMDGOALS),webroot)
+include $(pmk)
+endif
+
+webroot: www-posts $(www-files)
+$(www-root)/style.css: style.css
+ install -Dma+r $< $@
+$(www-root)/%: src/%
+ install -Dma+r $< $@
+$(www-root)/fonts/%: fonts/%
+ install -Dma+r $< $@
+$(www-root)/papers/%: papers/%
+ install -Dma+r $< $@
+$(www-root)/images/%: images/%
+ install -Dma+r $< $@
+
+
+# TeX papers are expected to have their own Makefiles as well as an abstract.tex
+papers/%.pdf: papers/%/abstract.tex
+ $(MAKE) -C $(dir $<) pdf
+ cp $(dir $<)/$*.pdf $@
+papers/%.dvi: papers/%/abstract.tex
+ $(MAKE) -C $(dir $<) dvi
+ cp $(dir $<)/$*.dvi $@
docs/papers/.list: thoughts articles
echo "$(articles) $(texticles)" | tr ' ' '\n' | tools/doclist >$@
-images: images/tp/Makefile
- $(MAKE) -C '$(dir $<)' all check
-images/tp/Makefile: images/tp/gen-makefile
- ( cd images/tp/ && ./gen-makefile ) >$@
-
-pages: $(pages) $(pages_md)
-articles: $(articles) $(texticles)
-docs: pages articles
-www-root: docs thoughts images
- mkdir -p www-root/papers
- ( cd docs/ \
- && find . -maxdepth 2 -name '*.html' -exec ../tools/doc-cp {} ../www-root/{} \; \
- && find . -maxdepth 3 \( -name '*.pdf' -o -name '*.dvi' \) -exec cp {} ../www-root/{} \; \
- )
- mkdir -p www-root/images/
- cp -v images/*.* images/tp/*.png www-root/images/
- cp -rv fonts/ www-root/
- cp -rv _raw/* www-root/
- cp -v style.css www-root/
- mkdir -p www-root/docs
- cp -rv docs/gh/ www-root/docs/
- cp -rv docs/about/resume www-root/about/
- cp -rv docs/hoxsl www-root/hoxsl
-
clean:
- rm -rf www-root/
- rm -f $(pages) $(pages_md) $(articles) $(texticles)
+ rm -rf $(www-root) $(pmeta) $(phtml) $(pmk)