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 18ifeq ($(O),) 19out-dir := $(CURDIR)/out 20else 21out-dir := $(O) 22endif 23 24bindir ?= /usr/bin 25libdir ?= /usr/lib 26 27ifneq ($V,1) 28 q := @ 29 echo := @echo 30else 31 q := 32 echo := @: 33endif 34# export 'q', used by sub-makefiles. 35export q 36 37EXAMPLES = $(wildcard examples/*) 38EXAMPLES_CLEAN = $(EXAMPLES:%=%-clean) 39 40TARGET ?= aarch64-unknown-linux-gnu 41CROSS_COMPILE ?= aarch64-linux-gnu- 42 43# If _HOST or _TA specific compiler/target are not specified, then use common 44# compiler/target for both 45CROSS_COMPILE_HOST ?= $(CROSS_COMPILE) 46CROSS_COMPILE_TA ?= $(CROSS_COMPILE) 47TARGET_HOST ?= $(TARGET) 48TARGET_TA ?= $(TARGET) 49 50.PHONY: all examples $(EXAMPLES) install clean 51ifneq ($(wildcard $(TA_DEV_KIT_DIR)/host_include/conf.mk),) 52all: examples 53else 54all: 55 $(q)echo "TA_DEV_KIT_DIR is not correctly defined" && false 56endif 57 58examples: $(EXAMPLES) 59$(EXAMPLES): 60 $(q)make -C $@ TARGET_HOST=$(TARGET_HOST) \ 61 TARGET_TA=$(TARGET_TA) \ 62 CROSS_COMPILE_HOST=$(CROSS_COMPILE_HOST) \ 63 CROSS_COMPILE_TA=$(CROSS_COMPILE_TA) \ 64 TA_DEV_KIT_DIR=$(TA_DEV_KIT_DIR) \ 65 OPTEE_CLIENT_EXPORT=$(OPTEE_CLIENT_EXPORT) 66 67install: examples 68 $(echo) ' INSTALL ${out-dir}/lib/optee_armtz' 69 $(q)mkdir -p ${out-dir}/lib/optee_armtz 70 $(q)find examples/*/ta/target/$(TARGET_TA)/ -name *.ta -exec cp {} ${out-dir}/lib/optee_armtz \; 71 $(echo) ' INSTALL ${out-dir}${bindir}' 72 $(q)mkdir -p ${out-dir}${bindir} 73 $(q)cp examples/*/host/target/$(TARGET_HOST)/release/*-rs ${out-dir}${bindir} 74 $(echo) ' INSTALL ${out-dir}${libdir}/tee-supplicant/plugins/' 75 $(q)mkdir -p ${out-dir}${libdir}/tee-supplicant/plugins/ 76 $(q)find examples/*/plugin/target/$(TARGET_HOST)/ -name *.plugin.so -exec cp {} ${out-dir}${libdir}/tee-supplicant/plugins/ \; 77 78examples-clean: $(EXAMPLES_CLEAN) out-clean 79$(EXAMPLES_CLEAN): 80 $(q)make -C $(@:-clean=) clean 81 82out-clean: 83 rm -rf out 84 85clean: $(EXAMPLES_CLEAN) out-clean 86