-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
78 lines (63 loc) · 2.08 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
CXX := -g++
CXXFLAGS := -Wall -Wno-psabi -Werror -Wextra -Wno-implicit-fallthrough
LDFLAGS := -L/usr/lib -lbluetooth -L/usr/local/lib -lstdc++ -lm
BUILD := ./build
OBJ_DIR := $(BUILD)
APP_DIR := $(BUILD)
RELEASE_DIR := deb/govee-gateway/usr/local/bin
TARGET := govee-gateway
ifeq ($(MQTT),1)
CXXFLAGS += -DMQTT
LDFLAGS += -lpaho-mqttpp3 -lpaho-mqtt3a
endif
INCLUDE := -I. -I./src -I/usr/local/include
SRC := \
$(wildcard *.cpp) \
$(wildcard src/*.cpp) \
OBJECTS := $(SRC:%.cpp=$(OBJ_DIR)/%.o)
DEPENDENCIES \
:= $(OBJECTS:.o=.d)
$(OBJ_DIR)/%.o: %.cpp
@mkdir -p $(@D)
$(CXX) $(CXXFLAGS) $(INCLUDE) -c $< -MMD -o $@
$(APP_DIR)/$(TARGET): $(OBJECTS)
@echo "Test version in ${APP_DIR}"
@mkdir -p $(@D)
$(CXX) $(CXXFLAGS) -o $(APP_DIR)/$(TARGET) $^ $(LDFLAGS)
$(RELEASE_DIR)/$(TARGET): $(OBJECTS)
@mkdir -p $(@D)
$(CXX) $(CXXFLAGS) -o $(RELEASE_DIR)/$(TARGET) $^ $(LDFLAGS)
-include $(DEPENDENCIES)
.PHONY: all build clean debug release doc info
all: clean
all: build $(APP_DIR)/$(TARGET)
build:
@mkdir -p $(APP_DIR)
@mkdir -p $(OBJ_DIR)
debug:
@echo "Debug version in ${APP_DIR}"
debug: CXXFLAGS += -DDEBUG -g
debug: all
release:
@echo "Release version in ${RELEASE_DIR}"
release: CXXFLAGS += -O3 -Wno-array-bounds -Wno-stringop-truncation
release: build $(RELEASE_DIR)/$(TARGET)
clean:
-@rm -rvf $(OBJ_DIR)/*
-@rm -rvf $(APP_DIR)/*
-@rm -rvf $(RELEASE_DIR)/$(TARGET)
-@rm -rvf doc/*
doc:
@echo "Building documentation"
@doxygen ./doxygen.config
info:
@echo "[*] Application dir: ${APP_DIR} "
@echo "[*] Object dir: ${OBJ_DIR} "
@echo "[*] Sources: ${SRC} "
@echo "[*] Objects: ${OBJECTS} "
@echo "[*] Dependencies: ${DEPENDENCIES}"
deb: release
deb: $(RELEASE_DIR)/$(TARGET) deb/govee-gateway/DEBIAN/control deb/govee-gateway/usr/local/lib/systemd/system/govee-gateway.service
chmod a+x deb/govee-gateway/DEBIAN/control deb/govee-gateway/DEBIAN/postinst deb/govee-gateway/DEBIAN/postrm deb/govee-gateway/DEBIAN/prerm
dpkg-deb --build deb/govee-gateway
@echo "Debian package created"