From e506f7c2e6fc7a2a15b33ccb62363db4f8d4f02e Mon Sep 17 00:00:00 2001 From: Joe Carstairs Date: Wed, 17 Jun 2026 18:31:46 +0100 Subject: [PATCH] reorganises Makefile, adds headings --- http/Makefile | 45 +++++++++++++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 14 deletions(-) diff --git a/http/Makefile b/http/Makefile index f343c00..2818de2 100644 --- a/http/Makefile +++ b/http/Makefile @@ -1,23 +1,47 @@ include config.mk + +############# +# VARIABLES # +############# + src_files := $(filter-out %.args,$(wildcard src/*.upp*)) src_files += $(filter-out %.args,$(wildcard src/**/*.upp*)) src_files_ext := $(suffix $(src_files)) out_deps_ext := $(src_files_ext:.upp%=%) + layout_files := $(wildcard share/layouts/*.layout.upp*) layouts := $(notdir $(basename $(basename $(layout_files)))) + out_deps := $(addprefix out/,$(src_files:src/%=%)) remove_layout_from_out_deps = out_deps := $$(subst $(1).upp,.,$$(out_deps)) $(foreach layout,$(layouts),$(eval $(call remove_layout_from_out_deps,.$(layout)))) $(eval $(call remove_layout_from_out_deps,)) +blogs := $(subst blogs/,,$(wildcard blogs/*)) + + +############# +# FUNCTIONS # +############# + +blog_post_target = src/$(blog)/%$(if $(BLOG_LAYOUT_$(blog)),.$(BLOG_LAYOUT_$(blog))).upphtml +blog_post_src = blogs/$(blog)/%.$(BLOG_EXT_$(blog)) $$(wildcard bin/*) +blog_src = $(patsubst \ + blogs/$(blog)/%.$(BLOG_EXT_$(blog)),\ + src/$(blog)/%$(if $(BLOG_LAYOUT_$(blog)),.$(BLOG_LAYOUT_$(blog))).upphtml,\ + $(shell find -L "blogs/$(blog)" -type f -and -name *.$(BLOG_EXT_$(blog)))) + define out_rule = out/%.$(ext): src/%$(layout).upp$(ext) ./bin/mkws https://joeac.net "$$$$(realpath $$<)" endef -blog_post_target = src/$(blog)/%$(if $(BLOG_LAYOUT_$(blog)),.$(BLOG_LAYOUT_$(blog))).upphtml -blog_post_src = blogs/$(blog)/%.$(BLOG_EXT_$(blog)) $$(wildcard bin/*) +define blog_rule = +.PHONY: $(blog) +$(blog): $(blog_src) +endef + define blog_post_rule = $(blog_post_target): $(blog_post_src) ./bin/blog \ @@ -27,24 +51,17 @@ $(blog_post_target): $(blog_post_src) -f $$*.$(BLOG_EXT_$(blog)) endef -blogs := $(subst blogs/,,$(wildcard blogs/*)) - -blog_src = $(patsubst \ - blogs/$(blog)/%.$(BLOG_EXT_$(blog)),\ - src/$(blog)/%$(if $(BLOG_LAYOUT_$(blog)),.$(BLOG_LAYOUT_$(blog))).upphtml,\ - $(shell find -L "blogs/$(blog)" -type f -and -name *.$(BLOG_EXT_$(blog)))) - -define blog_rule = -.PHONY: $(blog) -$(blog): $(blog_src) -endef - define prune_blog_rule = .PHONY: prune_$(blog) prune_$(blog): ./bin/prune_blog $(blog) endef + +######### +# RULES # +######### + all: $(blogs) public out .PHONY: out