2026-06-23 19:34:36 -05:00
|
|
|
# Makefile for card-games -- byte-compile, test, and package.
|
|
|
|
|
EMACS ?= emacs
|
|
|
|
|
PKG = card-games
|
2026-07-01 14:32:32 -05:00
|
|
|
VERSION = 1.0.91
|
2026-06-23 19:34:36 -05:00
|
|
|
# Source files in dependency order (cg-core first).
|
Add two-player Russian Bank (Crapette) vs the computer
* cg-crapette.el: new game on cg-core — eight foundations (up by suit,
two decks), eight shared houses (down, alternating colour), per-player
reserve/waste/hand; foundation priority; loading onto the opponent; a
greedy AI; text UI with cursor pick/drop, undo, and q-to-menu.
* card-games.el: require cg-crapette and add the chooser entry.
* Makefile (EL): add cg-crapette.el.
* test/card-games-tests.el: 5 ERT (deal, legality, win, AI turn, AI foundation).
2026-07-01 03:09:27 -05:00
|
|
|
EL = cg-core.el cg-svg.el cg-render.el cg-net.el cg-bid.el cg-gaps.el cg-bid-ui.el cg-bid-net.el cg-solitaire.el cg-trick.el cg-eights.el cg-patience.el cg-president.el cg-rummy.el cg-rum500.el cg-handfoot.el cg-match.el cg-cribbage.el cg-scopa.el cg-trick-ext.el cg-spite.el cg-bridge.el cg-crapette.el card-games.el
|
2026-06-23 19:34:36 -05:00
|
|
|
ELC = $(EL:.el=.elc)
|
|
|
|
|
PKGDESC = $(PKG)-pkg.el
|
|
|
|
|
TARDIR = $(PKG)-$(VERSION)
|
|
|
|
|
TAR = $(TARDIR).tar
|
|
|
|
|
SRCTAR = $(PKG)-$(VERSION)-src.tar.gz
|
|
|
|
|
DIST = dist
|
|
|
|
|
BATCH = $(EMACS) -Q --batch -L .
|
2026-07-01 11:55:05 -05:00
|
|
|
MANUAL = doc/card-games.texi
|
2026-07-01 14:06:02 -05:00
|
|
|
VERTEXI = doc/version.texi
|
2026-07-01 11:55:05 -05:00
|
|
|
INFO = doc/card-games.info
|
2026-07-01 14:06:02 -05:00
|
|
|
IMAGES = doc/images/klondike.png doc/images/hearts.png
|
2026-07-01 11:55:05 -05:00
|
|
|
MAKEINFO ?= makeinfo
|
|
|
|
|
TEXI2PDF ?= texi2pdf
|
2026-07-01 14:06:02 -05:00
|
|
|
README = README.md
|
|
|
|
|
EXTRA = README.org $(README) $(PKGDESC) $(MANUAL) $(VERTEXI) $(IMAGES)
|
2026-06-23 19:34:36 -05:00
|
|
|
|
2026-08-03 22:18:02 -05:00
|
|
|
.PHONY: all compile test clean distclean checkdoc lint check package tarball elpa release help \
|
2026-07-01 14:06:02 -05:00
|
|
|
info info-emacs html pdf docclean version readme hooks
|
2026-06-23 19:34:36 -05:00
|
|
|
|
|
|
|
|
help:
|
|
|
|
|
@echo "card-games $(VERSION) -- make targets:"
|
|
|
|
|
@echo " compile byte-compile all sources"
|
|
|
|
|
@echo " test run the ERT test suite"
|
|
|
|
|
@echo " checkdoc run checkdoc on all sources"
|
|
|
|
|
@echo " lint run package-lint (if installed)"
|
2026-08-03 22:18:02 -05:00
|
|
|
@echo " check compile + checkdoc + lint + test (the full gate)"
|
2026-07-01 14:06:02 -05:00
|
|
|
@echo " version regenerate $(VERTEXI) from VERSION"
|
|
|
|
|
@echo " readme export README.org -> README.md (Emacs batch)"
|
|
|
|
|
@echo " hooks install the git pre-commit hook"
|
|
|
|
|
@echo " info build the Info manual ($(INFO)) with makeinfo"
|
|
|
|
|
@echo " info-emacs build the Info manual with Emacs alone (fallback)"
|
2026-07-01 11:55:05 -05:00
|
|
|
@echo " html build the one-file HTML manual"
|
|
|
|
|
@echo " pdf build the PDF manual (needs a TeX installation)"
|
2026-06-23 19:34:36 -05:00
|
|
|
@echo " package build the installable package tarball ($(TAR))"
|
|
|
|
|
@echo " elpa build a one-package ELPA archive in $(DIST)/"
|
|
|
|
|
@echo " release clean + test + package + source tarball"
|
|
|
|
|
@echo " clean remove .elc and build artifacts"
|
|
|
|
|
|
|
|
|
|
all: compile
|
|
|
|
|
|
|
|
|
|
# Compile in order so each file sees its compiled dependencies.
|
|
|
|
|
compile:
|
|
|
|
|
$(BATCH) -f batch-byte-compile $(EL)
|
|
|
|
|
|
|
|
|
|
test:
|
|
|
|
|
$(BATCH) -L test -l test/$(PKG)-tests.el -f ert-run-tests-batch-and-exit
|
|
|
|
|
|
2026-08-03 22:18:02 -05:00
|
|
|
# One gate a contributor (or CI) can run: the same quality tools MELPA
|
|
|
|
|
# asks for -- byte-compile, checkdoc, package-lint -- plus the ERT suite.
|
|
|
|
|
check: compile checkdoc lint test
|
|
|
|
|
@echo "card-games $(VERSION): compile + checkdoc + lint + tests all green"
|
|
|
|
|
|
2026-06-23 19:34:36 -05:00
|
|
|
checkdoc:
|
2026-08-03 22:18:02 -05:00
|
|
|
$(BATCH) --eval "(progn (dolist (f '($(EL))) (checkdoc-file (symbol-name f))))"
|
2026-06-23 19:34:36 -05:00
|
|
|
|
|
|
|
|
lint:
|
|
|
|
|
-$(BATCH) --eval "(progn (require 'package) (package-initialize) \
|
|
|
|
|
(unless (require 'package-lint nil t) (error \"package-lint not installed\")) \
|
|
|
|
|
(setq package-lint-main-file \"$(PKG).el\") \
|
|
|
|
|
(dolist (f '($(EL))) (with-temp-buffer (insert-file-contents f) \
|
|
|
|
|
(emacs-lisp-mode) (package-lint-buffer))))"
|
|
|
|
|
|
|
|
|
|
# Installable multi-file package: card-games-VERSION.tar with a top
|
|
|
|
|
# directory of the same name (package.el / package-install-file format).
|
|
|
|
|
package: tarball
|
|
|
|
|
# Uses GNU tar's --transform to add the top directory without a temp copy.
|
|
|
|
|
tarball: $(EL) $(EXTRA)
|
|
|
|
|
tar --transform 's,^,$(TARDIR)/,' -cf $(TAR) $(EL) $(EXTRA)
|
|
|
|
|
@echo "Built $(TAR)"
|
|
|
|
|
|
|
|
|
|
# A minimal ELPA archive (archive-contents + tar) under dist/.
|
|
|
|
|
# Testers can: (add-to-list 'package-archives '("cg" . "/path/to/dist/"))
|
|
|
|
|
elpa: tarball
|
|
|
|
|
rm -rf $(DIST)
|
|
|
|
|
mkdir -p $(DIST)
|
|
|
|
|
$(BATCH) --eval "(progn (require 'package-x) \
|
|
|
|
|
(let ((package-archive-upload-base (expand-file-name \"$(DIST)\"))) \
|
|
|
|
|
(package-upload-file \"$(TAR)\")))"
|
|
|
|
|
@echo "ELPA archive in $(DIST)/"
|
|
|
|
|
|
|
|
|
|
# Source snapshot for a GitHub release. Archive an explicit file list
|
|
|
|
|
# (not ".") so the growing output tarball and editor lock files are never
|
|
|
|
|
# read mid-write -- which is what caused "tar: .: file changed as we read it".
|
2026-07-01 14:06:02 -05:00
|
|
|
SRCFILES = $(EL) $(EXTRA) build.el hooks Makefile .gitignore test
|
2026-08-03 22:18:02 -05:00
|
|
|
release: distclean version readme check tarball
|
2026-06-23 19:34:36 -05:00
|
|
|
rm -f $(SRCTAR)
|
|
|
|
|
tar --transform 's,^,$(TARDIR)/,' \
|
|
|
|
|
--exclude='*.elc' --exclude='*.tar' --exclude='*.tar.gz' \
|
|
|
|
|
--exclude='.#*' --exclude='$(DIST)' --exclude='.git' \
|
|
|
|
|
-czf $(SRCTAR) $(SRCFILES)
|
|
|
|
|
@echo "Built $(SRCTAR) and $(TAR) for release $(VERSION)"
|
|
|
|
|
|
2026-07-01 11:55:05 -05:00
|
|
|
# Documentation. The Texinfo source lives in doc/; the Info manual is
|
2026-07-01 14:06:02 -05:00
|
|
|
# built from it with makeinfo. doc/version.texi carries the version and
|
|
|
|
|
# is committed; `make version' regenerates it from VERSION (run at release).
|
|
|
|
|
version:
|
|
|
|
|
@printf '@set VERSION %s\n@set UPDATED %s\n@set YEAR %s\n' \
|
|
|
|
|
"$(VERSION)" "$$(date '+%-d %B %Y')" "$$(date +%Y)" > $(VERTEXI)
|
|
|
|
|
@echo "Wrote $(VERTEXI) (VERSION $(VERSION))"
|
|
|
|
|
|
|
|
|
|
# README: Org is the source; GitHub and MELPA render Markdown better than
|
|
|
|
|
# Org, so we export README.org -> README.md with Emacs batch (ox-md). The
|
|
|
|
|
# git pre-commit hook (make hooks) keeps README.md in step automatically.
|
|
|
|
|
readme: $(README)
|
|
|
|
|
$(README): README.org build.el
|
|
|
|
|
$(BATCH) -l build.el
|
|
|
|
|
|
|
|
|
|
# Install the pre-commit hook into this checkout's .git/hooks.
|
|
|
|
|
hooks:
|
|
|
|
|
@if [ -d .git ]; then \
|
|
|
|
|
cp hooks/pre-commit .git/hooks/pre-commit && \
|
|
|
|
|
chmod +x .git/hooks/pre-commit && \
|
|
|
|
|
echo "Installed .git/hooks/pre-commit"; \
|
|
|
|
|
else \
|
|
|
|
|
echo "No .git directory here; skipping hook install."; \
|
|
|
|
|
fi
|
|
|
|
|
|
2026-07-01 11:55:05 -05:00
|
|
|
info: $(INFO)
|
2026-07-01 14:06:02 -05:00
|
|
|
$(INFO): $(MANUAL) $(VERTEXI)
|
2026-07-01 11:55:05 -05:00
|
|
|
$(MAKEINFO) -o $@ $(MANUAL)
|
|
|
|
|
|
2026-07-01 14:06:02 -05:00
|
|
|
# Fallback: build the Info manual with Emacs alone (no makeinfo needed).
|
|
|
|
|
# Handy on Windows/MSYS2 where Emacs is present but texinfo may not be.
|
|
|
|
|
# The native formatter is lower fidelity than makeinfo, so `make info'
|
|
|
|
|
# stays the default; this is only for a makeinfo-less environment.
|
|
|
|
|
info-emacs: $(MANUAL) $(VERTEXI)
|
|
|
|
|
cd doc && $(EMACS) -Q --batch --eval "(require 'texinfmt)" \
|
|
|
|
|
-f batch-texinfo-format card-games.texi
|
|
|
|
|
|
|
|
|
|
html: $(MANUAL) $(VERTEXI)
|
2026-07-01 11:55:05 -05:00
|
|
|
$(MAKEINFO) --html --no-split -o doc/card-games.html $(MANUAL)
|
|
|
|
|
|
2026-07-01 14:06:02 -05:00
|
|
|
pdf: $(MANUAL) $(VERTEXI)
|
2026-07-01 11:55:05 -05:00
|
|
|
cd doc && $(TEXI2PDF) -q card-games.texi
|
|
|
|
|
|
|
|
|
|
docclean:
|
|
|
|
|
rm -f $(INFO) doc/card-games.html doc/card-games.pdf \
|
|
|
|
|
doc/card-games.aux doc/card-games.cp doc/card-games.cps \
|
|
|
|
|
doc/card-games.fn doc/card-games.ky doc/card-games.log \
|
|
|
|
|
doc/card-games.pg doc/card-games.toc doc/card-games.tp \
|
|
|
|
|
doc/card-games.vr doc/card-games.fns
|
|
|
|
|
|
2026-06-23 19:34:36 -05:00
|
|
|
clean:
|
|
|
|
|
rm -f $(ELC)
|
|
|
|
|
|
2026-07-01 11:55:05 -05:00
|
|
|
distclean: clean docclean
|
2026-06-23 19:34:36 -05:00
|
|
|
rm -rf $(DIST) $(TARDIR) $(TAR) $(SRCTAR)
|