Files
letterpress/Makefile
Dunya Kirkali c0c95fdff5
Some checks failed
Continuous Integration / words (push) Has been cancelled
Continuous Integration / lint (push) Has been cancelled
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 <exedev@writting.exe.xyz>
Co-authored-by: Shelley <shelley@exe.dev>
2026-08-08 22:07:18 +02:00

57 lines
1.1 KiB
Makefile

SOURCE_FOLDER := source
SHELL := /bin/bash
.PHONY: all count clean lint
ASCIIDOC_FILES := $(wildcard $(SOURCE_FOLDER)/*.adoc)
FIGURES = $(shell find . -name '*.svg')
PDF_NAME := book.pdf
PDF_PATH := output/$(PDF_NAME)
EPUB_NAME := book.epub
EPUB_PATH := output/$(EPUB_NAME)
ASCIIDOC_FLAGS = \
--doctype book
.PHONY: all count clean lint epubcheck
all: $(PDF_PATH) $(EPUB_PATH)
$(PDF_PATH): $(ASCIIDOC_FILES) $(FIGURES) Makefile metadata.yaml | output
asciidoctor-pdf book.adoc $(ASCIIDOC_FLAGS) \
-o $@ \
-r asciidoctor-diagram \
-r asciidoctor-mathematical
$(EPUB_PATH): $(ASCIIDOC_FILES) $(FIGURES) Makefile metadata.yaml | output
asciidoctor-epub3 book.adoc $(ASCIIDOC_FLAGS) \
-o $@ \
-r asciidoctor-diagram \
-r asciidoctor-mathematical
count:
@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)
output:
mkdir output
clean:
rm -vrf output
lint:
vale source/