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