-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
60 lines (47 loc) · 1.27 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
# Options to choose which interfaces and libraries should be supported:
OPTION_CURL = true
OPTION_MQTT = true
OPTION_TINKERFORGE = true
CXX := -g++
CXXFLAGS := -pthread -Wall -Wextra -Wno-unused-parameter -O2
LDFLAGS := -L/usr/lib -lstdc++ -lm
BUILD := ./build
OBJ_DIR := $(BUILD)/objects
APP_DIR := .
TARGET := sensorlogger
INCLUDE := -Iinclude/
SRC := $(wildcard src/*.cpp)
# Libcurl support to make HTTP(s) requests.
ifeq ($(OPTION_CURL), true)
CXXFLAGS += -DOPTION_CURL
LDFLAGS += -lcurl
endif
# MQTT Support
ifeq ($(OPTION_MQTT), true)
CXXFLAGS += -DOPTION_MQTT
LDFLAGS += -lpaho-mqttpp3 -lpaho-mqtt3as
endif
# Tinkerforge Support
ifeq ($(OPTION_TINKERFORGE), true)
CXXFLAGS += -DOPTION_TINKERFORGE
INCLUDE += -Itinkerforge/
SRC += $(wildcard tinkerforge/*.cpp)
endif
OBJECTS := $(SRC:%.cpp=$(OBJ_DIR)/%.o)
all: build $(APP_DIR)/$(TARGET)
$(OBJ_DIR)/%.o: %.cpp
@mkdir -p $(@D)
$(CXX) $(CXXFLAGS) $(INCLUDE) -o $@ -c $<
$(APP_DIR)/$(TARGET): $(OBJECTS)
@mkdir -p $(@D)
$(CXX) $(CXXFLAGS) $(INCLUDE) $(LDFLAGS) -o $(APP_DIR)/$(TARGET) $(OBJECTS)
.PHONY: all build clean debug release
build:
@mkdir -p $(APP_DIR)
@mkdir -p $(OBJ_DIR)
debug: CXXFLAGS += -DDEBUG -g
debug: all
release: CXXFLAGS += -O2
release: all
clean:
-@rm -rvf $(OBJ_DIR)/*