summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2025-04-03 15:36:16 -0300
committerEuAndreh <eu@euandre.org>2025-04-03 15:36:16 -0300
commit55b752812db4a45278fc3ab65b4d435db9a77684 (patch)
tree73567ab6e477325f549b27efc89b4f98cad3786c /Makefile
parentUpdate deps.mk (diff)
downloadpapo.im-55b752812db4a45278fc3ab65b4d435db9a77684.tar.gz
papo.im-55b752812db4a45278fc3ab65b4d435db9a77684.tar.xz
Makefile: Generate .gz files and update to newer mkwb
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile127
1 files changed, 106 insertions, 21 deletions
diff --git a/Makefile b/Makefile
index 914d99a..6a95693 100644
--- a/Makefile
+++ b/Makefile
@@ -23,8 +23,9 @@ LDLIBS =
.SUFFIXES:
-.SUFFIXES: .adoc .conf .snippets .indexentry .feedentry .sortdata .xml .xmldeps
+.SUFFIXES: .adoc .conf .snippets .indexentry .feedentry .sortdata .xml
.SUFFIXES: .htmlbody .htmlheader .htmlfooter .htmllisting .html
+.SUFFIXES: .gz
.adoc.conf:
mkwb conf src/global.conf $< > $@
@@ -66,6 +67,7 @@ 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)
@@ -73,16 +75,14 @@ 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 \
-contents = \
+dynamic-contents = \
$(sources.html) \
$(feeds.xml) \
@@ -90,34 +90,76 @@ static-contents = \
$(sources.extras) \
$(images.svg) \
src/content/style.css \
+ src/content/.well-known/security.txt \
+dynamic-contents.gz = $(dynamic-contents:=.gz)
-derived-assets = \
+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-snippets = \
+ $(sources.snippets) \
+ $(sources.snippets.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 \
+ src/all-contents.txt \
+ src/all-snippets-list.txt \
+ src/install.txt \
+ src/sources.txt \
+ install.txt \
+ sources.txt \
side-assets = \
src/collections/*/*/*/*/*.html.*.txt \
+ src/collections/*/*/*/*/*.html.*.txt.gz \
src/collections/*/index.html.*.txt \
+ src/collections/*/sortdata.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
@@ -131,7 +173,59 @@ $(listings.html):
cat $*.htmlheader $*.htmllisting $*.htmlbody $*.htmlfooter > $@
$(feeds.xml):
- mkwb feed src/global.conf $*.xmldeps > $@
+ mkwb feed src/global.conf $(@D)/sortdata.txt > $@
+
+$(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' >> $@
+
+src/sources.txt:
+ printf '%s\n' $(sources) > $@
+
+src/all-contents.txt:
+ printf '%s\n' $(all-contents) > $@
+
+src/all-snippets-list.txt:
+ printf '%s\n' $(all-snippets) > $@
+
+src/install.txt: src/all-contents.txt src/all-snippets-list.txt $(all-snippets)
+ cat src/all-contents.txt `cat src/all-snippets-list.txt` > $@
+
+sources.txt: src/sources.txt
+install.txt: src/install.txt
+sources.txt install.txt:
+ sed 's|^src/content/||' src/$(@F) > $@
@@ -163,19 +257,10 @@ clean:
## 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)$(HTMLDIR)'/"`dirname "$${f#src/content/}"`"; \
- mkdir -p "$$dir"; \
- cp -P "$$f" "$$dir"; \
- done
- for f in $(sources); do \
- dir='$(DESTDIR)$(SRCDIR)'/"`dirname "$${f#src/content/}"`"; \
- mkdir -p "$$dir"; \
- cp -P "$$f" "$$dir"; \
- done
+ rsync --mkpath -a --files-from=install.txt src/content/ \
+ '$(DESTDIR)$(HTMLDIR)'
+ rsync --mkpath -a --files-from=sources.txt src/content/ \
+ '$(DESTDIR)$(SRCDIR)'
## Uninstalls from $(DESTDIR)$(PREFIX). This is a perfect mirror
## of the "install" target, and removes *all* that was installed.