forked from ZX-Pluto/Yazi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
60 lines (44 loc) · 1.94 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
.PHONY: plugin
#指定编译器
CC = g++
#找出当前目录下,所有的源文件(以.cpp结尾)
SRCS := $(shell find ./* -type f | grep '\.cpp' | grep -v '\.svn' | grep -v '\./plugin' | grep -v '\./log' | grep -v 'main\.cpp'|grep -v '\./yazi-json'|grep -v '\./thread11' |grep -v '\./yazi-reflect'|grep -v '\./yazi-rpc')
$(warning SRCS is ${SRCS})
#确定cpp源文件对应的目标文件
OBJS := $(patsubst %.cpp, %.o, $(filter %.cpp, $(SRCS)))
$(warning OBJS is ${OBJS})
#编译选项
CFLAGS = -g -O2 -Wall -Werror -Wno-unused -ldl -fPIC
$(warning CFLAGS is ${CFLAGS})
#找出当前目录下所有头文件
INCLUDE_TEMP = $(shell find ./* -type d | grep -v '\.svn' | grep -v '\./plugin' | grep -v '\./client' | grep -v '\./config' | grep -v '\./log' |grep -v '\./yazi-json'| grep -v '\./thread11'|grep -v '\./yazi-reflect'|grep -v '\./yazi-rpc')
INCLUDE = $(patsubst %,-I %, $(INCLUDE_TEMP))
$(warning INCLUDE is ${INCLUDE})
LDFLAG = -lpthread -std=c++11
#主程序
SRC_MAIN = main.cpp
OBJ_MAIN = ${SRC_MAIN:%.cpp=%.o}
EXE_MAIN = main
target: ${EXE_MAIN}
$(EXE_MAIN): $(OBJ_MAIN) $(OBJS)
$(CC) -o $@ $^ $(CFLAGS) $(INCLUDE) $(LDFLAG)
%.o: %.cpp
${CC} ${CFLAGS} ${INCLUDE} -c $< -o $@
# test 插件
PULGIN_TEST = plugin/testplugin.so
SRC_PLUGIN_TEST = plugin/TestPlugin.cpp json/Parser.cpp json/Json.cpp
# user 插件
PLUGIN_USER = plugin/userplugin.so
SRC_PLUGIN_USER = plugin/UserPlugin.cpp json/Parser.cpp json/Json.cpp
# echo 插件
PLUGIN_ECHO = plugin/echoplugin.so
SRC_PLUGIN_ECHO = plugin/EchoPlugin.cpp utility/Logger.cpp utility/System.cpp
${PULGIN_TEST}:
${CC} -shared -fPIC ${INCLUDE} ${SRC_PLUGIN_TEST} -o ${PULGIN_TEST}
${PLUGIN_USER}:
${CC} -shared -fPIC ${INCLUDE} ${SRC_PLUGIN_USER} -o ${PLUGIN_USER}
${PLUGIN_ECHO}:
${CC} -shared -fPIC ${INCLUDE} ${SRC_PLUGIN_ECHO} -o ${PLUGIN_ECHO}
plugin: ${PULGIN_TEST} ${PLUGIN_USER} ${PLUGIN_ECHO}
clean:
rm -f ${OBJS} ${OBJ_MAIN} ${EXE_MAIN}