-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMakefile
77 lines (65 loc) · 2 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
ROOT=$(shell pwd)
SERVER=$(ROOT)/server
CLIENT=$(ROOT)/client
LOG=$(ROOT)/log
POOL=$(ROOT)/data_pool
COMM=$(ROOT)/comm
LIB=$(ROOT)/lib
WINDOW=$(ROOT)/window
CONF=$(ROOT)/conf
PLUGIN=$(ROOT)/plugin
SERVER_BIN=chat_system
CLIENT_BIN=chat_client
INCLUDE=-I$(POOL) -I$(LOG) -I$(COMM) -I$(LIB)/include -I$(WINDOW)
LDFLAGS= -L$(LIB)/lib -lpthread -ljson -lncurses
SERVER_OBJ=$(shell ls $(SERVER) | grep -E '\.cpp$$' | sed 's/\.cpp/\.o/')
SERVER_OBJ+=$(shell ls $(LOG) | grep -E '\.cpp$$' | sed 's/\.cpp/\.o/')
SERVER_OBJ+=$(shell ls $(POOL) | grep -E '\.cpp$$' | sed 's/\.cpp/\.o/')
SERVER_OBJ+=$(shell ls $(COMM) | grep -E '\.cpp$$' | sed 's/\.cpp/\.o/')
CLIENT_OBJ=$(shell ls $(CLIENT) | grep -E '\.cpp$$' | sed 's/\.cpp/\.o/g')
CLIENT_OBJ+=$(shell ls $(LOG) | grep -E '\.cpp$$' | sed 's/\.cpp/\.o/')
CLIENT_OBJ+=$(shell ls $(COMM) | grep -E '\.cpp$$' | sed 's/\.cpp/\.o/')
CLIENT_OBJ+=$(shell ls $(WINDOW) | grep -E '\.cpp$$' | sed 's/\.cpp/\.o/')
CC=g++
.PHONY:all
all:$(SERVER_BIN) $(CLIENT_BIN)
$(SERVER_BIN):$(SERVER_OBJ)
@$(CC) -o $@ $^ $(LDFLAGS)
@echo "linking [$^] to [$@] .....done"
$(CLIENT_BIN):$(CLIENT_OBJ)
@$(CC) -o $@ $^ $(LDFLAGS)
@echo "linking [$^] to [$@] .....done"
%.o:$(CLIENT)/%.cpp
@$(CC) -c $< $(INCLUDE)
@echo "comping [$^] to [$@]......done"
%.o:$(SERVER)/%.cpp
@$(CC) -c $< $(INCLUDE)
@echo "comping [$^] to [$@]......done"
%.o:$(POOL)/%.cpp
@$(CC) -c $<
@echo "comping [$^] to [$@]......done"
%.o:$(LOG)/%.cpp
@$(CC) -c $<
@echo "comping [$^] to [$@]......done"
%.o:$(COMM)/%.cpp
@$(CC) -c $< $(INCLUDE)
@echo "comping [$^] to [$@]......done"
%.o:$(WINDOW)/%.cpp
@$(CC) -c $< $(INCLUDE)
@echo "comping [$^] to [$@]......done"
.PHONY:debug
debug:
echo $(SERVER_OBJ)
echo $(CLIENT_OBJ)
.PHONY:output
output:
mkdir -p output/server
mkdir -p output/client
mkdir -p output/server/log
cp $(SERVER_BIN) output/server
cp $(CLIENT_BIN) output/client
cp $(PLUGIN)/ctl_server.sh output/server
cp -rf $(CONF) output/server
.PHONY:clean
clean:
rm -rf *.o $(SERVER_BIN) $(CLIENT_BIN) output