2019-11-16 21:59:32 -08:00
|
|
|
VERSION ?=
|
|
|
|
CMD ?=
|
|
|
|
|
2019-07-10 19:12:20 -07:00
|
|
|
EMACS ?= emacs
|
|
|
|
|
|
|
|
# The order is important for compilation.
|
|
|
|
for_compile := *.el
|
|
|
|
for_checkdoc := *.el
|
|
|
|
for_longlines := $(wildcard *.el *.md *.yml) Makefile
|
|
|
|
|
2019-11-16 21:59:32 -08:00
|
|
|
.PHONY: help
|
|
|
|
help: ## Show this message
|
|
|
|
@echo "usage:" >&2
|
|
|
|
@grep -h "[#]# " $(MAKEFILE_LIST) | \
|
|
|
|
sed 's/^/ make /' | \
|
|
|
|
sed 's/:[^#]*[#]# /|/' | \
|
|
|
|
sed 's/%/LANG/' | \
|
|
|
|
column -t -s'|' >&2
|
|
|
|
|
|
|
|
.PHONY: lint
|
|
|
|
lint: compile checkdoc longlines ## Build project and run all linters
|
2019-07-10 19:12:20 -07:00
|
|
|
|
|
|
|
.PHONY: compile
|
2019-07-10 22:06:18 -07:00
|
|
|
compile: ## Check for byte-compiler errors
|
2019-07-10 19:12:20 -07:00
|
|
|
@for file in $(for_compile); do \
|
|
|
|
echo "[compile] $$file" ;\
|
2019-07-10 22:17:26 -07:00
|
|
|
rm -f "$${file}c" ;\
|
2019-07-10 19:12:20 -07:00
|
|
|
$(EMACS) -Q --batch -L . -f batch-byte-compile $$file 2>&1 \
|
|
|
|
| grep -v "^Wrote" \
|
|
|
|
| grep . && exit 1 || true ;\
|
|
|
|
done
|
|
|
|
|
|
|
|
.PHONY: checkdoc
|
2019-07-10 22:06:18 -07:00
|
|
|
checkdoc: ## Check for missing or poorly formatted docstrings
|
2019-07-10 19:12:20 -07:00
|
|
|
@for file in $(for_checkdoc); do \
|
|
|
|
echo "[checkdoc] $$file" ;\
|
|
|
|
$(EMACS) -Q --batch \
|
|
|
|
--eval "(or (fboundp 'checkdoc-file) (kill-emacs))" \
|
|
|
|
--eval "(setq sentence-end-double-space nil)" \
|
|
|
|
--eval "(checkdoc-file \"$$file\")" 2>&1 \
|
|
|
|
| grep . && exit 1 || true ;\
|
|
|
|
done
|
|
|
|
|
|
|
|
.PHONY: longlines
|
2019-07-10 22:06:18 -07:00
|
|
|
longlines: ## Check for lines longer than 79 characters
|
2019-07-10 19:12:20 -07:00
|
|
|
@for file in $(for_longlines); do \
|
2019-11-16 21:59:32 -08:00
|
|
|
echo "[longlines] $$file" ;\
|
2019-07-10 19:12:20 -07:00
|
|
|
cat "$$file" \
|
|
|
|
| sed '/[l]onglines-start/,/longlines-stop/d' \
|
|
|
|
| grep -E '.{80}' \
|
|
|
|
| grep -E -v 'https?://' \
|
|
|
|
| sed "s/^/$$file:long line: /" \
|
|
|
|
| grep . && exit 1 || true ;\
|
|
|
|
done
|
|
|
|
|
|
|
|
.PHONY: clean
|
2019-07-10 22:06:18 -07:00
|
|
|
clean: ## Remove build artifacts
|
2019-07-10 19:12:20 -07:00
|
|
|
@echo "[clean]" *.elc
|
|
|
|
@rm -f *.elc
|
2019-07-10 22:06:18 -07:00
|
|
|
|
|
|
|
.PHONY: docker
|
2019-07-10 22:50:01 -07:00
|
|
|
docker: ## Start a Docker shell; e.g. make docker VERSION=25.3
|
2019-11-16 22:05:28 -08:00
|
|
|
@scripts/docker.bash "$(VERSION)" "$(CMD)"
|