f5b4014263940d96a4562edba1c0a9eaaa0db2da
[~bandali/bndl.org] / GNUmakefile
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 txt2html < $< > $@
12 gen_fa = perl txt2html --lang='fa' < $< > $@
13 port := $(if $(port),$(port),8000)
14
15 TXT := $(filter-out bandali-pubkey.txt bandali.txt,$(wildcard *.txt))
16 OUT := $(patsubst %.txt,%.html,$(TXT))
17 OUT := $(patsubst bandali-%.html,%.html,$(OUT))
18
19 TXT_FA := $(filter-out fa/bandali.fa.txt,$(wildcard fa/*.fa.txt))
20 OUT_FA := $(patsubst fa/%.fa.txt,fa/%.html,$(TXT_FA))
21 OUT_FA := $(patsubst fa/bandali-%.html,fa/%.html,$(OUT_FA))
22
23 all: $(OUT) $(OUT_FA) index.html fa/index.html
24
25 %.html: bandali-%.txt ; $(gen)
26 %.html: %.txt ; $(gen)
27 index.html: bandali.txt ; $(gen)
28
29 fa/%.html: fa/bandali-%.fa.txt ; $(gen_fa)
30 fa/%.html: fa/%.fa.txt ; $(gen_fa)
31 fa/index.html: fa/bandali.fa.txt ; $(gen_fa)
32
33
34 clean:
35 rm -f $(OUT) $(OUT_FA) index.html fa/index.html
36
37 serve:
38 python -m http.server $(port) || python -m SimpleHTTPServer $(port)
39
40 watch:
41 while true; do \
42 echo $(TXT) $(TXT_FA) bandali.txt fa/bandali.fa.txt \
43 GNUmakefile txt2html | tr " " "\n" | entr -d make; done
44
45 .PHONY: all clean serve watch