| 1 | # GNUmakefile --- GNU Makefile for building my personal site |
| 2 | |
| 3 | # Copyright (c) 2020-2021 bandali |
| 4 | # |
| 5 | # Copying and distribution of this file, with or without modification, |
| 6 | # are permitted in any medium without royalty provided the copyright |
| 7 | # notice and this notice are preserved. This file is offered as-is, |
| 8 | # without any warranty. |
| 9 | |
| 10 | |
| 11 | gen = perl txt2pre $(1) < $< > $@ |
| 12 | port := $(if $(port),$(port),8000) |
| 13 | |
| 14 | TXT := $(filter-out bandali-pubkey.txt bandali.txt,$(wildcard *.txt)) |
| 15 | OUT := $(patsubst %.txt,%.html,$(TXT)) |
| 16 | OUT := $(patsubst bandali-%.html,%.html,$(OUT)) |
| 17 | FEEDS := $(wildcard *.atom) $(wildcard *.rss) |
| 18 | NOTES := $\ |
| 19 | libreplanet-2021.txt $\ |
| 20 | fsf-internship-beyond.txt $\ |
| 21 | fsf-internship-intro.txt $\ |
| 22 | bandali-computing.txt $\ |
| 23 | |
| 24 | TXT_FA := $(filter-out fa/bandali.fa.txt,$(wildcard fa/*.fa.txt)) |
| 25 | OUT_FA := $(patsubst fa/%.fa.txt,fa/%.html,$(TXT_FA)) |
| 26 | OUT_FA := $(patsubst fa/bandali-%.html,fa/%.html,$(OUT_FA)) |
| 27 | FEEDS_FA := $(wildcard fa/*.atom) $(wildcard fa/*.rss) |
| 28 | NOTES_FA := $\ |
| 29 | fa/fsf-internship-beyond.fa.txt $\ |
| 30 | fa/fsf-internship-intro.fa.txt $\ |
| 31 | fa/bandali-computing.fa.txt $\ |
| 32 | |
| 33 | all: $(OUT) $(FEEDS) index.html $(OUT_FA) $(FEEDS_FA) fa/index.html |
| 34 | |
| 35 | %.html: bandali-%.txt txt2pre; $(gen) |
| 36 | %.html: %.txt txt2pre; $(gen) |
| 37 | index.html: bandali.txt txt2pre; $(call gen,--index) |
| 38 | notes.%: $(NOTES) txt2pre |
| 39 | perl txt2pre --index --header --format='$*' > $@ |
| 40 | for n in $(NOTES); do perl txt2pre --format='$*' < "$$n" >> $@; done |
| 41 | perl txt2pre --index --footer --format='$*' >> $@ |
| 42 | |
| 43 | fa/%.html: fa/bandali-%.fa.txt txt2pre; $(call gen,--lang='fa') |
| 44 | fa/%.html: fa/%.fa.txt txt2pre; $(call gen,--lang='fa') |
| 45 | fa/index.html: fa/bandali.fa.txt txt2pre; $(call gen,--lang='fa' --index) |
| 46 | fa/notes.%: $(NOTES_FA) txt2pre |
| 47 | perl txt2pre --lang='fa' --index --header --format='$*' > $@ |
| 48 | for n in $(NOTES_FA); do perl txt2pre --lang='fa' --format='$*' < "$$n" >> $@; done |
| 49 | perl txt2pre --lang='fa' --index --footer --format='$*' >> $@ |
| 50 | |
| 51 | |
| 52 | clean: |
| 53 | rm -f $(OUT) $(OUT_FA) index.html fa/index.html |
| 54 | |
| 55 | serve: |
| 56 | python -m http.server $(port) || python -m SimpleHTTPServer $(port) |
| 57 | |
| 58 | watch: |
| 59 | while true; do \ |
| 60 | echo $(TXT) $(TXT_FA) bandali.txt fa/bandali.fa.txt \ |
| 61 | GNUmakefile txt2pre | tr " " "\n" | entr -d make; done |
| 62 | |
| 63 | .PHONY: all clean serve watch |