transition to a simple txt-based setup, plus txt2html
[~bandali/bndl.org] / GNUmakefile
diff --git a/GNUmakefile b/GNUmakefile
new file mode 100644 (file)
index 0000000..2330e5d
--- /dev/null
@@ -0,0 +1,45 @@
+# GNUmakefile --- GNU Makefile for building my personal site
+
+# Copyright (c) 2020-2021 bandali
+#
+# Copying and distribution of this file, with or without modification,
+# are permitted in any medium without royalty provided the copyright
+# notice and this notice are preserved.  This file is offered as-is,
+# without any warranty.
+
+
+gen = perl txt2html < $< > $@
+gen_fa = perl txt2html 'fa' < $< > $@
+port := $(if $(port),$(port),8000)
+
+TXT := $(filter-out bandali-pubkey.txt bandali.txt,$(wildcard *.txt))
+OUT := $(patsubst %.txt,%.html,$(TXT))
+OUT := $(patsubst bandali-%.html,%.html,$(OUT))
+
+TXT_FA := $(filter-out fa/bandali.fa.txt,$(wildcard fa/*.fa.txt))
+OUT_FA := $(patsubst fa/%.fa.txt,fa/%.html,$(TXT_FA))
+OUT_FA := $(patsubst fa/bandali-%.html,fa/%.html,$(OUT_FA))
+
+all: $(OUT) $(OUT_FA) index.html fa/index.html
+
+%.html: bandali-%.txt ; $(gen)
+%.html: %.txt ; $(gen)
+index.html: bandali.txt ; $(gen)
+
+fa/%.html: fa/bandali-%.fa.txt ; $(gen_fa)
+fa/%.html: fa/%.fa.txt ; $(gen_fa)
+fa/index.html: fa/bandali.fa.txt ; $(gen_fa)
+
+
+clean:
+       rm -f $(OUT) $(OUT_FA) index.html fa/index.html
+
+serve:
+       python -m http.server $(port) || python -m SimpleHTTPServer $(port)
+
+watch:
+       while true; do \
+       echo $(TXT) $(TXT_FA) bandali.txt fa/bandali.fa.txt \
+       GNUmakefile txt2html | tr " " "\n" | entr -d make; done
+
+.PHONY: all clean serve watch