blob: 08173e1147e4cc4e34339396cca106b48fdb9eb0 [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 Bakker9d781402011-05-09 16:17:09 +000025APPS = test_suite_aes test_suite_arc4 \
Paul Bakkera9379c02012-07-04 11:02:11 +000026 test_suite_base64 test_suite_blowfish \
Paul Bakker6132d0a2012-07-04 17:10:40 +000027 test_suite_camellia test_suite_cipher.aes \
28 test_suite_cipher.blowfish \
29 test_suite_cipher.camellia \
Paul Bakkerfab5c822012-02-06 16:45:10 +000030 test_suite_cipher.des test_suite_cipher.null \
31 test_suite_ctr_drbg test_suite_debug \
Paul Bakker9d781402011-05-09 16:17:09 +000032 test_suite_des test_suite_dhm \
Paul Bakkerd589a0d2013-03-13 16:30:17 +010033 test_suite_ecdh test_suite_ecdsa \
Paul Bakkera95919b2013-01-16 17:00:05 +010034 test_suite_ecp \
Paul Bakker89e80c92012-03-20 13:50:09 +000035 test_suite_error test_suite_gcm.decrypt \
36 test_suite_gcm.decrypt test_suite_hmac_shax \
Paul Bakker9d781402011-05-09 16:17:09 +000037 test_suite_md test_suite_mdx \
Paul Bakkerf518b162012-08-23 13:03:18 +000038 test_suite_mpi test_suite_pbkdf2 \
39 test_suite_pkcs1_v21 \
Paul Bakker9d781402011-05-09 16:17:09 +000040 test_suite_rsa test_suite_shax \
Paul Bakker6d620502012-02-16 14:09:13 +000041 test_suite_x509parse test_suite_x509write \
42 test_suite_xtea test_suite_version
Paul Bakker0049c2f2009-07-11 19:15:43 +000043
44.SILENT:
45
46all: $(APPS)
47
Paul Bakker46c17942011-07-13 14:54:54 +000048test_suite_cipher.aes.c : suites/test_suite_cipher.function suites/test_suite_cipher.aes.data scripts/generate_code.pl suites/helpers.function
49 echo " Generate $@"
50 scripts/generate_code.pl suites test_suite_cipher test_suite_cipher.aes
51
Paul Bakker6132d0a2012-07-04 17:10:40 +000052test_suite_cipher.blowfish.c : suites/test_suite_cipher.function suites/test_suite_cipher.blowfish.data scripts/generate_code.pl suites/helpers.function
53 echo " Generate $@"
54 scripts/generate_code.pl suites test_suite_cipher test_suite_cipher.blowfish
55
Paul Bakker46c17942011-07-13 14:54:54 +000056test_suite_cipher.camellia.c : suites/test_suite_cipher.function suites/test_suite_cipher.camellia.data scripts/generate_code.pl suites/helpers.function
57 echo " Generate $@"
58 scripts/generate_code.pl suites test_suite_cipher test_suite_cipher.camellia
59
60test_suite_cipher.des.c : suites/test_suite_cipher.function suites/test_suite_cipher.des.data scripts/generate_code.pl suites/helpers.function
61 echo " Generate $@"
62 scripts/generate_code.pl suites test_suite_cipher test_suite_cipher.des
63
Paul Bakkerfab5c822012-02-06 16:45:10 +000064test_suite_cipher.null.c : suites/test_suite_cipher.function suites/test_suite_cipher.null.data scripts/generate_code.pl suites/helpers.function
65 echo " Generate $@"
66 scripts/generate_code.pl suites test_suite_cipher test_suite_cipher.null
67
Paul Bakker89e80c92012-03-20 13:50:09 +000068test_suite_gcm.decrypt.c : suites/test_suite_gcm.function suites/test_suite_gcm.decrypt.data scripts/generate_code.pl suites/helpers.function
69 echo " Generate $@"
70 scripts/generate_code.pl suites test_suite_gcm test_suite_gcm.decrypt
71
72test_suite_gcm.encrypt.c : suites/test_suite_gcm.function suites/test_suite_gcm.encrypt.data scripts/generate_code.pl suites/helpers.function
73 echo " Generate $@"
74 scripts/generate_code.pl suites test_suite_gcm test_suite_gcm.encrypt
75
Paul Bakker4fa1a762011-03-13 16:56:11 +000076%.c : suites/%.function suites/%.data scripts/generate_code.pl suites/helpers.function
Paul Bakker0049c2f2009-07-11 19:15:43 +000077 echo " Generate $@"
Paul Bakker46c17942011-07-13 14:54:54 +000078 scripts/generate_code.pl suites $* $*
Paul Bakker0049c2f2009-07-11 19:15:43 +000079
80test_suite_aes: test_suite_aes.c ../library/libpolarssl.a
81 echo " CC $@.c"
82 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
83
84test_suite_arc4: test_suite_arc4.c ../library/libpolarssl.a
85 echo " CC $@.c"
86 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
87
88test_suite_base64: test_suite_base64.c ../library/libpolarssl.a
89 echo " CC $@.c"
90 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
91
Paul Bakkera9379c02012-07-04 11:02:11 +000092test_suite_blowfish: test_suite_blowfish.c ../library/libpolarssl.a
93 echo " CC $@.c"
94 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
95
Paul Bakker0049c2f2009-07-11 19:15:43 +000096test_suite_camellia: test_suite_camellia.c ../library/libpolarssl.a
97 echo " CC $@.c"
98 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
99
Paul Bakker46c17942011-07-13 14:54:54 +0000100test_suite_cipher.aes: test_suite_cipher.aes.c ../library/libpolarssl.a
101 echo " CC $@.c"
102 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
103
Paul Bakker6132d0a2012-07-04 17:10:40 +0000104test_suite_cipher.blowfish: test_suite_cipher.blowfish.c ../library/libpolarssl.a
105 echo " CC $@.c"
106 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
107
Paul Bakker46c17942011-07-13 14:54:54 +0000108test_suite_cipher.camellia: test_suite_cipher.camellia.c ../library/libpolarssl.a
109 echo " CC $@.c"
110 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
111
Paul Bakkerfab5c822012-02-06 16:45:10 +0000112test_suite_cipher.des: test_suite_cipher.des.c ../library/libpolarssl.a
Paul Bakker0e04d0e2011-11-27 14:46:59 +0000113 echo " CC $@.c"
114 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
115
Paul Bakkerfab5c822012-02-06 16:45:10 +0000116test_suite_cipher.null: test_suite_cipher.null.c ../library/libpolarssl.a
117 echo " CC $@.c"
118 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
119
120test_suite_ctr_drbg: test_suite_ctr_drbg.c ../library/libpolarssl.a
Paul Bakker8123e9d2011-01-06 15:37:30 +0000121 echo " CC $@.c"
122 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
123
Paul Bakker0049c2f2009-07-11 19:15:43 +0000124test_suite_des: test_suite_des.c ../library/libpolarssl.a
125 echo " CC $@.c"
126 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
127
128test_suite_dhm: test_suite_dhm.c ../library/libpolarssl.a
129 echo " CC $@.c"
130 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
131
Paul Bakkerd589a0d2013-03-13 16:30:17 +0100132test_suite_ecdh: test_suite_ecdh.c ../library/libpolarssl.a
133 echo " CC $@.c"
134 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
135
136test_suite_ecdsa: test_suite_ecdsa.c ../library/libpolarssl.a
137 echo " CC $@.c"
138 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
139
Paul Bakkera95919b2013-01-16 17:00:05 +0100140test_suite_ecp: test_suite_ecp.c ../library/libpolarssl.a
141 echo " CC $@.c"
142 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
143
Paul Bakker9d781402011-05-09 16:17:09 +0000144test_suite_error: test_suite_error.c ../library/libpolarssl.a
145 echo " CC $@.c"
146 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
147
Paul Bakker89e80c92012-03-20 13:50:09 +0000148test_suite_gcm.decrypt: test_suite_gcm.decrypt.c ../library/libpolarssl.a
149 echo " CC $@.c"
150 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
151
152test_suite_gcm.encrypt: test_suite_gcm.encrypt.c ../library/libpolarssl.a
153 echo " CC $@.c"
154 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
155
Paul Bakker0049c2f2009-07-11 19:15:43 +0000156test_suite_hmac_shax: test_suite_hmac_shax.c ../library/libpolarssl.a
157 echo " CC $@.c"
158 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
159
Paul Bakker17373852011-01-06 14:20:01 +0000160test_suite_md: test_suite_md.c ../library/libpolarssl.a
161 echo " CC $@.c"
162 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
163
Paul Bakker0049c2f2009-07-11 19:15:43 +0000164test_suite_mdx: test_suite_mdx.c ../library/libpolarssl.a
165 echo " CC $@.c"
166 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
167
168test_suite_mpi: test_suite_mpi.c ../library/libpolarssl.a
169 echo " CC $@.c"
170 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
171
Paul Bakkerf518b162012-08-23 13:03:18 +0000172test_suite_pbkdf2: test_suite_pbkdf2.c ../library/libpolarssl.a
173 echo " CC $@.c"
174 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
175
Paul Bakker9dcc3222011-03-08 14:16:06 +0000176test_suite_pkcs1_v21: test_suite_pkcs1_v21.c ../library/libpolarssl.a
177 echo " CC $@.c"
178 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
179
Paul Bakker0049c2f2009-07-11 19:15:43 +0000180test_suite_rsa: test_suite_rsa.c ../library/libpolarssl.a
181 echo " CC $@.c"
182 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
183
184test_suite_shax: test_suite_shax.c ../library/libpolarssl.a
185 echo " CC $@.c"
186 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
187
188test_suite_x509parse: test_suite_x509parse.c ../library/libpolarssl.a
189 echo " CC $@.c"
190 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
191
Paul Bakker6d620502012-02-16 14:09:13 +0000192test_suite_x509write: test_suite_x509write.c ../library/libpolarssl.a
193 echo " CC $@.c"
194 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
195
Paul Bakker0049c2f2009-07-11 19:15:43 +0000196test_suite_xtea: test_suite_xtea.c ../library/libpolarssl.a
197 echo " CC $@.c"
198 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
199
Paul Bakker7d7f4f42010-02-18 18:26:04 +0000200test_suite_debug: test_suite_debug.c ../library/libpolarssl.a
201 echo " CC $@.c"
202 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
203
Paul Bakker3ac1b2d2010-06-18 22:47:29 +0000204test_suite_version: test_suite_version.c ../library/libpolarssl.a
205 echo " CC $@.c"
206 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
207
Paul Bakker0049c2f2009-07-11 19:15:43 +0000208clean:
Paul Bakker62f88dc2012-05-10 21:26:28 +0000209ifndef WINDOWS
Paul Bakker0049c2f2009-07-11 19:15:43 +0000210 rm -f $(APPS) *.c
Paul Bakker62f88dc2012-05-10 21:26:28 +0000211endif
212ifdef WINDOWS
213 del /Q /F *.c *.exe
214endif
Paul Bakker0049c2f2009-07-11 19:15:43 +0000215
Paul Bakker9794cb42009-07-28 18:55:00 +0000216check: $(APPS)
Paul Bakker62f88dc2012-05-10 21:26:28 +0000217ifndef WINDOWS
Paul Bakkerd14cd352012-05-08 15:39:50 +0000218 echo "Running checks (Success if all tests PASSED)"
219 RETURN=0; \
Paul Bakkerd947d762009-07-28 20:16:47 +0000220 for i in $(APPS); \
221 do \
222 echo " - $${i}"; \
Paul Bakkerd14cd352012-05-08 15:39:50 +0000223 RESULT=`./$${i} | grep -v 'PASS$$' | grep -v -- '-----' | grep -v '^$$'`; \
224 FAILED=`echo $$RESULT |grep FAILED`; \
225 echo " $$RESULT"; \
226 if [ "$$FAILED" != "" ]; \
227 then \
228 echo "**** Failed ***************"; \
229 RETURN=1; \
230 fi; \
Paul Bakkerd947d762009-07-28 20:16:47 +0000231 echo ""; \
Paul Bakkerd14cd352012-05-08 15:39:50 +0000232 done; \
233 if [ "$$RETURN" -eq 1 ]; then exit 1; fi
Paul Bakker62f88dc2012-05-10 21:26:28 +0000234endif