blob: be5e09831ac18c602dd5131047b68e8bc299a9f7 [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 Bakkera95919b2013-01-16 17:00:05 +010033 test_suite_ecp \
Paul Bakker89e80c92012-03-20 13:50:09 +000034 test_suite_error test_suite_gcm.decrypt \
35 test_suite_gcm.decrypt test_suite_hmac_shax \
Paul Bakker9d781402011-05-09 16:17:09 +000036 test_suite_md test_suite_mdx \
Paul Bakkerf518b162012-08-23 13:03:18 +000037 test_suite_mpi test_suite_pbkdf2 \
38 test_suite_pkcs1_v21 \
Paul Bakker9d781402011-05-09 16:17:09 +000039 test_suite_rsa test_suite_shax \
Paul Bakker6d620502012-02-16 14:09:13 +000040 test_suite_x509parse test_suite_x509write \
41 test_suite_xtea test_suite_version
Paul Bakker0049c2f2009-07-11 19:15:43 +000042
43.SILENT:
44
45all: $(APPS)
46
Paul Bakker46c17942011-07-13 14:54:54 +000047test_suite_cipher.aes.c : suites/test_suite_cipher.function suites/test_suite_cipher.aes.data scripts/generate_code.pl suites/helpers.function
48 echo " Generate $@"
49 scripts/generate_code.pl suites test_suite_cipher test_suite_cipher.aes
50
Paul Bakker6132d0a2012-07-04 17:10:40 +000051test_suite_cipher.blowfish.c : suites/test_suite_cipher.function suites/test_suite_cipher.blowfish.data scripts/generate_code.pl suites/helpers.function
52 echo " Generate $@"
53 scripts/generate_code.pl suites test_suite_cipher test_suite_cipher.blowfish
54
Paul Bakker46c17942011-07-13 14:54:54 +000055test_suite_cipher.camellia.c : suites/test_suite_cipher.function suites/test_suite_cipher.camellia.data scripts/generate_code.pl suites/helpers.function
56 echo " Generate $@"
57 scripts/generate_code.pl suites test_suite_cipher test_suite_cipher.camellia
58
59test_suite_cipher.des.c : suites/test_suite_cipher.function suites/test_suite_cipher.des.data scripts/generate_code.pl suites/helpers.function
60 echo " Generate $@"
61 scripts/generate_code.pl suites test_suite_cipher test_suite_cipher.des
62
Paul Bakkerfab5c822012-02-06 16:45:10 +000063test_suite_cipher.null.c : suites/test_suite_cipher.function suites/test_suite_cipher.null.data scripts/generate_code.pl suites/helpers.function
64 echo " Generate $@"
65 scripts/generate_code.pl suites test_suite_cipher test_suite_cipher.null
66
Paul Bakker89e80c92012-03-20 13:50:09 +000067test_suite_gcm.decrypt.c : suites/test_suite_gcm.function suites/test_suite_gcm.decrypt.data scripts/generate_code.pl suites/helpers.function
68 echo " Generate $@"
69 scripts/generate_code.pl suites test_suite_gcm test_suite_gcm.decrypt
70
71test_suite_gcm.encrypt.c : suites/test_suite_gcm.function suites/test_suite_gcm.encrypt.data scripts/generate_code.pl suites/helpers.function
72 echo " Generate $@"
73 scripts/generate_code.pl suites test_suite_gcm test_suite_gcm.encrypt
74
Paul Bakker4fa1a762011-03-13 16:56:11 +000075%.c : suites/%.function suites/%.data scripts/generate_code.pl suites/helpers.function
Paul Bakker0049c2f2009-07-11 19:15:43 +000076 echo " Generate $@"
Paul Bakker46c17942011-07-13 14:54:54 +000077 scripts/generate_code.pl suites $* $*
Paul Bakker0049c2f2009-07-11 19:15:43 +000078
79test_suite_aes: test_suite_aes.c ../library/libpolarssl.a
80 echo " CC $@.c"
81 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
82
83test_suite_arc4: test_suite_arc4.c ../library/libpolarssl.a
84 echo " CC $@.c"
85 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
86
87test_suite_base64: test_suite_base64.c ../library/libpolarssl.a
88 echo " CC $@.c"
89 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
90
Paul Bakkera9379c02012-07-04 11:02:11 +000091test_suite_blowfish: test_suite_blowfish.c ../library/libpolarssl.a
92 echo " CC $@.c"
93 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
94
Paul Bakker0049c2f2009-07-11 19:15:43 +000095test_suite_camellia: test_suite_camellia.c ../library/libpolarssl.a
96 echo " CC $@.c"
97 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
98
Paul Bakker46c17942011-07-13 14:54:54 +000099test_suite_cipher.aes: test_suite_cipher.aes.c ../library/libpolarssl.a
100 echo " CC $@.c"
101 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
102
Paul Bakker6132d0a2012-07-04 17:10:40 +0000103test_suite_cipher.blowfish: test_suite_cipher.blowfish.c ../library/libpolarssl.a
104 echo " CC $@.c"
105 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
106
Paul Bakker46c17942011-07-13 14:54:54 +0000107test_suite_cipher.camellia: test_suite_cipher.camellia.c ../library/libpolarssl.a
108 echo " CC $@.c"
109 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
110
Paul Bakkerfab5c822012-02-06 16:45:10 +0000111test_suite_cipher.des: test_suite_cipher.des.c ../library/libpolarssl.a
Paul Bakker0e04d0e2011-11-27 14:46:59 +0000112 echo " CC $@.c"
113 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
114
Paul Bakkerfab5c822012-02-06 16:45:10 +0000115test_suite_cipher.null: test_suite_cipher.null.c ../library/libpolarssl.a
116 echo " CC $@.c"
117 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
118
119test_suite_ctr_drbg: test_suite_ctr_drbg.c ../library/libpolarssl.a
Paul Bakker8123e9d2011-01-06 15:37:30 +0000120 echo " CC $@.c"
121 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
122
Paul Bakker0049c2f2009-07-11 19:15:43 +0000123test_suite_des: test_suite_des.c ../library/libpolarssl.a
124 echo " CC $@.c"
125 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
126
127test_suite_dhm: test_suite_dhm.c ../library/libpolarssl.a
128 echo " CC $@.c"
129 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
130
Paul Bakkera95919b2013-01-16 17:00:05 +0100131test_suite_ecp: test_suite_ecp.c ../library/libpolarssl.a
132 echo " CC $@.c"
133 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
134
Paul Bakker9d781402011-05-09 16:17:09 +0000135test_suite_error: test_suite_error.c ../library/libpolarssl.a
136 echo " CC $@.c"
137 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
138
Paul Bakker89e80c92012-03-20 13:50:09 +0000139test_suite_gcm.decrypt: test_suite_gcm.decrypt.c ../library/libpolarssl.a
140 echo " CC $@.c"
141 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
142
143test_suite_gcm.encrypt: test_suite_gcm.encrypt.c ../library/libpolarssl.a
144 echo " CC $@.c"
145 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
146
Paul Bakker0049c2f2009-07-11 19:15:43 +0000147test_suite_hmac_shax: test_suite_hmac_shax.c ../library/libpolarssl.a
148 echo " CC $@.c"
149 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
150
Paul Bakker17373852011-01-06 14:20:01 +0000151test_suite_md: test_suite_md.c ../library/libpolarssl.a
152 echo " CC $@.c"
153 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
154
Paul Bakker0049c2f2009-07-11 19:15:43 +0000155test_suite_mdx: test_suite_mdx.c ../library/libpolarssl.a
156 echo " CC $@.c"
157 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
158
159test_suite_mpi: test_suite_mpi.c ../library/libpolarssl.a
160 echo " CC $@.c"
161 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
162
Paul Bakkerf518b162012-08-23 13:03:18 +0000163test_suite_pbkdf2: test_suite_pbkdf2.c ../library/libpolarssl.a
164 echo " CC $@.c"
165 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
166
Paul Bakker9dcc3222011-03-08 14:16:06 +0000167test_suite_pkcs1_v21: test_suite_pkcs1_v21.c ../library/libpolarssl.a
168 echo " CC $@.c"
169 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
170
Paul Bakker0049c2f2009-07-11 19:15:43 +0000171test_suite_rsa: test_suite_rsa.c ../library/libpolarssl.a
172 echo " CC $@.c"
173 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
174
175test_suite_shax: test_suite_shax.c ../library/libpolarssl.a
176 echo " CC $@.c"
177 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
178
179test_suite_x509parse: test_suite_x509parse.c ../library/libpolarssl.a
180 echo " CC $@.c"
181 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
182
Paul Bakker6d620502012-02-16 14:09:13 +0000183test_suite_x509write: test_suite_x509write.c ../library/libpolarssl.a
184 echo " CC $@.c"
185 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
186
Paul Bakker0049c2f2009-07-11 19:15:43 +0000187test_suite_xtea: test_suite_xtea.c ../library/libpolarssl.a
188 echo " CC $@.c"
189 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
190
Paul Bakker7d7f4f42010-02-18 18:26:04 +0000191test_suite_debug: test_suite_debug.c ../library/libpolarssl.a
192 echo " CC $@.c"
193 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
194
Paul Bakker3ac1b2d2010-06-18 22:47:29 +0000195test_suite_version: test_suite_version.c ../library/libpolarssl.a
196 echo " CC $@.c"
197 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
198
Paul Bakker0049c2f2009-07-11 19:15:43 +0000199clean:
Paul Bakker62f88dc2012-05-10 21:26:28 +0000200ifndef WINDOWS
Paul Bakker0049c2f2009-07-11 19:15:43 +0000201 rm -f $(APPS) *.c
Paul Bakker62f88dc2012-05-10 21:26:28 +0000202endif
203ifdef WINDOWS
204 del /Q /F *.c *.exe
205endif
Paul Bakker0049c2f2009-07-11 19:15:43 +0000206
Paul Bakker9794cb42009-07-28 18:55:00 +0000207check: $(APPS)
Paul Bakker62f88dc2012-05-10 21:26:28 +0000208ifndef WINDOWS
Paul Bakkerd14cd352012-05-08 15:39:50 +0000209 echo "Running checks (Success if all tests PASSED)"
210 RETURN=0; \
Paul Bakkerd947d762009-07-28 20:16:47 +0000211 for i in $(APPS); \
212 do \
213 echo " - $${i}"; \
Paul Bakkerd14cd352012-05-08 15:39:50 +0000214 RESULT=`./$${i} | grep -v 'PASS$$' | grep -v -- '-----' | grep -v '^$$'`; \
215 FAILED=`echo $$RESULT |grep FAILED`; \
216 echo " $$RESULT"; \
217 if [ "$$FAILED" != "" ]; \
218 then \
219 echo "**** Failed ***************"; \
220 RETURN=1; \
221 fi; \
Paul Bakkerd947d762009-07-28 20:16:47 +0000222 echo ""; \
Paul Bakkerd14cd352012-05-08 15:39:50 +0000223 done; \
224 if [ "$$RETURN" -eq 1 ]; then exit 1; fi
Paul Bakker62f88dc2012-05-10 21:26:28 +0000225endif