-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMakefile
More file actions
151 lines (111 loc) · 6.51 KB
/
Makefile
File metadata and controls
151 lines (111 loc) · 6.51 KB
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
# Sources:
# https://github.com/google/googlemock/blob/master/googlemock/make/Makefile
# https://github.com/google/googletest/blob/master/googletest/make/Makefile
# Points to the root of Google Test, relative to where this file is.
# Remember to tweak this if you move this file.
GTEST_DIR=googletest/googletest
GMOCK_DIR=googletest/googlemock
# Flags passed to the preprocessor.
# Set Google Test's header directory as a system directory, such that
# the compiler doesn't generate warnings in Google Test headers.
CPPFLAGS += -isystem $(GTEST_DIR)/include -isystem $(GMOCK_DIR)/include
# Flags passed to the C++ compiler.
CXXFLAGS += -g -Wall -Wextra -Werror -static-libgcc -static-libstdc++ -pthread -Wl,-Bstatic -lm -std=c++0x
# All Google Test headers. Usually you shouldn't change this
# definition.
GTEST_HEADERS = $(GTEST_DIR)/include/gtest/*.h \
$(GTEST_DIR)/include/gtest/internal/*.h
GMOCK_HEADERS = $(GMOCK_DIR)/include/gmock/*.h \
$(GMOCK_DIR)/include/gmock/internal/*.h \
$(GTEST_HEADERS)
# Builds gtest.a and gtest_main.a.
# Usually you shouldn't tweak such internal variables, indicated by a
# trailing _.
GTEST_SRCS_ = $(GTEST_DIR)/src/*.cc $(GTEST_DIR)/src/*.h $(GTEST_HEADERS)
GMOCK_SRCS_ = $(GMOCK_DIR)/src/*.cc $(GMOCK_HEADERS)
.PHONY: clean deploy
all: server
clean:
rm -f config_parser server *_test *.o *.a *.gcno *.gcda *.gcov
deploy:
docker build -t httpserver.build . ; \
docker run httpserver.build > ./deploy/binary.tar; tar -xvf ./deploy/binary.tar -C ./deploy; \
rm -f ./deploy/binary.tar; docker build -t httpserver -f deploy/Dockerfile.run ./deploy; \
docker save httpserver | bzip2 | ssh -i cs130.pem ubuntu@ec2-54-202-151-253.us-west-2.compute.amazonaws.com 'bunzip2 | docker load; docker stop httpserver; docker rm -f `docker ps -aq -f name=httpserver`; docker run --name=httpserver --rm -t -p 80:8080 httpserver;'
server: server_main.o server.o config_parser.o echo_handler.o request_handler.o static_file_handler.o not_found_handler.o \
status_counter.o status_handler.o reverse_proxy_handler.o redirect_handler.o markdown.o markdown_tokens.o compressor.o
$(CXX) $(CXXFLAGS) -lpthread $^ -o $@ -lboost_system -lboost_regex -lboost_iostreams -lz
config_parser: config_parser.cc config_parser_main.cc
g++ config_parser.cc config_parser_main.cc -std=c++0x -g -Wall -o config_parser
# For simplicity and to avoid depending on Google Test's
# implementation details, the dependencies specified below are
# conservative and not optimized. This is fine as Google Test
# compiles fast and for ordinary users its source rarely changes.
gtest-all.o : $(GTEST_SRCS_)
$(CXX) $(CPPFLAGS) -I$(GTEST_DIR) $(CXXFLAGS) -c \
$(GTEST_DIR)/src/gtest-all.cc
gtest_main.o : $(GTEST_SRCS_)
$(CXX) $(CPPFLAGS) -I$(GTEST_DIR) $(CXXFLAGS) -c \
$(GTEST_DIR)/src/gtest_main.cc
gtest.a : gtest-all.o
$(AR) $(ARFLAGS) $@ $^
gtest_main.a : gtest-all.o gtest_main.o
$(AR) $(ARFLAGS) $@ $^
gmock-all.o : $(GMOCK_SRCS_)
$(CXX) $(CPPFLAGS) -I$(GTEST_DIR) -I$(GMOCK_DIR) $(CXXFLAGS) \
-c $(GMOCK_DIR)/src/gmock-all.cc
gmock_main.o : $(GMOCK_SRCS_)
$(CXX) $(CPPFLAGS) -I$(GTEST_DIR) -I$(GMOCK_DIR) $(CXXFLAGS) \
-c $(GMOCK_DIR)/src/gmock_main.cc
gmock.a : gmock-all.o gtest-all.o
$(AR) $(ARFLAGS) $@ $^
gmock_main.a : gmock-all.o gtest-all.o gmock_main.o
$(AR) $(ARFLAGS) $@ $^
$(basename $(wildcard %.o)) : %.cc
$(CXX) $(CXXFLAGS) -c %.cc
$(basename $(wildcard %_test.o)) : %_test.cc $(GMOCK_HEADERS)
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c %_test.cc
request_handler_test : request_handler_test.o request_handler.o echo_handler.o static_file_handler.o not_found_handler.o \
status_handler.o status_counter.o gmock_main.a markdown.o markdown_tokens.o compressor.o
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -lpthread $^ -o $@ -lboost_system -lboost_regex -lboost_iostreams -lz
echo_handler_test : echo_handler_test.o echo_handler.o request_handler.o compressor.o gmock_main.a
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -lpthread $^ -o $@ -lboost_system -lboost_iostreams -lz
server_test : config_parser.o server.o server_test.o request_handler.o echo_handler.o static_file_handler.o \
status_counter.o status_handler.o not_found_handler.o gmock_main.a reverse_proxy_handler.o \
redirect_handler.o markdown.o markdown_tokens.o compressor.o
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -lpthread $^ -o $@ -lboost_system -lboost_regex -lboost_iostreams -lz
config_parser_test : config_parser.o config_parser_test.o gtest_main.a
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -lpthread $^ -o $@ -lboost_system
static_file_handler_test : static_file_handler.o static_file_handler_test.o request_handler.o not_found_handler.o \
markdown.o markdown_tokens.o compressor.o gmock_main.a
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -lpthread $^ -o $@ -lboost_system -lboost_regex -lboost_iostreams -lz
not_found_handler_test : not_found_handler_test.o not_found_handler.o request_handler.o gmock_main.a
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -lpthread $^ -o $@ -lboost_system
status_handler_test : status_handler_test.o status_handler.o request_handler.o status_counter.o gmock_main.a markdown.o markdown_tokens.o
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -lpthread $^ -o $@ -lboost_system -lboost_regex
status_counter_test : status_counter_test.o status_counter.o gmock_main.a
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -lpthread $^ -o $@ -lboost_system
redirect_handler_test : redirect_handler_test.o redirect_handler.o request_handler.o gmock_main.a
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -lpthread $^ -o $@ -lboost_system
reverse_proxy_handler_test : reverse_proxy_handler_test.o reverse_proxy_handler.o request_handler.o config_parser.o gmock_main.a
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -lpthread $^ -o $@ -lboost_system
compressor_test : compressor.o compressor_test.o gtest_main.a
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -lpthread $^ -o $@ -lboost_system -lboost_iostreams -lz
TESTS = config_parser_test server_test echo_handler_test \
request_handler_test static_file_handler_test \
not_found_handler_test status_handler_test \
redirect_handler_test reverse_proxy_handler_test \
compressor_test
test : $(TESTS)
for t in $^ ; do ./$$t ; done
coverage : CXXFLAGS += -fprofile-arcs -ftest-coverage
coverage : clean test
gcov -r server.cc; gcov -r config_parser.cc; \
gcov -r echo_handler.cc; gcov -r request_handler.cc; \
gcov -r static_file_handler.cc; gcov -r status_handler.cc; \
gcov -r not_found_handler.cc; gcov -r status_counter.cc; \
gcov -r compressor.cc; gcov -r redirect_handler.cc; gcov -r reverse_proxy_handler.cc;
integration :
make clean && make;
python server_integration_test.py;
python multithreading_test.py;