blob: d6c11f53121a6a666ca4486de3a79ba3494cc298 (
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
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
|
DISTROS=debian10
VERSION=$(shell dpkg-parsechangelog --show-field Version)
PROJECTNAME=webserver
PLUGINS=static-files webbox cgi # weblog fcgi
CXX=clang++-10
ifeq ($(shell which $(CXX)),)
CXX=clang++
endif
ifeq ($(shell which $(CXX)),)
CXX=g++-9
endif
ifeq ($(CXXFLAGS),)
#CXXFLAGS=-O2 -DNDEBUG
CXXFLAGS=-O0 -g -D_DEBUG
endif
# -fprofile-instr-generate -fcoverage-mapping
# gcc:--coverage
CXXFLAGS+= -Wall -I. -DVERSION=\"$(VERSION)\"
CXXFLAGS+= -pthread
ifeq ($(CXX),clang++-10)
CXXFLAGS+=-std=c++20 #-stdlib=libc++
else
CXXFLAGS+=-std=c++17
endif
CXXTESTFLAGS=-Igoogletest/include -Igooglemock/include/ -Igoogletest -Igooglemock
LIBS=\
-lboost_context \
-lboost_system \
-lboost_filesystem \
-lpthread \
-lssl -lcrypto \
-ldl
#-lboost_coroutine \
#-lboost_program_options \
#-lboost_thread \
#-lboost_regex \
ifeq ($(CXX),clang++-10)
LIBS+= \
-fuse-ld=lld-10 \
-lstdc++
#-lc++ \
#-lc++abi
#-lc++fs
#-lstdc++fs
else
LIBS+= \
-lstdc++ \
-lstdc++fs
endif
PROGSRC=\
base64.cpp \
config.cpp \
file.cpp \
http.cpp \
https.cpp \
plugin.cpp \
privileges.cpp \
response.cpp \
server.cpp
TESTSRC=\
test-webserver.cpp \
googlemock/src/gmock-all.cpp \
googletest/src/gtest-all.cpp \
$(PROGSRC)
SRC=$(PROGSRC) webserver.cpp
build: $(PROJECTNAME) test-$(PROJECTNAME)
+set -e ; for i in $(PLUGINS) ; do make -C plugins/$$i ; done
./test-$(PROJECTNAME)
all: build
./webserver -c webserver.conf
# testsuite ----------------------------------------------
test-$(PROJECTNAME): $(TESTSRC:.cpp=.o)
$(CXX) $(CXXFLAGS) $^ $(LIBS) -o $@
$(PROJECTNAME): $(SRC:.cpp=.o)
$(CXX) $(CXXFLAGS) $^ $(LIBS) -o $@
dep: $(TESTSRC:.cpp=.d)
%.d: %.cpp
$(CXX) $(CXXFLAGS) $(CXXTESTFLAGS) -MM -MP -MF $@ -c $<
%.o: %.cpp %.d
$(CXX) $(CXXFLAGS) $(CXXTESTFLAGS) -c $< -o $@
googletest/src/%.o: googletest/src/%.cc
$(CXX) $(CXXFLAGS) $(CXXTESTFLAGS) -c $< -o $@
# dependencies
ADD_DEP=Makefile
install:
mkdir -p $(DESTDIR)/usr/bin
cp webserver $(DESTDIR)/usr/bin
mkdir -p $(DESTDIR)/usr/lib/webserver/plugins
set -e ; for i in $(PLUGINS) ; do make -C plugins/$$i install ; done
mkdir -p $(DESTDIR)/usr/local/lib/webserver/plugins
mkdir -p $(DESTDIR)/etc
cp webserver.conf $(DESTDIR)/etc/webserver.conf
# misc ---------------------------------------------------
deb:
# build binary deb package
dpkg-buildpackage -us -uc -rfakeroot
deb-src:
dpkg-source -b .
$(DISTROS): deb-src
sudo pbuilder build --basetgz /var/cache/pbuilder/$@.tgz --buildresult result/$@ ../webserver_$(VERSION).dsc
debs: $(DISTROS)
clean:
-rm -f test-$(PROJECTNAME) $(PROJECTNAME)
-rm -f plugins/*.so
-find . -name '*.o' -o -name '*.d' -o -name '*.gcno' -o -name '*.gcda' | xargs rm -f
for i in $(PLUGINS) ; do make -C plugins/$$i clean ; done
zip: clean
-rm -f ../$(PROJECTNAME).zip
zip -r ../$(PROJECTNAME).zip *
ls -l ../$(PROJECTNAME).zip
.PHONY: clean all zip install deb deb-src debs all $(DISTROS)
-include $(wildcard $(SRC:.cpp=.d))
|