-
Notifications
You must be signed in to change notification settings - Fork 110
/
Makefile
71 lines (49 loc) · 2.6 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
.PHONY: all test clean deps test-deps tags
CXX=g
CXXFLAGS = -g -Wall
LDFLAGS = -pthread
MULTIPART_PARSER_INC_PATH=-I deps/multipart-parser-c/
MULTIPART_PARSER_LIB_PATH=deps/multipart-parser-c/multipart_parser.o
DEPS_INCLUDE_PATH=-I deps/json-cpp/include/ -I deps/http-parser/ $(MULTIPART_PARSER_INC_PATH)
DEPS_LIB_PATH=deps/json-cpp/output/lib/libjson_libmt.a deps/http-parser/libhttp_parser.a $(MULTIPART_PARSER_LIB_PATH)
GTEST_INC=-I deps/googletest/googletest/include
GTEST_LIB=deps/googletest/googletest/make/gtest_main.a
SRC_INCLUDE_PATH=-I src
OUTPUT_INCLUDE_PATH=-I output/include
OUTPUT_LIB_PATH=output/lib/libsimpleserver.a
objects := $(patsubst %.cpp,%.o,$(wildcard src/*.cpp))
all: libsimpleserver.a
prepare:
mkdir -p output/include output/lib output/bin
cp src/*.h output/include/
tags:
ctags -R /usr/include src deps
deps: prepare
make -C deps/http-parser package
make -C deps/json-cpp
make -C deps/multipart-parser-c
test-deps:
make -C deps/googletest/googletest/make
libsimpleserver.a: deps $(objects)
ar -rcs libsimpleserver.a src/*.o
mv libsimpleserver.a output/lib/
test: libsimpleserver.a http_server_test sim_parser_test issue5_server threadpool_test
%.o: %.cpp
$(CXX) -c $(CXXFLAGS) $(DEPS_INCLUDE_PATH) $(SRC_INCLUDE_PATH) $< -o $@
http_server_test: test/http_server_test.cpp
$(CXX) $(CXXFLAGS) $(LDFLAGS) $(DEPS_INCLUDE_PATH) $(OUTPUT_INCLUDE_PATH) $< $(OUTPUT_LIB_PATH) $(DEPS_LIB_PATH) -o output/bin/$@
threadpool_test: test/threadpool_test.cpp test-deps libsimpleserver.a
$(CXX) $(CXXFLAGS) $(LDFLAGS) $(DEPS_INCLUDE_PATH) $(OUTPUT_INCLUDE_PATH) $(GTEST_INC) $< $(OUTPUT_LIB_PATH) $(DEPS_LIB_PATH) $(GTEST_LIB) -o output/bin/$@
http_multi_thread_demo: test/http_multi_thread_demo.cpp test-deps libsimpleserver.a
$(CXX) $(CXXFLAGS) $(LDFLAGS) $(DEPS_INCLUDE_PATH) $(OUTPUT_INCLUDE_PATH) $(GTEST_INC) $< $(OUTPUT_LIB_PATH) $(DEPS_LIB_PATH) $(GTEST_LIB) -o output/bin/$@
http_multipart_demo: test/http_multipart_demo.cpp libsimpleserver.a
$(CXX) $(CXXFLAGS) $(LDFLAGS) $(DEPS_INCLUDE_PATH) $(OUTPUT_INCLUDE_PATH) $(GTEST_INC) $< $(OUTPUT_LIB_PATH) $(DEPS_LIB_PATH) -o output/bin/$@
sim_parser_test: test/sim_parser_test.cpp test-deps
$(CXX) $(CXXFLAGS) $(LDFLAGS) $(DEPS_INCLUDE_PATH) $(OUTPUT_INCLUDE_PATH) $(GTEST_INC) $< $(OUTPUT_LIB_PATH) $(DEPS_LIB_PATH) $(GTEST_LIB) -o output/bin/$@
issue5_server: test/issue5/issue5_server.cpp
$(CXX) $(CXXFLAGS) $(LDFLAGS) $(DEPS_INCLUDE_PATH) $(OUTPUT_INCLUDE_PATH) $< $(OUTPUT_LIB_PATH) $(DEPS_LIB_PATH) -o output/bin/$@
clean:
rm -rf src/*.o
rm -rf output/*
make -C deps/multipart-parser-c clean
make -C deps/googletest/googletest/make clean