-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.bak
155 lines (146 loc) · 4.21 KB
/
Makefile.bak
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
#!/usr/bin/make
# 使用的编译器
CC=gcc
# 预处理参数
CPPLFAGS=-I./include \
-I/usr/include/fastdfs \
-I/usr/include/fastcommon \
-I/usr/local/include/hiredis/ \
-I/usr/include/mysql/
# 选项
CFLAGS=-Wall
# 需要链接的动态库
LIBS=-lfdfsclient \
-lfastcommon \
-lhiredis \
-lfcgi \
-lm \
-lmysqlclient
# 目录路径
TEST_PATH=test
COMMON_PATH=common
CGI_BIN_PATH=bin_cgi
CGI_SRC_PATH=src_cgi
# 子目标, 因为是测试,所有需要单独生成很多子目标
# 测试用
main=main
redis=redis
# 项目用
login=$(CGI_BIN_PATH)/login
register=$(CGI_BIN_PATH)/register
upload=$(CGI_BIN_PATH)/upload
md5=$(CGI_BIN_PATH)/md5
myfiles=$(CGI_BIN_PATH)/myfiles
dealfile=$(CGI_BIN_PATH)/dealfile
sharefiles=$(CGI_BIN_PATH)/sharefiles
dealsharefile=$(CGI_BIN_PATH)/dealsharefile
# 最终目标
target=$(login) \
$(register) \
$(upload) \
$(md5) \
$(myfiles) \
$(dealfile) \
$(sharefiles) \
$(dealsharefile)
ALL:$(target)
#######################################################################
# 测试程序相关的规则
# 生成每一个子目标,
# main程序
$(main):$(TEST_PATH)/main.o $(TEST_PATH)/fdfs_api.o $(COMMON_PATH)/make_log.o
$(CC) $^ $(LIBS) -o $@
# redis test 程序
$(redis):$(TEST_PATH)/myredis.o
$(CC) $^ $(LIBS) -o $@
#######################################################################
# =====================================================================
# 项目程序规则
# 登录
$(login): $(CGI_SRC_PATH)/login_cgi.o \
$(COMMON_PATH)/make_log.o \
$(COMMON_PATH)/cJSON.o \
$(COMMON_PATH)/deal_mysql.o \
$(COMMON_PATH)/redis_op.o \
$(COMMON_PATH)/cfg.o \
$(COMMON_PATH)/util_cgi.o \
$(COMMON_PATH)/des.o \
$(COMMON_PATH)/base64.o \
$(COMMON_PATH)/md5.o
$(CC) $^ -o $@ $(LIBS)
# 注册
$(register): $(CGI_SRC_PATH)/reg_cgi.o \
$(COMMON_PATH)/make_log.o \
$(COMMON_PATH)/util_cgi.o \
$(COMMON_PATH)/cJSON.o \
$(COMMON_PATH)/deal_mysql.o \
$(COMMON_PATH)/redis_op.o \
$(COMMON_PATH)/cfg.o
$(CC) $^ -o $@ $(LIBS)
# 秒传
$(md5): $(CGI_SRC_PATH)/md5_cgi.o \
$(COMMON_PATH)/make_log.o \
$(COMMON_PATH)/util_cgi.o \
$(COMMON_PATH)/cJSON.o \
$(COMMON_PATH)/deal_mysql.o \
$(COMMON_PATH)/redis_op.o \
$(COMMON_PATH)/cfg.o
$(CC) $^ -o $@ $(LIBS)
# 上传
$(upload):$(CGI_SRC_PATH)/upload_cgi.o \
$(COMMON_PATH)/make_log.o \
$(COMMON_PATH)/util_cgi.o \
$(COMMON_PATH)/cJSON.o \
$(COMMON_PATH)/deal_mysql.o \
$(COMMON_PATH)/redis_op.o \
$(COMMON_PATH)/md5.o \
$(COMMON_PATH)/cfg.o
$(CC) $^ -o $@ $(LIBS)
# 用户列表展示
$(myfiles): $(CGI_SRC_PATH)/myfiles_cgi.o \
$(COMMON_PATH)/make_log.o \
$(COMMON_PATH)/util_cgi.o \
$(COMMON_PATH)/cJSON.o \
$(COMMON_PATH)/deal_mysql.o \
$(COMMON_PATH)/redis_op.o \
$(COMMON_PATH)/cfg.o
$(CC) $^ -o $@ $(LIBS)
# 分享、删除文件、pv字段处理
$(dealfile):$(CGI_SRC_PATH)/dealfile_cgi.o \
$(COMMON_PATH)/make_log.o \
$(COMMON_PATH)/util_cgi.o \
$(COMMON_PATH)/cJSON.o \
$(COMMON_PATH)/deal_mysql.o \
$(COMMON_PATH)/redis_op.o \
$(COMMON_PATH)/cfg.o
$(CC) $^ -o $@ $(LIBS)
# 共享文件列表展示
$(sharefiles): $(CGI_SRC_PATH)/sharefiles_cgi.o \
$(COMMON_PATH)/make_log.o \
$(COMMON_PATH)/util_cgi.o \
$(COMMON_PATH)/cJSON.o \
$(COMMON_PATH)/deal_mysql.o \
$(COMMON_PATH)/redis_op.o \
$(COMMON_PATH)/cfg.o
$(CC) $^ -o $@ $(LIBS)
# 共享文件pv字段处理、取消分享、转存文件
$(dealsharefile): $(CGI_SRC_PATH)/dealsharefile_cgi.o \
$(COMMON_PATH)/make_log.o \
$(COMMON_PATH)/util_cgi.o \
$(COMMON_PATH)/cJSON.o \
$(COMMON_PATH)/deal_mysql.o \
$(COMMON_PATH)/redis_op.o \
$(COMMON_PATH)/cfg.o
$(CC) $^ -o $@ $(LIBS)
# =====================================================================
#######################################################################
# 所有程序都需要的规则
# 生成所有的.o 文件
%.o:%.c
$(CC) -c $< -o $@ $(CPPLFAGS) $(CFLAGS)
# 项目清除
clean:
-rm -rf *.o $(target) $(TEST_PATH)/*.o $(CGI_SRC_PATH)/*.o $(COMMON_PATH)/*.o
# 声明伪文件
.PHONY:clean ALL
#######################################################################