-
Notifications
You must be signed in to change notification settings - Fork 38
/
Copy pathMakefile
108 lines (73 loc) · 1.8 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
97
98
99
100
101
102
103
104
105
106
107
108
CC=gcc
CPPFLAGS=-I./include -I./ -I/usr/include/mysql/ -I/usr/include/fastdfs/ -I/usr/include/fastcommon/
CFLAGS=-Wall
LIBS= -lfcgi -lm -lmysqlclient -lhiredis -lfdfsclient
#找到当前目录下所有的.c文件
src = $(wildcard *.c)
#将当前目录下所有的.c 转换成.o给obj
obj = $(patsubst %.c, %.o, $(src))
#test
test_config=test/test_config
test_redis=test/test_redis
#cgi
upload=cgi_bin/upload
data=cgi_bin/data
reg=cgi_bin/reg
login=cgi_bin/login
target=$(upload) $(data) $(reg) $(login) $(test_config) $(test_redis)
ALL:$(target)
#生成所有的.o文件
$(obj):%.o:%.c
$(CC) -c $< -o $@ $(CPPFLAGS) $(CFLAGS)
#upload cgi程序
$(upload):upload_cgi.o \
cJSON.o \
dao_mysql.o \
util_cgi.o \
make_log.o \
redis_op.o \
config.o
$(CC) $^ -o $@ $(LIBS)
#data cgi程序
$(data): data_cgi.o \
cJSON.o \
dao_mysql.o \
util_cgi.o \
make_log.o \
redis_op.o \
config.o
$(CC) $^ -o $@ $(LIBS)
#reg cgi程序
$(reg): reg_cgi.o \
cJSON.o \
dao_mysql.o \
util_cgi.o \
make_log.o \
redis_op.o \
config.o
$(CC) $^ -o $@ $(LIBS)
#login cgi程序
$(login): login_cgi.o \
cJSON.o \
dao_mysql.o \
util_cgi.o \
make_log.o \
redis_op.o \
config.o
$(CC) $^ -o $@ $(LIBS)
#test_config 程序
$(test_config): test/test_config.o \
config.o
$(CC) $^ -o $@ $(LIBS)
#test_redis 程序
$(test_redis): test/test_redis_main.o \
redis_op.o \
make_log.o
$(CC) $^ -o $@ $(LIBS)
#clean指令
clean:
-rm -rf $(obj) $(target) ./test/*.o
distclean:
-rm -rf $(obj) $(target) ./test/*.o
#将clean目标 改成一个虚拟符号
.PHONY: clean ALL distclean