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