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