summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2023-11-06 14:44:46 +0100
committerThomas Voss <mail@thomasvoss.com> 2023-11-06 14:44:46 +0100
commit038788ff0870713d1906970d51de8ac2fb9626d6 (patch)
treef33d39905ba438d7cc87389bd1a9f444decb31d4
parent64311437ff55ff47c272e531b78116869ffbec34 (diff)
Switch from a Makefile to a (better written) GNUmakefile
-rw-r--r--GNUmakefile53
-rw-r--r--Makefile62
2 files changed, 53 insertions, 62 deletions
diff --git a/GNUmakefile b/GNUmakefile
new file mode 100644
index 0000000..3a63f69
--- /dev/null
+++ b/GNUmakefile
@@ -0,0 +1,53 @@
+.PHONY: check clean serve watch push-fonts
+
+# Source- and destination files
+srcs := $(shell find src -type f -not -name '*.gsp' -or -name 'index.gsp')
+dsts := $(srcs:src/%=out/%)
+dsts := $(dsts:%.gsp=%.html)
+dsts := $(dsts:%.dot=%.svg)
+
+# Destination directories
+dirs := $(sort $(dir $(dsts)))
+
+# Files that most *.gsp files will depend on
+incs := $(wildcard include/*)
+
+all: $(dirs) $(dsts)
+
+$(dirs)&:
+ @mkdir -p $(dirs)
+ @printf 'MKDIR\t%s\n' $(dirs)
+
+out/%: src/%
+ @cp $< $@
+ @printf 'CP\t%s\n' $@
+
+out/%.svg: src/%.dot
+ @dot -Tsvg $< >$@
+ @printf 'DOT\t%s\n' $@
+
+
+# Generate dependencies for GSP pages
+gendeps = $(incs) $(wildcard $(dir $(patsubst out/%.html,src/%.gsp,$1))*.gsp)
+
+.SECONDEXPANSION:
+out/%.html: src/%.gsp $$(call gendeps,$$@)
+ @PATH="$$PATH:./include" \
+ m4 -P $(foreach dir,$(^D),-I$(dir)) include/lib.m4 $< | gsp >$@
+ @printf 'GSP\t%s\n' "$@"
+
+check:
+ LANG=en_US.UTF-8 find src -name 'index.gsp' -exec \
+ aspell --home-dir=./ --ignore-case check {} \;
+
+clean:
+ rm -rf out
+
+serve:
+ darkhttpd out --daemon
+
+watch:
+ git ls-files | entr make
+
+push-fonts:
+ rsync -a fonts vps:/var/www/www.thomasvoss.com/out/
diff --git a/Makefile b/Makefile
deleted file mode 100644
index 6acdb36..0000000
--- a/Makefile
+++ /dev/null
@@ -1,62 +0,0 @@
-.PHONY: check clean serve
-
-gendeps = $(filter-out %/index.gsp,$(wildcard $1/*))
-fonts := $(wildcard fonts/*)
-includes := $(wildcard include/*)
-srcdirs := $(shell find src -type d)
-outdirs := $(srcdirs:src%=out%)
-sources := $(shell find src -type f -regextype egrep -regex '.*/(index\.gsp|.*\.(css|svg|png|dot))')
-outputs := $(sources:src/%=out/%)
-outputs := $(outputs:%.gsp=%.html)
-outputs := $(outputs:%.dot=%.svg)
-
-all: $(outdirs) out/fonts $(outputs)
-
-out/fonts: $(fonts)
- @cp -r fonts out
- @printf 'CP\tfonts\n'
-
-$(outdirs):
- @mkdir -p $@
- @printf 'MKDIR\t%s\n' "$@"
-
-out/%: src/%
- @cp $< $@
- @printf 'CP\t%s\n' "$@"
-
-out/%.svg: src/%.dot
- @dot -Tsvg $< >$@
- @printf 'DOT\t%s\n' "$@"
-
-out/%.html: src/%.gsp $(includes) src/style.css
- @PATH="$$PATH:./include" \
- m4 -P $(foreach dir,$(^D),-I$(dir)) include/lib.m4 $< | gsp >$@
- @printf 'GSP\t%s\n' "$@"
-
-src/srp/fw-ec/index.gsp: $(call gendeps,src/srp/fw-ec)
- @touch $@
-src/srp/gsp/index.gsp: $(call gendeps,src/srp/gsp)
- @touch $@
-src/prj/mmv/index.gsp: $(call gendeps,src/prj/mmv)
- @touch $@
-src/prj/mkpass/index.gsp: $(call gendeps,src/prj/mkpass)
- @touch $@
-src/prj/totp/index.gsp: $(call gendeps,src/prj/totp)
- @touch $@
-
-check:
- LANG=en_US.UTF-8 find src -name 'index.gsp' -exec \
- aspell --home-dir=./ --ignore-case check {} \;
-
-clean:
- rm -rf out
-
-serve:
- darkhttpd out --daemon
-
-watch:
- git ls-files | entr make
-
-push-fonts:
- ./gen-fonts
- rsync -a fonts vps:/var/www/www.thomasvoss.com/out/