summaryrefslogtreecommitdiff
path: root/Makefile
blob: 2e03b9bc62dc00456056e50a1db9d552c91804e6 (plain) (blame)
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
52
53
54
55
56
57
58
59
60
61
62
63
LUA ?= lua
FENNEL ?= fennel
FNLSOURCES = init.fnl
LUASOURCES = $(FNLSOURCES:.fnl=.lua)
FNLTESTS = tests/fn.fnl tests/macros.fnl tests/core.fnl
FNLDOCS = init.fnl macros.fnl tests/test.fnl
LUATESTS = $(FNLTESTS:.fnl=.lua)
LUA_EXECUTABLES ?= lua luajit
FENNELDOC := $(shell command -v fenneldoc)

.PHONY: build clean distclean help test luacov luacov-console fenneldoc $(LUA_EXECUTABLES)

build: $(LUASOURCES)

${LUASOURCES}: $(FNLSOURCES)

%.lua: %.fnl
	$(FENNEL) --lua $(LUA) --compile $< > $@

clean:
	rm -f $(LUASOURCES) $(LUATESTS)

distclean: clean
	rm -f luacov*

test: $(FNLTESTS)
	@echo "Testing on" $$($(LUA) -v) >&2
ifdef FENNELDOC
	@fenneldoc --mode check $(FNLDOCS) || exit
else
	@echo ""
	@echo "fenneldoc is not installed" >&2
	@echo "Please install fenneldoc to check documentation during testing" >&2
	@echo "https://gitlab.com/andreyorst/fenneldoc" >&2
	@echo ""
endif
	@$(foreach test,$?,$(FENNEL) --lua $(LUA) --metadata $(test) || exit;)

testall: $(LUA_EXECUTABLES)
	@$(foreach lua,$?,LUA=$(lua) make test || exit;)

luacov: build $(LUATESTS)
	@$(foreach test,$(LUATESTS),$(LUA) -lluarocks.loader -lluacov $(test) || exit;)
	luacov

luacov-console: luacov
	@$(foreach test, $(LUATESTS), mv $(test) $(test).tmp;)
	luacov-console .
	@$(foreach test, $(LUATESTS), mv $(test).tmp $(test);)

fenneldoc:
	fenneldoc $(FNLDOCS)

help:
	@echo "make                -- run tests and create lua library" >&2
	@echo "make test           -- run tests" >&2
	@echo "make clean          -- remove lua files" >&2
	@echo "make distclean      -- remove all unnecessary files" >&2
	@echo "make luacov         -- build coverage report" >&2
	@echo "make luacov-console -- build coverage report for luacov-console" >&2
	@echo "make help           -- print this message and exit" >&2

-include .depend.mk