summaryrefslogtreecommitdiffhomepage
path: root/Makefile
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2023-10-29 22:39:48 +0100
committerThomas Voss <mail@thomasvoss.com> 2023-10-29 22:39:48 +0100
commit9cad508b5c98ca1029460807249cafb712f28f1e (patch)
tree2ad62d1ca57b7dc691550865cb7fb0b55c26da34 /Makefile
parentc88b4c2d0842dfbb32fa744dde781601b9e4e7cf (diff)
Migrate the site to GSP and a Makefile
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile84
1 files changed, 78 insertions, 6 deletions
diff --git a/Makefile b/Makefile
index ca084fe..2040f7c 100644
--- a/Makefile
+++ b/Makefile
@@ -1,10 +1,82 @@
-all: bilingual_sort server
+# Eurozone coin and -banknote types
+eznotes := 5e 10e 20e 50e 100e 200e 500e
+ezcoins := 1c 2c 5c 10c 20c 50c 1e 2e
+ezcodes := $(shell \
+ grep -Eo '^[A-Z]{2}' data/coins \
+ | sort \
+ | uniq \
+ | tr A-Z a-z \
+)
-bilingual_sort: bilingual_sort.c
- ${CC} -O3 -o $@ $<
+# Source files that aren’t dynamically generated
+sources := \
+ $(shell find src -type f -name 'index.gsp') \
+ $(shell find src -type f -name '*.css') \
+ $(shell find src -type f -name '*.svg')
-server: server.go
- go build $<
+# Different euro coin and -banknote page types
+eurocc := $(ezcodes:%=out/euro/%/index.html)
+eurocd := $(ezcoins:%=out/euro/%/index.html)
+eurond := $(eznotes:%=out/euro/%/index.html)
+euront := out/euro/tn/index.html
+
+# Output files we want to generate
+outputs := $(sources:%.gsp=%.html)
+outputs := $(outputs:src/%=out/%)
+outputs := $(outputs) $(eurocc) $(eurocd) $(eurond) $(euront)
+
+# Folders we need to generate before the files. The sort function is used to
+# remove duplicates.
+outdirs := $(sort $(dir $(outputs)))
+
+# Common files that (almost) all *.gsp files depend on
+gspdeps := lib.m4 src/nav.gsp src/head.gsp src/foot.gsp src/table-key.gsp
+
+# Dependencies for certain /euro files
+euroxyzdeps := src/euro/index.xyz.gsp src/euro/nav.xyz.gsp data/country-info
+euroccdeps := $(subst xyz,ccoins,$(euroxyzdeps)) data/coins data/ccs data/errors
+eurocddeps := $(subst xyz,dcoins,$(euroxyzdeps)) data/coins
+euronddeps := $(subst xyz,dnotes,$(euroxyzdeps)) data/notes data/note-info
+eurotndeps := src/euro/index.tnotes.gsp src/euro/nav.dnotes.gsp data/notes
+
+# Macro to get a countries demonym from their country code
+demonym = $(shell awk '$$1 == toupper("$1") { print $$2 }' data/country-info)
+
+all: $(outdirs) $(outputs)
+
+$(outdirs)&:
+ mkdir -p $(outdirs)
+
+out/%.html: src/%.gsp $(gspdeps)
+ m4 -P lib.m4 $< | gsp >$@
+
+$(eurocc): out/euro/%/index.html: $(gspdeps) $(euroccdeps)
+ m4 -P -D__coins -D__code=$* -D__demonym=$(call demonym,$*) \
+ lib.m4 src/euro/index.ccoins.gsp | gsp >$@
+
+$(eurocd): out/euro/%/index.html: $(gspdeps) $(eurocddeps)
+ m4 -P -D__coins -D__denom=$* lib.m4 src/euro/index.dcoins.gsp | gsp >$@
+
+$(eurond): out/euro/%/index.html: $(gspdeps) $(euronddeps)
+ m4 -P -D__notes -D__denom=$* lib.m4 src/euro/index.dnotes.gsp | gsp >$@
+
+$(euront): out/euro/%/index.html: $(gspdeps) $(eurotndeps)
+ m4 -P -D__notes lib.m4 src/euro/index.tnotes.gsp | gsp >$@
+
+out/%.css: src/%.css
+ cp $< $@
+
+out/%.svg: src/%.svg
+ cp $< $@
+
+check:
+ LANG=en_US.UTF-8 find src -name '*.gsp' -exec \
+ aspell --home-dir=./ --ignore-case check {} \;
clean:
- rm -f bilingual_sort server
+ rm -rf out
+
+serve:
+ darkhttpd out --daemon
+
+.PHONY: all check clean serve