add some logging
[ghsmtp.git] / Makefile
blobcc436718f56d5ac64d10a32fb2f29085e79c4f81
1 USES := ldns libglog libidn2 opendkim openssl libseccomp
3 CXXFLAGS += -IPEGTL/include -Ijson/include
5 LDLIBS += \
6 -lboost_filesystem \
7 -lboost_iostreams \
8 -lboost_system \
9 -lcdb \
10 -lfmt \
11 -lgflags \
12 -lmagic \
13 -lopenarc \
14 -lopendmarc \
15 -lpsl \
16 -lresolv \
17 -lspf2 \
18 -lunistring
20 PROGRAMS := dns_tool smtp msg sasl snd socks5
22 arcsign_STEMS := arcsign \
23 message Domain IP IP4 IP6 Mailbox OpenARC OpenDKIM OpenDMARC Pill Reply osutil esc
25 arcverify_STEMS := arcverify \
26 message Domain IP IP4 IP6 Mailbox OpenARC OpenDKIM OpenDMARC Pill Reply osutil esc
28 DNS := DNS DNS-rrs DNS-fcrdns DNS-message
30 dns_tool_STEMS := dns_tool \
31 $(DNS) \
32 Domain \
33 IP \
34 IP4 \
35 IP6 \
36 POSIX \
37 SPF \
38 Sock \
39 SockBuffer \
40 TLS-OpenSSL \
41 esc \
42 osutil
44 msg_STEMS := msg \
45 CDB \
46 $(DNS) \
47 Domain \
48 IP \
49 IP4 \
50 IP6 \
51 Mailbox \
52 OpenDKIM \
53 OpenDMARC \
54 POSIX \
55 SPF \
56 Sock \
57 SockBuffer \
58 TLS-OpenSSL \
59 esc \
60 osutil
62 sasl_STEMS := sasl \
63 Base64 \
64 Domain \
65 IP \
66 IP4 \
67 IP6 \
68 POSIX \
69 Sock \
70 SockBuffer \
71 TLS-OpenSSL \
72 esc \
73 osutil
75 smtp_STEMS := smtp \
76 CDB \
77 $(DNS) \
78 Domain \
79 IP \
80 IP4 \
81 IP6 \
82 Mailbox \
83 MessageStore \
84 OpenARC \
85 OpenDKIM \
86 OpenDMARC \
87 POSIX \
88 Pill \
89 SPF \
90 Session \
91 Sock \
92 SockBuffer \
93 TLS-OpenSSL \
94 esc \
95 osutil
97 snd_STEMS := snd \
98 Base64 \
99 $(DNS) \
100 Domain \
101 IP \
102 IP4 \
103 IP6 \
104 Magic \
105 Mailbox \
106 MessageStore \
107 OpenDKIM \
108 OpenDMARC \
109 POSIX \
110 Pill \
111 SPF \
112 Sock \
113 SockBuffer \
114 TLS-OpenSSL \
115 esc \
116 osutil
118 socks5_STEMS := socks5 \
119 $(DNS) \
120 Domain \
121 IP \
122 IP4 \
123 IP6 \
124 POSIX \
125 Pill \
126 Sock \
127 SockBuffer \
128 TLS-OpenSSL \
129 esc \
130 osutil
132 TESTS := \
133 Base64-test \
134 CDB-test \
135 DNS-test \
136 Domain-test \
137 IP4-test \
138 IP6-test \
139 Magic-test \
140 Mailbox-test \
141 MessageStore-test \
142 Now-test \
143 OpenDKIM-test \
144 POSIX-test \
145 Pill-test \
146 SPF-test \
147 Session-test \
148 Sock-test \
149 SockBuffer-test \
150 TLD-test \
151 TLS-OpenSSL-test \
152 default_init_allocator-test \
153 esc-test \
154 iequal-test \
155 iobuffer-test \
156 is_ascii-test \
157 osutil-test
159 Base64-test_STEMS := Base64
160 CDB-test_STEMS := CDB osutil
162 DNS-test_STEMS := $(DNS) DNS-ldns Domain IP IP4 IP6 POSIX Sock SockBuffer TLS-OpenSSL esc osutil
164 Domain-test_STEMS := Domain IP IP4 IP6
165 IP4-test_STEMS := Domain IP IP4 IP6
166 IP6-test_STEMS := Domain IP IP4 IP6
167 Magic-test_STEMS := Magic
168 Mailbox-test_STEMS := Mailbox Domain IP IP4 IP6 osutil
169 MessageStore-test_STEMS := $(DNS) Domain IP IP4 IP6 MessageStore Pill POSIX Sock SockBuffer TLS-OpenSSL esc osutil
170 OpenDKIM-test_STEMS := OpenDKIM
171 POSIX-test_STEMS := POSIX
172 Pill-test_STEMS := Pill
173 SPF-test_STEMS := $(DNS) Domain IP IP4 IP6 SPF POSIX Sock SockBuffer TLS-OpenSSL esc osutil
175 osutil-test_STEMS := osutil
177 Session-test_STEMS := \
178 CDB \
179 $(DNS) \
180 Domain \
181 IP \
182 IP4 \
183 IP6 \
184 Mailbox \
185 MessageStore \
186 OpenARC \
187 OpenDKIM \
188 OpenDMARC \
189 POSIX \
190 Pill \
191 SPF \
192 Session \
193 Sock \
194 SockBuffer \
195 TLS-OpenSSL \
196 esc \
197 osutil
199 Sock-test_STEMS := Domain IP IP4 IP6 POSIX Sock SockBuffer TLS-OpenSSL esc osutil
200 SockBuffer-test_STEMS := Domain IP IP4 IP6 POSIX Sock SockBuffer TLS-OpenSSL esc osutil
201 TLS-OpenSSL-test_STEMS := Domain IP IP4 IP6 POSIX TLS-OpenSSL osutil
202 esc-test_STEMS := esc
204 databases := \
205 accept_domains.cdb \
206 allow.cdb \
207 bad_recipients.cdb \
208 bad_recipients_data.cdb \
209 bad_senders.cdb \
210 block.cdb \
211 forward.cdb \
212 ip-block.cdb \
213 temp_fail.cdb
215 all:: $(databases) public_suffix_list.dat
217 TMPDIR ?= /tmp
219 export TEST_MAILDIR=$(TMPDIR)/Maildir
220 export MAILDIR=$(TEST_MAILDIR)
222 export ASAN_OPTIONS=detect_leaks=0
224 export GHSMTP_SERVER_ID=digilicious.com
226 export LLVM_PROFILE_FILE=smtp.profraw
228 $(TEST_MAILDIR):
229 mkdir -p $@
231 #smtp.cpp: smtp.rl
232 # ragel -o smtp.cpp smtp.rl
234 clean-test::
235 rm -f smtp.profraw
236 rm -f smtp.profdata
237 rm -rf $(TEST_MAILDIR)/*
239 %.cdb : % cdb-gen
240 ./cdb-gen < $< | cdb -c $@
242 clean::
243 rm -f accept_domains.cdb
244 rm -f block.cdb
245 rm -f cdb-gen
246 rm -f forward.cdb
247 rm -f ip-block.cdb
248 rm -f allow.cdb
250 accept_domains.cdb: accept_domains cdb-gen
251 allow.cdb: allow cdb-gen
252 block.cdb: block cdb-gen
253 ip-block.cdb: ip-block cdb-gen
254 three-level-tlds.cdb: three-level-tlds cdb-gen
256 forward.cdb: forward
257 cat $< | cdb -c $@
259 public_suffix_list.dat:
260 wget --timestamping https://publicsuffix.org/list/public_suffix_list.dat
262 opt_flags := -Og
264 # safty_flags := # nada
266 # visibility_flags := # nada
268 lto_flags := # nada
270 include MKUltra/rules
272 regression:: $(programs) $(TEST_MAILDIR)
273 @for f in testcase_dir/* ; do \
274 echo -n test `basename $$f` ""; \
275 tmp_out=`mktemp`; \
276 valgrind ./smtp < $$f > $$tmp_out; \
277 diff testout_dir/`basename $$f` $$tmp_out && echo ...pass; \
278 rm $$tmp_out; \
279 done
281 check::
282 @for f in testcase_dir/* ; do \
283 echo -n test `basename $$f` ""; \
284 tmp_out=`mktemp`; \
285 ./smtp < $$f > $$tmp_out; \
286 diff testout_dir/`basename $$f` $$tmp_out && echo ...pass; \
287 if [ -e smtp.profraw ] ; then mv smtp.profraw /tmp/smtp-profile/`basename $$f`; fi; \
288 rm $$tmp_out; \
289 done
291 net-check::
292 @for f in testcase_dir/* ; do \
293 echo -n test `basename $$f` ""; \
294 tmp_out=`mktemp`; \
295 ncat localhost 225 < $$f > $$tmp_out; \
296 diff testout_dir/`basename $$f` $$tmp_out && echo ...pass; \
297 if [ -e smtp.profraw ] ; then mv smtp.profraw /tmp/smtp-profile/`basename $$f`; fi; \
298 rm $$tmp_out; \
299 done
301 check:: msg snd
302 ./msg --selftest
303 GHSMTP_CLIENT_ID=digilicious.com ./snd --selftest
305 show::
306 llvm-profdata merge -sparse /tmp/smtp-profile/* -o smtp.profdata
307 llvm-cov show ./smtp -instr-profile=smtp.profdata
309 init::
310 touch accept_domains bad_recipients bad_recipients_data bad_senders block ip-block temp_fail
311 sudo dnf install boost-devel file-devel fmt-devel glog-devel ldns-devel libidn2-devel tinycdb-devel libunistring-devel
313 .PHONY:: list
314 list:
315 @LC_ALL=C $(MAKE) -pRrq -f $(firstword $(MAKEFILE_LIST)) : 2>/dev/null | awk -v RS= -F: '/(^|\n)# Files(\n|$$)/,/(^|\n)# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | sort | uniq | grep -E -v -e '^[^[:alnum:]]' -e '^$@$$'