-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
52 lines (38 loc) · 1 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
# Compiler
CC = g++
CXX = $(CC)
# OSX include paths
CFLAGS = -Wc++11-extensions -std=c++11 -I./include -DENABLE_PRECOMPILED_HEADERS=OFF $(shell pkg-config --cflags opencv4)
# Dwarf include paths
CXXFLAGS = $(CFLAGS)
# Opencv libraries
LDLIBS = $(shell pkg-config --libs opencv4)
# Directories
BINDIR = ./bin
SRCDIR = ./src
OBJDIR = ./obj
INCDIR = ./include
# Target exe
TARGET = $(BINDIR)/main
# Source files
SRCS = $(wildcard $(SRCDIR)/*.cpp)
# Object files
OBJS = $(SRCS:$(SRCDIR)/%.cpp=$(OBJDIR)/%.o)
# Ensure the output directory exists
$(shell mkdir -p $(BINDIR) $(OBJDIR))
# Build the target
$(TARGET): $(OBJS)
$(CC) $^ -o [email protected] $(LDLIBS)
# # Linking executable to object files
$(OBJDIR)/%.o: $(SRCDIR)/%.cpp
$(CC) $(CXXFLAGS) -c $< -o $@
# Include dependencies
-include $(OBJS:.o=.d)
# Generate dependencies
$(OBJDIR)/%.d: $(SRCDIR)/%.cpp
$(CC) $(CXXFLAGS) -MM -MT $(@:.d=.o) $< > $@
# Clean up
clean:
rm -f $(OBJDIR)/*.o $(TARGET)
# Phony targets - will run regardless of file existence
.PHONY: clean