.POSIX: DATE = 1970-01-01 VERSION = 0.1.0 NAME = euandre.org 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) HTMLDIR = $(SHAREDIR)/html/$(NAME) EXEC = ./ ## Where to store the installation. Empty by default. DESTDIR = LDLIBS = .SUFFIXES: .SUFFIXES: .adoc .conf .snippets .indexentry .feedentry .sortdata .xml .xmldeps .SUFFIXES: .htmlbody .htmlheader .htmlfooter .htmllisting .html .SUFFIXES: .gz .adoc.conf: ifok -o $@ mkwb conf src/global.conf $< .adoc.htmlbody: ifok -o $@ mkwb htmlbody $< .htmlbody.html: ifok -o $@ mkwb html $< .conf.htmlheader: ifok -o $@ mkwb html -H $< .conf.htmlfooter: ifok -o $@ mkwb html -F $< .conf.htmllisting: ifok -o $@ mkwb indexbody $< .adoc.snippets: ifok -o $@ mkwb snippets $< .conf.indexentry: ifok -o $@ mkwb indexentry $< .htmlbody.feedentry: ifok -o $@ mkwb feedentry $< .conf.sortdata: ifok -o $@ mkwb sortdata $< all: include deps.mk sources.adoc = $(articles.adoc) $(listings.adoc) $(pages.adoc) sources.htmlbody = $(sources.adoc:.adoc=.htmlbody) sources.html = $(sources.adoc:.adoc=.html) sources.snippets = $(sources.adoc:.adoc=.snippets) sources.snippets.gz = $(sources.adoc:.adoc=.snippets.gz) sources.conf = $(sources.adoc:.adoc=.conf) articles.indexentry = $(articles.adoc:.adoc=.indexentry) articles.feedentry = $(articles.adoc:.adoc=.feedentry) articles.sortdata = $(articles.adoc:.adoc=.sortdata) listings.htmlheader = $(listings.adoc:.adoc=.htmlheader) listings.htmlfooter = $(listings.adoc:.adoc=.htmlfooter) listings.htmllisting = $(listings.adoc:.adoc=.htmllisting) listings.htmldeps = $(listings.adoc:.adoc=.htmldeps) listings.html = $(listings.adoc:.adoc=.html) feeds.xmldeps = $(feeds.xml:.xml=.xmldeps) sources = \ $(sources.adoc) \ $(images.svg) \ src/content/style.css \ dynamic-contents = \ $(sources.html) \ $(feeds.xml) \ static-contents = \ $(sources.extras) \ $(images.svg) \ src/content/style.css \ src/content/.well-known/security.txt \ dynamic-contents.gz = $(dynamic-contents:=.gz) static-contents.gz = \ $(images.svg:=.gz) \ src/content/style.css.gz \ src/content/.well-known/security.txt.gz \ contents.gz = \ $(dynamic-contents.gz) \ $(static-contents.gz) \ contents = \ $(dynamic-contents) \ $(static-contents) \ src/content/security.txt \ src/content/security.txt.gz \ all-contents = \ $(contents) \ $(contents.gz) \ derived-assets = \ $(dynamic-contents) \ $(contents.gz) \ $(sources.htmlbody) \ $(sources.snippets) \ $(sources.snippets.gz) \ $(sources.conf) \ src/global.conf \ $(listings.htmlheader) \ $(listings.htmlfooter) \ $(listings.htmllisting) \ $(listings.htmldeps) \ $(feeds.xmldeps) \ $(articles.indexentry) \ $(articles.feedentry) \ $(articles.sortdata) \ email.txt \ baseurl.txt \ expiry.txt \ src/content/security.txt \ src/content/security.txt.gz \ src/content/.well-known/security.txt \ install.html.txt \ install.src.txt \ side-assets = \ src/collections/*/*/*/*/*.html.*.txt \ src/collections/*/*/*/*/*.html.*.txt.gz \ src/collections/*/index.html.*.txt \ src/collections/*/*.sortdata \ src/pages/*/*.html.*.txt \ src/content/.well-known/ \ ## Default target. Builds all artifacts required for testing ## and installation. all: $(derived-assets) all: src/content/public.asc $(derived-assets): Makefile deps.mk $(sources.conf): src/global.conf src/headers.txt src/global.conf: src/base.conf ifok -o $@ mkwb conf -G src/base.conf $(listings.html): cat $*.htmlheader $*.htmllisting $*.htmlbody $*.htmlfooter > $@ $(feeds.xml): ifok -o $@ mkwb feed src/global.conf $*.xmldeps $(contents.gz): gzip -9fk $* touch $@ $(sources.snippets.gz): if [ -s $* ]; then gzip -9fk `cat $*`; fi sed 's/$$/.gz/' $* > $@ src/content/public.asc: gpg --export --armour "`jq -r '.email' < meta.json`" > $@ email.txt: meta.json jq -r '.email' < meta.json > $@ baseurl.txt: meta.json jq -r '.baseurl' < meta.json > $@ expiry.txt: src/content/public.asc gpg --show-key --with-colons src/content/public.asc | \ awk -F: '/^pub:/ { print $$7 }' | \ xargs -I% date -Is -d@% > $@ src/content/security.txt.gz: src/content/.well-known/security.txt.gz src/content/security.txt: src/content/.well-known/security.txt src/content/security.txt src/content/security.txt.gz: ln -fs .well-known/$(@F) $@ src/content/.well-known/security.txt.gz: src/content/.well-known/security.txt src/content/.well-known/security.txt: email.txt baseurl.txt expiry.txt mkdir -p $(@D) printf 'Contact: mailto:%s\n' "`cat email.txt`" > $@ printf 'Expires: %s\n' "`cat expiry.txt`" >> $@ printf 'Encryption: %s/public.asc\n' "`cat baseurl.txt`" >> $@ printf 'Preferred-Languages: en, pt, fr, eo, es\n' >> $@ install.html.txt: $(all-contents) $(sources.snippets) $(sources.snippets.gz) @echo '# find ... > $@. Use -n of make(1) for full listing.' @find $(all-contents) `cat $(sources.snippets) $(sources.snippets.gz)` \ | sed 's|^src/content/||' > $@ install.src.txt: $(sources) @echo '# find ... > $@. Use -n of make(1) for full listing.' @find $(sources) | sed 's|^src/content/||' > $@ 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 rsync --mkpath -a --files-from=install.html.txt src/content/ \ '$(DESTDIR)$(HTMLDIR)' rsync --mkpath -a --files-from=install.src.txt src/content/ \ '$(DESTDIR)$(SRCDIR)' ## 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)$(HTMLDIR)' \ PORT = 3333 ## Run file server for local installed static files. run: serve -n -p $(PORT) -d '$(DESTDIR)$(HTMLDIR)' ALWAYS: