blob: c295e179c355218e828c97f9ac8f7c0e170d4ed4 [file] [log] [blame]
Paul Bakker0049c2f2009-07-11 19:15:43 +00001
2# To compile on SunOS: add "-lsocket -lnsl" to LDFLAGS
Paul Bakker62f88dc2012-05-10 21:26:28 +00003# To compile on MinGW: add "-lws2_32" to LDFLAGS or define WINDOWS in your env
Paul Bakker43b7e352011-01-18 15:27:19 +00004# To compile with PKCS11: add "-lpkcs11-helper" to LDFLAGS
Paul Bakker0049c2f2009-07-11 19:15:43 +00005
Paul Bakker46eb1382011-01-30 17:10:13 +00006CFLAGS += -I../include -D_FILE_OFFSET_BITS=64 -Wall -W -Wdeclaration-after-statement \
Paul Bakker0049c2f2009-07-11 19:15:43 +00007 -Wno-unused-function -Wno-unused-value
8
Paul Bakkerf1ab0ec2012-10-23 12:12:53 +00009OFLAGS = -O2
Paul Bakkera585beb2011-06-21 08:59:44 +000010LDFLAGS += -L../library -lpolarssl $(SYS_LDFLAGS)
Paul Bakker0049c2f2009-07-11 19:15:43 +000011
Paul Bakkerc7ffd362012-04-05 12:08:29 +000012ifdef DEBUG
13CFLAGS += -g3
14endif
15
Paul Bakkercd5b5292012-05-10 20:49:10 +000016ifdef WINDOWS
17LDFLAGS += -lws2_32
18endif
19
Paul Bakker2770fbd2012-07-03 13:30:23 +000020# Zlib shared library extensions:
21ifdef ZLIB
22LDFLAGS += -lz
23endif
24
Paul Bakker286bf3c2013-04-08 18:09:51 +020025APPS = test_suite_aes.ecb test_suite_aes.cbc \
26 test_suite_aes.cfb test_suite_aes.rest \
27 test_suite_arc4 \
Paul Bakkera9379c02012-07-04 11:02:11 +000028 test_suite_base64 test_suite_blowfish \
Paul Bakker6132d0a2012-07-04 17:10:40 +000029 test_suite_camellia test_suite_cipher.aes \
30 test_suite_cipher.blowfish \
31 test_suite_cipher.camellia \
Paul Bakkerfab5c822012-02-06 16:45:10 +000032 test_suite_cipher.des test_suite_cipher.null \
33 test_suite_ctr_drbg test_suite_debug \
Paul Bakker9d781402011-05-09 16:17:09 +000034 test_suite_des test_suite_dhm \
Paul Bakkerd589a0d2013-03-13 16:30:17 +010035 test_suite_ecdh test_suite_ecdsa \
Paul Bakkera95919b2013-01-16 17:00:05 +010036 test_suite_ecp \
Paul Bakker286bf3c2013-04-08 18:09:51 +020037 test_suite_error \
38 test_suite_gcm.decrypt_128 \
39 test_suite_gcm.decrypt_192 \
40 test_suite_gcm.decrypt_256 \
41 test_suite_gcm.encrypt_128 \
42 test_suite_gcm.encrypt_192 \
43 test_suite_gcm.encrypt_256 \
44 test_suite_hmac_shax \
Paul Bakker9d781402011-05-09 16:17:09 +000045 test_suite_md test_suite_mdx \
Paul Bakkerf518b162012-08-23 13:03:18 +000046 test_suite_mpi test_suite_pbkdf2 \
47 test_suite_pkcs1_v21 \
Paul Bakker9d781402011-05-09 16:17:09 +000048 test_suite_rsa test_suite_shax \
Paul Bakker6d620502012-02-16 14:09:13 +000049 test_suite_x509parse test_suite_x509write \
50 test_suite_xtea test_suite_version
Paul Bakker0049c2f2009-07-11 19:15:43 +000051
52.SILENT:
53
54all: $(APPS)
55
Paul Bakker286bf3c2013-04-08 18:09:51 +020056test_suite_aes.ecb.c : suites/test_suite_aes.function suites/test_suite_aes.ecb.data scripts/generate_code.pl suites/helpers.function
57 echo " Generate $@"
58 scripts/generate_code.pl suites test_suite_aes test_suite_aes.ecb
59
60test_suite_aes.cbc.c : suites/test_suite_aes.function suites/test_suite_aes.cbc.data scripts/generate_code.pl suites/helpers.function
61 echo " Generate $@"
62 scripts/generate_code.pl suites test_suite_aes test_suite_aes.cbc
63
64test_suite_aes.cfb.c : suites/test_suite_aes.function suites/test_suite_aes.cfb.data scripts/generate_code.pl suites/helpers.function
65 echo " Generate $@"
66 scripts/generate_code.pl suites test_suite_aes test_suite_aes.cfb
67
68test_suite_aes.rest.c : suites/test_suite_aes.function suites/test_suite_aes.rest.data scripts/generate_code.pl suites/helpers.function
69 echo " Generate $@"
70 scripts/generate_code.pl suites test_suite_aes test_suite_aes.rest
71
Paul Bakker46c17942011-07-13 14:54:54 +000072test_suite_cipher.aes.c : suites/test_suite_cipher.function suites/test_suite_cipher.aes.data scripts/generate_code.pl suites/helpers.function
73 echo " Generate $@"
74 scripts/generate_code.pl suites test_suite_cipher test_suite_cipher.aes
75
Paul Bakker6132d0a2012-07-04 17:10:40 +000076test_suite_cipher.blowfish.c : suites/test_suite_cipher.function suites/test_suite_cipher.blowfish.data scripts/generate_code.pl suites/helpers.function
77 echo " Generate $@"
78 scripts/generate_code.pl suites test_suite_cipher test_suite_cipher.blowfish
79
Paul Bakker46c17942011-07-13 14:54:54 +000080test_suite_cipher.camellia.c : suites/test_suite_cipher.function suites/test_suite_cipher.camellia.data scripts/generate_code.pl suites/helpers.function
81 echo " Generate $@"
82 scripts/generate_code.pl suites test_suite_cipher test_suite_cipher.camellia
83
84test_suite_cipher.des.c : suites/test_suite_cipher.function suites/test_suite_cipher.des.data scripts/generate_code.pl suites/helpers.function
85 echo " Generate $@"
86 scripts/generate_code.pl suites test_suite_cipher test_suite_cipher.des
87
Paul Bakkerfab5c822012-02-06 16:45:10 +000088test_suite_cipher.null.c : suites/test_suite_cipher.function suites/test_suite_cipher.null.data scripts/generate_code.pl suites/helpers.function
89 echo " Generate $@"
90 scripts/generate_code.pl suites test_suite_cipher test_suite_cipher.null
91
Paul Bakker286bf3c2013-04-08 18:09:51 +020092test_suite_gcm.decrypt_128.c : suites/test_suite_gcm.function suites/test_suite_gcm.decrypt_128.data scripts/generate_code.pl suites/helpers.function
Paul Bakker89e80c92012-03-20 13:50:09 +000093 echo " Generate $@"
Paul Bakker286bf3c2013-04-08 18:09:51 +020094 scripts/generate_code.pl suites test_suite_gcm test_suite_gcm.decrypt_128
Paul Bakker89e80c92012-03-20 13:50:09 +000095
Paul Bakker286bf3c2013-04-08 18:09:51 +020096test_suite_gcm.decrypt_192.c : suites/test_suite_gcm.function suites/test_suite_gcm.decrypt_192.data scripts/generate_code.pl suites/helpers.function
Paul Bakker89e80c92012-03-20 13:50:09 +000097 echo " Generate $@"
Paul Bakker286bf3c2013-04-08 18:09:51 +020098 scripts/generate_code.pl suites test_suite_gcm test_suite_gcm.decrypt_192
99
100test_suite_gcm.decrypt_256.c : suites/test_suite_gcm.function suites/test_suite_gcm.decrypt_256.data scripts/generate_code.pl suites/helpers.function
101 echo " Generate $@"
102 scripts/generate_code.pl suites test_suite_gcm test_suite_gcm.decrypt_256
103
104test_suite_gcm.encrypt_128.c : suites/test_suite_gcm.function suites/test_suite_gcm.encrypt_128.data scripts/generate_code.pl suites/helpers.function
105 echo " Generate $@"
106 scripts/generate_code.pl suites test_suite_gcm test_suite_gcm.encrypt_128
107
108test_suite_gcm.encrypt_192.c : suites/test_suite_gcm.function suites/test_suite_gcm.encrypt_192.data scripts/generate_code.pl suites/helpers.function
109 echo " Generate $@"
110 scripts/generate_code.pl suites test_suite_gcm test_suite_gcm.encrypt_192
111
112test_suite_gcm.encrypt_256.c : suites/test_suite_gcm.function suites/test_suite_gcm.encrypt_256.data scripts/generate_code.pl suites/helpers.function
113 echo " Generate $@"
114 scripts/generate_code.pl suites test_suite_gcm test_suite_gcm.encrypt_256
Paul Bakker89e80c92012-03-20 13:50:09 +0000115
Paul Bakker4fa1a762011-03-13 16:56:11 +0000116%.c : suites/%.function suites/%.data scripts/generate_code.pl suites/helpers.function
Paul Bakker0049c2f2009-07-11 19:15:43 +0000117 echo " Generate $@"
Paul Bakker46c17942011-07-13 14:54:54 +0000118 scripts/generate_code.pl suites $* $*
Paul Bakker0049c2f2009-07-11 19:15:43 +0000119
Paul Bakker286bf3c2013-04-08 18:09:51 +0200120test_suite_aes.ecb: test_suite_aes.ecb.c ../library/libpolarssl.a
121 echo " CC $@.c"
122 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
123
124test_suite_aes.cbc: test_suite_aes.cbc.c ../library/libpolarssl.a
125 echo " CC $@.c"
126 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
127
128test_suite_aes.cfb: test_suite_aes.cfb.c ../library/libpolarssl.a
129 echo " CC $@.c"
130 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
131
132test_suite_aes.rest: test_suite_aes.rest.c ../library/libpolarssl.a
Paul Bakker0049c2f2009-07-11 19:15:43 +0000133 echo " CC $@.c"
134 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
135
136test_suite_arc4: test_suite_arc4.c ../library/libpolarssl.a
137 echo " CC $@.c"
138 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
139
140test_suite_base64: test_suite_base64.c ../library/libpolarssl.a
141 echo " CC $@.c"
142 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
143
Paul Bakkera9379c02012-07-04 11:02:11 +0000144test_suite_blowfish: test_suite_blowfish.c ../library/libpolarssl.a
145 echo " CC $@.c"
146 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
147
Paul Bakker0049c2f2009-07-11 19:15:43 +0000148test_suite_camellia: test_suite_camellia.c ../library/libpolarssl.a
149 echo " CC $@.c"
150 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
151
Paul Bakker46c17942011-07-13 14:54:54 +0000152test_suite_cipher.aes: test_suite_cipher.aes.c ../library/libpolarssl.a
153 echo " CC $@.c"
154 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
155
Paul Bakker6132d0a2012-07-04 17:10:40 +0000156test_suite_cipher.blowfish: test_suite_cipher.blowfish.c ../library/libpolarssl.a
157 echo " CC $@.c"
158 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
159
Paul Bakker46c17942011-07-13 14:54:54 +0000160test_suite_cipher.camellia: test_suite_cipher.camellia.c ../library/libpolarssl.a
161 echo " CC $@.c"
162 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
163
Paul Bakkerfab5c822012-02-06 16:45:10 +0000164test_suite_cipher.des: test_suite_cipher.des.c ../library/libpolarssl.a
Paul Bakker0e04d0e2011-11-27 14:46:59 +0000165 echo " CC $@.c"
166 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
167
Paul Bakkerfab5c822012-02-06 16:45:10 +0000168test_suite_cipher.null: test_suite_cipher.null.c ../library/libpolarssl.a
169 echo " CC $@.c"
170 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
171
172test_suite_ctr_drbg: test_suite_ctr_drbg.c ../library/libpolarssl.a
Paul Bakker8123e9d2011-01-06 15:37:30 +0000173 echo " CC $@.c"
174 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
175
Paul Bakker0049c2f2009-07-11 19:15:43 +0000176test_suite_des: test_suite_des.c ../library/libpolarssl.a
177 echo " CC $@.c"
178 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
179
180test_suite_dhm: test_suite_dhm.c ../library/libpolarssl.a
181 echo " CC $@.c"
182 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
183
Paul Bakkerd589a0d2013-03-13 16:30:17 +0100184test_suite_ecdh: test_suite_ecdh.c ../library/libpolarssl.a
185 echo " CC $@.c"
186 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
187
188test_suite_ecdsa: test_suite_ecdsa.c ../library/libpolarssl.a
189 echo " CC $@.c"
190 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
191
Paul Bakkera95919b2013-01-16 17:00:05 +0100192test_suite_ecp: test_suite_ecp.c ../library/libpolarssl.a
193 echo " CC $@.c"
194 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
195
Paul Bakker9d781402011-05-09 16:17:09 +0000196test_suite_error: test_suite_error.c ../library/libpolarssl.a
197 echo " CC $@.c"
198 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
199
Paul Bakker286bf3c2013-04-08 18:09:51 +0200200test_suite_gcm.decrypt_128: test_suite_gcm.decrypt_128.c ../library/libpolarssl.a
Paul Bakker89e80c92012-03-20 13:50:09 +0000201 echo " CC $@.c"
202 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
203
Paul Bakker286bf3c2013-04-08 18:09:51 +0200204test_suite_gcm.decrypt_192: test_suite_gcm.decrypt_192.c ../library/libpolarssl.a
205 echo " CC $@.c"
206 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
207
208test_suite_gcm.decrypt_256: test_suite_gcm.decrypt_256.c ../library/libpolarssl.a
209 echo " CC $@.c"
210 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
211
212test_suite_gcm.encrypt_128: test_suite_gcm.encrypt_128.c ../library/libpolarssl.a
213 echo " CC $@.c"
214 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
215
216test_suite_gcm.encrypt_192: test_suite_gcm.encrypt_192.c ../library/libpolarssl.a
217 echo " CC $@.c"
218 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
219
220test_suite_gcm.encrypt_256: test_suite_gcm.encrypt_256.c ../library/libpolarssl.a
Paul Bakker89e80c92012-03-20 13:50:09 +0000221 echo " CC $@.c"
222 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
223
Paul Bakker0049c2f2009-07-11 19:15:43 +0000224test_suite_hmac_shax: test_suite_hmac_shax.c ../library/libpolarssl.a
225 echo " CC $@.c"
226 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
227
Paul Bakker17373852011-01-06 14:20:01 +0000228test_suite_md: test_suite_md.c ../library/libpolarssl.a
229 echo " CC $@.c"
230 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
231
Paul Bakker0049c2f2009-07-11 19:15:43 +0000232test_suite_mdx: test_suite_mdx.c ../library/libpolarssl.a
233 echo " CC $@.c"
234 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
235
236test_suite_mpi: test_suite_mpi.c ../library/libpolarssl.a
237 echo " CC $@.c"
238 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
239
Paul Bakkerf518b162012-08-23 13:03:18 +0000240test_suite_pbkdf2: test_suite_pbkdf2.c ../library/libpolarssl.a
241 echo " CC $@.c"
242 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
243
Paul Bakker9dcc3222011-03-08 14:16:06 +0000244test_suite_pkcs1_v21: test_suite_pkcs1_v21.c ../library/libpolarssl.a
245 echo " CC $@.c"
246 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
247
Paul Bakker0049c2f2009-07-11 19:15:43 +0000248test_suite_rsa: test_suite_rsa.c ../library/libpolarssl.a
249 echo " CC $@.c"
250 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
251
252test_suite_shax: test_suite_shax.c ../library/libpolarssl.a
253 echo " CC $@.c"
254 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
255
256test_suite_x509parse: test_suite_x509parse.c ../library/libpolarssl.a
257 echo " CC $@.c"
258 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
259
Paul Bakker6d620502012-02-16 14:09:13 +0000260test_suite_x509write: test_suite_x509write.c ../library/libpolarssl.a
261 echo " CC $@.c"
262 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
263
Paul Bakker0049c2f2009-07-11 19:15:43 +0000264test_suite_xtea: test_suite_xtea.c ../library/libpolarssl.a
265 echo " CC $@.c"
266 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
267
Paul Bakker7d7f4f42010-02-18 18:26:04 +0000268test_suite_debug: test_suite_debug.c ../library/libpolarssl.a
269 echo " CC $@.c"
270 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
271
Paul Bakker3ac1b2d2010-06-18 22:47:29 +0000272test_suite_version: test_suite_version.c ../library/libpolarssl.a
273 echo " CC $@.c"
274 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
275
Paul Bakker0049c2f2009-07-11 19:15:43 +0000276clean:
Paul Bakker62f88dc2012-05-10 21:26:28 +0000277ifndef WINDOWS
Paul Bakker0049c2f2009-07-11 19:15:43 +0000278 rm -f $(APPS) *.c
Paul Bakker62f88dc2012-05-10 21:26:28 +0000279endif
280ifdef WINDOWS
281 del /Q /F *.c *.exe
282endif
Paul Bakker0049c2f2009-07-11 19:15:43 +0000283
Paul Bakker9794cb42009-07-28 18:55:00 +0000284check: $(APPS)
Paul Bakker62f88dc2012-05-10 21:26:28 +0000285ifndef WINDOWS
Paul Bakkerd14cd352012-05-08 15:39:50 +0000286 echo "Running checks (Success if all tests PASSED)"
287 RETURN=0; \
Paul Bakkerd947d762009-07-28 20:16:47 +0000288 for i in $(APPS); \
289 do \
290 echo " - $${i}"; \
Paul Bakkerd14cd352012-05-08 15:39:50 +0000291 RESULT=`./$${i} | grep -v 'PASS$$' | grep -v -- '-----' | grep -v '^$$'`; \
292 FAILED=`echo $$RESULT |grep FAILED`; \
293 echo " $$RESULT"; \
294 if [ "$$FAILED" != "" ]; \
295 then \
296 echo "**** Failed ***************"; \
297 RETURN=1; \
298 fi; \
Paul Bakkerd947d762009-07-28 20:16:47 +0000299 echo ""; \
Paul Bakkerd14cd352012-05-08 15:39:50 +0000300 done; \
301 if [ "$$RETURN" -eq 1 ]; then exit 1; fi
Paul Bakker62f88dc2012-05-10 21:26:28 +0000302endif