-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
60 lines (48 loc) · 1.64 KB
/
Makefile
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
# All possible Lua version to suuport.
SUPPORTED_VERSIONS = lua lua-5.1 lua-5.2 lua-5.3 lua-5.4 luajit
# Search exec in the PATH and return as list
FOUND_EXECS := $(foreach exec,$(SUPPORTED_VERSIONS),\
$(if $(shell which $(exec) 2> /dev/null),$(exec),))
# Get first found exec and use it.
LUA := $(firstword $(FOUND_EXECS))
LUA := $(if $(LUA),$(LUA),$(error 'No Lua executable found. Please install any of the following Lua versions: $(SUPPORTED_VERSIONS)'))
# LUA := "lua-5.1"
# LUA := "lua-5.2"
# LUA := "lua-5.3"
# LUA := "luajit"
# Get lua version.
LUA_VERSION != $(LUA) -e 'io.write(_VERSION:match("%d+%.%d+"))'
# These can be overriden from the shell.
# For example:
# PREFIX=/usr/local make install
# BINDIR=/usr/local/bin make install
# LIBDIR=/usr/local/share/lua/5.4 make install
PREFIX ?= /usr/local
BINDIR ?= ${PREFIX}/bin
LIBDIR ?= ${PREFIX}/share/lua/${LUA_VERSION}
default:
@echo "Possible make targets are: install, uninstall, test, lint, coverage"
install:
@echo "Installing Laura executable file"
cp ./bin/laura $(BINDIR)/
chmod 0755 $(BINDIR)/laura
@echo "Installing Laura shared files"
mkdir -pv $(LIBDIR)/laura
cp -r $(shell pwd)/src/laura $(LIBDIR)
find $(LIBDIR)/laura -type f -exec chmod 644 {} \;
@echo "Done"
uninstall:
@echo "Uninstalling Laura exec file and shared files"
rm -rf $(BINDIR)/laura $(LIBDIR)/laura
@echo "Done"
test:
@echo "Running tests"
$(LUA) -v
LAURA_DEV_TEST=1 $(LUA) ./bin/laura --nocoverage test
coverage:
@echo "Running tests and coverage"
$(LUA) -v
LAURA_DEV_TEST=1 $(LUA) ./bin/laura --coverage test
lint:
luacheck .
.PHONY: all install uninstall test lint coverage