Files
tepbc-ross-retyped/Makefile
T
bdeshiandClaude Sonnet 5.5 d48ce1f50c Re-encode plates to lossless JBIG2 / JPEG at build time (115 MB -> 12 MB)
The scan is a bilevel 300 dpi JBIG2 layer plus lower-resolution colour, so
storing every plate as 8-bit PNG only added size. tools/optimize_plates.py
writes copies under work/plates-opt (bilevel to generic-mode, lossless JBIG2;
genuine halftone to JPEG q88) and repoints work/pages at them; plates/ and
src/ are untouched. The Dockerfile builds jbig2enc and adds qpdf, ghostscript
and img2pdf.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-09-29 14:36:18 +06:00

57 lines
2.3 KiB
Makefile

# All heavy tools run inside the container; the host drives via make.
# Set NODOCKER=1 to run directly if xelatex/poppler/tesseract are installed locally.
# zsh does not export UID/GID; compose.yaml needs them to run as the tree's owner.
export UID := $(shell id -u)
export GID := $(shell id -g)
RUN := $(if $(NODOCKER),,docker compose run --rm -T tex)
OUT := ross-1988-retypeset.pdf
SOURCES := build.sh tools/polish.py tools/optimize_plates.py src/preamble.tex src/colophon.tex src/errata.tex \
$(wildcard src/pages/*.tex)
.DEFAULT_GOAL := pdf
.PHONY: pdf build image prep plate check reprocheck verify clean distclean shell help
# The PDF is a build product and is not in git. This remakes it from src/ and
# plates/, neither of which needs the ProQuest scan — only prep and plate do.
pdf: $(OUT) ## typeset the edition (only if a source changed)
$(OUT): $(SOURCES)
$(RUN) ./build.sh
build: ## typeset unconditionally, even if nothing changed
$(RUN) ./build.sh
image: ## build the toolchain image (once)
docker compose build
prep: ## rasterize + OCR-scaffold pages A..B: make prep A=19 B=32 [needs source/]
$(RUN) tools/prep.sh $(A) $(B)
plate: ## crop plate image for PDF page N: make plate N=40 [ARGS="--top 0.06"] [needs source/]
$(RUN) python3 tools/crop_plate.py $(N) $(ARGS)
check: ## consistency checks (manifest <-> files <-> macros), no build
$(RUN) python3 tools/check.py
reprocheck: ## every token of src/pages must reach the built PDF
$(RUN) python3 tools/reprocheck.py $(OUT)
# Depends on `build`, not `pdf`: `pdf` is timestamp-conditional, and a source edited
# while a build is running leaves a PDF NEWER than the source it does not contain,
# so make would skip the rebuild and verify would pass against stale output.
verify: check build reprocheck ## the full gate: check, typeset unconditionally, then prove nothing was dropped
shell: ## interactive shell in the container
docker compose run --rm tex bash
clean: ## remove LaTeX aux and scratch rasters (keeps plates and the PDF)
rm -rf work/*
distclean: clean ## also drop the page rasters and the built PDF
rm -rf scans/* $(OUT)
help:
@grep -E '^[a-z-]+:.*##' Makefile | sed 's/:.*##/ —/'