someone said
[ghsmtp.git] / Makefile
blob9543a9f8555cc9760e53726d0899554fd478da57
1 USES := ldns libglog libidn2 opendkim openssl
3 CXXFLAGS += -IPEGTL/include -Ijson/include -Icppcodec
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 := arcsign arcverify 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 Reply \
90 SPF \
91 Send \
92 Session \
93 Sock \
94 SockBuffer \
95 TLS-OpenSSL \
96 esc \
97 message \
98 osutil
100 snd_STEMS := snd \
101 Base64 \
102 $(DNS) \
103 Domain \
104 IP \
105 IP4 \
106 IP6 \
107 Magic \
108 Mailbox \
109 MessageStore \
110 OpenDKIM \
111 OpenDMARC \
112 POSIX \
113 Pill \
114 SPF \
115 Sock \
116 SockBuffer \
117 TLS-OpenSSL \
118 esc \
119 osutil
121 socks5_STEMS := socks5 \
122 $(DNS) \
123 Domain \
124 IP \
125 IP4 \
126 IP6 \
127 POSIX \
128 Pill \
129 Sock \
130 SockBuffer \
131 TLS-OpenSSL \
132 esc \
133 osutil
135 TESTS := \
136 Base64-test \
137 CDB-test \
138 DNS-test \
139 Domain-test \
140 Hash-test \
141 IP4-test \
142 IP6-test \
143 Magic-test \
144 Mailbox-test \
145 MessageStore-test \
146 Now-test \
147 OpenDKIM-test \
148 POSIX-test \
149 Pill-test \
150 Reply-test \
151 SPF-test \
152 Send-test \
153 Session-test \
154 Sock-test \
155 SockBuffer-test \
156 TLD-test \
157 TLS-OpenSSL-test \
158 default_init_allocator-test \
159 esc-test \
160 iequal-test \
161 iobuffer-test \
162 is_ascii-test \
163 message-test \
164 osutil-test
166 Base64-test_STEMS := Base64
167 CDB-test_STEMS := CDB osutil
169 DNS-test_STEMS := $(DNS) DNS-ldns Domain IP IP4 IP6 POSIX Sock SockBuffer TLS-OpenSSL esc osutil
171 Domain-test_STEMS := $(DNS) Domain IP IP4 IP6 POSIX Sock SockBuffer TLS-OpenSSL esc osutil
172 IP4-test_STEMS := $(DNS) Domain IP IP4 IP6 POSIX Sock SockBuffer TLS-OpenSSL esc osutil
173 IP6-test_STEMS := $(DNS) Domain IP IP4 IP6 POSIX Sock SockBuffer TLS-OpenSSL esc osutil
174 Magic-test_STEMS := Magic
175 Mailbox-test_STEMS := Mailbox Domain IP IP4 IP6 osutil
176 MessageStore-test_STEMS := $(DNS) Domain IP IP4 IP6 MessageStore Pill POSIX Sock SockBuffer TLS-OpenSSL esc osutil
177 OpenDKIM-test_STEMS := OpenDKIM
178 POSIX-test_STEMS := POSIX
179 Pill-test_STEMS := Pill
180 Reply-test_STEMS := Reply osutil Domain IP IP4 IP6 Mailbox
181 SPF-test_STEMS := $(DNS) Domain IP IP4 IP6 SPF POSIX Sock SockBuffer TLS-OpenSSL esc osutil
182 SRS-test_STEMS := SRS Domain Mailbox IP IP4 IP6
183 Send-test_STEMS := $(DNS) Domain IP IP4 IP6 Mailbox OpenARC OpenDKIM OpenDMARC POSIX Pill SPF Send Sock SockBuffer TLS-OpenSSL esc message osutil
185 osutil-test_STEMS := osutil
186 message-test_STEMS := message Domain IP IP4 IP6 Mailbox OpenARC OpenDKIM OpenDMARC Pill Reply osutil esc
188 Session-test_STEMS := \
189 CDB \
190 $(DNS) \
191 Domain \
192 IP \
193 IP4 \
194 IP6 \
195 Mailbox \
196 MessageStore \
197 OpenARC \
198 OpenDKIM \
199 OpenDMARC \
200 POSIX \
201 Pill \
202 Reply \
203 SPF \
204 Send \
205 Session \
206 Sock \
207 SockBuffer \
208 TLS-OpenSSL \
209 esc \
210 message \
211 osutil
213 Sock-test_STEMS := Domain IP IP4 IP6 POSIX Sock SockBuffer TLS-OpenSSL esc osutil
214 SockBuffer-test_STEMS := Domain IP IP4 IP6 POSIX Sock SockBuffer TLS-OpenSSL esc osutil
215 TLS-OpenSSL-test_STEMS := Domain IP IP4 IP6 POSIX TLS-OpenSSL osutil
216 esc-test_STEMS := esc
218 databases := \
219 accept_domains.cdb \
220 allow.cdb \
221 bad_recipients.cdb \
222 bad_recipients_data.cdb \
223 bad_senders.cdb \
224 block.cdb \
225 forward.cdb \
226 ip-block.cdb \
227 temp_fail.cdb
229 all:: $(databases) public_suffix_list.dat
231 TMPDIR ?= /tmp
233 export TEST_MAILDIR=$(TMPDIR)/Maildir
234 export MAILDIR=$(TEST_MAILDIR)
236 export ASAN_OPTIONS=detect_leaks=0
238 export GHSMTP_SERVER_ID=digilicious.com
240 export LLVM_PROFILE_FILE=smtp.profraw
242 $(TEST_MAILDIR):
243 mkdir -p $@
245 #smtp.cpp: smtp.rl
246 # ragel -o smtp.cpp smtp.rl
248 clean-test::
249 rm -f smtp.profraw
250 rm -f smtp.profdata
251 rm -rf $(TEST_MAILDIR)/*
253 %.cdb : % cdb-gen
254 ./cdb-gen < $< | cdb -c $@
256 clean::
257 rm -f accept_domains.cdb
258 rm -f block.cdb
259 rm -f cdb-gen
260 rm -f forward.cdb
261 rm -f ip-block.cdb
262 rm -f allow.cdb
264 accept_domains.cdb: accept_domains cdb-gen
265 allow.cdb: allow cdb-gen
266 block.cdb: block cdb-gen
267 ip-block.cdb: ip-block cdb-gen
268 three-level-tlds.cdb: three-level-tlds cdb-gen
270 forward.cdb: forward
271 cat $< | cdb -c $@
273 public_suffix_list.dat:
274 wget --timestamping https://publicsuffix.org/list/public_suffix_list.dat
276 opt_flags := -Og
278 # safty_flags := # nada
280 # visibility_flags := # nada
282 lto_flags := # nada
284 include MKUltra/rules
286 regression:: $(programs) $(TEST_MAILDIR)
287 @for f in testcase_dir/* ; do \
288 echo -n test `basename $$f` ""; \
289 tmp_out=`mktemp`; \
290 valgrind ./smtp < $$f > $$tmp_out; \
291 diff testout_dir/`basename $$f` $$tmp_out && echo ...pass; \
292 rm $$tmp_out; \
293 done
295 check::
296 @for f in testcase_dir/* ; do \
297 echo -n test `basename $$f` ""; \
298 tmp_out=`mktemp`; \
299 ./smtp < $$f > $$tmp_out; \
300 diff testout_dir/`basename $$f` $$tmp_out && echo ...pass; \
301 if [ -e smtp.profraw ] ; then mv smtp.profraw /tmp/smtp-profile/`basename $$f`; fi; \
302 rm $$tmp_out; \
303 done
305 net-check::
306 @for f in testcase_dir/* ; do \
307 echo -n test `basename $$f` ""; \
308 tmp_out=`mktemp`; \
309 ncat localhost 225 < $$f > $$tmp_out; \
310 diff testout_dir/`basename $$f` $$tmp_out && echo ...pass; \
311 if [ -e smtp.profraw ] ; then mv smtp.profraw /tmp/smtp-profile/`basename $$f`; fi; \
312 rm $$tmp_out; \
313 done
315 check:: msg snd
316 ./msg --selftest
317 GHSMTP_CLIENT_ID=digilicious.com ./snd --selftest
319 show::
320 llvm-profdata merge -sparse /tmp/smtp-profile/* -o smtp.profdata
321 llvm-cov show ./smtp -instr-profile=smtp.profdata
323 init::
324 touch accept_domains bad_recipients bad_recipients_data bad_senders block ip-block temp_fail
325 sudo dnf install boost-devel file-devel fmt-devel glog-devel ldns-devel libidn2-devel libopenarc-devel libopendkim-devel libopendmarc-devel libpsl-devel libspf2-devel tinycdb-devel libunistring-devel