From 629664bd50ed4e72cffc33bf2e7082119d483469 Mon Sep 17 00:00:00 2001 From: Kévin Le Gouguec Date: Sun, 12 Apr 2020 20:00:08 +0200 Subject: Finish fixing some files being inaccessible Make generate-deps.py compute the list of indices instead of relying on the list of source folders that contain text files, otherwise we will miss intermediate folders that do not contain any file. Remove TODO entry to maintain Makefile dependencies to scripts: that sounds too tedious. Let's assume that at some point the Makefile and these scripts will be bundled together into a proper package. --- repo/www/Makefile | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'repo/www/Makefile') diff --git a/repo/www/Makefile b/repo/www/Makefile index bc9933a..9050626 100644 --- a/repo/www/Makefile +++ b/repo/www/Makefile @@ -1,28 +1,30 @@ -# TODO: set dependencies to scripts correctly +# TODO: add a target for the file tree; use it in generate-* scripts. TOP_DIR = ../.. OUT_DIR = $(TOP_DIR)/public TEXT_FILES = md org dirname = $(patsubst %/,%,$(dir $(1))) +dirnames = $(sort $(call dirname,$(1))) text_patterns = $(foreach ext,$(TEXT_FILES),'$(TOP_DIR)/**.$(ext)') - -text_folders = $(sort $(call dirname,$(shell git ls-files $(text_patterns)))) -page_folders = $(patsubst $(TOP_DIR)%,$(OUT_DIR)%,$(text_folders)) -indices = $(addsuffix /index.html,$(page_folders)) +text_folders = $(call dirnames,$(shell git ls-files $(text_patterns))) all: site +# Defines $(pages) and $(indices). dependencies = deps.mk include $(dependencies) -$(dependencies): generate-deps.py $(text_folders) - python3 $< "$(TEXT_FILES)" $(OUT_DIR) +$(dependencies): $(text_folders) + ./generate-deps.py "$(TEXT_FILES)" $(OUT_DIR) site: $(pages) $(indices) -$(page_folders): +# $(text_folders) may be missing some intermediate folders since it +# only contains folders that hold some text files. Rely on the full +# list of HTML pages and indices. +$(call dirnames,$(pages) $(indices)): mkdir -p $@ $(pages): @@ -30,8 +32,8 @@ $(pages): # ⚠ When tweaking this rule, check whether it still works for the # top-level index.html. -$(indices): $(OUT_DIR)%/index.html: $(TOP_DIR)% generate-index.py | $(OUT_DIR)% - python3 generate-index.py "$(TEXT_FILES)" "$<" $@ +$(indices): $(OUT_DIR)/%index.html: + ./generate-index.py "$(TEXT_FILES)" "$(patsubst %/,%,$*)" $@ clean: -rm $(dependencies) -- cgit v1.2.3