summaryrefslogtreecommitdiffhomepage
path: root/tests/Makefile
blob: c88a2857fe87054a8e15e0e119f99e5dddfead87 (plain)
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
CXXFLAGS=-g -O0

include ../common.mk

PROJECTNAME=test-webserver

ifeq ($(CXXTYPE),clang++)
CXXFLAGS+=-fprofile-instr-generate -fcoverage-mapping
LDFLAGS+=-fprofile-instr-generate -fcoverage-mapping
else
# GCC
CXXFLAGS+=--coverage
LDFLAGS+=--coverage
endif

CXXFLAGS+= -I. -I.. -fPIE

CXXTESTFLAGS=

CXXFLAGS+=$(shell pkg-config --cflags fcgi)

LIBS+=\
-lreichwein \
-lboost_context \
-lboost_filesystem \
-lboost_timer \
-lboost_system \
-lcrypt \
-lpthread \
-lssl -lcrypto \
-ldl \
$(shell pkg-config --libs fcgi)

LDFLAGS+=-pie

UNITS=\
    auth.cpp \
    config.cpp \
    fastcgiprocess.cpp \
    http.cpp \
    plugin.cpp \
    privileges.cpp \
    response.cpp \
    statistics.cpp \
    server.cpp \
    webserver.cpp \
    websocket.cpp

TESTSRC=\
    test-auth.cpp \
    test-config.cpp \
    test-environment.cpp \
    test-http.cpp \
    test-plugin.cpp \
    test-privileges.cpp \
    test-response.cpp \
    test-server.cpp \
    test-statistics.cpp \
    test-webserver.cpp \
    helper.cpp \
    webserverprocess.cpp \
    websocketserverprocess.cpp

build: $(PROJECTNAME) fcgi1

ifeq ($(CXXTYPE),clang++)
	LLVM_PROFILE_FILE="$(PROJECTNAME).profraw" ./$(PROJECTNAME)
	$(LLVMPROFDATA) merge -sparse $(PROJECTNAME).profraw -o $(PROJECTNAME).profdata
	$(LLVMCOV) report --ignore-filename-regex='google' --ignore-filename-regex='test-' --show-region-summary=0 -instr-profile $(PROJECTNAME).profdata $(PROJECTNAME)
else
	./$(PROJECTNAME)
	gcovr -r ..
endif

$(PROJECTNAME): $(TESTSRC:.cpp=.o) $(UNITS:.cpp=.o)
	$(CXX) $(LDFLAGS) $^ $(LDLIBS) $(LIBS) -o $@

fcgi1: fcgi1.o
	$(CXX) $(LDFLAGS) $^ $(LDLIBS) $(LIBS) -o $@

dep: $(TESTSRC:.cpp=.d)

%.d: %.cpp
	$(CXX) $(CXXFLAGS) $(CXXTESTFLAGS) -MM -MP -MF $@ -c $<

%.o: %.cpp %.d
	$(CXX) $(CXXFLAGS) $(CXXTESTFLAGS) -c $< -o $@

auth.o: ../auth.cpp
	$(CXX) $(CXXFLAGS) $(CXXTESTFLAGS) -c $< -o $@
config.o: ../config.cpp
	$(CXX) $(CXXFLAGS) $(CXXTESTFLAGS) -c $< -o $@
fastcgiprocess.o: ../plugins/fcgi/fastcgiprocess.cpp
	$(CXX) $(CXXFLAGS) $(CXXTESTFLAGS) -c $< -o $@
http.o: ../http.cpp
	$(CXX) $(CXXFLAGS) $(CXXTESTFLAGS) -c $< -o $@
plugin.o: ../plugin.cpp
	$(CXX) $(CXXFLAGS) $(CXXTESTFLAGS) -c $< -o $@
privileges.o: ../privileges.cpp
	$(CXX) $(CXXFLAGS) $(CXXTESTFLAGS) -c $< -o $@
response.o: ../response.cpp
	$(CXX) $(CXXFLAGS) $(CXXTESTFLAGS) -c $< -o $@
statistics.o: ../statistics.cpp
	$(CXX) $(CXXFLAGS) $(CXXTESTFLAGS) -c $< -o $@
server.o: ../server.cpp
	$(CXX) $(CXXFLAGS) $(CXXTESTFLAGS) -c $< -o $@
webserver.o: ../webserver.cpp
	$(CXX) $(CXXFLAGS) $(CXXTESTFLAGS) -c $< -o $@
websocket.o: ../websocket.cpp
	$(CXX) $(CXXFLAGS) $(CXXTESTFLAGS) -c $< -o $@

ADD_DEP=Makefile

# misc ---------------------------------------------------

clean:
	-rm -f *.o *.a *.d $(PROJECTNAME) *.gcda *.gcno *.profraw *.profdata *.gcov fcgi1

.PHONY: clean all install

-include $(wildcard $(TESTSRC:.cpp=.d))