reorganises Makefile, adds headings

This commit is contained in:
2026-06-17 18:31:46 +01:00
parent 574b2d6646
commit e506f7c2e6
+31 -14
View File
@@ -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