Skip to content

Commit 93b54dd

Browse files
committed
Makefile update
1 parent fd2982b commit 93b54dd

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed

Examples/opencv-basic_5CRO/Makefile

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#
2+
# make file
3+
#
4+
5+
.SUFFIXES : .cpp .o
6+
7+
# GNU C++ compiler
8+
CC = g++
9+
10+
TARGET = $(notdir $(shell pwd)) ## current foldername is target name
11+
12+
BUILD_PATH = ./build
13+
14+
BIN_PATH = $(BUILD_PATH)/bin
15+
OBJ_PATH = $(BUILD_PATH)/obj
16+
17+
SRC_PATH = .
18+
19+
SRCS = $(wildcard $(SRC_PATH)/*.cpp)
20+
OBJS = $(SRCS:$(SRC_PATH)/%.cpp=$(OBJ_PATH)/%.o)
21+
22+
INCS += -I.
23+
INCS += -I/usr/local/include
24+
25+
CXXFLAGS = $(INCS) -c -O2 #-std=c++11 -W -Wall -O0 $(shell pkg-config --cflags opencv)
26+
27+
# Link Options
28+
LIBS += -lpthread
29+
30+
# OpenCV default
31+
LIBS += $(shell pkg-config --libs opencv)
32+
33+
LDFLAGS = $(LIVDIRS) -lm $(LIBS)
34+
35+
# rm options
36+
RM = @rm -rfv
37+
38+
# mkdir options
39+
MKDIR = @mkdir -p
40+
41+
$(BIN_PATH)/$(TARGET): $(OBJS)
42+
$(MKDIR) $(BIN_PATH)
43+
$(CC) -o $(BIN_PATH)/$(TARGET) $(OBJS) $(LDFLAGS)
44+
45+
$(OBJ_PATH)/%.o: $(SRC_PATH)/%.cpp
46+
$(MKDIR) $(OBJ_PATH)
47+
$(CC) $(CXXFLAGS) $< -o $@
48+
49+
all : $(BIN_PATH)/$(TARGET)
50+
51+
# dependency
52+
dep :
53+
$(MKDIR) $(BUILD_PATH)
54+
$(CC) -M $(INCS) $(SRCS) > $(BUILD_PATH)/.depend
55+
56+
# clean
57+
clean:
58+
$(RM) $(BUILD_PATH)
59+
$(RM) $(TARGET)
60+
@echo "Done."
61+
62+
# include dependency
63+
ifeq (.depend,$(wildcard .depend))
64+
include .depend
65+
endif

0 commit comments

Comments
 (0)