Paul Bakker | 0049c2f | 2009-07-11 19:15:43 +0000 | [diff] [blame] | 1 | |
| 2 | # To compile on SunOS: add "-lsocket -lnsl" to LDFLAGS |
| 3 | # To compile on MinGW: add "-lws2_32" to LDFLAGS |
Paul Bakker | 43b7e35 | 2011-01-18 15:27:19 +0000 | [diff] [blame] | 4 | # To compile with PKCS11: add "-lpkcs11-helper" to LDFLAGS |
Paul Bakker | 0049c2f | 2009-07-11 19:15:43 +0000 | [diff] [blame] | 5 | |
Paul Bakker | 46eb138 | 2011-01-30 17:10:13 +0000 | [diff] [blame] | 6 | CFLAGS += -I../include -D_FILE_OFFSET_BITS=64 -Wall -W -Wdeclaration-after-statement \ |
Paul Bakker | 0049c2f | 2009-07-11 19:15:43 +0000 | [diff] [blame] | 7 | -Wno-unused-function -Wno-unused-value |
| 8 | |
| 9 | OFLAGS = -O |
Paul Bakker | a585beb | 2011-06-21 08:59:44 +0000 | [diff] [blame] | 10 | LDFLAGS += -L../library -lpolarssl $(SYS_LDFLAGS) |
Paul Bakker | 0049c2f | 2009-07-11 19:15:43 +0000 | [diff] [blame] | 11 | |
Paul Bakker | c7ffd36 | 2012-04-05 12:08:29 +0000 | [diff] [blame] | 12 | ifdef DEBUG |
| 13 | CFLAGS += -g3 |
| 14 | endif |
| 15 | |
Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 16 | APPS = test_suite_aes test_suite_arc4 \ |
| 17 | test_suite_base64 test_suite_camellia \ |
Paul Bakker | 46c1794 | 2011-07-13 14:54:54 +0000 | [diff] [blame] | 18 | test_suite_cipher.aes test_suite_cipher.camellia \ |
Paul Bakker | fab5c82 | 2012-02-06 16:45:10 +0000 | [diff] [blame] | 19 | test_suite_cipher.des test_suite_cipher.null \ |
| 20 | test_suite_ctr_drbg test_suite_debug \ |
Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 21 | test_suite_des test_suite_dhm \ |
Paul Bakker | 89e80c9 | 2012-03-20 13:50:09 +0000 | [diff] [blame] | 22 | test_suite_error test_suite_gcm.decrypt \ |
| 23 | test_suite_gcm.decrypt test_suite_hmac_shax \ |
Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 24 | test_suite_md test_suite_mdx \ |
| 25 | test_suite_mpi test_suite_pkcs1_v21 \ |
| 26 | test_suite_rsa test_suite_shax \ |
Paul Bakker | 6d62050 | 2012-02-16 14:09:13 +0000 | [diff] [blame] | 27 | test_suite_x509parse test_suite_x509write \ |
| 28 | test_suite_xtea test_suite_version |
Paul Bakker | 0049c2f | 2009-07-11 19:15:43 +0000 | [diff] [blame] | 29 | |
| 30 | .SILENT: |
| 31 | |
| 32 | all: $(APPS) |
| 33 | |
Paul Bakker | 46c1794 | 2011-07-13 14:54:54 +0000 | [diff] [blame] | 34 | test_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 | |
| 38 | test_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 | |
| 42 | test_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 Bakker | fab5c82 | 2012-02-06 16:45:10 +0000 | [diff] [blame] | 46 | test_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 Bakker | 89e80c9 | 2012-03-20 13:50:09 +0000 | [diff] [blame] | 50 | test_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 | |
| 54 | test_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 Bakker | 4fa1a76 | 2011-03-13 16:56:11 +0000 | [diff] [blame] | 58 | %.c : suites/%.function suites/%.data scripts/generate_code.pl suites/helpers.function |
Paul Bakker | 0049c2f | 2009-07-11 19:15:43 +0000 | [diff] [blame] | 59 | echo " Generate $@" |
Paul Bakker | 46c1794 | 2011-07-13 14:54:54 +0000 | [diff] [blame] | 60 | scripts/generate_code.pl suites $* $* |
Paul Bakker | 0049c2f | 2009-07-11 19:15:43 +0000 | [diff] [blame] | 61 | |
| 62 | test_suite_aes: test_suite_aes.c ../library/libpolarssl.a |
| 63 | echo " CC $@.c" |
| 64 | $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@ |
| 65 | |
| 66 | test_suite_arc4: test_suite_arc4.c ../library/libpolarssl.a |
| 67 | echo " CC $@.c" |
| 68 | $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@ |
| 69 | |
| 70 | test_suite_base64: test_suite_base64.c ../library/libpolarssl.a |
| 71 | echo " CC $@.c" |
| 72 | $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@ |
| 73 | |
| 74 | test_suite_camellia: test_suite_camellia.c ../library/libpolarssl.a |
| 75 | echo " CC $@.c" |
| 76 | $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@ |
| 77 | |
Paul Bakker | 46c1794 | 2011-07-13 14:54:54 +0000 | [diff] [blame] | 78 | test_suite_cipher.aes: test_suite_cipher.aes.c ../library/libpolarssl.a |
| 79 | echo " CC $@.c" |
| 80 | $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@ |
| 81 | |
| 82 | test_suite_cipher.camellia: test_suite_cipher.camellia.c ../library/libpolarssl.a |
| 83 | echo " CC $@.c" |
| 84 | $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@ |
| 85 | |
Paul Bakker | fab5c82 | 2012-02-06 16:45:10 +0000 | [diff] [blame] | 86 | test_suite_cipher.des: test_suite_cipher.des.c ../library/libpolarssl.a |
Paul Bakker | 0e04d0e | 2011-11-27 14:46:59 +0000 | [diff] [blame] | 87 | echo " CC $@.c" |
| 88 | $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@ |
| 89 | |
Paul Bakker | fab5c82 | 2012-02-06 16:45:10 +0000 | [diff] [blame] | 90 | test_suite_cipher.null: test_suite_cipher.null.c ../library/libpolarssl.a |
| 91 | echo " CC $@.c" |
| 92 | $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@ |
| 93 | |
| 94 | test_suite_ctr_drbg: test_suite_ctr_drbg.c ../library/libpolarssl.a |
Paul Bakker | 8123e9d | 2011-01-06 15:37:30 +0000 | [diff] [blame] | 95 | echo " CC $@.c" |
| 96 | $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@ |
| 97 | |
Paul Bakker | 0049c2f | 2009-07-11 19:15:43 +0000 | [diff] [blame] | 98 | test_suite_des: test_suite_des.c ../library/libpolarssl.a |
| 99 | echo " CC $@.c" |
| 100 | $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@ |
| 101 | |
| 102 | test_suite_dhm: test_suite_dhm.c ../library/libpolarssl.a |
| 103 | echo " CC $@.c" |
| 104 | $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@ |
| 105 | |
Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 106 | test_suite_error: test_suite_error.c ../library/libpolarssl.a |
| 107 | echo " CC $@.c" |
| 108 | $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@ |
| 109 | |
Paul Bakker | 89e80c9 | 2012-03-20 13:50:09 +0000 | [diff] [blame] | 110 | test_suite_gcm.decrypt: test_suite_gcm.decrypt.c ../library/libpolarssl.a |
| 111 | echo " CC $@.c" |
| 112 | $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@ |
| 113 | |
| 114 | test_suite_gcm.encrypt: test_suite_gcm.encrypt.c ../library/libpolarssl.a |
| 115 | echo " CC $@.c" |
| 116 | $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@ |
| 117 | |
Paul Bakker | 0049c2f | 2009-07-11 19:15:43 +0000 | [diff] [blame] | 118 | test_suite_hmac_shax: test_suite_hmac_shax.c ../library/libpolarssl.a |
| 119 | echo " CC $@.c" |
| 120 | $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@ |
| 121 | |
Paul Bakker | 1737385 | 2011-01-06 14:20:01 +0000 | [diff] [blame] | 122 | test_suite_md: test_suite_md.c ../library/libpolarssl.a |
| 123 | echo " CC $@.c" |
| 124 | $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@ |
| 125 | |
Paul Bakker | 0049c2f | 2009-07-11 19:15:43 +0000 | [diff] [blame] | 126 | test_suite_mdx: test_suite_mdx.c ../library/libpolarssl.a |
| 127 | echo " CC $@.c" |
| 128 | $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@ |
| 129 | |
| 130 | test_suite_mpi: test_suite_mpi.c ../library/libpolarssl.a |
| 131 | echo " CC $@.c" |
| 132 | $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@ |
| 133 | |
Paul Bakker | 9dcc322 | 2011-03-08 14:16:06 +0000 | [diff] [blame] | 134 | test_suite_pkcs1_v21: test_suite_pkcs1_v21.c ../library/libpolarssl.a |
| 135 | echo " CC $@.c" |
| 136 | $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@ |
| 137 | |
Paul Bakker | 0049c2f | 2009-07-11 19:15:43 +0000 | [diff] [blame] | 138 | test_suite_rsa: test_suite_rsa.c ../library/libpolarssl.a |
| 139 | echo " CC $@.c" |
| 140 | $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@ |
| 141 | |
| 142 | test_suite_shax: test_suite_shax.c ../library/libpolarssl.a |
| 143 | echo " CC $@.c" |
| 144 | $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@ |
| 145 | |
| 146 | test_suite_x509parse: test_suite_x509parse.c ../library/libpolarssl.a |
| 147 | echo " CC $@.c" |
| 148 | $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@ |
| 149 | |
Paul Bakker | 6d62050 | 2012-02-16 14:09:13 +0000 | [diff] [blame] | 150 | test_suite_x509write: test_suite_x509write.c ../library/libpolarssl.a |
| 151 | echo " CC $@.c" |
| 152 | $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@ |
| 153 | |
Paul Bakker | 0049c2f | 2009-07-11 19:15:43 +0000 | [diff] [blame] | 154 | test_suite_xtea: test_suite_xtea.c ../library/libpolarssl.a |
| 155 | echo " CC $@.c" |
| 156 | $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@ |
| 157 | |
Paul Bakker | 7d7f4f4 | 2010-02-18 18:26:04 +0000 | [diff] [blame] | 158 | test_suite_debug: test_suite_debug.c ../library/libpolarssl.a |
| 159 | echo " CC $@.c" |
| 160 | $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@ |
| 161 | |
Paul Bakker | 3ac1b2d | 2010-06-18 22:47:29 +0000 | [diff] [blame] | 162 | test_suite_version: test_suite_version.c ../library/libpolarssl.a |
| 163 | echo " CC $@.c" |
| 164 | $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@ |
| 165 | |
Paul Bakker | 0049c2f | 2009-07-11 19:15:43 +0000 | [diff] [blame] | 166 | clean: |
| 167 | rm -f $(APPS) *.c |
| 168 | |
Paul Bakker | 9794cb4 | 2009-07-28 18:55:00 +0000 | [diff] [blame] | 169 | check: $(APPS) |
Paul Bakker | d14cd35 | 2012-05-08 15:39:50 +0000 | [diff] [blame^] | 170 | echo "Running checks (Success if all tests PASSED)" |
| 171 | RETURN=0; \ |
Paul Bakker | d947d76 | 2009-07-28 20:16:47 +0000 | [diff] [blame] | 172 | for i in $(APPS); \ |
| 173 | do \ |
| 174 | echo " - $${i}"; \ |
Paul Bakker | d14cd35 | 2012-05-08 15:39:50 +0000 | [diff] [blame^] | 175 | 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 Bakker | d947d76 | 2009-07-28 20:16:47 +0000 | [diff] [blame] | 183 | echo ""; \ |
Paul Bakker | d14cd35 | 2012-05-08 15:39:50 +0000 | [diff] [blame^] | 184 | done; \ |
| 185 | if [ "$$RETURN" -eq 1 ]; then exit 1; fi |