-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
81 lines (66 loc) · 2.79 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
76
77
78
79
80
81
BOOST_FLAGS = -lboost_log_setup -lboost_log -lboost_thread -lboost_system -lboost_regex
TEST_FLAGS = -fprofile-arcs -ftest-coverage
COMMON_FLAGS = -lpthread
GTEST_DIR = googletest/googletest
CPP_FILES = $(wildcard ./src/*.cc)
OBJ_FILES := $(CPP_FILES:.cc=.o)
NGINX_FILE= nginx-configparser/config_parser.cc
NGINX_OBJ= nginx-configparser/config_parser.o
MARKDOWN_SOURCE = cpp-markdown/src/markdown-tokens.cpp cpp-markdown/src/markdown.cpp
MARKDOWN_OBJ = $(patsubst %.cpp, %.o, $(MARKDOWN_SOURCE))
ZLIB_OBJ = src/library/zlib.o
ZLIB_FILE = src/library/zlib.cpp
TEST_FILES = $(wildcard ./test/*_test.cc)
TESTS = $(TEST_FILES:%.cc=%)
CPP_EXCEPT_MAIN = $(filter-out ./src/webserver_main.cc, $(CPP_FILES))
AWS_KEY = ~/Downloads/cs130.pem
webserver: $(OBJ_FILES) $(NGINX_OBJ) $(MARKDOWN_OBJ) $(ZLIB_OBJ)
$(CXX) -o $@ $^ -static-libgcc -static-libstdc++ $(COMMON_FLAGS) -Wl,-Bstatic $(BOOST_FLAGS) -lz
.PHONY: webserver
cpp-markdown/src/%.o: cpp-markdown/src/%.cpp
g++ -std=c++11 $^ -c -o $@
nginx-configparser/config_parser.o: $(NGINX_FILE)
g++ -std=c++11 -g -I ${GTEST_DIR}/include -I . -c -BOOST_ALL_DYN_LINK -o $@ $<
src/library/zlib.o: src/library/zlib.cpp
g++ -std=c++11 -c $< -o $@
src/%.o: src/%.cc
g++ -std=c++11 -g -I ${GTEST_DIR}/include -I . -c -BOOST_ALL_DYN_LINK -o $@ $<
test/%_test : test/%_test.cc libgtest.a src/%.cc
g++ -std=c++11 -DBOOST_LOG_DYN_LINK -isystem ${GTEST_DIR}/include -I ./src -I . -o $@ $(ZLIB_FILE) $(CPP_EXCEPT_MAIN) $(NGINX_FILE) ${GTEST_DIR}/src/gtest_main.cc $(MARKDOWN_SOURCE) $(word 1, $^) $(word 2, $^) $(TEST_FLAGS) $(COMMON_FLAGS) $(BOOST_FLAGS) -lz
$@
rm $@
@mv *.gcno src/
@mv *.gcda src/
gcov -r $(word 3, $^)
test: $(TESTS) webserver
chmod a+x integration-test.py
./integration-test.py
chmod a+x multi_thread_integration_test.py
./multi-thread-integration-test.py
./proxy-integration-test.sh
.PHONY: test
proxy:
./proxy-integration-test.sh
libgtest.a: $(GTEST_DIR)
g++ -std=c++11 -isystem ${GTEST_DIR}/include -I${GTEST_DIR} -pthread -c ${GTEST_DIR}/src/gtest-all.cc
ar -rv libgtest.a gtest-all.o
clean:
@find . -name \*.o -delete
@find . -name \*.gcov -delete
@find . -name \*.gcno -delete
@find . -name \*.gcda -delete
@rm -rf webserver *.d *.a
docker-build:
docker build -t httpserver.build .
docker run httpserver.build > ./deploy/binary.tar
tar -xzvf ./deploy/binary.tar -C ./deploy
rm ./deploy/binary.tar
docker build -t httpserver deploy
docker-deploy: $(AWS_KEY)
docker save -o ./httpserver.tar httpserver
scp -i $(AWS_KEY) ./httpserver.tar [email protected]:~
rm ./httpserver.tar
ssh -i $(AWS_KEY) [email protected] \
-t 'docker stop $$(docker ps -a -q); docker load -i httpserver.tar; docker run -d -t -p 80:80 httpserver; exit'
.PHONY: docker-deploy
print-% : ; @echo $* = $($*)