blob: 460858ad1f723b9f91cd7baa2d93904f4bea1fc9 [file] [log] [blame]
Paul Bakker0049c2f2009-07-11 19:15:43 +00001
2# To compile on SunOS: add "-lsocket -lnsl" to LDFLAGS
3# To compile on MinGW: add "-lws2_32" to LDFLAGS
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
9OFLAGS = -O
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 Bakker9d781402011-05-09 16:17:09 +000016APPS = test_suite_aes test_suite_arc4 \
17 test_suite_base64 test_suite_camellia \
Paul Bakker46c17942011-07-13 14:54:54 +000018 test_suite_cipher.aes test_suite_cipher.camellia \
Paul Bakkerfab5c822012-02-06 16:45:10 +000019 test_suite_cipher.des test_suite_cipher.null \
20 test_suite_ctr_drbg test_suite_debug \
Paul Bakker9d781402011-05-09 16:17:09 +000021 test_suite_des test_suite_dhm \
Paul Bakker89e80c92012-03-20 13:50:09 +000022 test_suite_error test_suite_gcm.decrypt \
23 test_suite_gcm.decrypt test_suite_hmac_shax \
Paul Bakker9d781402011-05-09 16:17:09 +000024 test_suite_md test_suite_mdx \
25 test_suite_mpi test_suite_pkcs1_v21 \
26 test_suite_rsa test_suite_shax \
Paul Bakker6d620502012-02-16 14:09:13 +000027 test_suite_x509parse test_suite_x509write \
28 test_suite_xtea test_suite_version
Paul Bakker0049c2f2009-07-11 19:15:43 +000029
30.SILENT:
31
32all: $(APPS)
33
Paul Bakker46c17942011-07-13 14:54:54 +000034test_suite_cipher.aes.c : suites/test_suite_cipher.function suites/test_suite_cipher.aes.data scripts/generate_code.pl suites/helpers.function
35 echo " Generate $@"
36 scripts/generate_code.pl suites test_suite_cipher test_suite_cipher.aes
37
38test_suite_cipher.camellia.c : suites/test_suite_cipher.function suites/test_suite_cipher.camellia.data scripts/generate_code.pl suites/helpers.function
39 echo " Generate $@"
40 scripts/generate_code.pl suites test_suite_cipher test_suite_cipher.camellia
41
42test_suite_cipher.des.c : suites/test_suite_cipher.function suites/test_suite_cipher.des.data scripts/generate_code.pl suites/helpers.function
43 echo " Generate $@"
44 scripts/generate_code.pl suites test_suite_cipher test_suite_cipher.des
45
Paul Bakkerfab5c822012-02-06 16:45:10 +000046test_suite_cipher.null.c : suites/test_suite_cipher.function suites/test_suite_cipher.null.data scripts/generate_code.pl suites/helpers.function
47 echo " Generate $@"
48 scripts/generate_code.pl suites test_suite_cipher test_suite_cipher.null
49
Paul Bakker89e80c92012-03-20 13:50:09 +000050test_suite_gcm.decrypt.c : suites/test_suite_gcm.function suites/test_suite_gcm.decrypt.data scripts/generate_code.pl suites/helpers.function
51 echo " Generate $@"
52 scripts/generate_code.pl suites test_suite_gcm test_suite_gcm.decrypt
53
54test_suite_gcm.encrypt.c : suites/test_suite_gcm.function suites/test_suite_gcm.encrypt.data scripts/generate_code.pl suites/helpers.function
55 echo " Generate $@"
56 scripts/generate_code.pl suites test_suite_gcm test_suite_gcm.encrypt
57
Paul Bakker4fa1a762011-03-13 16:56:11 +000058%.c : suites/%.function suites/%.data scripts/generate_code.pl suites/helpers.function
Paul Bakker0049c2f2009-07-11 19:15:43 +000059 echo " Generate $@"
Paul Bakker46c17942011-07-13 14:54:54 +000060 scripts/generate_code.pl suites $* $*
Paul Bakker0049c2f2009-07-11 19:15:43 +000061
62test_suite_aes: test_suite_aes.c ../library/libpolarssl.a
63 echo " CC $@.c"
64 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
65
66test_suite_arc4: test_suite_arc4.c ../library/libpolarssl.a
67 echo " CC $@.c"
68 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
69
70test_suite_base64: test_suite_base64.c ../library/libpolarssl.a
71 echo " CC $@.c"
72 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
73
74test_suite_camellia: test_suite_camellia.c ../library/libpolarssl.a
75 echo " CC $@.c"
76 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
77
Paul Bakker46c17942011-07-13 14:54:54 +000078test_suite_cipher.aes: test_suite_cipher.aes.c ../library/libpolarssl.a
79 echo " CC $@.c"
80 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
81
82test_suite_cipher.camellia: test_suite_cipher.camellia.c ../library/libpolarssl.a
83 echo " CC $@.c"
84 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
85
Paul Bakkerfab5c822012-02-06 16:45:10 +000086test_suite_cipher.des: test_suite_cipher.des.c ../library/libpolarssl.a
Paul Bakker0e04d0e2011-11-27 14:46:59 +000087 echo " CC $@.c"
88 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
89
Paul Bakkerfab5c822012-02-06 16:45:10 +000090test_suite_cipher.null: test_suite_cipher.null.c ../library/libpolarssl.a
91 echo " CC $@.c"
92 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
93
94test_suite_ctr_drbg: test_suite_ctr_drbg.c ../library/libpolarssl.a
Paul Bakker8123e9d2011-01-06 15:37:30 +000095 echo " CC $@.c"
96 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
97
Paul Bakker0049c2f2009-07-11 19:15:43 +000098test_suite_des: test_suite_des.c ../library/libpolarssl.a
99 echo " CC $@.c"
100 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
101
102test_suite_dhm: test_suite_dhm.c ../library/libpolarssl.a
103 echo " CC $@.c"
104 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
105
Paul Bakker9d781402011-05-09 16:17:09 +0000106test_suite_error: test_suite_error.c ../library/libpolarssl.a
107 echo " CC $@.c"
108 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
109
Paul Bakker89e80c92012-03-20 13:50:09 +0000110test_suite_gcm.decrypt: test_suite_gcm.decrypt.c ../library/libpolarssl.a
111 echo " CC $@.c"
112 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
113
114test_suite_gcm.encrypt: test_suite_gcm.encrypt.c ../library/libpolarssl.a
115 echo " CC $@.c"
116 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
117
Paul Bakker0049c2f2009-07-11 19:15:43 +0000118test_suite_hmac_shax: test_suite_hmac_shax.c ../library/libpolarssl.a
119 echo " CC $@.c"
120 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
121
Paul Bakker17373852011-01-06 14:20:01 +0000122test_suite_md: test_suite_md.c ../library/libpolarssl.a
123 echo " CC $@.c"
124 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
125
Paul Bakker0049c2f2009-07-11 19:15:43 +0000126test_suite_mdx: test_suite_mdx.c ../library/libpolarssl.a
127 echo " CC $@.c"
128 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
129
130test_suite_mpi: test_suite_mpi.c ../library/libpolarssl.a
131 echo " CC $@.c"
132 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
133
Paul Bakker9dcc3222011-03-08 14:16:06 +0000134test_suite_pkcs1_v21: test_suite_pkcs1_v21.c ../library/libpolarssl.a
135 echo " CC $@.c"
136 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
137
Paul Bakker0049c2f2009-07-11 19:15:43 +0000138test_suite_rsa: test_suite_rsa.c ../library/libpolarssl.a
139 echo " CC $@.c"
140 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
141
142test_suite_shax: test_suite_shax.c ../library/libpolarssl.a
143 echo " CC $@.c"
144 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
145
146test_suite_x509parse: test_suite_x509parse.c ../library/libpolarssl.a
147 echo " CC $@.c"
148 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
149
Paul Bakker6d620502012-02-16 14:09:13 +0000150test_suite_x509write: test_suite_x509write.c ../library/libpolarssl.a
151 echo " CC $@.c"
152 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
153
Paul Bakker0049c2f2009-07-11 19:15:43 +0000154test_suite_xtea: test_suite_xtea.c ../library/libpolarssl.a
155 echo " CC $@.c"
156 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
157
Paul Bakker7d7f4f42010-02-18 18:26:04 +0000158test_suite_debug: test_suite_debug.c ../library/libpolarssl.a
159 echo " CC $@.c"
160 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
161
Paul Bakker3ac1b2d2010-06-18 22:47:29 +0000162test_suite_version: test_suite_version.c ../library/libpolarssl.a
163 echo " CC $@.c"
164 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
165
Paul Bakker0049c2f2009-07-11 19:15:43 +0000166clean:
167 rm -f $(APPS) *.c
168
Paul Bakker9794cb42009-07-28 18:55:00 +0000169check: $(APPS)
Paul Bakkerd14cd352012-05-08 15:39:50 +0000170 echo "Running checks (Success if all tests PASSED)"
171 RETURN=0; \
Paul Bakkerd947d762009-07-28 20:16:47 +0000172 for i in $(APPS); \
173 do \
174 echo " - $${i}"; \
Paul Bakkerd14cd352012-05-08 15:39:50 +0000175 RESULT=`./$${i} | grep -v 'PASS$$' | grep -v -- '-----' | grep -v '^$$'`; \
176 FAILED=`echo $$RESULT |grep FAILED`; \
177 echo " $$RESULT"; \
178 if [ "$$FAILED" != "" ]; \
179 then \
180 echo "**** Failed ***************"; \
181 RETURN=1; \
182 fi; \
Paul Bakkerd947d762009-07-28 20:16:47 +0000183 echo ""; \
Paul Bakkerd14cd352012-05-08 15:39:50 +0000184 done; \
185 if [ "$$RETURN" -eq 1 ]; then exit 1; fi