Loading...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | # Get the dir of the ta-dev-kit, requires make version 3.81 or later
ta-dev-kit-dir := $(patsubst %/,%,$(abspath $(dir $(lastword $(MAKEFILE_LIST)))..))
.PHONY: all
all:
include $(ta-dev-kit-dir)/mk/conf.mk
ta-dev-kit-dir$(sm) := $(ta-dev-kit-dir)
ifneq (1, $(words $(BINARY) $(LIBNAME) $(SHLIBNAME)))
$(error You must specify exactly one of BINARY, LIBNAME or SHLIBNAME)
endif
ifneq ($O,)
out-dir := $O
else
out-dir := .
endif
link-out-dir := $(out-dir) # backward compat
link-out-dir$(sm) := $(out-dir)
user-ta-uuid := $(BINARY)
user-ta-version := $(if $(CFG_TA_VERSION),$(CFG_TA_VERSION),0)
user-ta-ldadd := $(LDADD)
libname := $(LIBNAME)
shlibname := $(SHLIBNAME)
shlibuuid := $(SHLIBUUID)
ifneq ($V,1)
q := @
cmd-echo := true
cmd-echo-silent := echo
else
q :=
cmd-echo := echo
cmd-echo-silent := true
endif
ifneq ($(filter 4.%,$(MAKE_VERSION)),) # make-4
ifneq ($(filter %s ,$(firstword x$(MAKEFLAGS))),)
cmd-echo-silent := true
endif
else # make-3.8x
ifneq ($(findstring s, $(MAKEFLAGS)),)
cmd-echo-silent := true
endif
endif
cppflags$(sm) := $($(sm)-platform-cppflags) $(CPPFLAGS_$(sm))
aflags$(sm) := $($(sm)-platform-aflags)
cflags$(sm) := $($(sm)-platform-cflags) $(CFLAGS_$(sm))
cxxflags$(sm) := $($(sm)-platform-cxxflags) $(CXXFLAGS_$(sm))
ifneq (,$(shlibname))
# Exception handling is not supported in shared libraries (with GCC it would
# require to use the shared libgcc, which depend on the GNU libc)
cxxflags$(sm) += -fno-exceptions
endif
CFG_TEE_TA_LOG_LEVEL ?= 2
cppflags$(sm) += -DTRACE_LEVEL=$(CFG_TEE_TA_LOG_LEVEL)
cppflags$(sm) += -I. -I$(ta-dev-kit-dir$(sm))/include
ifeq ($(CFG_TA_MCOUNT),y)
cppflags$(sm) += -pg
endif
libdirs += $(ta-dev-kit-dir$(sm))/lib
libnames += utils
libdeps += $(ta-dev-kit-dir$(sm))/lib/libutils.a
libnames += utee
libdeps += $(ta-dev-kit-dir$(sm))/lib/libutee.a
ifeq ($(CFG_TA_MBEDTLS),y)
libnames += mbedtls
libdeps += $(ta-dev-kit-dir$(sm))/lib/libmbedtls.a
endif
libnames += dl
libdeps += $(ta-dev-kit-dir$(sm))/lib/libdl.a
# libutils provides __getauxval symbol which is needed by libgcc 10.x. We can't
# link libutils after libgcc, because libgcc will replace some symbols provided
# by libutils, which will cause further linking issues.
#
# But if we place libutils before libgcc, linker will not be able to resolve
# __getauxval. So we need to link with libutils twice: before and after libgcc.
# Hence it included both in $(libnames) and in $(libnames-after-libgcc)
libnames-after-libgcc += utils
libdeps-after-libgcc += $(ta-dev-kit-dir$(sm))/lib/libutils.a
# Pass config variable (CFG_) from conf.mk on the command line
cppflags$(sm) += $(strip \
$(foreach var, $(filter CFG_%,$(.VARIABLES)), \
$(if $(filter y,$($(var))), \
-D$(var)=1, \
$(if $(filter xn x,x$($(var))),,-D$(var)='$($(var))'))))
include $(ta-dev-kit-dir$(sm))/mk/cleandirs.mk
.PHONY: clean
clean:
@$(cmd-echo-silent) ' CLEAN $(out-dir)'
${q}rm -f $(cleanfiles)
${q}dirs="$(call cleandirs-for-rmdir)"; if [ "$$dirs" ]; then $(RMDIR) $$dirs; fi
@$(cmd-echo-silent) ' CLEAN $(O)'
${q}if [ -d "$(O)" ]; then $(RMDIR) $(O); fi
include $(ta-dev-kit-dir$(sm))/mk/$(COMPILER_$(sm)).mk
include $(ta-dev-kit-dir$(sm))/mk/cc-option.mk
subdirs = .
include $(ta-dev-kit-dir$(sm))/mk/subdir.mk
ifneq ($(user-ta-uuid),)
# Build target is TA
vpath %.c $(ta-dev-kit-dir$(sm))/src
srcs += user_ta_header.c
ifeq ($(sm),ta_arm32)
vpath %.S $(ta-dev-kit-dir$(sm))/src
srcs += ta_entry_a32.S
endif
endif
SCRIPTS_DIR := $(ta-dev-kit-dir)/scripts
include $(ta-dev-kit-dir$(sm))/mk/compile.mk
ifneq ($(user-ta-uuid),)
include $(ta-dev-kit-dir$(sm))/mk/link.mk
endif
ifneq ($(libname),)
# Build target is static library
all: $(libname).a
cleanfiles += $(libname).a
$(libname).a: $(objs)
@echo ' AR $@'
$(q)rm -f $@ && $(AR$(sm)) rcs -o $@ $^
endif
ifneq (,$(shlibname))
include $(ta-dev-kit-dir$(sm))/mk/link_shlib.mk
endif
|