From c0c95fdff57b9bc1da5a782c6132c7af860e1135 Mon Sep 17 00:00:00 2001 From: Dunya Kirkali Date: Sat, 8 Aug 2026 22:07:18 +0200 Subject: [PATCH] Improve word count target (#8) Recurse into source subdirectories and print a total, backported from em_book. The previous 'wc -w source/*' only counted top-level files and errored on subdirectories. - Use find to recurse and sort output for stable ordering - Print a running total - Reference SOURCE_FOLDER instead of hardcoded 'source' - Set SHELL := /bin/bash (needed for process substitution) - Add .PHONY declarations Co-authored-by: Dunya Kirkali Co-authored-by: Shelley --- Makefile | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 8324c67..5baa54a 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,9 @@ SOURCE_FOLDER := source +SHELL := /bin/bash + +.PHONY: all count clean lint + ASCIIDOC_FILES := $(wildcard $(SOURCE_FOLDER)/*.adoc) FIGURES = $(shell find . -name '*.svg') @@ -30,7 +34,14 @@ $(EPUB_PATH): $(ASCIIDOC_FILES) $(FIGURES) Makefile metadata.yaml | output -r asciidoctor-mathematical count: - wc -w source/* + @dir="$(SOURCE_FOLDER)"; \ + total=0; \ + while read -r file; do \ + words=$$(wc -w < "$$file"); \ + total=$$((total + words)); \ + printf "%6d %s\n" "$$words" "$$file"; \ + done < <(find "$$dir" -type f -name "*.adoc" | sort); \ + printf "%6d total\n" "$$total" epubcheck: $(EPUB_PATH) epubcheck $(EPUB_PATH)