-
Notifications
You must be signed in to change notification settings - Fork 72
/
Makefile
executable file
·65 lines (56 loc) · 1.87 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
# Redis Lock Makefile
CC = gcc
CCC = g++
CXX = g++
BASICOPTS = -g -O -Wall -fPIC -Wno-reorder
CBASICOPTS = -g -O -Wall -fPIC
CFLAGS = $(CBASICOPTS)
CCFLAGS = $(BASICOPTS)
CXXFLAGS = $(BASICOPTS)
CCADMIN =
INCLUDE = -I./ -I/usr/local/include/ -I./redlock-cpp/ -I./hiredis/
CINCLUDE = -I./ -I/usr/local/include/
LOCKLIB = -L./bin -lredlock -L./hiredis -lhiredis
# 动态库目录
TARGETDIR_BIN=bin
OUTPUT = libredlock.a
EXOUTPUT = LockExample
EXOUTPUTCLOCK = CLockExample
all: $(TARGETDIR_BIN)/$(OUTPUT) $(TARGETDIR_BIN)/$(EXOUTPUT) $(TARGETDIR_BIN)/$(EXOUTPUTCLOCK)
## 编译文件
OBJS_libcomm = \
$(TARGETDIR_BIN)/sds.o\
$(TARGETDIR_BIN)/redlock.o
EXOBJS = \
$(TARGETDIR_BIN)/LockExample.o\
$(TARGETDIR_BIN)/sds.o\
$(TARGETDIR_BIN)/redlock.o
EXOBJSCLOCK = \
$(TARGETDIR_BIN)/CLockExample.o\
$(TARGETDIR_BIN)/sds.o\
$(TARGETDIR_BIN)/redlock.o
# 链接或归档
ARCPP = $(AR) $(ARFLAGS) $@
$(TARGETDIR_BIN)/$(OUTPUT): $(TARGETDIR_BIN) $(OBJS_libcomm)
$(ARCPP) $(OBJS_libcomm)
$(TARGETDIR_BIN)/$(EXOUTPUT): $(TARGETDIR_BIN) $(EXOBJS)
$(CXX) $(CXXFLAGS) -o $(TARGETDIR_BIN)/$(EXOUTPUT) $(EXOBJS) $(LOCKLIB)
$(TARGETDIR_BIN)/$(EXOUTPUTCLOCK): $(TARGETDIR_BIN) $(EXOBJSCLOCK)
$(CXX) $(CXXFLAGS) -o $(TARGETDIR_BIN)/$(EXOUTPUTCLOCK) $(EXOBJSCLOCK) $(LOCKLIB)
# 将原文件编译为 .o 文件
$(TARGETDIR_BIN)/%.o : ./redlock-cpp/%.cpp
$(CXX) $(CXXFLAGS) $(INCLUDE) -o $@ -c $(filter %.cpp, $^)
$(TARGETDIR_BIN)/%.o : ./redlock-cpp/%.c
$(CC) $(CFLAGS) $(CINCLUDE) -o $@ -c $<
$(TARGETDIR_BIN)/%.o : ./%.cpp
$(CXX) $(CXXFLAGS) $(INCLUDE) -o $@ -c $(filter %.cpp, $^)
#### 清理目标,删除所生成的文件 ####
clean:
rm -f \
$(TARGETDIR_BIN)/$(OUTPUT) \
$(TARGETDIR_BIN)/*.o
$(CCADMIN)
rm -f -r $(TARGETDIR_BIN)
# 创建目标目录(如果需要)
$(TARGETDIR_BIN):
mkdir -p $(TARGETDIR_BIN)