1# Licensed to the Apache Software Foundation (ASF) under one 2# or more contributor license agreements. See the NOTICE file 3# distributed with this work for additional information 4# regarding copyright ownership. The ASF licenses this file 5# to you under the Apache License, Version 2.0 (the 6# "License"); you may not use this file except in compliance 7# with the License. You may obtain a copy of the License at 8# 9# http://www.apache.org/licenses/LICENSE-2.0 10# 11# Unless required by applicable law or agreed to in writing, 12# software distributed under the License is distributed on an 13# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14# KIND, either express or implied. See the License for the 15# specific language governing permissions and limitations 16# under the License. 17 18OPTEE_PATH ?= $(OPTEE_DIR) 19OPTEE_BUILD_PATH ?= $(OPTEE_PATH)/build 20OPTEE_OS_PATH ?= $(OPTEE_PATH)/optee_os 21OPTEE_CLIENT_PATH ?= $(OPTEE_PATH)/optee_client 22 23CCACHE ?= $(shell which ccache) 24 25EXAMPLES = $(wildcard examples/*) 26EXAMPLES_INSTALL = $(EXAMPLES:%=%-install) 27EXAMPLES_CLEAN = $(EXAMPLES:%=%-clean) 28 29ifneq ($(ARCH), arm) 30 VENDOR := qemu_v8.mk 31 AARCH_CROSS_COMPILE := $(OPTEE_PATH)/toolchains/aarch64/bin/aarch64-linux-gnu- 32 HOST_TARGET := aarch64-unknown-linux-gnu 33 TA_TARGET := aarch64-unknown-optee-trustzone 34else 35 VENDOR := qemu.mk 36 ARCH_CROSS_COMPILE := $(OPTEE_PATH)/toolchains/aarch32/bin/arm-linux-gnueabihf- 37 HOST_TARGET := arm-unknown-linux-gnueabihf 38 TA_TARGET := arm-unknown-optee-trustzone 39endif 40 41all: toolchains optee-os optee-client examples 42optee: toolchains optee-os optee-client 43 44toolchains: 45 make -C $(OPTEE_BUILD_PATH) -f $(VENDOR) toolchains 46 47optee-os: 48 make -C $(OPTEE_BUILD_PATH) -f $(VENDOR) optee-os 49 50OPTEE_CLIENT_FLAGS ?= CROSS_COMPILE="$(CCACHE) $(AARCH_CROSS_COMPILE)" \ 51 CFG_TEE_BENCHMARK=n \ 52 CFG_TA_TEST_PATH=y 53 54optee-client: 55 make -C $(OPTEE_CLIENT_PATH) $(OPTEE_CLIENT_FLAGS) 56 57examples: $(EXAMPLES) toolchains optee-os optee-client 58$(EXAMPLES): 59 make -C $@ 60 61examples-install: $(EXAMPLES_INSTALL) 62$(EXAMPLES_INSTALL): 63 install -D $(@:%-install=%)/host/target/$(HOST_TARGET)/release/$(@:examples/%-install=%) -t out/host/ 64 install -D $(@:%-install=%)/ta/target/$(TA_TARGET)/release/*.ta -t out/ta/ 65 if [ -d "$(@:%-install=%)/plugin/target/" ]; then \ 66 install -D $(@:%-install=%)/plugin/target/$(HOST_TARGET)/release/*.plugin.so -t out/plugin/; \ 67 fi 68 69optee-os-clean: 70 make -C $(OPTEE_OS_PATH) O=out/arm clean 71 72optee-client-clean: 73 make -C $(OPTEE_CLIENT_PATH) $(OPTEE_CLIENT_CLEAN_FLAGS) clean 74 75examples-clean: $(EXAMPLES_CLEAN) out-clean 76$(EXAMPLES_CLEAN): 77 make -C $(@:-clean=) clean 78 79out-clean: 80 rm -rf out 81 82.PHONY: clean optee-os-clean optee-client-clean $(EXAMPLES) $(EXAMPLES_CLEAN) 83 84clean: optee-os-clean optee-client-clean $(EXAMPLES_CLEAN) 85