This repository was archived by the owner on Jan 19, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
183 lines (150 loc) · 4.69 KB
/
Makefile
File metadata and controls
183 lines (150 loc) · 4.69 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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
# Makefile work is licensed under a Creative Commons Attribution-ShareAlike 4.0
# International License. See <https://creativecommons.org/licenses/by-sa/4.0/>.
.PHONY: clean
include UserVariables.mk
ADDITIONAL_CFLAGS ?=
ADDITIONAL_LDFLAGS ?=
CC = clang
CFLAGS = -Wall -Wextra -Wpedantic -g -I. $(ADDITIONAL_CFLAGS)
LDFLAGS = -pthread -lm $(ADDITIONAL_LDFLAGS)
# Dependencies using pkg-config (OpenSSL, brotli)
DEPENDENCIES = openssl libbrotlicommon libbrotlienc
CFLAGS += `pkg-config --cflags $(DEPENDENCIES)`
LDFLAGS += `pkg-config --static --libs $(DEPENDENCIES)`
BINARIES = \
bin/base/global_state.so \
bin/cache/cache.so \
bin/cache/compression.so \
bin/core/h1.so \
bin/core/h2.so \
bin/core/security.so \
bin/core/server.so \
bin/http/response_headers.so \
bin/http/strings.so \
bin/http/syntax.so \
bin/http2/frames/settings.so \
bin/http2/debugging.so \
bin/http2/frame.so \
bin/misc/io.so \
bin/misc/options.so \
bin/misc/statistics.so \
bin/redir/client.so \
bin/redir/server.so \
all: server bin/tests/redir
server: main.c bin/dirinfo $(BINARIES)
$(CC) $(CFLAGS) -o $@ main.c $(BINARIES) $(LDFLAGS)
# This target will create the directory structure for the build files. The
# binaries should have approximately the same path. For example: 'foo/bar.c'
# should cast to 'bin/foo/bar.o'
bin/dirinfo:
@mkdir -p bin/base
@touch bin/dirinfo
@mkdir bin/cache
@mkdir bin/core
@mkdir bin/http
@mkdir bin/http2
@mkdir bin/http2/frames
@mkdir bin/misc
@mkdir bin/redir
@mkdir bin/tests
@mkdir bin/tests/base
@mkdir bin/tests/base/global_state
bin/base/global_state.so: base/global_state.c \
base/global_state.h
$(CC) $(CFLAGS) -c -o $@ base/global_state.c
bin/cache/cache.so: cache/cache.c \
cache/cache.h \
http/strings.h
$(CC) $(CFLAGS) -c -o $@ cache/cache.c
bin/cache/compression.so: cache/compression.c \
cache/compression.h \
http/strings.h
$(CC) $(CFLAGS) -c -o $@ cache/compression.c
bin/core/h1.so: core/h1.c \
core/h1.h \
core/security.h
$(CC) $(CFLAGS) -c -o $@ core/h1.c
bin/core/h2.so: core/h2.c \
core/h2.h \
core/security.h \
misc/default.h
$(CC) $(CFLAGS) -c -o $@ core/h2.c
bin/core/security.so: core/security.c \
core/security.h
$(CC) $(CFLAGS) -c -o $@ core/security.c
bin/core/server.so: core/server.c \
core/server.h
$(CC) $(CFLAGS) -c -o $@ core/server.c
bin/http/response_headers.so: http/response_headers.c \
http/response_headers.h
$(CC) $(CFLAGS) -c -o $@ http/response_headers.c
bin/http/strings.so: http/strings.c \
http/strings.h
$(CC) $(CFLAGS) -c -o $@ http/strings.c
bin/http/syntax.so: http/syntax.c \
http/syntax.h
$(CC) $(CFLAGS) -c -o $@ http/syntax.c
bin/http2/frames/settings.so: http2/frames/settings.c \
http2/frames/settings.h \
http2/settings.h \
core/security.h \
misc/default.h
$(CC) $(CFLAGS) -c -o $@ http2/frames/settings.c
bin/http2/debugging.so: http2/debugging.c \
http2/debugging.h
$(CC) $(CFLAGS) -c -o $@ http2/debugging.c
bin/http2/frame.so: http2/frame.c \
http2/frame.h \
core/security.h
$(CC) $(CFLAGS) -c -o $@ http2/frame.c
bin/misc/io.so: misc/io.c \
misc/io.h
$(CC) $(CFLAGS) -c -o $@ misc/io.c
bin/misc/options.so: misc/options.c \
misc/options.h
$(CC) $(CFLAGS) -c -o $@ misc/options.c
bin/misc/statistics.so: misc/statistics.c \
misc/statistics.h
$(CC) $(CFLAGS) -c -o $@ misc/statistics.c
bin/redir/client.so: redir/client.c \
redir/server.h
$(CC) $(CFLAGS) -c -o $@ redir/client.c
bin/redir/server.so: redir/server.c \
redir/server.h
$(CC) $(CFLAGS) -c -o $@ redir/server.c
# Tests
bin/tests/redir: tests/redir/main.c \
redir/client.h
$(CC) $(CFLAGS) -o $@ tests/redir/main.c -lpthread bin/redir/client.so \
bin/base/global_state.so bin/http/syntax.so bin/misc/io.so \
bin/http/response_headers.so bin/misc/statistics.so \
bin/misc/options.so bin/http/strings.so
bin/tests/base/global_state/gspopulateproductname.so: \
tests/base/global_state/gspopulateproductname.c \
base/global_state.c \
base/global_state.h \
bin/misc/options.so
$(CC) $(CFLAGS) -o $@ tests/base/global_state/gspopulateproductname.c \
bin/misc/io.so \
bin/misc/statistics.so \
$(LDFLAGS)
# Destroys ALL build files, but will leave the source files intact.
clean:
rm -rf bin
rm -f server
## Tools
# the 'memory' target will invoke Valgrind, which will run the executable and
# can track memory usage. Memory leaks, double free()'s, use-after-free,
# uninitialised values, etc. can be found by using this tool.
memory:
valgrind --num-callers=100 \
--leak-resolution=high \
--leak-check=full \
--track-origins=yes \
--show-leak-kinds=all \
--track-fds=yes \
./server
# the 'cppcheck' target will invoke the cppcheck program. This program
# statically analyzes the code.
cppcheck:
cppcheck -I. -q --std=c99 --enable=all .