Paul Bakker | 0049c2f | 2009-07-11 19:15:43 +0000 | [diff] [blame] | 1 | |
| 2 | # To compile on SunOS: add "-lsocket -lnsl" to LDFLAGS |
Paul Bakker | 43b7e35 | 2011-01-18 15:27:19 +0000 | [diff] [blame] | 3 | # To compile with PKCS11: add "-lpkcs11-helper" to LDFLAGS |
Paul Bakker | 0049c2f | 2009-07-11 19:15:43 +0000 | [diff] [blame] | 4 | |
Mohammad Azim Khan | 9540261 | 2017-07-19 10:15:54 +0100 | [diff] [blame] | 5 | CFLAGS ?= -O2 |
Alon Bar-Lev | f7a9f30 | 2015-02-18 17:55:05 +0200 | [diff] [blame] | 6 | WARNING_CFLAGS ?= -Wall -W -Wdeclaration-after-statement -Wno-unused-function -Wno-unused-value |
Alon Bar-Lev | ada4105 | 2015-02-18 17:47:52 +0200 | [diff] [blame] | 7 | LDFLAGS ?= |
Paul Bakker | 0049c2f | 2009-07-11 19:15:43 +0000 | [diff] [blame] | 8 | |
Alon Bar-Lev | f7a9f30 | 2015-02-18 17:55:05 +0200 | [diff] [blame] | 9 | LOCAL_CFLAGS = $(WARNING_CFLAGS) -I../include -D_FILE_OFFSET_BITS=64 |
Mohammad Azim Khan | 94aefaf | 2017-03-23 12:32:54 +0000 | [diff] [blame] | 10 | LOCAL_LDFLAGS = -L../library \ |
Manuel Pégourié-Gonnard | 21e1ac2 | 2015-06-25 08:45:12 +0200 | [diff] [blame] | 11 | -lmbedtls$(SHARED_SUFFIX) \ |
Manuel Pégourié-Gonnard | 5c59a4f | 2015-06-24 13:06:24 +0200 | [diff] [blame] | 12 | -lmbedx509$(SHARED_SUFFIX) \ |
Manuel Pégourié-Gonnard | 21e1ac2 | 2015-06-25 08:45:12 +0200 | [diff] [blame] | 13 | -lmbedcrypto$(SHARED_SUFFIX) |
Paul Bakker | 0049c2f | 2009-07-11 19:15:43 +0000 | [diff] [blame] | 14 | |
Nicholas Wilson | 61fa436 | 2018-06-25 12:10:00 +0100 | [diff] [blame] | 15 | # Enable definition of various functions used throughout the testsuite |
| 16 | # (gethostname, strdup, fileno...) even when compiling with -std=c99. Harmless |
| 17 | # on non-POSIX platforms. |
| 18 | LOCAL_CFLAGS += -D_POSIX_C_SOURCE=200809L |
| 19 | |
Paul Bakker | 674e0b0 | 2014-03-26 13:26:52 +0100 | [diff] [blame] | 20 | ifndef SHARED |
Manuel Pégourié-Gonnard | 5c59a4f | 2015-06-24 13:06:24 +0200 | [diff] [blame] | 21 | DEP=../library/libmbedcrypto.a ../library/libmbedx509.a ../library/libmbedtls.a |
Paul Bakker | 674e0b0 | 2014-03-26 13:26:52 +0100 | [diff] [blame] | 22 | else |
Manuel Pégourié-Gonnard | 5c59a4f | 2015-06-24 13:06:24 +0200 | [diff] [blame] | 23 | DEP=../library/libmbedcrypto.$(DLEXT) ../library/libmbedx509.$(DLEXT) ../library/libmbedtls.$(DLEXT) |
Paul Bakker | 674e0b0 | 2014-03-26 13:26:52 +0100 | [diff] [blame] | 24 | endif |
| 25 | |
Paul Bakker | c7ffd36 | 2012-04-05 12:08:29 +0000 | [diff] [blame] | 26 | ifdef DEBUG |
Alon Bar-Lev | f7a9f30 | 2015-02-18 17:55:05 +0200 | [diff] [blame] | 27 | LOCAL_CFLAGS += -g3 |
Paul Bakker | c7ffd36 | 2012-04-05 12:08:29 +0000 | [diff] [blame] | 28 | endif |
| 29 | |
Manuel Pégourié-Gonnard | 5c59a4f | 2015-06-24 13:06:24 +0200 | [diff] [blame] | 30 | # if we're running on Windows, build for Windows |
Paul Bakker | cd5b529 | 2012-05-10 20:49:10 +0000 | [diff] [blame] | 31 | ifdef WINDOWS |
Alon Bar-Lev | 18ba0cc | 2015-02-14 01:04:58 +0200 | [diff] [blame] | 32 | WINDOWS_BUILD=1 |
| 33 | endif |
| 34 | |
| 35 | ifdef WINDOWS_BUILD |
| 36 | DLEXT=dll |
| 37 | EXEXT=.exe |
Alon Bar-Lev | ada4105 | 2015-02-18 17:47:52 +0200 | [diff] [blame] | 38 | LOCAL_LDFLAGS += -lws2_32 |
Alon Bar-Lev | 18ba0cc | 2015-02-14 01:04:58 +0200 | [diff] [blame] | 39 | ifdef SHARED |
| 40 | SHARED_SUFFIX=.$(DLEXT) |
| 41 | endif |
Mohammad Azim Khan | 8a3628f | 2018-06-26 17:30:16 +0100 | [diff] [blame] | 42 | PYTHON ?= python |
Manuel Pégourié-Gonnard | 8d4a613 | 2015-06-24 12:16:20 +0200 | [diff] [blame] | 43 | else |
Andres Amaya Garcia | 420f0cc | 2018-03-27 19:17:21 +0100 | [diff] [blame] | 44 | DLEXT ?= so |
Manuel Pégourié-Gonnard | 8d4a613 | 2015-06-24 12:16:20 +0200 | [diff] [blame] | 45 | EXEXT= |
| 46 | SHARED_SUFFIX= |
Mohammad Azim Khan | 8a3628f | 2018-06-26 17:30:16 +0100 | [diff] [blame] | 47 | # python2 for POSIX since FreeBSD has only python2 as default. |
| 48 | PYTHON ?= python2 |
Paul Bakker | cd5b529 | 2012-05-10 20:49:10 +0000 | [diff] [blame] | 49 | endif |
| 50 | |
Paul Bakker | 2770fbd | 2012-07-03 13:30:23 +0000 | [diff] [blame] | 51 | # Zlib shared library extensions: |
| 52 | ifdef ZLIB |
Alon Bar-Lev | ada4105 | 2015-02-18 17:47:52 +0200 | [diff] [blame] | 53 | LOCAL_LDFLAGS += -lz |
Paul Bakker | 2770fbd | 2012-07-03 13:30:23 +0000 | [diff] [blame] | 54 | endif |
| 55 | |
Mohammad Azim Khan | 53faf5c | 2018-06-26 17:34:48 +0100 | [diff] [blame] | 56 | APPS = test_suite_aes.ecb test_suite_aes.cbc \ |
| 57 | test_suite_aes.cfb test_suite_aes.ofb \ |
| 58 | test_suite_aes.xts \ |
| 59 | test_suite_aes.rest test_suite_arc4 \ |
| 60 | test_suite_aria test_suite_asn1write \ |
| 61 | test_suite_base64 test_suite_blowfish \ |
| 62 | test_suite_camellia test_suite_ccm \ |
| 63 | test_suite_chacha20 test_suite_chachapoly \ |
| 64 | test_suite_aria \ |
| 65 | test_suite_cmac \ |
| 66 | test_suite_cipher.aes \ |
| 67 | test_suite_cipher.arc4 test_suite_cipher.ccm \ |
| 68 | test_suite_cipher.chacha20 \ |
| 69 | test_suite_cipher.gcm \ |
| 70 | test_suite_cipher.blowfish \ |
| 71 | test_suite_cipher.camellia \ |
| 72 | test_suite_cipher.des test_suite_cipher.null \ |
| 73 | test_suite_cipher.padding \ |
| 74 | test_suite_ctr_drbg test_suite_debug \ |
| 75 | test_suite_des test_suite_dhm \ |
| 76 | test_suite_ecdh test_suite_ecdsa \ |
| 77 | test_suite_ecjpake test_suite_ecp \ |
| 78 | test_suite_error test_suite_entropy \ |
| 79 | test_suite_gcm.aes128_de \ |
| 80 | test_suite_gcm.aes192_de \ |
| 81 | test_suite_gcm.aes256_de \ |
| 82 | test_suite_gcm.aes128_en \ |
| 83 | test_suite_gcm.aes192_en \ |
| 84 | test_suite_gcm.aes256_en \ |
| 85 | test_suite_gcm.camellia \ |
| 86 | test_suite_hkdf \ |
| 87 | test_suite_hmac_drbg.misc \ |
| 88 | test_suite_hmac_drbg.no_reseed \ |
| 89 | test_suite_hmac_drbg.nopr \ |
| 90 | test_suite_hmac_drbg.pr \ |
| 91 | test_suite_md test_suite_mdx \ |
| 92 | test_suite_memory_buffer_alloc \ |
| 93 | test_suite_mpi \ |
| 94 | test_suite_pem test_suite_pkcs1_v15 \ |
| 95 | test_suite_pkcs1_v21 test_suite_pkcs5 \ |
| 96 | test_suite_pkparse test_suite_pkwrite \ |
| 97 | test_suite_pk \ |
| 98 | test_suite_rsa test_suite_shax \ |
| 99 | test_suite_ssl test_suite_timing \ |
| 100 | test_suite_x509parse test_suite_x509write \ |
| 101 | test_suite_xtea test_suite_version |
Mohammad Azim Khan | 94aefaf | 2017-03-23 12:32:54 +0000 | [diff] [blame] | 102 | |
| 103 | BINARIES := $(addsuffix $(EXEXT),$(APPS)) |
| 104 | |
| 105 | # Look up for associated function files |
Mohammad Azim Khan | 1f29be7 | 2017-03-20 22:21:22 +0000 | [diff] [blame] | 106 | func.test_suite_aes.ecb := test_suite_aes |
| 107 | func.test_suite_aes.cbc := test_suite_aes |
| 108 | func.test_suite_aes.cfb := test_suite_aes |
| 109 | func.test_suite_aes.ofb := test_suite_aes |
| 110 | func.test_suite_aes.xts := test_suite_aes |
| 111 | func.test_suite_aes.rest := test_suite_aes |
| 112 | func.test_suite_arc4 := test_suite_arc4 |
| 113 | func.test_suite_aria := test_suite_aria |
| 114 | func.test_suite_asn1write := test_suite_asn1write |
| 115 | func.test_suite_base64 := test_suite_base64 |
| 116 | func.test_suite_blowfish := test_suite_blowfish |
| 117 | func.test_suite_camellia := test_suite_camellia |
| 118 | func.test_suite_ccm := test_suite_ccm |
| 119 | func.test_suite_chacha20 := test_suite_chacha20 |
| 120 | func.test_suite_chachapoly := test_suite_chachapoly |
| 121 | func.test_suite_cmac := test_suite_cmac |
| 122 | func.test_suite_cipher.chachapoly := test_suite_cipher |
| 123 | func.test_suite_cipher.aes := test_suite_cipher |
| 124 | func.test_suite_cipher.arc4 := test_suite_cipher |
| 125 | func.test_suite_cipher.ccm := test_suite_cipher |
| 126 | func.test_suite_cipher.chacha20 := test_suite_cipher |
| 127 | func.test_suite_cipher.gcm := test_suite_cipher |
| 128 | func.test_suite_cipher.blowfish := test_suite_cipher |
| 129 | func.test_suite_cipher.camellia := test_suite_cipher |
| 130 | func.test_suite_cipher.des := test_suite_cipher |
| 131 | func.test_suite_cipher.null := test_suite_cipher |
| 132 | func.test_suite_cipher.padding := test_suite_cipher |
| 133 | func.test_suite_ctr_drbg := test_suite_ctr_drbg |
| 134 | func.test_suite_debug := test_suite_debug |
| 135 | func.test_suite_des := test_suite_des |
| 136 | func.test_suite_dhm := test_suite_dhm |
| 137 | func.test_suite_ecdh := test_suite_ecdh |
| 138 | func.test_suite_ecdsa := test_suite_ecdsa |
| 139 | func.test_suite_ecjpake := test_suite_ecjpake |
| 140 | func.test_suite_ecp := test_suite_ecp |
| 141 | func.test_suite_error := test_suite_error |
| 142 | func.test_suite_entropy := test_suite_entropy |
| 143 | func.test_suite_gcm.aes128_de := test_suite_gcm |
| 144 | func.test_suite_gcm.aes192_de := test_suite_gcm |
| 145 | func.test_suite_gcm.aes256_de := test_suite_gcm |
| 146 | func.test_suite_gcm.aes128_en := test_suite_gcm |
| 147 | func.test_suite_gcm.aes192_en := test_suite_gcm |
| 148 | func.test_suite_gcm.aes256_en := test_suite_gcm |
| 149 | func.test_suite_gcm.camellia := test_suite_gcm |
| 150 | func.test_suite_hkdf := test_suite_hkdf |
| 151 | func.test_suite_hmac_drbg.misc := test_suite_hmac_drbg |
| 152 | func.test_suite_hmac_drbg.no_reseed := test_suite_hmac_drbg |
| 153 | func.test_suite_hmac_drbg.nopr := test_suite_hmac_drbg |
| 154 | func.test_suite_hmac_drbg.pr := test_suite_hmac_drbg |
| 155 | func.test_suite_md := test_suite_md |
| 156 | func.test_suite_mdx := test_suite_mdx |
| 157 | func.test_suite_memory_buffer_alloc := test_suite_memory_buffer_alloc |
| 158 | func.test_suite_mpi := test_suite_mpi |
| 159 | func.test_suite_nist_kw := test_suite_nist_kw |
| 160 | func.test_suite_pem := test_suite_pem |
| 161 | func.test_suite_pkcs1_v15 := test_suite_pkcs1_v15 |
| 162 | func.test_suite_pkcs1_v21 := test_suite_pkcs1_v21 |
| 163 | func.test_suite_pkcs5 := test_suite_pkcs5 |
| 164 | func.test_suite_pkparse := test_suite_pkparse |
| 165 | func.test_suite_pkwrite := test_suite_pkwrite |
| 166 | func.test_suite_pk := test_suite_pk |
| 167 | func.test_suite_rsa := test_suite_rsa |
| 168 | func.test_suite_shax := test_suite_shax |
| 169 | func.test_suite_ssl := test_suite_ssl |
| 170 | func.test_suite_timing := test_suite_timing |
| 171 | func.test_suite_x509parse := test_suite_x509parse |
| 172 | func.test_suite_x509write := test_suite_x509write |
| 173 | func.test_suite_xtea := test_suite_xtea |
| 174 | func.test_suite_version := test_suite_version |
Paul Bakker | 0049c2f | 2009-07-11 19:15:43 +0000 | [diff] [blame] | 175 | |
| 176 | .SILENT: |
| 177 | |
Manuel Pégourié-Gonnard | 5c59a4f | 2015-06-24 13:06:24 +0200 | [diff] [blame] | 178 | .PHONY: all check test clean |
| 179 | |
Azim Khan | 1de892b | 2017-06-09 15:02:36 +0100 | [diff] [blame] | 180 | all: $(BINARIES) |
| 181 | |
Manuel Pégourié-Gonnard | 5c59a4f | 2015-06-24 13:06:24 +0200 | [diff] [blame] | 182 | $(DEP): |
Manuel Pégourié-Gonnard | fc36708 | 2015-06-26 16:50:24 +0200 | [diff] [blame] | 183 | $(MAKE) -C ../library |
Manuel Pégourié-Gonnard | 5c59a4f | 2015-06-24 13:06:24 +0200 | [diff] [blame] | 184 | |
Manuel Pégourié-Gonnard | 6cacde2 | 2015-07-08 16:02:43 +0200 | [diff] [blame] | 185 | # invoke perl explicitly for the sake of mingw32-make |
| 186 | |
Mohammad Azim Khan | 94aefaf | 2017-03-23 12:32:54 +0000 | [diff] [blame] | 187 | C_FILES := $(addsuffix .c,$(APPS)) |
| 188 | |
| 189 | .SECONDEXPANSION: |
Mohammad Azim Khan | 78befd9 | 2018-03-06 11:49:41 +0000 | [diff] [blame] | 190 | $(C_FILES): %.c: suites/$$(func.$$*).function suites/%.data scripts/generate_test_code.py suites/helpers.function suites/main_test.function suites/host_test.function |
Manuel Pégourié-Gonnard | 78ec2b0 | 2015-07-08 22:12:06 +0100 | [diff] [blame] | 191 | echo " Gen $@" |
Mohammad Azim Khan | 78befd9 | 2018-03-06 11:49:41 +0000 | [diff] [blame] | 192 | $(PYTHON) scripts/generate_test_code.py -f suites/$(func.$*).function \ |
Mohammad Azim Khan | fff4904 | 2017-03-28 01:48:31 +0100 | [diff] [blame] | 193 | -d suites/$*.data \ |
Azim Khan | 1de892b | 2017-06-09 15:02:36 +0100 | [diff] [blame] | 194 | -t suites/main_test.function \ |
Mohammad Azim Khan | 9540261 | 2017-07-19 10:15:54 +0100 | [diff] [blame] | 195 | -p suites/host_test.function \ |
Mohammad Azim Khan | fff4904 | 2017-03-28 01:48:31 +0100 | [diff] [blame] | 196 | -s suites \ |
| 197 | --help-file suites/helpers.function \ |
| 198 | -o . |
Paul Bakker | 286bf3c | 2013-04-08 18:09:51 +0200 | [diff] [blame] | 199 | |
Paul Bakker | 286bf3c | 2013-04-08 18:09:51 +0200 | [diff] [blame] | 200 | |
Mohammad Azim Khan | 94aefaf | 2017-03-23 12:32:54 +0000 | [diff] [blame] | 201 | $(BINARIES): %$(EXEXT): %.c $(DEP) |
Manuel Pégourié-Gonnard | 78ec2b0 | 2015-07-08 22:12:06 +0100 | [diff] [blame] | 202 | echo " CC $<" |
Alon Bar-Lev | f7a9f30 | 2015-02-18 17:55:05 +0200 | [diff] [blame] | 203 | $(CC) $(LOCAL_CFLAGS) $(CFLAGS) $< $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ |
Paul Bakker | 286bf3c | 2013-04-08 18:09:51 +0200 | [diff] [blame] | 204 | |
Paul Bakker | 286bf3c | 2013-04-08 18:09:51 +0200 | [diff] [blame] | 205 | |
Paul Bakker | 0049c2f | 2009-07-11 19:15:43 +0000 | [diff] [blame] | 206 | clean: |
Paul Bakker | 62f88dc | 2012-05-10 21:26:28 +0000 | [diff] [blame] | 207 | ifndef WINDOWS |
Mohammad Azim Khan | 00c4b09 | 2018-06-28 13:10:19 +0100 | [diff] [blame^] | 208 | rm -rf $(APPS) *.c *.datax TESTS |
Manuel Pégourié-Gonnard | 5c59a4f | 2015-06-24 13:06:24 +0200 | [diff] [blame] | 209 | else |
Mohammad Azim Khan | 00c4b09 | 2018-06-28 13:10:19 +0100 | [diff] [blame^] | 210 | del /Q /F *.c *.exe *.datax |
Mohammad Azim Khan | 1f29be7 | 2017-03-20 22:21:22 +0000 | [diff] [blame] | 211 | rmdir /Q /S TESTS |
Paul Bakker | 62f88dc | 2012-05-10 21:26:28 +0000 | [diff] [blame] | 212 | endif |
Paul Bakker | 0049c2f | 2009-07-11 19:15:43 +0000 | [diff] [blame] | 213 | |
Mohammad Azim Khan | 94aefaf | 2017-03-23 12:32:54 +0000 | [diff] [blame] | 214 | check: $(BINARIES) |
Manuel Pégourié-Gonnard | 8511384 | 2015-07-08 21:20:03 +0100 | [diff] [blame] | 215 | perl scripts/run-test-suites.pl |
Manuel Pégourié-Gonnard | 5c59a4f | 2015-06-24 13:06:24 +0200 | [diff] [blame] | 216 | |
| 217 | test: check |
Mohammad Azim Khan | 1f29be7 | 2017-03-20 22:21:22 +0000 | [diff] [blame] | 218 | |
Azim Khan | 1de892b | 2017-06-09 15:02:36 +0100 | [diff] [blame] | 219 | # Create separate targets for generating embedded tests. |
| 220 | EMBEDDED_TESTS := $(addprefix embedded_,$(APPS)) |
Mohammad Azim Khan | 1f29be7 | 2017-03-20 22:21:22 +0000 | [diff] [blame] | 221 | |
Mohammad Azim Khan | 9540261 | 2017-07-19 10:15:54 +0100 | [diff] [blame] | 222 | # Generate test code for target. |
Mohammad Azim Khan | 1f29be7 | 2017-03-20 22:21:22 +0000 | [diff] [blame] | 223 | |
| 224 | .SECONDEXPANSION: |
Mohammad Azim Khan | 78befd9 | 2018-03-06 11:49:41 +0000 | [diff] [blame] | 225 | $(EMBEDDED_TESTS): embedded_%: suites/$$(func.$$*).function suites/%.data scripts/generate_test_code.py suites/helpers.function suites/main_test.function suites/target_test.function |
Mohammad Azim Khan | fff4904 | 2017-03-28 01:48:31 +0100 | [diff] [blame] | 226 | echo " Gen ./TESTS/mbedtls/$*/$*.c" |
Mohammad Azim Khan | 78befd9 | 2018-03-06 11:49:41 +0000 | [diff] [blame] | 227 | $(PYTHON) scripts/generate_test_code.py -f suites/$(func.$*).function \ |
Mohammad Azim Khan | 1f29be7 | 2017-03-20 22:21:22 +0000 | [diff] [blame] | 228 | -d suites/$*.data \ |
Azim Khan | 1de892b | 2017-06-09 15:02:36 +0100 | [diff] [blame] | 229 | -t suites/main_test.function \ |
Mohammad Azim Khan | 9540261 | 2017-07-19 10:15:54 +0100 | [diff] [blame] | 230 | -p suites/target_test.function \ |
Mohammad Azim Khan | 1f29be7 | 2017-03-20 22:21:22 +0000 | [diff] [blame] | 231 | -s suites \ |
| 232 | --help-file suites/helpers.function \ |
Mohammad Azim Khan | fff4904 | 2017-03-28 01:48:31 +0100 | [diff] [blame] | 233 | -o ./TESTS/mbedtls/$* |
Mohammad Azim Khan | 1f29be7 | 2017-03-20 22:21:22 +0000 | [diff] [blame] | 234 | |
Mohammad Azim Khan | ff560f2 | 2018-06-28 11:43:17 +0100 | [diff] [blame] | 235 | generate-target-tests: $(EMBEDDED_TESTS) |
Mohammad Azim Khan | 1f29be7 | 2017-03-20 22:21:22 +0000 | [diff] [blame] | 236 | |