about summary refs log tree commit diff
path: root/makefile
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--makefile54
1 files changed, 28 insertions, 26 deletions
diff --git a/makefile b/makefile
index 0348ce2..b495f54 100644
--- a/makefile
+++ b/makefile
@@ -1,41 +1,38 @@
+PANDOC := pandoc
+ENTR   := entr
+CADDY  := caddy
+
 all: gen
 
-# generator
-ZIG     ?= /usr/bin/zig-bin-0.16.0
-rbc_SRC := src/main.zig $(wildcard src/*.zig)
-rbc_BIN := bin/rbc
+site_DIR := site
+htm_DIR := src/inc
 
-ifdef REL
-rbc_OPT := ReleaseFast
-else
-rbc_OPT := Debug
-endif
+htm_SRC := $(shell find $(htm_DIR) -name '*.htm' -not -name 'meta.*' -print)
+htm_OUT := $(subst $(htm_DIR),$(site_DIR),$(htm_SRC:%.htm=%.html))
 
-$(rbc_BIN): $(rbc_SRC)
-	@ mkdir -p $(dir $@)
-	$(ZIG) build-exe -lc -O $(rbc_OPT) -freference-trace -femit-bin=$@ $<
+mdn_SRC := $(wildcard $(htm_DIR)/*.md)
+mdn_OUT := $(mdn_SRC:%.md=%.htm)
 
-rbc: $(rbc_BIN)
+gen: $(rbc_BIN) $(mdn_OUT) $(htm_OUT)
 
-check:
-	$(ZIG) test -lc -O Debug -freference-trace --test-filter Context src/Context.zig
+gen-htm: $(htm_OUT)
+	$(MAKE) $(htm_OUT)
 
-clean:
-	@ rm -rf $(rbc_BIN)
+$(site_DIR)/%.html: $(htm_DIR)/%.htm
+	$(rbc_BIN) $< $(site_DIR)
 
-site-clean:
-	@ rm -rf site/* $(md_SRC:%.md=%.htm)
+gen-mdn: $(mdn_OUT)
+	$(MAKE) $(mdn_OUT)
 
-gen: $(rbc_BIN)
-	# TODO: fix the panic
-	@ $(rbc_BIN) md
-	@ $(rbc_BIN) gen
+$(mdn_OUT): %.htm: %.md
+	$(PANDOC) --from=markdown+wikilinks_title_after_pipe+autolink_bare_uris --to=html5 --lua-filter=./preproc.lua --strip-comments --output=$@ $<
 
 watch:
-	@ $(rbc_BIN) watch
+	@ printf '%s\n' $(htm_SRC) $(mdn_SRC) | $(ENTR) -cd -- $(MAKE) /_
 
 serve:
-	@ $(rbc_BIN) serve
+	@ $(CADDY) fmt --overwrite
+	@ $(CADDY) run --watch
 
 watch-and-serve:
 	@ ${MAKE} -j2 watch serve
@@ -43,7 +40,12 @@ watch-and-serve:
 was: watch-and-serve
 dev: watch-and-serve
 
-.PHONY: gen clean serve watch watch-and-serve was
+site-clean:
+	rm -rf site/*
+	rm -rf $(mdn_SRC:%.md=%.htm)
+
+.PHONY: gen serve watch watch-and-serve was site-clean
 
 include webdeploy.mk
 include edit.mk
+include rbc.mk