-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
67 lines (52 loc) · 1.74 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
# Compiler
CXX = arm-linux-gnueabihf-g++
CC = arm-linux-gnueabihf-gcc
CXXFLAGS = -Wall -Werror -O3 -std=c++17
# SSH
SSH_USERNAME = pi
SSH_IP = 192.168.0.102
SSH_TARGET_FOLDER = /home/pi/
SSH_MODES_FOLDER = /home/pi/
# rgbmatrix lib
RGB_LIB_DISTRIBUTION=lib/rpi-rgb-led-matrix
RGB_INCDIR=$(RGB_LIB_DISTRIBUTION)/include
RGB_LIBDIR=$(RGB_LIB_DISTRIBUTION)/lib
RGB_LIBRARY_NAME=rgbmatrix
RGB_LIBRARY=$(RGB_LIBDIR)/lib$(RGB_LIBRARY_NAME).a
LDFLAGS+=-L$(RGB_LIBDIR) -l$(RGB_LIBRARY_NAME) -lrt -lm -lpthread -static
# lua lib
LUA_LIB_DISTRIBUTION=lib/lua
LUA_INCDIR=$(LUA_LIB_DISTRIBUTION)/lua-5.4.4/install/include
LUA_BUILDDIR=$(LUA_LIB_DISTRIBUTION)/lua-5.4.4
LUA_LIBDIR=$(LUA_LIB_DISTRIBUTION)/lua-5.4.4/install/lib
LUA_LIBRARY_NAME=lua
LUA_LIBRARY=$(LUA_LIBDIR)/lib$(LUA_LIBRARY_NAME).a
LDFLAGS+=-L$(LUA_LIBDIR) -l$(LUA_LIBRARY_NAME) -static
# Target
TARGET = target.out
MODES = src/modes
# main
MAIN_CPP = main.cpp
MAIN_O = main.o
# src/
SRCS_DIR = src
SRCS = $(shell find $(SRCS_DIR) -name '*.cpp')
OBJS = $(patsubst $(SRCS_DIR)/%.cpp,$(SRCS_DIR)/%.o,$(SRCS))
.PHONY: all clean
all: $(TARGET) push
push: $(TARGET)
scp $(TARGET) $(SSH_USERNAME)@$(SSH_IP):$(SSH_TARGET_FOLDER)
scp -r $(MODES) $(SSH_USERNAME)@$(SSH_IP):$(SSH_MODES_FOLDER)
$(TARGET): $(OBJS) main.o
$(CXX) $(CXXFLAGS) -o $@ $^ $(LDFLAGS)
main.o: main.cpp $(SRCS_DIR)/*.h
$(CXX) $(CXXFLAGS) -o $@ $< -c -I$(LUA_INCDIR) $(RGB_INCDIR)
$(SRCS_DIR)/%.o: $(SRCS_DIR)/%.cpp $(SRCS_DIR)/*.h $(RGB_LIBRARY) $(LUA_LIBRARY)
$(CXX) $(CXXFLAGS) -c $< -o $@ -I$(LUA_INCDIR) $(RGB_INCDIR)
$(RGB_LIBRARY):
$(MAKE) -C $(RGB_LIBDIR) CXX=$(CXX) CC=$(CC)
$(LUA_LIBRARY):
$(MAKE) -C $(LUA_BUILDDIR) CXX=$(CXX) CC=$(CC)
$(MAKE) -C $(LUA_BUILDDIR) local CXX=$(CXX) CC=$(CC)
clean:
rm -f *.o $(SRCS_DIR)/*.o $(TARGET)