summaryrefslogtreecommitdiff
path: root/http
diff options
context:
space:
mode:
Diffstat (limited to 'http')
-rw-r--r--http/Makefile93
1 files changed, 47 insertions, 46 deletions
diff --git a/http/Makefile b/http/Makefile
index 13eeb92..fcb2448 100644
--- a/http/Makefile
+++ b/http/Makefile
@@ -1,20 +1,61 @@
include config.mk
-all: microlog blog public out
+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,))
-.PHONY: out
-out: $(out_files)
+define out_rule =
+out/%.$(1): src/%$(2).upp$(1)
+ ./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_post_rule =
+$(blog_post_target): $(blog_post_src)
+ ./bin/blog \
+ -i $(blog) \
+ $(if $(BLOG_LAYOUT_$(blog)),-l $(BLOG_LAYOUT_$(blog))) \
+ $(BLOG_FLAGS_$(blog)) \
+ -f $$*.$(BLOG_EXT_$(blog))
+endef
+
+blogs := $(subst blogs/,,$(wildcard blogs/*))
-blog_src_files = $(patsubst \
+blog_deps = $(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))))
+all: microlog blog public out
+
+.PHONY: out
+out: $(out_deps)
+
+$(foreach ext,$(sort $(out_deps_ext)),\
+ $(eval $(call out_rule,$(ext),)))
+$(foreach layout,$(layouts),\
+ $(foreach ext,$(sort $(out_deps_ext)),\
+ $(eval $(call out_rule,$(ext),.$(layout)))))
+
.PHONY: microlog
-microlog: $(let blog,microlog,$(blog_src_files))
+microlog: $(let blog,microlog,$(blog_deps))
.PHONY: blog
-blog: $(let blog,blog,$(blog_src_files))
+blog: $(let blog,blog,$(blog_deps))
+
+$(foreach blog,$(blogs),\
+ $(foreach layout,$(layouts),\
+ $(eval $(call blog_post_rule,$(blog),$(layout)))))
+$(foreach blog,$(blogs),\
+ $(eval $(call blog_post_rule,$(blog),)))
.PHONY: public
public: $(subst public/,out/,$(shell find -L public/ -type f))
@@ -40,43 +81,3 @@ prune_blog:
.PHONY: clean
clean:
rm -rf out src/microlog src/blog
-
-src_files := $(filter-out %.args,$(wildcard src/*.upp*))
-src_files += $(filter-out %.args,$(wildcard src/**/*.upp*))
-src_files_ext := $(suffix $(src_files))
-out_files_ext := $(src_files_ext:.upp%=%)
-layout_files := $(wildcard share/layouts/*.layout.upp*)
-layouts := $(notdir $(basename $(basename $(layout_files))))
-out_files := $(addprefix out/,$(src_files:src/%=%))
-remove_layout_from_out_files = out_files := $$(subst $(1).upp,.,$$(out_files))
-$(foreach layout,$(layouts),$(eval $(call remove_layout_from_out_files,.$(layout))))
-$(eval $(call remove_layout_from_out_files,))
-
-define out_rule =
-out/%.$(1): src/%$(2).upp$(1)
- ./bin/mkws https://joeac.net "$$$$(realpath $$<)"
-endef
-
-$(foreach ext,$(sort $(out_files_ext)),\
- $(eval $(call out_rule,$(ext),)))
-$(foreach layout,$(layouts),\
- $(foreach ext,$(sort $(out_files_ext)),\
- $(eval $(call out_rule,$(ext),.$(layout)))))
-
-blog_src_files = src/$(blog)/%$(if $(BLOG_LAYOUT_$(blog)),.$(BLOG_LAYOUT_$(blog))).upphtml
-blog_files = blogs/$(blog)/%.$(BLOG_EXT_$(blog)) $$(wildcard bin/*)
-define blog_rule =
-$(blog_src_files): $(blog_files)
- ./bin/blog \
- -i $(blog) \
- $(if $(BLOG_LAYOUT_$(blog)),-l $(BLOG_LAYOUT_$(blog))) \
- $(BLOG_FLAGS_$(blog)) \
- -f $$*.$(BLOG_EXT_$(blog))
-endef
-
-blogs := $(subst blogs/,,$(wildcard blogs/*))
-$(foreach blog,$(blogs),\
- $(foreach layout,$(layouts),\
- $(eval $(call blog_rule,$(blog),$(layout)))))
-$(foreach blog,$(blogs),\
- $(eval $(call blog_rule,$(blog),)))