Merge pull request #216 from hinrik/add_perl6_impl
[jackhill/mal.git] / lua / Makefile
1 TESTS =
2
3 SOURCES_BASE = utils.lua types.lua reader.lua printer.lua
4 SOURCES_LISP = env.lua core.lua stepA_mal.lua
5 SOURCES = $(SOURCES_BASE) $(SOURCES_LISP)
6
7 all: libs
8
9 dist: mal.lua mal
10
11 SOURCE_NAMES = $(patsubst %.lua,%,$(SOURCES))
12 mal.lua: $(SOURCES)
13 echo "local $(foreach n,$(SOURCE_NAMES),$(n),) M" > $@
14 echo "M={} $(foreach n,$(SOURCE_NAMES),$(n)=M);" >> $@
15 cat $+ | grep -v -e "return M$$" \
16 -e "return Env" \
17 -e "local M =" \
18 -e "^#!" \
19 $(foreach n,$(SOURCE_NAMES),-e "require('$(n)')") >> $@
20
21 mal: mal.lua
22 echo "#!/usr/bin/env lua" > $@
23 cat $< >> $@
24 chmod +x $@
25
26
27 clean:
28 rm -f linenoise.so mal.lua mal
29 rm -rf lib/lua/5.1
30
31 .PHONY: stats tests $(TESTS)
32
33 stats: $(SOURCES)
34 @wc $^
35 @printf "%5s %5s %5s %s\n" `grep -E "^[[:space:]]*--|^[[:space:]]*$$" $^ | wc` "[comments/blanks]"
36 stats-lisp: $(SOURCES_LISP)
37 @wc $^
38 @printf "%5s %5s %5s %s\n" `grep -E "^[[:space:]]*--|^[[:space:]]*$$" $^ | wc` "[comments/blanks]"
39
40
41 .PHONY: libs
42 libs: linenoise.so
43
44 linenoise.so:
45 luarocks install --tree=./ linenoise
46 ln -sf lib/lua/5.1/linenoise.so $@
47