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. 4ifeq ($O,) 5$(error output path should be specified when calling this makefile) 6endif 7 8include $(TA_DEV_KIT_DIR)/host_include/conf.mk 9 10# By default we expect optee_client exported folder to be on a certain relative 11# path, but if the client specifies the OPTEE_CLIENT_EXPORT then that path will 12# be used instead. 13OPTEE_CLIENT_EXPORT ?= ../../client_export/ 14ifeq "$(COMPILE_NS_USER)" "64" 15OPTEE_CLIENT_LIB ?= ../../../../bin/optee_v2/lib/arm64/ 16else 17ifeq "$(TOOLCHAIN_UCLIBC)" "y" 18OPTEE_CLIENT_LIB ?= ../../../../bin/optee_v2/uclibc_lib/arm/ 19else 20OPTEE_CLIENT_LIB ?= ../../../../bin/optee_v2/lib/arm/ 21endif 22endif 23 24CC ?= $(CROSS_COMPILE)gcc 25CPP ?= $(CROSS_COMPILE)cpp 26LD ?= $(CROSS_COMPILE)ld 27AR ?= $(CROSS_COMPILE)ar 28NM ?= $(CROSS_COMPILE)nm 29OBJCOPY ?= $(CROSS_COMPILE)objcopy 30OBJDUMP ?= $(CROSS_COMPILE)objdump 31READELF ?= $(CROSS_COMPILE)readelf 32 33 34SRC_PATH := . 35 36srcs := $(wildcard $(SRC_PATH)/*.c) 37 38objs := $(patsubst %.c,$(O)/%.o, $(srcs)) 39 40 41CFLAGS += -I$(OPTEE_CLIENT_EXPORT)/public 42CFLAGS += -I$(TA_DEV_KIT_DIR)/host_include 43CFLAGS += -I../../ta/rk_test/include 44CFLAGS += -I./include 45CFLAGS += -Wall -Wcast-align \ 46 -Werror-implicit-function-declaration -Wextra -Wfloat-equal \ 47 -Wformat-nonliteral -Wformat-security -Wformat=2 -Winit-self \ 48 -Wmissing-declarations -Wmissing-format-attribute \ 49 -Wmissing-include-dirs -Wmissing-noreturn \ 50 -Wmissing-prototypes -Wnested-externs -Wpointer-arith \ 51 -Wshadow -Wstrict-prototypes -Wswitch-default \ 52 -Wwrite-strings \ 53 -Wno-missing-field-initializers -Wno-format-zero-length 54 55LDFLAGS += -L$(OPTEE_CLIENT_LIB) 56LDFLAGS += -L$(OPTEE_CLIENT_EXPORT)/lib -lteec -lpthread 57 58 59.PHONY: all 60all: rk_test 61 62rk_test: rktest 63 64rktest: $(objs) 65 @echo " LD $(O)/$@" 66 $(q)@$(CC) -o $(O)/$@ $+ $(LDFLAGS) 67 @echo " OPTEE_CLIENT_LIB=$(OPTEE_CLIENT_LIB)" 68 69 70$(O)/%.o: $(CURDIR)/%.c 71 $(q)mkdir -p $(O)/ 72 @echo ' CC $<' 73 $(q)$(CC) $(CFLAGS) -c $< -o $@ 74 75.PHONY: clean 76clean: 77 @echo ' CLEAN $(O)' 78 $(q)rm -f $(O)/rktest 79 $(q)$(foreach obj,$(objs), rm -f $(obj)) 80