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 | |
Victor Chong | 717f2bd | 2020-05-13 14:02:22 +0100 | [diff] [blame] | 36 | # OpenSSL is used by: |
| 37 | # - GP tests series 8500 |
| 38 | # - Mbed TLS test 8103 |
| 39 | # - User/group login tests 1027 and 1028 |
| 40 | WITH_OPENSSL ?= y |
| 41 | ifeq ($(WITH_OPENSSL),y) |
Etienne Carriere | c0e8678 | 2018-06-25 09:20:04 +0200 | [diff] [blame] | 42 | CFLAGS += -DOPENSSL_FOUND=1 |
| 43 | ifneq ($(OPTEE_OPENSSL_EXPORT),) |
| 44 | LDFLAGS += -lcrypto |
| 45 | CFLAGS += -I$(OPTEE_OPENSSL_EXPORT) |
| 46 | else #OPTEE_OPENSSL_EXPORT |
| 47 | CFLAGS += -I../openssl/include |
Jerome Forissier | 227d6f4 | 2019-10-09 16:43:22 +0200 | [diff] [blame] | 48 | ifeq ($(call cc-bits, $(call cc-arch, $(CC))),32) |
Jerome Forissier | 4b0d43d | 2018-06-05 10:09:31 +0200 | [diff] [blame] | 49 | LDFLAGS += ../openssl/lib/arm/libcrypto.a -ldl |
Jerome Forissier | 43d58a5 | 2018-05-18 16:40:40 +0200 | [diff] [blame] | 50 | else |
Jerome Forissier | 4b0d43d | 2018-06-05 10:09:31 +0200 | [diff] [blame] | 51 | LDFLAGS += ../openssl/lib/aarch64/libcrypto.a -ldl |
Jerome Forissier | 43d58a5 | 2018-05-18 16:40:40 +0200 | [diff] [blame] | 52 | endif |
Etienne Carriere | c0e8678 | 2018-06-25 09:20:04 +0200 | [diff] [blame] | 53 | endif #OPTEE_OPENSSL_EXPORT |
| 54 | endif #require OpenSSL |
Jerome Forissier | 43d58a5 | 2018-05-18 16:40:40 +0200 | [diff] [blame] | 55 | |
Jerome Forissier | 213ca8a | 2017-03-31 11:27:56 +0200 | [diff] [blame] | 56 | srcs := regression_1000.c |
Jens Wiklander | 02389a9 | 2016-12-16 11:13:38 +0100 | [diff] [blame] | 57 | |
| 58 | ifeq ($(CFG_GP_SOCKETS),y) |
Jerome Forissier | 213ca8a | 2017-03-31 11:27:56 +0200 | [diff] [blame] | 59 | srcs += regression_2000.c \ |
Jens Wiklander | 02389a9 | 2016-12-16 11:13:38 +0100 | [diff] [blame] | 60 | sock_server.c \ |
| 61 | rand_stream.c |
| 62 | endif |
| 63 | |
Jerome Forissier | 213ca8a | 2017-03-31 11:27:56 +0200 | [diff] [blame] | 64 | srcs += adbg/src/adbg_case.c \ |
Pascal Brand | c639ac8 | 2015-07-02 08:53:34 +0200 | [diff] [blame] | 65 | adbg/src/adbg_enum.c \ |
| 66 | adbg/src/adbg_expect.c \ |
| 67 | adbg/src/adbg_log.c \ |
Pascal Brand | c639ac8 | 2015-07-02 08:53:34 +0200 | [diff] [blame] | 68 | adbg/src/adbg_run.c \ |
Jerome Forissier | 213ca8a | 2017-03-31 11:27:56 +0200 | [diff] [blame] | 69 | adbg/src/security_utils_hex.c \ |
| 70 | aes_perf.c \ |
| 71 | benchmark_1000.c \ |
| 72 | benchmark_2000.c \ |
| 73 | regression_4000.c \ |
Jens Wiklander | b4c75aa | 2018-11-15 10:43:29 +0100 | [diff] [blame] | 74 | regression_4100.c \ |
Jerome Forissier | 213ca8a | 2017-03-31 11:27:56 +0200 | [diff] [blame] | 75 | regression_5000.c \ |
| 76 | regression_6000.c \ |
Jens Wiklander | cd0186b | 2017-04-05 11:34:22 +0200 | [diff] [blame] | 77 | regression_8000.c \ |
Jens Wiklander | 2932647 | 2018-04-20 11:22:15 +0200 | [diff] [blame] | 78 | regression_8100.c \ |
Jerome Forissier | 213ca8a | 2017-03-31 11:27:56 +0200 | [diff] [blame] | 79 | sha_perf.c \ |
Jens Wiklander | 254a3e3 | 2019-01-31 12:25:08 +0100 | [diff] [blame] | 80 | stats.c \ |
Jerome Forissier | 213ca8a | 2017-03-31 11:27:56 +0200 | [diff] [blame] | 81 | xtest_helpers.c \ |
| 82 | xtest_main.c \ |
Vesa Jääskeläinen | 7e2a230 | 2020-04-05 20:11:58 +0300 | [diff] [blame] | 83 | xtest_test.c \ |
| 84 | xtest_uuid_helpers.c |
Pascal Brand | c639ac8 | 2015-07-02 08:53:34 +0200 | [diff] [blame] | 85 | |
Jens Wiklander | f261a6d | 2017-11-09 16:45:51 +0100 | [diff] [blame] | 86 | ifeq ($(CFG_SECSTOR_TA_MGMT_PTA),y) |
| 87 | srcs += install_ta.c |
| 88 | endif |
| 89 | |
Etienne Carriere | 41343db | 2017-03-17 15:38:52 +0100 | [diff] [blame] | 90 | ifeq ($(CFG_SECURE_DATA_PATH),y) |
| 91 | srcs += sdp_basic.c |
| 92 | endif |
| 93 | |
Etienne Carriere | 109c1d7 | 2019-01-09 11:02:02 +0100 | [diff] [blame] | 94 | ifeq ($(CFG_PKCS11_TA),y) |
| 95 | srcs += pkcs11_1000.c |
Etienne Carriere | 109c1d7 | 2019-01-09 11:02:02 +0100 | [diff] [blame] | 96 | endif |
| 97 | |
Etienne Carriere | 3ddc362 | 2017-03-13 15:31:15 +0100 | [diff] [blame] | 98 | objs := $(patsubst %.c,$(out-dir)/xtest/%.o, $(srcs)) |
Pascal Brand | c639ac8 | 2015-07-02 08:53:34 +0200 | [diff] [blame] | 99 | |
Sahil Malhotra | 5abbcdf | 2021-04-19 12:07:49 +0530 | [diff] [blame] | 100 | ifeq ($(CFG_PKCS11_TA),y) |
| 101 | CFLAGS += -DCFG_PKCS11_TA |
| 102 | endif |
Pascal Brand | c639ac8 | 2015-07-02 08:53:34 +0200 | [diff] [blame] | 103 | CFLAGS += -I./ |
| 104 | CFLAGS += -I./adbg/include |
Aleksandr Anisimov | 01f6f06 | 2021-01-19 11:02:25 +0300 | [diff] [blame] | 105 | CFLAGS += -I../supp_plugin/include |
Jens Wiklander | f6efe24 | 2017-11-06 13:16:43 +0100 | [diff] [blame] | 106 | CFLAGS += -I$(out-dir)/xtest |
Pascal Brand | c639ac8 | 2015-07-02 08:53:34 +0200 | [diff] [blame] | 107 | |
| 108 | CFLAGS += -I$(OPTEE_CLIENT_EXPORT)/include |
| 109 | CFLAGS += -I$(TA_DEV_KIT_DIR)/host_include |
| 110 | |
Jens Wiklander | ff1be9e | 2018-02-01 14:16:57 +0100 | [diff] [blame] | 111 | CFLAGS += -I../../ta/include |
Pascal Brand | c639ac8 | 2015-07-02 08:53:34 +0200 | [diff] [blame] | 112 | CFLAGS += -I../../ta/create_fail_test/include |
| 113 | CFLAGS += -I../../ta/crypt/include |
| 114 | CFLAGS += -I../../ta/enc_fs/include |
| 115 | CFLAGS += -I../../ta/os_test/include |
| 116 | CFLAGS += -I../../ta/rpc_test/include |
| 117 | CFLAGS += -I../../ta/sims/include |
Ovidiu Mihalachi | 15cecff | 2019-04-02 16:36:31 +0300 | [diff] [blame] | 118 | CFLAGS += -I../../ta/miss/include |
| 119 | CFLAGS += -I../../ta/sims_keepalive/include |
James Kung | df1e6cf | 2015-09-14 22:42:24 +0800 | [diff] [blame] | 120 | CFLAGS += -I../../ta/storage_benchmark/include |
Jens Wiklander | ac27ec1 | 2015-07-15 15:23:14 +0200 | [diff] [blame] | 121 | CFLAGS += -I../../ta/concurrent/include |
Jens Wiklander | 7067297 | 2016-04-06 00:01:45 +0200 | [diff] [blame] | 122 | CFLAGS += -I../../ta/concurrent_large/include |
Igor Opaniuk | 136644a | 2016-09-13 13:40:56 +0300 | [diff] [blame] | 123 | CFLAGS += -I../../ta/sha_perf/include |
Igor Opaniuk | 44aff4b | 2016-09-16 10:18:00 +0300 | [diff] [blame] | 124 | CFLAGS += -I../../ta/aes_perf/include |
Jens Wiklander | 02389a9 | 2016-12-16 11:13:38 +0100 | [diff] [blame] | 125 | CFLAGS += -I../../ta/socket/include |
Etienne Carriere | 41343db | 2017-03-17 15:38:52 +0100 | [diff] [blame] | 126 | CFLAGS += -I../../ta/sdp_basic/include |
Javier Almansa Sobrino | cddc000 | 2020-02-10 13:35:37 +0000 | [diff] [blame] | 127 | CFLAGS += -I../../ta/tpm_log_test/include |
Jens Wiklander | 94fb158 | 2021-05-19 10:14:57 +0200 | [diff] [blame^] | 128 | CFLAGS += -I../../ta/large/include |
Aleksandr Anisimov | 01f6f06 | 2021-01-19 11:02:25 +0300 | [diff] [blame] | 129 | CFLAGS += -I../../ta/supp_plugin/include |
Etienne Carriere | 41343db | 2017-03-17 15:38:52 +0100 | [diff] [blame] | 130 | |
l00176142 | 087f204 | 2017-08-28 20:03:28 +0800 | [diff] [blame] | 131 | TA_DIR ?= /lib/optee_armtz |
| 132 | CFLAGS += -DTA_DIR=\"$(TA_DIR)\" |
| 133 | |
Jerome Forissier | f9b8925 | 2016-08-23 18:30:43 +0200 | [diff] [blame] | 134 | # Include configuration file generated by OP-TEE OS (CFG_* macros) |
| 135 | CFLAGS += -include conf.h |
Pascal Brand | c639ac8 | 2015-07-02 08:53:34 +0200 | [diff] [blame] | 136 | |
Pascal Brand | c639ac8 | 2015-07-02 08:53:34 +0200 | [diff] [blame] | 137 | CFLAGS += -Wall -Wcast-align -Werror \ |
| 138 | -Werror-implicit-function-declaration -Wextra -Wfloat-equal \ |
| 139 | -Wformat-nonliteral -Wformat-security -Wformat=2 -Winit-self \ |
| 140 | -Wmissing-declarations -Wmissing-format-attribute \ |
Ross Burton | 3b9a63a | 2020-10-27 17:00:16 +0000 | [diff] [blame] | 141 | -Wmissing-include-dirs \ |
Pascal Brand | c639ac8 | 2015-07-02 08:53:34 +0200 | [diff] [blame] | 142 | -Wmissing-prototypes -Wnested-externs -Wpointer-arith \ |
| 143 | -Wshadow -Wstrict-prototypes -Wswitch-default \ |
Jerome Forissier | 659e221 | 2020-10-27 18:39:05 +0100 | [diff] [blame] | 144 | -Wwrite-strings -Wno-unused-parameter \ |
André Draszik | b873974 | 2019-02-07 01:29:08 +0000 | [diff] [blame] | 145 | -Wno-declaration-after-statement \ |
Pascal Brand | c639ac8 | 2015-07-02 08:53:34 +0200 | [diff] [blame] | 146 | -Wno-missing-field-initializers -Wno-format-zero-length |
Pascal Brand | c639ac8 | 2015-07-02 08:53:34 +0200 | [diff] [blame] | 147 | |
Jerome Forissier | a8b78f1 | 2016-08-17 09:40:59 +0200 | [diff] [blame] | 148 | CFLAGS += -g3 |
| 149 | |
Pascal Brand | c639ac8 | 2015-07-02 08:53:34 +0200 | [diff] [blame] | 150 | LDFLAGS += -L$(OPTEE_CLIENT_EXPORT)/lib -lteec |
Sahil Malhotra | 5abbcdf | 2021-04-19 12:07:49 +0530 | [diff] [blame] | 151 | ifeq ($(CFG_PKCS11_TA),y) |
| 152 | LDFLAGS += -lckteec |
| 153 | endif |
Igor Opaniuk | 136644a | 2016-09-13 13:40:56 +0300 | [diff] [blame] | 154 | LDFLAGS += -lpthread -lm |
Pascal Brand | c639ac8 | 2015-07-02 08:53:34 +0200 | [diff] [blame] | 155 | |
| 156 | .PHONY: all |
| 157 | all: xtest |
| 158 | |
| 159 | xtest: $(objs) |
Etienne Carriere | 3ddc362 | 2017-03-13 15:31:15 +0100 | [diff] [blame] | 160 | @echo " LD $(out-dir)/xtest/$@" |
Jerome Forissier | c820858 | 2017-11-13 08:46:29 +0100 | [diff] [blame] | 161 | $(q)$(CC) -o $(out-dir)/xtest/$@ $+ $(LDFLAGS) |
Pascal Brand | c639ac8 | 2015-07-02 08:53:34 +0200 | [diff] [blame] | 162 | |
Etienne Carriere | 3ddc362 | 2017-03-13 15:31:15 +0100 | [diff] [blame] | 163 | $(out-dir)/xtest/%.o: $(CURDIR)/%.c |
| 164 | $(q)mkdir -p $(out-dir)/xtest/adbg/src |
Pascal Brand | c639ac8 | 2015-07-02 08:53:34 +0200 | [diff] [blame] | 165 | @echo ' CC $<' |
| 166 | $(q)$(CC) $(CFLAGS) -c $< -o $@ |
| 167 | |
Etienne Carriere | 3ddc362 | 2017-03-13 15:31:15 +0100 | [diff] [blame] | 168 | RMDIR := rmdir --ignore-fail-on-non-empty |
| 169 | define rm-build-dirs |
| 170 | $(q)for d in $1; do $(RMDIR) $(out-dir)/xtest/$$d 2> /dev/null; true; done |
| 171 | $(q)$(RMDIR) $(out-dir)/xtest 2> /dev/null; true |
| 172 | $(q)$(RMDIR) $(out-dir) 2> /dev/null; true |
| 173 | endef |
| 174 | |
Jens Wiklander | f6efe24 | 2017-11-06 13:16:43 +0100 | [diff] [blame] | 175 | ifeq ($(CFG_GCM_NIST_VECTORS),y) |
| 176 | GCM_NIST_VECTORS_DECRYPT = gcmDecrypt128 gcmDecrypt192 gcmDecrypt256 |
| 177 | GCM_NIST_VECTORS_ENCRYPT = gcmEncryptExtIV128 gcmEncryptExtIV192 \ |
| 178 | gcmEncryptExtIV256 |
| 179 | |
| 180 | cleanfiles += $(out-dir)/gcmtestvectors.zip |
| 181 | $(out-dir)/gcmtestvectors.zip: |
| 182 | @echo ' DL $@' |
| 183 | $(q)curl https://csrc.nist.gov/csrc/media/projects/cryptographic-algorithm-validation-program/documents/mac/gcmtestvectors.zip -o $@ |
| 184 | |
| 185 | define create-nist-gcm-vectors |
| 186 | cleanfiles += $(out-dir)/xtest/$(1).h $(out-dir)/$(1).rsp |
| 187 | |
| 188 | $(out-dir)/$(1).rsp: $(out-dir)/gcmtestvectors.zip |
| 189 | @echo ' UNZIP $$@' |
| 190 | $(q)unzip -o $$< $$(notdir $$@) -d $$(dir $$@) |
| 191 | $(q)touch $$@ |
| 192 | |
| 193 | |
| 194 | $(out-dir)/xtest/$(1).h: $(out-dir)/$(1).rsp |
| 195 | @echo ' GEN $$@' |
| 196 | $(q)../../scripts/rsp_to_gcm_test.py --inf $$< --outf $$@ --mode=$(2) \ |
| 197 | $(if $(filter y,$(CFG_GCM_NIST_VECTORS_LIMITED)),--limited) |
| 198 | |
| 199 | $(CURDIR)/regression_4000.c: $(out-dir)/xtest/$(1).h |
| 200 | endef |
| 201 | |
| 202 | $(foreach v, $(GCM_NIST_VECTORS_DECRYPT), $(eval $(call \ |
| 203 | create-nist-gcm-vectors,$v,decrypt))) |
| 204 | $(foreach v, $(GCM_NIST_VECTORS_ENCRYPT), $(eval $(call \ |
| 205 | create-nist-gcm-vectors,$v,encrypt))) |
| 206 | endif |
| 207 | |
Jens Wiklander | 97d6e29 | 2018-04-23 13:00:31 +0200 | [diff] [blame] | 208 | define embed-file |
| 209 | cleanfiles += $(out-dir)/xtest/$(1).h |
| 210 | |
| 211 | $(out-dir)/xtest/$(1).h: $(2) |
| 212 | @echo ' GEN $$@' |
| 213 | $(q)../../scripts/file_to_c.py --inf $$< --out $$@ --name $(1) |
| 214 | |
| 215 | $(CURDIR)/regression_8100.c: $(out-dir)/xtest/$(1).h |
| 216 | endef |
| 217 | |
| 218 | $(eval $(call embed-file,regression_8100_ca_crt,../../cert/ca.crt)) |
| 219 | $(eval $(call embed-file,regression_8100_mid_crt,../../cert/mid.crt)) |
| 220 | $(eval $(call embed-file,regression_8100_my_crt,../../cert/my.crt)) |
Jens Wiklander | 950ea1c | 2018-04-30 15:39:22 +0200 | [diff] [blame] | 221 | $(eval $(call embed-file,regression_8100_my_csr,../../cert/my.csr)) |
Jens Wiklander | f6efe24 | 2017-11-06 13:16:43 +0100 | [diff] [blame] | 222 | |
Pascal Brand | c639ac8 | 2015-07-02 08:53:34 +0200 | [diff] [blame] | 223 | .PHONY: clean |
| 224 | clean: |
Etienne Carriere | 3ddc362 | 2017-03-13 15:31:15 +0100 | [diff] [blame] | 225 | @echo ' CLEAN $(out-dir)' |
| 226 | $(q)rm -f $(out-dir)/xtest/xtest |
Pascal Brand | c639ac8 | 2015-07-02 08:53:34 +0200 | [diff] [blame] | 227 | $(q)$(foreach obj,$(objs), rm -f $(obj)) |
Jens Wiklander | f6efe24 | 2017-11-06 13:16:43 +0100 | [diff] [blame] | 228 | $(q)rm -f $(cleanfiles) |
Etienne Carriere | 3ddc362 | 2017-03-13 15:31:15 +0100 | [diff] [blame] | 229 | $(call rm-build-dirs,adbg/src adbg) |