-
Notifications
You must be signed in to change notification settings - Fork 1
/
makefile
61 lines (44 loc) · 1.19 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
# Compiler
CC = g++
CPPFLAGS := -Iinclude -MMD -MP
CFLAGS := $(shell pkg-config --cflags opencv4) -Wall -std=c++11
# Linker
LDFLAGS := $(shell pkg-config --libs opencv4)
LDLIBS := -pthread -lm
# Project Directories
SRC_DIR := src
# Project Files
TARGET := lane_line_detector
SRC := $(wildcard $(SRC_DIR)/*.cpp)
OBJ := $(SRC:$(SRC_DIR)/%.cpp=%.o)
# Debug Build
DBG_DIR := debug
DBG_TARGET := $(DBG_DIR)/$(TARGET)
DBG_OBJS := $(addprefix $(DBG_DIR)/, $(OBJ))
DBG_CFLAGS := -g -O0 -DDEBUG
# Release Build
REL_DIR := release
REL_TARGET := $(REL_DIR)/$(TARGET)
REL_OBJS := $(addprefix $(REL_DIR)/, $(OBJ))
REL_CFLAGS := -O3 -DNDEBUG
.PHONY: all clean debug release remake
all: prepare release
# Debug Rules
debug: $(DBG_TARGET)
$(DBG_TARGET): $(DBG_OBJS)
$(CC) $(LDFLAGS) $^ $(LDLIBS) -o $@
$(DBG_DIR)/%.o: $(SRC_DIR)/%.cpp
$(CC) $(CPPFLAGS) $(CFLAGS) $(DBG_CFLAGS) -c $< -o $@
# Release Rules
release: $(REL_TARGET)
$(REL_TARGET): $(REL_OBJS)
$(CC) $(LDFLAGS) $^ $(LDLIBS) -o $@
$(REL_DIR)/%.o: $(SRC_DIR)/%.cpp
$(CC) $(CPPFLAGS) $(CFLAGS) $(REL_CFLAGS) -c $< -o $@
# Other rules
prepare:
@mkdir -p $(DBG_DIR) $(REL_DIR)
remake: clean all
clean:
@$(RM) -rv $(REL_DIR) $(DBG_DIR)
-include $(OBJ:.o=.d)