-
Notifications
You must be signed in to change notification settings - Fork 0
/
GNUmakefile
138 lines (109 loc) · 4.36 KB
/
GNUmakefile
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
LAB=6
SOL=0
RPC=./rpc
LAB1GE=$(shell expr $(LAB) \>\= 1)
LAB2GE=$(shell expr $(LAB) \>\= 2)
LAB3GE=$(shell expr $(LAB) \>\= 3)
LAB4GE=$(shell expr $(LAB) \>\= 4)
LAB5GE=$(shell expr $(LAB) \>\= 5)
LAB6GE=$(shell expr $(LAB) \>\= 6)
LAB7GE=$(shell expr $(LAB) \>\= 7)
CXXFLAGS = -g -MMD -I. -I$(RPC) -DLAB=$(LAB) -DSOL=$(SOL) -D_FILE_OFFSET_BITS=64 -std=c++11
FUSEFLAGS= -D_FILE_OFFSET_BITS=64 -DFUSE_USE_VERSION=25 -I/usr/local/include/fuse -I/usr/include/fuse
# choose librpc based on architecture
ifeq ($(shell getconf LONG_BIT),64)
RPCLIB= librpc64.a
else
RPCLIB= librpc86.a
endif
ifeq ($(shell uname -s),Darwin)
MACFLAGS= -D__FreeBSD__=10
else
MACFLAGS=
endif
LDFLAGS = -L. -L/usr/local/lib
LDLIBS = -lpthread
ifeq ($(LAB1GE),1)
ifeq ($(shell uname -s),Darwin)
ifeq ($(shell sw_vers -productVersion | sed -e "s/.*\(10\.[0-9]\).*/\1/"),10.6)
LDLIBS += -lfuse_ino64
else
LDLIBS += -lfuse
endif
else
LDLIBS += -lfuse
endif
endif
#ifeq ($(LAB6GE),1)
# LDLIBS += -lssl -lcrypto
#endif
LDLIBS += $(shell test -f `gcc -print-file-name=librt.so` && echo -lrt)
LDLIBS += $(shell test -f `gcc -print-file-name=libdl.so` && echo -ldl)
CC = g++
CXX = g++
lab: lab$(LAB)
lab1: lab1_tester
lab2: yfs_client
lab3: yfs_client extent_server test-lab-3-g
lab4: lock_server lock_tester lock_demo yfs_client extent_server test-lab-4-a test-lab-4-b
lab5: lock_server lock_tester lock_demo yfs_client extent_server test-lab-5
lab6: lock_server rsm_tester
lab7: lock_server lock_tester lock_demo yfs_client extent_server test_lab_7
lab8: lock_tester lock_server rsm_tester
hfiles1=rpc/fifo.h rpc/connection.h rpc/rpc.h rpc/marshall.h rpc/method_thread.h\
rpc/thr_pool.h rpc/pollmgr.h rpc/jsl_log.h rpc/slock.h rpc/rpctest.cc\
lock_protocol.h lock_server.h lock_client.h gettime.h gettime.cc lang/verify.h \
lang/algorithm.h
hfiles2=yfs_client.h extent_client.h extent_protocol.h extent_server.h
hfiles3=handle.h tprintf.h
hfiles4=log.h rsm.h rsm_protocol.h config.h paxos.h paxos_protocol.h rsm_state_transfer.h rsmtest_client.h tprintf.h
hfiles5=rsm_state_transfer.h rsm_client.h
rsm_files = rsm.cc paxos.cc config.cc log.cc handle.cc
rpc/rpctest=rpc/rpctest.cc
rpc/rpctest: $(patsubst %.cc,%.o,$(rpctest)) rpc/$(RPCLIB)
lock_demo=lock_demo.cc lock_client.cc
lock_demo : $(patsubst %.cc,%.o,$(lock_demo)) rpc/$(RPCLIB)
lock_tester=lock_tester.cc lock_client.cc
lock_tester : $(patsubst %.cc,%.o,$(lock_tester)) rpc/$(RPCLIB)
lock_server=lock_server.cc lock_smain.cc
ifeq ($(LAB6GE),1)
lock_server+= $(rsm_files)
endif
lock_server : $(patsubst %.cc,%.o,$(lock_server)) rpc/$(RPCLIB)
lab1_tester=lab1_tester.cc extent_client.cc extent_server.cc inode_manager.cc #disk.cc
lab1_tester : $(patsubst %.cc,%.o,$(lab1_tester))
test_lab_7=yfs_client.cc extent_client.cc test_lab_7.cc extent_server.cc inode_manager.cc #disk.cc
yfs_client=yfs_client.cc extent_client.cc fuse.cc extent_server.cc inode_manager.cc #disk.cc
ifeq ($(LAB3GE),1)
yfs_client += lock_client.cc
test_lab_7 += lock_client.cc
endif
yfs_client : $(patsubst %.cc,%.o,$(yfs_client)) rpc/$(RPCLIB)
test_lab_7 : $(patsubst %.cc,%.o,$(test_lab_7)) rpc/$(RPCLIB)
extent_server=extent_server.cc extent_smain.cc inode_manager.cc #disk.cc
extent_server : $(patsubst %.cc,%.o,$(extent_server)) rpc/$(RPCLIB)
test-lab-3-b=test-lab-3-b.c
test-lab-3-b: $(patsubst %.c,%.o,$(test_lab_4-b)) rpc/$(RPCLIB)
test-lab-3-c=test-lab-3-c.c
test-lab-4-c: $(patsubst %.c,%.o,$(test_lab_4-c)) rpc/$(RPCLIB)
rsm_tester=rsm_tester.cc rsmtest_client.cc
rsm_tester: $(patsubst %.cc,%.o,$(rsm_tester)) rpc/$(RPCLIB)
%.o: %.cc
$(CXX) $(CXXFLAGS) -c $< -o $@
fuse.o: fuse.cc
$(CXX) -c $(CXXFLAGS) $(FUSEFLAGS) $(MACFLAGS) $<
# mklab.inc is needed by 6.824 staff only. Just ignore it.
-include mklab.inc
-include *.d
-include rpc/*.d
clean_files=rpc/rpctest rpc/*.o rpc/*.d *.o *.d yfs_client extent_server lock_server lock_tester lock_demo rpctest test-lab-3-a test-lab-3-b test-lab-3-c test-lab-4-a test-lab-4-b test-lab-5 rsm_tester lab1_tester test_lab_7
.PHONY: clean handin
clean:
rm $(clean_files) -rf
handin_ignore=$(clean_files) core* *log
handin_file=lab$(LAB).tgz
labdir=$(shell basename $(PWD))
handin:
@bash -c "cd ../; tar -X <(tr ' ' '\n' < <(echo '$(handin_ignore)')) -czvf $(handin_file) $(labdir); mv $(handin_file) $(labdir); cd $(labdir)"
@echo Please modify lab5.tgz to lab5_[your student id].tgz and upload it to ftp.
@echo Thanks!