forked from iNavFlight/OpenTX-Telemetry-Widget
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
87 lines (66 loc) · 1.76 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
.PHONY: all clean print-version
SRC_ROOT := src
TELEMETRY := $(SRC_ROOT)/SCRIPTS/TELEMETRY
WIDGETS := $(SRC_ROOT)/WIDGETS
SRC := $(wildcard $(WIDGETS)/*.lua)
SRC += $(wildcard $(WIDGETS)/iNav/*.lua)
SRC += $(wildcard $(TELEMETRY)/*.lua)
SRC += $(wildcard $(TELEMETRY)/iNav/*.lua)
SRC += $(wildcard $(TELEMETRY)/iNav/*/*.wav)
DIST := dist
VERSION := $(shell grep VERSION $(TELEMETRY)/iNav.lua | head -n 1 | cut -d\" -f 2)
BUILD_SUFFIX ?=
ifneq ($(BUILD_SUFFIX),)
BUILD_SUFFIX := _$(BUILD_SUFFIX)
endif
ZIP := $(DIST)/LuaTelemetry_v$(VERSION)$(BUILD_SUFFIX).zip
OBJ := obj
OBJ_SRC := $(subst $(SRC_ROOT),$(OBJ),$(SRC))
OBJS := $(OBJ_SRC:.lua=.luac)
# These need to be added as .lua too, because OTX will only look for
# .lua files, ignoring .luac. It doesn't matter than there's actually
# .luac since lua can load both source and bytecode using the same API,
# using heuristics to figure what it is.
OBJS += $(OBJ)/WIDGETS/iNav/main.lua
OBJS += $(OBJ)/SCRIPTS/TELEMETRY/iNav.lua
LUA_DIST = 3rdparty/lua-5.2.4
LUA = $(LUA_DIST)/src/lua
LUAC = $(LUA)c
all: obj
$(LUA) $(LUAC): $(LUA_DIST)
$(MAKE) -C $< generic
$(OBJ)/%.luac: $(SRC_ROOT)/%.lua $(LUAC)
mkdir -p $(dir $@)
$(LUAC) -s -o "$@" "$<"
$(OBJ)/%.lua: $(OBJ)/%.luac
cp -f "$<" "$@"
$(OBJ)/%.wav: $(SRC_ROOT)/%.wav
mkdir -p $(dir $@)
cp -f "$<" "$@"
obj: $(OBJS)
dist: $(DIST_SRC) $(OBJS)
lua: $(LUA)
luac: $(LUAC)
$(ZIP):
mkdir -p $(DIST)
cd $(OBJ) && \
zip ../$@ -r *
zip: $(ZIP)
dist: zip
ifneq ($(SDCARD),)
install: obj
mkdir -p "$(SDCARD)"
cp -r $(OBJ)/* "$(SDCARD)"
else
install:
$(error $$SDCARD is empty - use SDCARD=dest make install)
endif
clean-obj:
$(RM) -r $(OBJ)
clean-zip:
$(RM) $(ZIP)
clean-lua:
$(MAKE) -C $(LUA_DIST) clean
clean: clean-obj clean-zip clean-lua
print-version:
@echo $(VERSION)