summaryrefslogtreecommitdiffstats
path: root/Makefile
blob: 7b8356b0cb10f887f865b8cb389fb6a4a9580d09 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# Development tasks. Everything runs through SBCL in script mode; Quicklisp
# resolves the dependencies, so it must be installed and loaded by your
# ~/.sbclrc (which is what `(ql:add-to-init-file)` does).
#
#   make            list the targets
#   make test       run the suite against a local HTTP server
#   make lint       compile everything from scratch, fail on any warning
#   make build      compile and load the library
SBCL ?= sbcl

DEPS := "dexador" "com.inuoe.jzon" "babel" "fiveam" "usocket" "bordeaux-threads"

LISP := $(SBCL) --non-interactive \
	--eval '(require :asdf)' \
	--eval '(push (uiop:getcwd) asdf:*central-registry*)'

CACHE := $(HOME)/.cache/common-lisp

.DEFAULT_GOAL := help
.PHONY: help test lint build check clean

help:
	@echo 'Targets:'
	@echo '  test       run the test suite'
	@echo '  lint       recompile from scratch, failing on any warning (read-only)'
	@echo '  build      compile and load the library'
	@echo '  check      lint + test + build, in that order'
	@echo '  clean      remove compiled files and this project'"'"'s ASDF cache'

test:
	$(LISP) \
		--eval '(ql:quickload "cepis/tests" :silent t)' \
		--eval '(uiop:quit (if (cepis/tests:run-tests) 0 1))'

# The dependencies are loaded outside the handler so that their own warnings,
# on the first compile of a fresh Quicklisp, are not counted as ours. The
# redefinition warnings that are skipped are the ones SBCL emits for a macro
# compiled and then loaded in the same image, which say nothing about the code.
LINT_FORM := (let ((warnings 0)) (handler-bind ((warning (lambda (condition) (unless (typep condition (quote sb-kernel:redefinition-warning)) (incf warnings) (format *error-output* "~&~a~%" condition))))) (asdf:load-system "cepis/tests" :force (list "cepis" "cepis/tests"))) (uiop:quit (if (plusp warnings) 1 0)))

lint:
	$(LISP) --eval '(ql:quickload (list $(DEPS)) :silent t)' --eval '$(LINT_FORM)'

build:
	$(LISP) --eval '(ql:quickload "cepis" :silent t)' --eval '(asdf:make "cepis")'

check: lint test build

clean:
	find . \( -name '*.fasl' -o -name '*.fas' -o -name '*.lib' \) -delete
	rm -rf $(CACHE)/*/$(patsubst /%,%,$(CURDIR))