208 lines
8.0 KiB
Makefile
208 lines
8.0 KiB
Makefile
# Justfile — Build orchestration for the Next Token Sachbuch PDF
|
||
#
|
||
# TeX/LaTeX is intentionally NOT provided by Devbox — host TeX Live
|
||
# (KOMA-Script / scrbook.cls) is used. Devbox may supply pandoc + just.
|
||
#
|
||
# Outputs:
|
||
# just pdf → dist/die-ki-hinter-dem-vorhang.pdf (A4 Lese-PDF)
|
||
# just pdf-print → dist/die-ki-hinter-dem-vorhang-print.pdf (KDP 6×9 B/W)
|
||
# just epub → dist/die-ki-hinter-dem-vorhang.epub (Kindle/KDP)
|
||
# just qa-epub → structural QA for the EPUB only
|
||
# just kdp-shop-cover → assets/cover/cover-kdp-shop.jpg (eBook Shop 1600×2560)
|
||
# just kdp-cover → dist/kdp-cover-wrap.pdf (Print-Umschlag, Seiten = _print_pages)
|
||
# just konsistenz → Konsistenz-Bericht (nur lesend, stdout)
|
||
|
||
default: pdf
|
||
|
||
# eBook: downsampled RGB stage mirrors MD paths under build/ebook-assets/.
|
||
_resource_path := "build/ebook-assets:.:manuskript:assets"
|
||
|
||
# Print: grayscale stage mirrors MD paths (assets/illustrations/… under
|
||
# build/print-assets/). First path wins → gray before RGB originals.
|
||
_print_resource_path := "build/print-assets:.:manuskript:assets"
|
||
|
||
# Print-Seitenzahl für den KDP-Umschlag (Rücken). Nur zusammen mit `just kdp-cover`
|
||
# ändern, nach `just pdf-print` gegen das gemessene PDF prüfen (`just konsistenz`).
|
||
# Wert 220 = gemessenes Print-PDF 2026-10-30 (KR3).
|
||
_print_pages := "220"
|
||
|
||
assemble:
|
||
@python3 scripts/assemble_book.py
|
||
|
||
ebook-assets:
|
||
@python3 scripts/prepare_ebook_assets.py
|
||
|
||
pdf-styled: assemble ebook-assets
|
||
@mkdir -p dist
|
||
pandoc build/book.md \
|
||
--pdf-engine=lualatex \
|
||
--template=pdf/templates/nexttoken-book.tex \
|
||
-H pdf/styles/nexttoken-colors.tex \
|
||
--metadata-file=pdf/metadata.yaml \
|
||
--lua-filter=pdf/filters/boxes.lua \
|
||
--lua-filter=pdf/filters/figures.lua \
|
||
--lua-filter=pdf/filters/illustrations.lua \
|
||
--lua-filter=pdf/filters/partpages.lua \
|
||
--lua-filter=pdf/filters/marks.lua \
|
||
--resource-path={{_resource_path}} \
|
||
-V lang=de-DE -V papersize=a4 -V colorlinks \
|
||
--toc --lof -o dist/die-ki-hinter-dem-vorhang.pdf
|
||
|
||
pdf: pdf-styled
|
||
|
||
pdf-draft: assemble ebook-assets
|
||
@mkdir -p dist
|
||
pandoc build/book.md \
|
||
--pdf-engine=lualatex \
|
||
--template=pdf/templates/nexttoken-book.tex \
|
||
-H pdf/styles/nexttoken-colors.tex \
|
||
--metadata-file=pdf/metadata.yaml \
|
||
--lua-filter=pdf/filters/boxes.lua \
|
||
--lua-filter=pdf/filters/figures.lua \
|
||
--lua-filter=pdf/filters/illustrations.lua \
|
||
--lua-filter=pdf/filters/partpages.lua \
|
||
--lua-filter=pdf/filters/marks.lua \
|
||
--resource-path={{_resource_path}} \
|
||
-V lang=de-DE -V papersize=a4 -V colorlinks \
|
||
-V draft=true \
|
||
--toc --lof -o dist/die-ki-hinter-dem-vorhang-draft.pdf
|
||
|
||
# Schnelle Vorschau: Prolog + Kap. 1–2 (ohne Assembler-Gesamtwerk)
|
||
pdf-sample:
|
||
@mkdir -p dist
|
||
pandoc \
|
||
manuskript/prolog.md \
|
||
manuskript/kapitel-01-geschichte.md \
|
||
manuskript/kapitel-02-was-ist-ein-llm.md \
|
||
--pdf-engine=lualatex \
|
||
-V documentclass=scrbook \
|
||
-V lang=de-DE \
|
||
-V papersize=a4 \
|
||
--toc --lof \
|
||
-o dist/die-ki-hinter-dem-vorhang-sample.pdf
|
||
|
||
pdf-sample-styled: ebook-assets
|
||
@mkdir -p dist
|
||
pandoc \
|
||
manuskript/prolog.md \
|
||
manuskript/kapitel-01-geschichte.md \
|
||
manuskript/kapitel-02-was-ist-ein-llm.md \
|
||
--pdf-engine=lualatex \
|
||
--template=pdf/templates/nexttoken-book.tex \
|
||
-H pdf/styles/nexttoken-colors.tex \
|
||
--metadata-file=pdf/metadata.yaml \
|
||
--lua-filter=pdf/filters/boxes.lua \
|
||
--lua-filter=pdf/filters/figures.lua \
|
||
--lua-filter=pdf/filters/illustrations.lua \
|
||
--lua-filter=pdf/filters/partpages.lua \
|
||
--lua-filter=pdf/filters/marks.lua \
|
||
--resource-path={{_resource_path}} \
|
||
-V lang=de-DE \
|
||
-V papersize=a4 \
|
||
-V colorlinks \
|
||
--toc --lof \
|
||
-o dist/die-ki-hinter-dem-vorhang-sample-styled.pdf
|
||
|
||
# --- KDP Paperback Interior (6×9, grayscale) --------------------------------
|
||
|
||
print-assets:
|
||
@python3 scripts/prepare_print_assets.py
|
||
|
||
pdf-print: assemble print-assets
|
||
@mkdir -p dist
|
||
pandoc build/book.md \
|
||
--pdf-engine=lualatex \
|
||
--template=pdf/templates/nexttoken-book.tex \
|
||
-H pdf/print/print-colors.tex \
|
||
--metadata-file=pdf/print/metadata.yaml \
|
||
--lua-filter=pdf/filters/boxes.lua \
|
||
--lua-filter=pdf/filters/figures.lua \
|
||
--lua-filter=pdf/filters/illustrations.lua \
|
||
--lua-filter=pdf/filters/partpages.lua \
|
||
--lua-filter=pdf/filters/marks.lua \
|
||
--resource-path={{_print_resource_path}} \
|
||
--syntax-highlighting=monochrome \
|
||
-V lang=de-DE \
|
||
-V printmode=true \
|
||
--toc --lof \
|
||
-o dist/die-ki-hinter-dem-vorhang-print.pdf
|
||
|
||
# Optional: Ghostscript grayscale/prepress pass (KDP-freundlicher, best-effort)
|
||
pdf-print-optimize:
|
||
@test -f dist/die-ki-hinter-dem-vorhang-print.pdf || (echo "Run just pdf-print first" && exit 1)
|
||
@command -v gs >/dev/null || (echo "Ghostscript (gs) not found" && exit 1)
|
||
gs -dBATCH -dNOPAUSE -dSAFER -sDEVICE=pdfwrite \
|
||
-dCompatibilityLevel=1.5 \
|
||
-dPDFSETTINGS=/prepress \
|
||
-dColorConversionStrategy=/Gray \
|
||
-dProcessColorModel=/DeviceGray \
|
||
-dEmbedAllFonts=true \
|
||
-dSubsetFonts=true \
|
||
-sOutputFile=dist/die-ki-hinter-dem-vorhang-print-opt.pdf \
|
||
dist/die-ki-hinter-dem-vorhang-print.pdf
|
||
@mv dist/die-ki-hinter-dem-vorhang-print-opt.pdf dist/die-ki-hinter-dem-vorhang-print.pdf
|
||
@echo "optimized → dist/die-ki-hinter-dem-vorhang-print.pdf"
|
||
|
||
qa:
|
||
@python3 scripts/check_pdf.py
|
||
|
||
qa-print:
|
||
@python3 scripts/check_pdf.py --pdf dist/die-ki-hinter-dem-vorhang-print.pdf --mode print
|
||
|
||
all: pdf qa
|
||
|
||
all-print: pdf-print qa-print
|
||
|
||
# --- KDP Kindle EPUB ---------------------------------------------------------
|
||
# EPUB-only: resized images under build/epub-assets/ (does not touch PDF/print).
|
||
# Stable OPF identifier — do not rotate casually (KDP update identity).
|
||
_epub_resource_path := "build/epub-assets:.:manuskript:assets"
|
||
_epub_id := "urn:uuid:7c3e9a12-4b8f-4d2e-9a1c-6e5f8b0d2c4a"
|
||
|
||
epub: assemble
|
||
@python3 scripts/prepare_epub.py
|
||
@mkdir -p dist
|
||
# -implicit_figures: avoid double captions (we emit p.figcaption ourselves)
|
||
pandoc build/epub.md \
|
||
-f markdown-implicit_figures \
|
||
--resource-path={{_epub_resource_path}} \
|
||
--css=pdf/epub/epub.css \
|
||
--epub-cover-image=assets/cover/cover.jpg \
|
||
--epub-metadata=pdf/epub/epub-metadata.xml \
|
||
--metadata title="Die KI hinter dem Vorhang" \
|
||
--metadata subtitle="Was LLMs, Agenten und AGI wirklich können – und was nicht" \
|
||
--metadata author="Martin Richardt" \
|
||
--metadata lang=de-DE \
|
||
--metadata rights="© 2026 Martin Richardt. Alle Rechte vorbehalten." \
|
||
--metadata identifier={{_epub_id}} \
|
||
--toc --toc-depth=1 \
|
||
--split-level=1 \
|
||
--epub-title-page=false \
|
||
-o dist/die-ki-hinter-dem-vorhang.epub
|
||
@# Kindle E20006/E21011: inject title-type=main (+ subtitle), dedupe meta
|
||
@python3 scripts/fix_epub_opf.py dist/die-ki-hinter-dem-vorhang.epub
|
||
@echo "epub → dist/die-ki-hinter-dem-vorhang.epub"
|
||
@python3 scripts/check_epub.py dist/die-ki-hinter-dem-vorhang.epub
|
||
|
||
qa-epub:
|
||
@python3 scripts/check_epub.py dist/die-ki-hinter-dem-vorhang.epub
|
||
|
||
# --- KDP eBook shop cover (ideal 1600×2560, separate from EPUB embed) --------
|
||
|
||
kdp-shop-cover:
|
||
@python3 scripts/build_kdp_shop_cover.py
|
||
|
||
# --- KDP Paperback cover wrap (front + spine + back) -------------------------
|
||
|
||
kdp-cover:
|
||
@python3 scripts/build_kdp_cover_wrap.py --pages {{_print_pages}} --paper white
|
||
|
||
# Konsistenz-Check (nur lesend): Kapitel, Wörter, Bilder, Stichtag, Auflage, Seiten/Umschlag
|
||
konsistenz *ARGS:
|
||
@python3 scripts/konsistenz_check.py {{ARGS}}
|
||
|
||
clean:
|
||
@rm -rf build
|
||
@rm -f dist/*.pdf dist/*.epub dist/*.aux dist/*.log dist/*.out dist/*.toc
|
||
@echo "cleaned build/ and dist/*.{pdf,epub}"
|