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