summaryrefslogtreecommitdiff
path: root/Makefile
blob: a7072504df57a98bd8b2f28c578929d7104d5a9f (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
all: test

MODULES := clod
LUA_VER := 5.1

PREFIX ?= /usr/local

INST_BASE := $(PREFIX)
INST_ROOT := $(DESTDIR)$(INST_BASE)/share/lua/$(LUA_VER)

MOD_FILES := $(patsubst %,%.lua,$(subst .,/,$(MODULES)))

install:
	mkdir -p $(INST_ROOT)
	for MOD in $(sort $(MOD_FILES)); do \
		cp lib/$${MOD} $(INST_ROOT)/$${MOD}; \
	done

LUA := LUA_PATH="$(shell pwd)/lib/?.lua;$(shell pwd)/extras/luacov/src/?.lua;;" lua$(LUA_VER)

clean:
	$(RM) luacov.report.out luacov.stats.out
	$(RM) -r html

distclean: clean
	find . -name "*~" -delete

.PHONY: example
example:
	$(LUA) example/simple-config-reader.lua
	$(LUA) example/change-setting.lua
	$(LUA) example/config-passthru.lua

.PHONY: test
test:
	@$(RM) luacov.stats.out
	@ERR=0; \
	for MOD in $(sort $(MODULES)); do \
		echo -n "$${MOD}: "; \
		$(LUA) test/test-$${MOD}.lua; \
		test "x$$?" = "x0" || ERR=1; \
	done; \
	$(LUA) extras/luacov/src/bin/luacov -X luacov. -X test. $(MODULES); \
	exit $$ERR

.PHONY: interactive
interactive:
	$(LUA) -e'clod=require"clod"' -i

doc:
	@ldoc .