diff options
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 183 |
1 files changed, 183 insertions, 0 deletions
diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..a2ca0fc --- /dev/null +++ b/Makefile @@ -0,0 +1,183 @@ +.POSIX: +DATE = 1970-01-01 +VERSION = 0.1.0 +NAME = website +NAME_UC = $(NAME) +LANGUAGES = en +## Installation prefix. Defaults to "/usr". +PREFIX = /usr +BINDIR = $(PREFIX)/bin +LIBDIR = $(PREFIX)/lib +INCLUDEDIR = $(PREFIX)/include +SRCDIR = $(PREFIX)/src/$(NAME) +SHAREDIR = $(PREFIX)/share +LOCALEDIR = $(SHAREDIR)/locale +MANDIR = $(SHAREDIR)/man +DOCDIR = $(SHAREDIR)/doc/$(NAME) +EXEC = ./ +## Where to store the installation. Empty by default. +DESTDIR = +LDLIBS = + + + +.SUFFIXES: +.SUFFIXES: .adoc .htmlbody .conf .snippets .html .indexentry .feedentry +.SUFFIXES: .sortdata .xml + +.adoc.conf: + mkwb conf src/base.conf src/global.conf $< > $@ + +.adoc.htmlbody: + mkwb htmlbody $< > $@ + +.htmlbody.html: + mkwb html $< > $@ + +.adoc.snippets: + mkwb snippets $< > $@ + +.conf.indexentry: + mkwb indexentry $< > $@ + +.htmlbody.feedentry: + mkwb feedentry $< > $@ + +.conf.sortdata: + mkwb sortdata $< > $@ + + + +all: +include deps.mk + + +sources.adoc = $(articles.adoc) $(pages.adoc) +sources.htmlbody = $(sources.adoc:.adoc=.htmlbody) +sources.html = $(sources.adoc:.adoc=.html) +sources.snippets = $(sources.adoc:.adoc=.snippets) +sources.conf = $(sources.adoc:.adoc=.conf) +articles.indexentry = $(articles.adoc:.adoc=.indexentry) +articles.feedentry = $(articles.adoc:.adoc=.feedentry) +articles.sortdata = $(articles.adoc:.adoc=.sortdata) + +sources = \ + $(sources.adoc) \ + $(images.svg) \ + src/style.css \ + +contents = \ + $(sources.html) \ + src/atom.xml \ + src/blog.html \ + +static-contents = \ + $(images.svg) \ + src/style.css \ + + +derived-assets = \ + $(contents) \ + $(sources.htmlbody) \ + $(sources.snippets) \ + $(sources.conf) \ + src/global.conf \ + $(articles.indexentry) \ + $(articles.feedentry) \ + $(articles.sortdata) \ + out/.gitignore \ + +side-assets = \ + src/blog/*/*/*/*.html*.txt \ + src/*.html.*.txt \ + src/*.sortdata \ + out/ \ + + + +## Default target. Builds all artifacts required for testing +## and installation. +all: $(derived-assets) + + +$(derived-assets): Makefile deps.mk +$(sources.conf): src/global.conf + + +src/global.conf: src/base.conf + mkwb conf src/base.conf > $@ + +src/atom.xml src/blog.html: $(articles.sortdata) src/base.conf src/global.conf + +src/atom.xml: $(articles.feedentry) + mkwb feed src/base.conf src/global.conf $(articles.sortdata) > $@ + +src/blog.html: $(articles.indexentry) src/blog.htmlbody + mkwb indexbody $*.conf $(articles.sortdata) | cat $*.htmlbody - > $@-t + mkwb html $@-t > $@ + rm -f $@-t + +out/.gitignore: + mkdir -p $(@D) + echo '*' > $@ + + + +check-unit: + + +integration-tests = \ + +.PRECIOUS: $(integration-tests) +$(integration-tests): ALWAYS + sh $@ + +check-integration: $(integration-tests) + + +## Run all tests. Each test suite is isolated, so that a parallel +## build can run tests at the same time. The required artifacts +## are created if missing. +check: check-unit check-integration + + + +## Remove *all* derived artifacts produced during the build. +## A dedicated test asserts that this is always true. +clean: + rm -rf $(derived-assets) $(side-assets) + + +## Installs into $(DESTDIR)$(PREFIX). Its dependency target +## ensures that all installable artifacts are crafted beforehand. +install: all + mkdir -p \ + '$(DESTDIR)$(SRCDIR)' \ + + for f in $(contents) $(static-contents) `cat $(sources.snippets)`; do \ + dir='$(DESTDIR)$(DOCDIR)'/"`dirname "$${f#src/}"`"; \ + mkdir -p "$$dir"; \ + cp -P "$$f" "$$dir"; \ + done + for f in $(sources); do \ + dir='$(DESTDIR)$(SRCDIR)'/"`dirname "$${f#src/}"`"; \ + mkdir -p "$$dir"; \ + cp -P "$$f" "$$dir"; \ + done + +## Uninstalls from $(DESTDIR)$(PREFIX). This is a perfect mirror +## of the "install" target, and removes *all* that was installed. +## A dedicated test asserts that this is always true. +uninstall: + rm -rf \ + '$(DESTDIR)$(SRCDIR)' \ + '$(DESTDIR)$(DOCDIR)' \ + + + +## Run it locally. +run: + serve -n -p 3333 -d out/share/doc/website/ + + +ALWAYS: |