Pascal Brand | c639ac8 | 2015-07-02 08:53:34 +0200 | [diff] [blame] | 1 | # Normally this makefile shouldn't be called directly and we expect the output |
| 2 | # path to be on a certain location to fit together with the other OP-TEE |
| 3 | # gits and helper scripts. |
Etienne Carriere | 3ddc362 | 2017-03-13 15:31:15 +0100 | [diff] [blame] | 4 | |
| 5 | include ../../scripts/common.mk |
| 6 | out-dir := $(call strip-trailing-slashes-and-dots,$(O)) |
| 7 | ifeq ($(out-dir),) |
| 8 | $(error invalid output directory (O=$(O))) |
Pascal Brand | c639ac8 | 2015-07-02 08:53:34 +0200 | [diff] [blame] | 9 | endif |
| 10 | |
Cedric Chaumont | 1390f3a | 2015-08-31 13:55:16 +0200 | [diff] [blame] | 11 | include $(TA_DEV_KIT_DIR)/host_include/conf.mk |
| 12 | |
Pascal Brand | c639ac8 | 2015-07-02 08:53:34 +0200 | [diff] [blame] | 13 | # By default we expect optee_client exported folder to be on a certain relative |
| 14 | # path, but if the client specifies the OPTEE_CLIENT_EXPORT then that path will |
| 15 | # be used instead. |
| 16 | OPTEE_CLIENT_EXPORT ?= ../../../optee_client/out/export |
| 17 | |
Sumit Garg | 0e00914 | 2015-11-04 15:34:07 -0500 | [diff] [blame] | 18 | CC ?= $(CROSS_COMPILE)gcc |
| 19 | CPP ?= $(CROSS_COMPILE)cpp |
| 20 | LD ?= $(CROSS_COMPILE)ld |
| 21 | AR ?= $(CROSS_COMPILE)ar |
| 22 | NM ?= $(CROSS_COMPILE)nm |
| 23 | OBJCOPY ?= $(CROSS_COMPILE)objcopy |
| 24 | OBJDUMP ?= $(CROSS_COMPILE)objdump |
| 25 | READELF ?= $(CROSS_COMPILE)readelf |
Pascal Brand | c639ac8 | 2015-07-02 08:53:34 +0200 | [diff] [blame] | 26 | |
Jerome Forissier | 227d6f4 | 2019-10-09 16:43:22 +0200 | [diff] [blame] | 27 | # Macros to detect the targeted architecture (e.g., arm-linux-gnueabihf or |
| 28 | # aarch64-linux-gnu) and the corresponding bit size (32 or 64). |
| 29 | define cc-arch |
| 30 | $(shell $(1) -v 2>&1 | grep Target | sed 's/Target: \([^-]*\).*/\1/') |
| 31 | endef |
| 32 | define cc-bits |
| 33 | $(if $(filter arm, $(1)),32,$(if $(filter aarch64, $(1)),64,unknown-arch)) |
| 34 | endef |
| 35 | |
Jerome Forissier | 43d58a5 | 2018-05-18 16:40:40 +0200 | [diff] [blame] | 36 | # OpenSSL is used by GP tests series 8500 and Mbed TLS test 8103 |
Etienne Carriere | 938702e | 2018-06-21 16:09:48 +0200 | [diff] [blame] | 37 | ifneq ($(CFG_GP_PACKAGE_PATH)$(filter y,$(CFG_TA_MBEDTLS)),) |
Etienne Carriere | c0e8678 | 2018-06-25 09:20:04 +0200 | [diff] [blame] | 38 | CFLAGS += -DOPENSSL_FOUND=1 |
| 39 | ifneq ($(OPTEE_OPENSSL_EXPORT),) |
| 40 | LDFLAGS += -lcrypto |
| 41 | CFLAGS += -I$(OPTEE_OPENSSL_EXPORT) |
| 42 | else #OPTEE_OPENSSL_EXPORT |
| 43 | CFLAGS += -I../openssl/include |
Jerome Forissier | 227d6f4 | 2019-10-09 16:43:22 +0200 | [diff] [blame] | 44 | ifeq ($(call cc-bits, $(call cc-arch, $(CC))),32) |
Jerome Forissier | 4b0d43d | 2018-06-05 10:09:31 +0200 | [diff] [blame] | 45 | LDFLAGS += ../openssl/lib/arm/libcrypto.a -ldl |
Jerome Forissier | 43d58a5 | 2018-05-18 16:40:40 +0200 | [diff] [blame] | 46 | else |
Jerome Forissier | 4b0d43d | 2018-06-05 10:09:31 +0200 | [diff] [blame] | 47 | LDFLAGS += ../openssl/lib/aarch64/libcrypto.a -ldl |
Jerome Forissier | 43d58a5 | 2018-05-18 16:40:40 +0200 | [diff] [blame] | 48 | endif |
Etienne Carriere | c0e8678 | 2018-06-25 09:20:04 +0200 | [diff] [blame] | 49 | endif #OPTEE_OPENSSL_EXPORT |
| 50 | endif #require OpenSSL |
Jerome Forissier | 43d58a5 | 2018-05-18 16:40:40 +0200 | [diff] [blame] | 51 | |
Jerome Forissier | 213ca8a | 2017-03-31 11:27:56 +0200 | [diff] [blame] | 52 | srcs := regression_1000.c |
Jens Wiklander | 02389a9 | 2016-12-16 11:13:38 +0100 | [diff] [blame] | 53 | |
| 54 | ifeq ($(CFG_GP_SOCKETS),y) |
Jerome Forissier | 213ca8a | 2017-03-31 11:27:56 +0200 | [diff] [blame] | 55 | srcs += regression_2000.c \ |
Jens Wiklander | 02389a9 | 2016-12-16 11:13:38 +0100 | [diff] [blame] | 56 | sock_server.c \ |
| 57 | rand_stream.c |
| 58 | endif |
| 59 | |
Jerome Forissier | 213ca8a | 2017-03-31 11:27:56 +0200 | [diff] [blame] | 60 | srcs += adbg/src/adbg_case.c \ |
Pascal Brand | c639ac8 | 2015-07-02 08:53:34 +0200 | [diff] [blame] | 61 | adbg/src/adbg_enum.c \ |
| 62 | adbg/src/adbg_expect.c \ |
| 63 | adbg/src/adbg_log.c \ |
Pascal Brand | c639ac8 | 2015-07-02 08:53:34 +0200 | [diff] [blame] | 64 | adbg/src/adbg_run.c \ |
Jerome Forissier | 213ca8a | 2017-03-31 11:27:56 +0200 | [diff] [blame] | 65 | adbg/src/security_utils_hex.c \ |
| 66 | aes_perf.c \ |
| 67 | benchmark_1000.c \ |
| 68 | benchmark_2000.c \ |
| 69 | regression_4000.c \ |
Jens Wiklander | b4c75aa | 2018-11-15 10:43:29 +0100 | [diff] [blame] | 70 | regression_4100.c \ |
Jerome Forissier | 213ca8a | 2017-03-31 11:27:56 +0200 | [diff] [blame] | 71 | regression_5000.c \ |
| 72 | regression_6000.c \ |
| 73 | regression_7000.c \ |
Jens Wiklander | cd0186b | 2017-04-05 11:34:22 +0200 | [diff] [blame] | 74 | regression_8000.c \ |
Jens Wiklander | 2932647 | 2018-04-20 11:22:15 +0200 | [diff] [blame] | 75 | regression_8100.c \ |
Jerome Forissier | 213ca8a | 2017-03-31 11:27:56 +0200 | [diff] [blame] | 76 | sha_perf.c \ |
Jens Wiklander | 254a3e3 | 2019-01-31 12:25:08 +0100 | [diff] [blame] | 77 | stats.c \ |
Jerome Forissier | 213ca8a | 2017-03-31 11:27:56 +0200 | [diff] [blame] | 78 | xtest_helpers.c \ |
| 79 | xtest_main.c \ |
Vesa Jääskeläinen | 7e2a230 | 2020-04-05 20:11:58 +0300 | [diff] [blame^] | 80 | xtest_test.c \ |
| 81 | xtest_uuid_helpers.c |
Pascal Brand | c639ac8 | 2015-07-02 08:53:34 +0200 | [diff] [blame] | 82 | |
Jens Wiklander | f261a6d | 2017-11-09 16:45:51 +0100 | [diff] [blame] | 83 | ifeq ($(CFG_SECSTOR_TA_MGMT_PTA),y) |
| 84 | srcs += install_ta.c |
| 85 | endif |
| 86 | |
Etienne Carriere | 41343db | 2017-03-17 15:38:52 +0100 | [diff] [blame] | 87 | ifeq ($(CFG_SECURE_DATA_PATH),y) |
| 88 | srcs += sdp_basic.c |
| 89 | endif |
| 90 | |
Etienne Carriere | 109c1d7 | 2019-01-09 11:02:02 +0100 | [diff] [blame] | 91 | ifeq ($(CFG_PKCS11_TA),y) |
| 92 | srcs += pkcs11_1000.c |
| 93 | |
| 94 | OPTEE_PKCS11_TA_HEADERS ?= ../../../optee_client/libckteec/include |
| 95 | CFLAGS += -DCFG_PKCS11_TA |
| 96 | CFLAGS += -I$(OPTEE_PKCS11_TA_HEADERS) |
| 97 | LDFLAGS += -L$(OPTEE_CLIENT_EXPORT)/lib -lckteec |
| 98 | endif |
| 99 | |
Jerome Forissier | e368834 | 2015-09-24 10:45:17 -0700 | [diff] [blame] | 100 | ifdef CFG_GP_PACKAGE_PATH |
| 101 | CFLAGS += -DWITH_GP_TESTS |
Pascal Brand | 8a74e36 | 2015-09-10 12:41:52 +0200 | [diff] [blame] | 102 | |
Jerome Forissier | 213ca8a | 2017-03-31 11:27:56 +0200 | [diff] [blame] | 103 | srcs += gp_7000.c \ |
| 104 | gp_7500.c \ |
| 105 | gp_8000.c \ |
| 106 | gp_8500.c \ |
| 107 | gp_9000.c |
Pascal Brand | c639ac8 | 2015-07-02 08:53:34 +0200 | [diff] [blame] | 108 | endif |
| 109 | |
Etienne Carriere | 3ddc362 | 2017-03-13 15:31:15 +0100 | [diff] [blame] | 110 | objs := $(patsubst %.c,$(out-dir)/xtest/%.o, $(srcs)) |
Pascal Brand | c639ac8 | 2015-07-02 08:53:34 +0200 | [diff] [blame] | 111 | |
| 112 | CFLAGS += -I./ |
| 113 | CFLAGS += -I./adbg/include |
| 114 | CFLAGS += -I./xml/include |
Jens Wiklander | f6efe24 | 2017-11-06 13:16:43 +0100 | [diff] [blame] | 115 | CFLAGS += -I$(out-dir)/xtest |
Pascal Brand | c639ac8 | 2015-07-02 08:53:34 +0200 | [diff] [blame] | 116 | |
| 117 | CFLAGS += -I$(OPTEE_CLIENT_EXPORT)/include |
| 118 | CFLAGS += -I$(TA_DEV_KIT_DIR)/host_include |
| 119 | |
Jens Wiklander | ff1be9e | 2018-02-01 14:16:57 +0100 | [diff] [blame] | 120 | CFLAGS += -I../../ta/include |
Pascal Brand | c639ac8 | 2015-07-02 08:53:34 +0200 | [diff] [blame] | 121 | CFLAGS += -I../../ta/create_fail_test/include |
| 122 | CFLAGS += -I../../ta/crypt/include |
| 123 | CFLAGS += -I../../ta/enc_fs/include |
| 124 | CFLAGS += -I../../ta/os_test/include |
| 125 | CFLAGS += -I../../ta/rpc_test/include |
| 126 | CFLAGS += -I../../ta/sims/include |
Ovidiu Mihalachi | 15cecff | 2019-04-02 16:36:31 +0300 | [diff] [blame] | 127 | CFLAGS += -I../../ta/miss/include |
| 128 | CFLAGS += -I../../ta/sims_keepalive/include |
James Kung | df1e6cf | 2015-09-14 22:42:24 +0800 | [diff] [blame] | 129 | CFLAGS += -I../../ta/storage_benchmark/include |
Jens Wiklander | ac27ec1 | 2015-07-15 15:23:14 +0200 | [diff] [blame] | 130 | CFLAGS += -I../../ta/concurrent/include |
Jens Wiklander | 7067297 | 2016-04-06 00:01:45 +0200 | [diff] [blame] | 131 | CFLAGS += -I../../ta/concurrent_large/include |
Igor Opaniuk | 136644a | 2016-09-13 13:40:56 +0300 | [diff] [blame] | 132 | CFLAGS += -I../../ta/sha_perf/include |
Igor Opaniuk | 44aff4b | 2016-09-16 10:18:00 +0300 | [diff] [blame] | 133 | CFLAGS += -I../../ta/aes_perf/include |
Jens Wiklander | 02389a9 | 2016-12-16 11:13:38 +0100 | [diff] [blame] | 134 | CFLAGS += -I../../ta/socket/include |
Etienne Carriere | 41343db | 2017-03-17 15:38:52 +0100 | [diff] [blame] | 135 | CFLAGS += -I../../ta/sdp_basic/include |
Javier Almansa Sobrino | cddc000 | 2020-02-10 13:35:37 +0000 | [diff] [blame] | 136 | CFLAGS += -I../../ta/tpm_log_test/include |
Etienne Carriere | 41343db | 2017-03-17 15:38:52 +0100 | [diff] [blame] | 137 | |
Jerome Forissier | e368834 | 2015-09-24 10:45:17 -0700 | [diff] [blame] | 138 | ifdef CFG_GP_PACKAGE_PATH |
Pascal Brand | c639ac8 | 2015-07-02 08:53:34 +0200 | [diff] [blame] | 139 | CFLAGS += -I../../ta/GP_TTA_Arithmetical |
| 140 | CFLAGS += -I../../ta/GP_TTA_Crypto |
| 141 | CFLAGS += -I../../ta/GP_TTA_DS |
| 142 | CFLAGS += -I../../ta/GP_TTA_TCF |
| 143 | CFLAGS += -I../../ta/GP_TTA_TCF_ICA |
| 144 | CFLAGS += -I../../ta/GP_TTA_TCF_ICA2 |
| 145 | CFLAGS += -I../../ta/GP_TTA_TCF_MultipleInstanceTA |
| 146 | CFLAGS += -I../../ta/GP_TTA_TCF_SingleInstanceTA |
| 147 | CFLAGS += -I../../ta/GP_TTA_Time |
| 148 | CFLAGS += -I../../ta/GP_TTA_answerErrorTo_Invoke |
| 149 | CFLAGS += -I../../ta/GP_TTA_answerErrorTo_OpenSession |
| 150 | CFLAGS += -I../../ta/GP_TTA_answerSuccessTo_OpenSession_Invoke |
| 151 | CFLAGS += -I../../ta/GP_TTA_check_OpenSession_with_4_parameters |
| 152 | CFLAGS += -I../../ta/GP_TTA_testingClientAPI |
| 153 | |
Pascal Brand | c639ac8 | 2015-07-02 08:53:34 +0200 | [diff] [blame] | 154 | |
Pascal Brand | c639ac8 | 2015-07-02 08:53:34 +0200 | [diff] [blame] | 155 | endif |
| 156 | |
l00176142 | 087f204 | 2017-08-28 20:03:28 +0800 | [diff] [blame] | 157 | TA_DIR ?= /lib/optee_armtz |
| 158 | CFLAGS += -DTA_DIR=\"$(TA_DIR)\" |
| 159 | |
Jerome Forissier | f9b8925 | 2016-08-23 18:30:43 +0200 | [diff] [blame] | 160 | # Include configuration file generated by OP-TEE OS (CFG_* macros) |
| 161 | CFLAGS += -include conf.h |
Pascal Brand | c639ac8 | 2015-07-02 08:53:34 +0200 | [diff] [blame] | 162 | |
Jerome Forissier | e368834 | 2015-09-24 10:45:17 -0700 | [diff] [blame] | 163 | ifndef CFG_GP_PACKAGE_PATH |
Pascal Brand | c639ac8 | 2015-07-02 08:53:34 +0200 | [diff] [blame] | 164 | CFLAGS += -Wall -Wcast-align -Werror \ |
| 165 | -Werror-implicit-function-declaration -Wextra -Wfloat-equal \ |
| 166 | -Wformat-nonliteral -Wformat-security -Wformat=2 -Winit-self \ |
| 167 | -Wmissing-declarations -Wmissing-format-attribute \ |
| 168 | -Wmissing-include-dirs -Wmissing-noreturn \ |
| 169 | -Wmissing-prototypes -Wnested-externs -Wpointer-arith \ |
| 170 | -Wshadow -Wstrict-prototypes -Wswitch-default \ |
| 171 | -Wwrite-strings \ |
André Draszik | b873974 | 2019-02-07 01:29:08 +0000 | [diff] [blame] | 172 | -Wno-declaration-after-statement \ |
Etienne Carriere | 5a83a50 | 2019-04-25 10:19:05 +0200 | [diff] [blame] | 173 | -Wno-unsafe-loop-optimizations \ |
Pascal Brand | c639ac8 | 2015-07-02 08:53:34 +0200 | [diff] [blame] | 174 | -Wno-missing-field-initializers -Wno-format-zero-length |
| 175 | endif |
| 176 | |
Jerome Forissier | a8b78f1 | 2016-08-17 09:40:59 +0200 | [diff] [blame] | 177 | CFLAGS += -g3 |
| 178 | |
Pascal Brand | c639ac8 | 2015-07-02 08:53:34 +0200 | [diff] [blame] | 179 | LDFLAGS += -L$(OPTEE_CLIENT_EXPORT)/lib -lteec |
Igor Opaniuk | 136644a | 2016-09-13 13:40:56 +0300 | [diff] [blame] | 180 | LDFLAGS += -lpthread -lm |
Pascal Brand | c639ac8 | 2015-07-02 08:53:34 +0200 | [diff] [blame] | 181 | |
| 182 | .PHONY: all |
| 183 | all: xtest |
| 184 | |
| 185 | xtest: $(objs) |
Etienne Carriere | 3ddc362 | 2017-03-13 15:31:15 +0100 | [diff] [blame] | 186 | @echo " LD $(out-dir)/xtest/$@" |
Jerome Forissier | c820858 | 2017-11-13 08:46:29 +0100 | [diff] [blame] | 187 | $(q)$(CC) -o $(out-dir)/xtest/$@ $+ $(LDFLAGS) |
Pascal Brand | c639ac8 | 2015-07-02 08:53:34 +0200 | [diff] [blame] | 188 | |
Etienne Carriere | 3ddc362 | 2017-03-13 15:31:15 +0100 | [diff] [blame] | 189 | $(out-dir)/xtest/%.o: $(CURDIR)/%.c |
| 190 | $(q)mkdir -p $(out-dir)/xtest/adbg/src |
Pascal Brand | c639ac8 | 2015-07-02 08:53:34 +0200 | [diff] [blame] | 191 | @echo ' CC $<' |
| 192 | $(q)$(CC) $(CFLAGS) -c $< -o $@ |
| 193 | |
Etienne Carriere | 3ddc362 | 2017-03-13 15:31:15 +0100 | [diff] [blame] | 194 | RMDIR := rmdir --ignore-fail-on-non-empty |
| 195 | define rm-build-dirs |
| 196 | $(q)for d in $1; do $(RMDIR) $(out-dir)/xtest/$$d 2> /dev/null; true; done |
| 197 | $(q)$(RMDIR) $(out-dir)/xtest 2> /dev/null; true |
| 198 | $(q)$(RMDIR) $(out-dir) 2> /dev/null; true |
| 199 | endef |
| 200 | |
Jens Wiklander | f6efe24 | 2017-11-06 13:16:43 +0100 | [diff] [blame] | 201 | ifeq ($(CFG_GCM_NIST_VECTORS),y) |
| 202 | GCM_NIST_VECTORS_DECRYPT = gcmDecrypt128 gcmDecrypt192 gcmDecrypt256 |
| 203 | GCM_NIST_VECTORS_ENCRYPT = gcmEncryptExtIV128 gcmEncryptExtIV192 \ |
| 204 | gcmEncryptExtIV256 |
| 205 | |
| 206 | cleanfiles += $(out-dir)/gcmtestvectors.zip |
| 207 | $(out-dir)/gcmtestvectors.zip: |
| 208 | @echo ' DL $@' |
| 209 | $(q)curl https://csrc.nist.gov/csrc/media/projects/cryptographic-algorithm-validation-program/documents/mac/gcmtestvectors.zip -o $@ |
| 210 | |
| 211 | define create-nist-gcm-vectors |
| 212 | cleanfiles += $(out-dir)/xtest/$(1).h $(out-dir)/$(1).rsp |
| 213 | |
| 214 | $(out-dir)/$(1).rsp: $(out-dir)/gcmtestvectors.zip |
| 215 | @echo ' UNZIP $$@' |
| 216 | $(q)unzip -o $$< $$(notdir $$@) -d $$(dir $$@) |
| 217 | $(q)touch $$@ |
| 218 | |
| 219 | |
| 220 | $(out-dir)/xtest/$(1).h: $(out-dir)/$(1).rsp |
| 221 | @echo ' GEN $$@' |
| 222 | $(q)../../scripts/rsp_to_gcm_test.py --inf $$< --outf $$@ --mode=$(2) \ |
| 223 | $(if $(filter y,$(CFG_GCM_NIST_VECTORS_LIMITED)),--limited) |
| 224 | |
| 225 | $(CURDIR)/regression_4000.c: $(out-dir)/xtest/$(1).h |
| 226 | endef |
| 227 | |
| 228 | $(foreach v, $(GCM_NIST_VECTORS_DECRYPT), $(eval $(call \ |
| 229 | create-nist-gcm-vectors,$v,decrypt))) |
| 230 | $(foreach v, $(GCM_NIST_VECTORS_ENCRYPT), $(eval $(call \ |
| 231 | create-nist-gcm-vectors,$v,encrypt))) |
| 232 | endif |
| 233 | |
Jens Wiklander | 97d6e29 | 2018-04-23 13:00:31 +0200 | [diff] [blame] | 234 | define embed-file |
| 235 | cleanfiles += $(out-dir)/xtest/$(1).h |
| 236 | |
| 237 | $(out-dir)/xtest/$(1).h: $(2) |
| 238 | @echo ' GEN $$@' |
| 239 | $(q)../../scripts/file_to_c.py --inf $$< --out $$@ --name $(1) |
| 240 | |
| 241 | $(CURDIR)/regression_8100.c: $(out-dir)/xtest/$(1).h |
| 242 | endef |
| 243 | |
| 244 | $(eval $(call embed-file,regression_8100_ca_crt,../../cert/ca.crt)) |
| 245 | $(eval $(call embed-file,regression_8100_mid_crt,../../cert/mid.crt)) |
| 246 | $(eval $(call embed-file,regression_8100_my_crt,../../cert/my.crt)) |
Jens Wiklander | 950ea1c | 2018-04-30 15:39:22 +0200 | [diff] [blame] | 247 | $(eval $(call embed-file,regression_8100_my_csr,../../cert/my.csr)) |
Jens Wiklander | f6efe24 | 2017-11-06 13:16:43 +0100 | [diff] [blame] | 248 | |
Pascal Brand | c639ac8 | 2015-07-02 08:53:34 +0200 | [diff] [blame] | 249 | .PHONY: clean |
| 250 | clean: |
Etienne Carriere | 3ddc362 | 2017-03-13 15:31:15 +0100 | [diff] [blame] | 251 | @echo ' CLEAN $(out-dir)' |
| 252 | $(q)rm -f $(out-dir)/xtest/xtest |
Pascal Brand | c639ac8 | 2015-07-02 08:53:34 +0200 | [diff] [blame] | 253 | $(q)$(foreach obj,$(objs), rm -f $(obj)) |
Jens Wiklander | f6efe24 | 2017-11-06 13:16:43 +0100 | [diff] [blame] | 254 | $(q)rm -f $(cleanfiles) |
Etienne Carriere | 3ddc362 | 2017-03-13 15:31:15 +0100 | [diff] [blame] | 255 | $(call rm-build-dirs,adbg/src adbg) |