forked from Sparkling-Water/yolo_darknet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
96 lines (69 loc) · 2 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
ifndef CC
CC = gcc
endif
ifndef AR
AR = ar
endif
ifndef CXX
CXX = g++
endif
ifndef CPPFLAGS
CPPFLAGS = -D_GNU_SOURCE -D_REENTRANT=1 -D_FILE_OFFSET_BITS=64 -DNDEBUG
endif
ifndef CXXFLAGS
CXXFLAGS = $(CFLAGS)
endif
ifndef CFLAGS
CFLAGS = -march=native -O2 -fPIC -fomit-frame-pointer -pipe -Wall -Wextra -Wno-unused-result -fno-strict-aliasing -ffunction-sections -fdata-sections
CFLAGS += $(shell pkg-config --cflags opencv4)
endif
ifndef LDFLAGS
LDFLAGS = -march=native -s -Xlinker --gc-sections -Xlinker --as-needed
endif
ifndef DIR
DIR = .
endif
ifndef INCLDIR
INCLDIR = -I.
endif
ifndef STATICLIB_DIR
STATICLIB_DIR = $(DIR)/lib
endif
ifndef LIBDIR
LIBDIR = -L.
LIBDIR += -L$(STATICLIB_DIR)
endif
ifndef LIBS
LIBS = -ldarknet
LIBS += $(shell pkg-config --libs opencv4)
endif
ifneq ($(STATICLIB_DIR), $(wildcard $(STATICLIB_DIR)))
$(shell mkdir -p $(STATICLIB_DIR))
endif
CUR_DIR= $(DIR)
CUR_OBJS=\
$(patsubst %.c,%.o,$(wildcard *.c)) \
$(patsubst %.cpp,%.o,$(wildcard *.cpp)) \
$(patsubst %.cxx,%.o,$(wildcard *.cxx)) \
$(patsubst %.cc,%.o,$(wildcard *.cc))
#搜索当前路径下是否还有其他文件夹
SUBDIRS=$(shell ls -l | grep ^d | awk '{print $$9}')
.SUFFIXES: .c .cpp .cxx .cc .o
.c.o:
$(CC) $(CPPFLAGS) $(CFLAGS) $(INCLDIR) $(LIBDIR) -c $(CUR_DIR)/$*.c
.cpp.o:
$(CXX) -std=c++11 $(CPPFLAGS) $(CXXFLAGS) $(INCLDIR) $(LIBS) -c $(CUR_DIR)/$*.cpp
.cxx.o:
$(CXX) -std=c++11 $(CPPFLAGS) $(CXXFLAGS) $(INCLDIR) $(LIBS) -c $*.cxx
.cc.o:
$(CXX) -std=c++11 $(CPPFLAGS) $(CXXFLAGS) $(INCLDIR) $(LIBS) -c $*.cc
#生成目标文件,之后合成静态库至静态库路径
TARGET = main
all: $(CUR_OBJS)
$(CXX) -std=c++11 -o $(TARGET) $(CUR_OBJS) $(INCLDIR) $(LIBS) # 生成可执行文件
ECHO:
@echo $(SUBDIRS)
#清除目标文件和文件夹对应的静态库文件
.PHONY: clean
clean:
$(RM) $(CUR_OBJS)