-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathMakefile
More file actions
80 lines (61 loc) · 1.99 KB
/
Makefile
File metadata and controls
80 lines (61 loc) · 1.99 KB
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
UNAME_S = $(shell uname -s)
WORK_DIR = $(shell pwd)
BUILD_DIR = $(WORK_DIR)/build
MAKE = make
GREEN='\033[0;32m'
RED='\033[0;31m'
BLUE='\033[0;34m'
END='\033[0m'
SERIAL_DIR= $(shell find ./3rdparty -name "src-serial")
THIRD_PARTY_LIB_DIR= $(shell find ./3rdparty -name "lib")
CC = g++
CPPFLAGS = -std=c++20 -O0 -g
#CPPFLAGS += -Wall
CPPFLAGS += -I$(WORK_DIR)/include
# NOTE: turn on debug here
CPPFLAGS += -D__DEBUG__
# FIXME: imtui dependency linking
CPPFLAGS += -I "./3rdparty/include"
CPPFLAGS += -L "./3rdparty/lib"
LDFLAGS += -lm -lpthread -ldl -lrt -lserial
#LDFLAGS = `pkg-config sdl --libs`
SRC = $(wildcard src/*.cpp) $(wildcard src/**/*.cpp) demo/demo1.cpp
INC = $(wildcard include/*.hpp) $(wildcard include/**/*.hpp)
OBJ = $(addprefix $(BUILD_DIR)/, $(addsuffix .o, $(basename $(SRC))))
BIN = Manager
.PHONY: all clean
all: dirs $(BIN)
dirs:
@echo -e + $(BLUE)MKDIR$(END) $(BUILD_DIR)
@mkdir -p $(BUILD_DIR)/src
@mkdir -p $(BUILD_DIR)/demo
# Setup can0 can1 and serial interfase
os-deps:
@sudo ip link set can0 up type can bitrate 1000000
@echo -e + $(BLUE)CAN0$(END) $(GREEN)UP$(END)
@sudo ip link set can1 up type can bitrate 1000000
@echo -e + $(BLUE)CAN1$(END) $(GREEN)UP$(END)
@sudo chmod -R 777 /dev/ttyACM0
@echo -e + $(BLUE)ACM0$(END) $(GREEN)UP$(END)
run: all
$(BUILD_DIR)/$(BIN)
clean-build: clean
@make all -j8
serial: $(SERIAL_DIR)
@$(MAKE) -C $< -j8
@echo -e + $(BLUE)MV$(END) $(SERIAL_DIR)/build/libserial.a $(THIRD_PARTY_LIB_DIR)
@mv $(SERIAL_DIR)/build/libserial.a $(THIRD_PARTY_LIB_DIR)
$(BIN): $(OBJ) serial $(INC)
@echo -e + $(GREEN)LN$(END) $(BUILD_DIR)/$(BIN)
@$(CC) -o $(BUILD_DIR)/$(BIN) $(OBJ) $(CPPFLAGS) $(LDFLAGS)
$(BUILD_DIR)/%.o: %.cpp
@mkdir -p $(dir $@)
@echo -e + $(GREEN)CC$(END) $<
@$(CC) -o $@ -c $< $(CPPFLAGS)
clean-serial: $(SERIAL_DIR)
$(MAKE) -C $< clean
clean: clean-serial
@echo -e + $(BLUE)RM$(END) 3rdparty/lib/libserial.a
@rm 3rdparty/lib/libserial.a
@echo -e + $(BLUE)RM$(END) $(BUILD_DIR)/$(BIN) OBJs
@rm -rf $(BUILD_DIR)/$(BIN) $(OBJ)