1# Public variables are stored in config.mk 2include ./config.mk 3 4######################################################################### 5# Set Internal Variables # 6# May be modified to match your setup # 7######################################################################### 8ifneq ($(V),1) 9VPREFIX := @ 10endif 11export VPREFIX 12 13EXPORT_DIR ?= $(O)/export 14DESTDIR ?= $(EXPORT_DIR) 15SBINDIR ?= /usr/sbin 16LIBDIR ?= /usr/lib 17INCLUDEDIR ?= /usr/include 18 19WITH_TEEACL ?= 1 20 21.PHONY: all build build-libteec build-libckteec build-libseteec \ 22 build-libteeacl install copy_export clean cscope \ 23 clean-cscope \ 24 checkpatch-pre-req checkpatch-modified-patch checkpatch-modified-file \ 25 checkpatch-last-commit-patch checkpatch-last-commit-file \ 26 checkpatch-base-commit-patch checkpatch-base-commit-file \ 27 checkpatch-all-files distclean 28 29all: build install 30 31build-libteec: 32 @echo "Building libteec.so" 33 @$(MAKE) --directory=libteec --no-print-directory --no-builtin-variables \ 34 CFG_TEE_BENCHMARK=$(CFG_TEE_BENCHMARK) CFG_TEE_CLIENT_LOG_LEVEL=$(CFG_TEE_CLIENT_LOG_LEVEL) 35 36build-tee-supplicant: build-libteec 37 @echo "Building tee-supplicant" 38 $(MAKE) --directory=tee-supplicant --no-print-directory --no-builtin-variables CFG_TEE_SUPP_LOG_LEVEL=$(CFG_TEE_SUPP_LOG_LEVEL) 39 40build: build-libteec build-tee-supplicant build-libckteec build-libseteec 41ifeq ($(WITH_TEEACL),1) 42build: build-libteeacl 43endif 44 45build-libckteec: build-libteec 46 @echo "Building libckteec.so" 47 @$(MAKE) --directory=libckteec --no-print-directory --no-builtin-variables 48 49build-libseteec: build-libteec 50 @echo "Building libseteec.so" 51 @$(MAKE) --directory=libseteec --no-print-directory --no-builtin-variables 52 53build-libteeacl: 54 @echo "Building libteeacl.so" 55 @$(MAKE) --directory=libteeacl --no-print-directory --no-builtin-variables 56 57install: copy_export 58 59clean: clean-libteec clean-tee-supplicant clean-cscope clean-libckteec \ 60 clean-libseteec 61ifeq ($(WITH_TEEACL),1) 62clean: clean-libteeacl 63endif 64 65clean-libteec: 66 @$(MAKE) --directory=libteec --no-print-directory clean 67 68clean-tee-supplicant: 69 @$(MAKE) --directory=tee-supplicant --no-print-directory clean 70 71clean-libckteec: 72 @$(MAKE) --directory=libckteec --no-print-directory clean 73 74clean-libseteec: 75 @$(MAKE) --directory=libseteec --no-print-directory clean 76 77clean-libteeacl: 78 @$(MAKE) --directory=libteeacl --no-print-directory clean 79 80cscope: 81 @echo " CSCOPE" 82 ${VPREFIX}find ${CURDIR} -name "*.[chsS]" > cscope.files 83 ${VPREFIX}cscope -b -q -k 84 85clean-cscope: 86 ${VPREFIX}rm -f cscope.* 87 88# Various checkpatch targets. The ones ending with "patch" only considers the 89# patch, whilst the ones ending with "file" checks the complete file. 90# +-------------------------------+------------+----------------------------+ 91# | Target commit | File/Patch | Comment | 92# +-------------------------------+------------+----------------------------+ 93# | checkpatch-modified-patch | Patch | Check local modifications | 94# +-------------------------------+------------+----------------------------+ 95# | checkpatch-modified-file | File | Check Local modifications | 96# +-------------------------------+------------+----------------------------+ 97# | checkpatch-last-commit-patch | Patch | Check against HEAD^ | 98# +-------------------------------+------------+----------------------------+ 99# | checkpatch-last-commit-file | File | Check against HEAD^ | 100# +-------------------------------+------------+----------------------------+ 101# | checkpatch-base-commit-patch | Patch | Against specic commit | 102# +-------------------------------+------------+----------------------------+ 103# | checkpatch-base-commit-file | File | Against specic commit | 104# +-------------------------------+------------+----------------------------+ 105# | checkpatch-all-files | File | Check all tracked files | 106# +-------------------------------+------------+----------------------------+ 107CHECKPATCH_IGNORE ?= --ignore NEW_TYPEDEFS --no-signoff 108CHECKPATCH_STRICT ?= --strict 109CHECKPATCH_ARGS ?= $(CHECKPATCH_IGNORE) $(CHECKPATCH_STRICT) --no-tree --terse 110CHECKPATCH_PATCH_ARGS := $(CHECKPATCH_ARGS) --patch 111CHECKPATCH_FILE_ARGS := $(CHECKPATCH_ARGS) --file --no-patch 112 113checkpatch-pre-req: 114 @echo " CHECKPATCH" 115ifndef CHECKPATCH 116 $(error "Environment variable CHECKPATCH must point to Linux kernels checkpatch script") 117else 118ifeq (,$(wildcard ${CHECKPATCH})) 119 $(error "CHECKPATCH points to the incorrect file") 120endif 121endif 122 123checkpatch-modified-patch: checkpatch-pre-req 124 ${VPREFIX}git diff | ${CHECKPATCH} $(CHECKPATCH_PATCH_ARGS) - || true 125 126checkpatch-modified-file: checkpatch-pre-req 127 ${VPREFIX}${CHECKPATCH} $(CHECKPATCH_FILE_ARGS) $(shell git diff --name-only) 128 129 130checkpatch-last-commit-patch: checkpatch-pre-req 131 ${VPREFIX}git diff HEAD^ | ${CHECKPATCH} $(CHECKPATCH_PATCH_ARGS) - || true 132 133checkpatch-last-commit-file: checkpatch-pre-req 134 ${VPREFIX}${CHECKPATCH} $(CHECKPATCH_FILE_ARGS) $(shell git diff --name-only HEAD^) 135 136 137checkpatch-base-commit-patch: checkpatch-pre-req 138ifndef BASE_COMMIT 139 $(error "Environment variable BASE_COMMIT must contain a valid commit") 140endif 141 ${VPREFIX}git diff $(BASE_COMMIT) | ${CHECKPATCH} $(CHECKPATCH_PATCH_ARGS) - || true 142 143checkpatch-base-commit-file: checkpatch-pre-req 144ifndef BASE_COMMIT 145 $(error "Environment variable BASE_COMMIT must contain a valid commit") 146endif 147 ${VPREFIX}${CHECKPATCH} $(CHECKPATCH_FILE_ARGS) $(shell git diff --name-only ${BASE_COMMIT}) 148 149checkpatch-all-files: checkpatch-pre-req 150 ${VPREFIX}${CHECKPATCH} $(CHECKPATCH_FILE_ARGS) $(shell git ls-files) 151 152distclean: clean 153 154copy_export: build 155 mkdir -p $(DESTDIR)$(SBINDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(INCLUDEDIR) 156 cp config.mk $(DESTDIR)/$(INCLUDEDIR)/optee_client_config.mk 157 cp -d ${O}/libteec/libteec.so* $(DESTDIR)$(LIBDIR) 158 cp -d ${O}/libteec/libteec.a $(DESTDIR)$(LIBDIR) 159 cp ${O}/tee-supplicant/tee-supplicant $(DESTDIR)$(SBINDIR) 160 cp public/*.h $(DESTDIR)$(INCLUDEDIR) 161 cp libckteec/include/*.h $(DESTDIR)$(INCLUDEDIR) 162 cp -d ${O}/libckteec/libckteec.so* $(DESTDIR)$(LIBDIR) 163 cp -d ${O}/libckteec/libckteec.a $(DESTDIR)$(LIBDIR) 164ifeq ($(WITH_TEEACL),1) 165 cp libteeacl/include/*.h $(DESTDIR)$(INCLUDEDIR) 166 cp -d ${O}/libteeacl/libteeacl.so* $(DESTDIR)$(LIBDIR) 167 cp -d ${O}/libteeacl/libteeacl.a $(DESTDIR)$(LIBDIR) 168endif 169 cp libseteec/include/*.h $(DESTDIR)$(INCLUDEDIR) 170 cp -d ${O}/libseteec/libseteec.so* $(DESTDIR)$(LIBDIR) 171 cp -d ${O}/libseteec/libseteec.a $(DESTDIR)$(LIBDIR) 172