-
Notifications
You must be signed in to change notification settings - Fork 5
/
Makefile
executable file
·46 lines (36 loc) · 1.14 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
#SDK测试程序
CXX = g++
CXXFLAGS = -Wall -Wno-strict-aliasing -Wno-unused-variable
#包含头文件路径
SUBDIR = $(shell ls ./src -R | grep /)
SUBDIRS = $(subst :,/,$(SUBDIR))
INCPATHS = $(subst ./,-I./,$(SUBDIRS))
INCPATHS += -I./include/
VPATH = $(subst : ,:,$(SUBDIR))./
SOURCE = $(foreach dir,$(SUBDIRS),$(wildcard $(dir)*.cpp))
#将cpp的路径名称的.cpp后缀换为.o
OBJS = $(patsubst %.cpp,%.o,$(SOURCE))
#取出.o的文件名,不带路径
OBJFILE = $(foreach dir,$(OBJS),$(notdir $(dir)))
#.o输出到.OBJ目录下
OBJSPATH = $(addprefix obj/,$(OBJFILE))
LIBPATH = ./lib/
LIBS = -Wl,-rpath=./:./HCNetSDKCom:../lib -lhcnetsdk
EXE = ./lib/rtmp-HK
#-lpthread
$(EXE):$(OBJFILE)
$(CXX) -L$(LIBPATH) -o $(EXE) $(OBJFILE) $(INCPATHS) $(LIBS) -lpthread -std=c++11
$(OBJFILE):%.o:%.cpp
$(CXX) -c -o $@ $< $(INCPATHS) -pipe -g -Wall -std=c++11
#依赖文件
DPPS = $(patsubst %.cpp,%.dpp,$(SOURCE))
include $(DPPS)
%.dpp: %.cpp
g++ $(INCPATHS) -MM $(CPPFLAGS) $< > $@.$$$$ -std=c++11; \
sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
rm -f $@.$$$$
.PHONY:clean
clean:
rm -rf $(OBJFILE)
rm -rf $(DPPS)
rm -rf $(EXE)