| Pascal Brand | 04ac465 | 2014-06-03 16:12:38 +0200 | [diff] [blame] | 1 | # Public variables are stored in config.mk |
| Pascal Brand | 5e98be7 | 2014-07-15 16:00:49 +0200 | [diff] [blame] | 2 | include ./config.mk |
| Pascal Brand | 04ac465 | 2014-06-03 16:12:38 +0200 | [diff] [blame] | 3 | |
| 4 | ######################################################################### |
| 5 | # Set Internal Variables # |
| 6 | # May be modified to match your setup # |
| 7 | ######################################################################### |
| Jerome Forissier | 0048dab | 2016-08-17 09:04:37 +0200 | [diff] [blame] | 8 | ifneq ($(V),1) |
| 9 | VPREFIX := @ |
| Pascal Brand | 04ac465 | 2014-06-03 16:12:38 +0200 | [diff] [blame] | 10 | endif |
| 11 | export VPREFIX |
| 12 | |
| Pascal Brand | 5e98be7 | 2014-07-15 16:00:49 +0200 | [diff] [blame] | 13 | EXPORT_DIR ?= $(O)/export |
| Jerome Forissier | 4dd96a6 | 2016-11-23 15:12:17 +0100 | [diff] [blame] | 14 | DESTDIR ?= $(EXPORT_DIR) |
| Etienne Carriere | c56b751 | 2019-02-07 10:43:36 +0100 | [diff] [blame] | 15 | SBINDIR ?= /usr/sbin |
| Etienne Carriere | 3f28557 | 2019-02-07 10:44:28 +0100 | [diff] [blame] | 16 | LIBDIR ?= /usr/lib |
| 17 | INCLUDEDIR ?= /usr/include |
| Clement Faure | 2096542 | 2023-01-04 15:03:02 +0100 | [diff] [blame] | 18 | sbindir ?= $(SBINDIR) |
| 19 | libdir ?= $(LIBDIR) |
| 20 | includedir ?= $(INCLUDEDIR) |
| Pascal Brand | 04ac465 | 2014-06-03 16:12:38 +0200 | [diff] [blame] | 21 | |
| Etienne Carriere | bbdf665 | 2022-11-10 12:05:24 +0100 | [diff] [blame] | 22 | WITH_TEEACL ?= 1 |
| 23 | |
| Eero Aaltonen | e58b158 | 2022-09-02 11:54:14 +0300 | [diff] [blame] | 24 | .PHONY: all build build-libteec build-libckteec build-libseteec \ |
| Baocheng Su | dd2d39b | 2022-11-07 20:19:29 +0800 | [diff] [blame] | 25 | build-libteeacl install copy_export clean cscope \ |
| Eero Aaltonen | 1560582 | 2020-11-27 14:39:57 +0200 | [diff] [blame] | 26 | clean-cscope \ |
| Pascal Brand | 04ac465 | 2014-06-03 16:12:38 +0200 | [diff] [blame] | 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 |
| Pascal Brand | 5e98be7 | 2014-07-15 16:00:49 +0200 | [diff] [blame] | 31 | |
| 32 | all: build install |
| Pascal Brand | 04ac465 | 2014-06-03 16:12:38 +0200 | [diff] [blame] | 33 | |
| 34 | build-libteec: |
| 35 | @echo "Building libteec.so" |
| Igor Opaniuk | 63106fb | 2016-11-09 14:06:09 +0000 | [diff] [blame] | 36 | @$(MAKE) --directory=libteec --no-print-directory --no-builtin-variables \ |
| Igor Opaniuk | bfe3771 | 2024-01-16 17:15:11 +0100 | [diff] [blame] | 37 | CFG_TEE_CLIENT_LOG_LEVEL=$(CFG_TEE_CLIENT_LOG_LEVEL) |
| Igor Opaniuk | 63106fb | 2016-11-09 14:06:09 +0000 | [diff] [blame] | 38 | |
| Jens Wiklander | 403c9a1 | 2017-04-19 13:38:26 +0200 | [diff] [blame] | 39 | build-tee-supplicant: build-libteec |
| Pascal Brand | 04ac465 | 2014-06-03 16:12:38 +0200 | [diff] [blame] | 40 | @echo "Building tee-supplicant" |
| Yongqin Liu | b6bfce9 | 2018-08-17 12:19:38 +0800 | [diff] [blame] | 41 | $(MAKE) --directory=tee-supplicant --no-print-directory --no-builtin-variables CFG_TEE_SUPP_LOG_LEVEL=$(CFG_TEE_SUPP_LOG_LEVEL) |
| Pascal Brand | 04ac465 | 2014-06-03 16:12:38 +0200 | [diff] [blame] | 42 | |
| Etienne Carriere | bbdf665 | 2022-11-10 12:05:24 +0100 | [diff] [blame] | 43 | build: build-libteec build-tee-supplicant build-libckteec build-libseteec |
| 44 | ifeq ($(WITH_TEEACL),1) |
| 45 | build: build-libteeacl |
| 46 | endif |
| Etienne Carriere | fa679fc | 2019-01-11 10:17:55 +0100 | [diff] [blame] | 47 | |
| Jerome Forissier | 2b2f2f6 | 2020-02-10 12:59:33 +0100 | [diff] [blame] | 48 | build-libckteec: build-libteec |
| Etienne Carriere | fa679fc | 2019-01-11 10:17:55 +0100 | [diff] [blame] | 49 | @echo "Building libckteec.so" |
| 50 | @$(MAKE) --directory=libckteec --no-print-directory --no-builtin-variables |
| Pascal Brand | 04ac465 | 2014-06-03 16:12:38 +0200 | [diff] [blame] | 51 | |
| Jorge Ramirez-Ortiz | f4f54e5 | 2021-11-03 12:28:47 +0100 | [diff] [blame] | 52 | build-libseteec: build-libteec |
| 53 | @echo "Building libseteec.so" |
| 54 | @$(MAKE) --directory=libseteec --no-print-directory --no-builtin-variables |
| 55 | |
| Baocheng Su | dd2d39b | 2022-11-07 20:19:29 +0800 | [diff] [blame] | 56 | build-libteeacl: |
| Eero Aaltonen | e58b158 | 2022-09-02 11:54:14 +0300 | [diff] [blame] | 57 | @echo "Building libteeacl.so" |
| 58 | @$(MAKE) --directory=libteeacl --no-print-directory --no-builtin-variables |
| 59 | |
| Pascal Brand | a2cacd0 | 2015-07-08 10:42:53 +0200 | [diff] [blame] | 60 | install: copy_export |
| Pascal Brand | 04ac465 | 2014-06-03 16:12:38 +0200 | [diff] [blame] | 61 | |
| Eero Aaltonen | e58b158 | 2022-09-02 11:54:14 +0300 | [diff] [blame] | 62 | clean: clean-libteec clean-tee-supplicant clean-cscope clean-libckteec \ |
| Etienne Carriere | bbdf665 | 2022-11-10 12:05:24 +0100 | [diff] [blame] | 63 | clean-libseteec |
| 64 | ifeq ($(WITH_TEEACL),1) |
| 65 | clean: clean-libteeacl |
| 66 | endif |
| Pascal Brand | 04ac465 | 2014-06-03 16:12:38 +0200 | [diff] [blame] | 67 | |
| 68 | clean-libteec: |
| 69 | @$(MAKE) --directory=libteec --no-print-directory clean |
| 70 | |
| 71 | clean-tee-supplicant: |
| 72 | @$(MAKE) --directory=tee-supplicant --no-print-directory clean |
| 73 | |
| Etienne Carriere | fa679fc | 2019-01-11 10:17:55 +0100 | [diff] [blame] | 74 | clean-libckteec: |
| 75 | @$(MAKE) --directory=libckteec --no-print-directory clean |
| 76 | |
| Jorge Ramirez-Ortiz | f4f54e5 | 2021-11-03 12:28:47 +0100 | [diff] [blame] | 77 | clean-libseteec: |
| 78 | @$(MAKE) --directory=libseteec --no-print-directory clean |
| 79 | |
| Eero Aaltonen | e58b158 | 2022-09-02 11:54:14 +0300 | [diff] [blame] | 80 | clean-libteeacl: |
| 81 | @$(MAKE) --directory=libteeacl --no-print-directory clean |
| 82 | |
| Pascal Brand | 04ac465 | 2014-06-03 16:12:38 +0200 | [diff] [blame] | 83 | cscope: |
| 84 | @echo " CSCOPE" |
| 85 | ${VPREFIX}find ${CURDIR} -name "*.[chsS]" > cscope.files |
| 86 | ${VPREFIX}cscope -b -q -k |
| 87 | |
| 88 | clean-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 | # +-------------------------------+------------+----------------------------+ |
| 110 | CHECKPATCH_IGNORE ?= --ignore NEW_TYPEDEFS --no-signoff |
| 111 | CHECKPATCH_STRICT ?= --strict |
| 112 | CHECKPATCH_ARGS ?= $(CHECKPATCH_IGNORE) $(CHECKPATCH_STRICT) --no-tree --terse |
| 113 | CHECKPATCH_PATCH_ARGS := $(CHECKPATCH_ARGS) --patch |
| 114 | CHECKPATCH_FILE_ARGS := $(CHECKPATCH_ARGS) --file --no-patch |
| 115 | |
| 116 | checkpatch-pre-req: |
| 117 | @echo " CHECKPATCH" |
| 118 | ifndef CHECKPATCH |
| 119 | $(error "Environment variable CHECKPATCH must point to Linux kernels checkpatch script") |
| 120 | else |
| 121 | ifeq (,$(wildcard ${CHECKPATCH})) |
| 122 | $(error "CHECKPATCH points to the incorrect file") |
| 123 | endif |
| 124 | endif |
| 125 | |
| 126 | checkpatch-modified-patch: checkpatch-pre-req |
| 127 | ${VPREFIX}git diff | ${CHECKPATCH} $(CHECKPATCH_PATCH_ARGS) - || true |
| 128 | |
| 129 | checkpatch-modified-file: checkpatch-pre-req |
| 130 | ${VPREFIX}${CHECKPATCH} $(CHECKPATCH_FILE_ARGS) $(shell git diff --name-only) |
| 131 | |
| 132 | |
| 133 | checkpatch-last-commit-patch: checkpatch-pre-req |
| 134 | ${VPREFIX}git diff HEAD^ | ${CHECKPATCH} $(CHECKPATCH_PATCH_ARGS) - || true |
| 135 | |
| 136 | checkpatch-last-commit-file: checkpatch-pre-req |
| 137 | ${VPREFIX}${CHECKPATCH} $(CHECKPATCH_FILE_ARGS) $(shell git diff --name-only HEAD^) |
| 138 | |
| 139 | |
| 140 | checkpatch-base-commit-patch: checkpatch-pre-req |
| 141 | ifndef BASE_COMMIT |
| 142 | $(error "Environment variable BASE_COMMIT must contain a valid commit") |
| 143 | endif |
| 144 | ${VPREFIX}git diff $(BASE_COMMIT) | ${CHECKPATCH} $(CHECKPATCH_PATCH_ARGS) - || true |
| 145 | |
| 146 | checkpatch-base-commit-file: checkpatch-pre-req |
| 147 | ifndef BASE_COMMIT |
| 148 | $(error "Environment variable BASE_COMMIT must contain a valid commit") |
| 149 | endif |
| 150 | ${VPREFIX}${CHECKPATCH} $(CHECKPATCH_FILE_ARGS) $(shell git diff --name-only ${BASE_COMMIT}) |
| 151 | |
| 152 | checkpatch-all-files: checkpatch-pre-req |
| 153 | ${VPREFIX}${CHECKPATCH} $(CHECKPATCH_FILE_ARGS) $(shell git ls-files) |
| 154 | |
| 155 | distclean: clean |
| 156 | |
| Jerome Forissier | 9598e16 | 2014-07-30 19:06:52 +0200 | [diff] [blame] | 157 | copy_export: build |
| Clement Faure | 2096542 | 2023-01-04 15:03:02 +0100 | [diff] [blame] | 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) |
| Eero Aaltonen | 3ac968e | 2023-08-10 15:37:40 +0300 | [diff] [blame] | 163 | cp libteec/include/*.h $(DESTDIR)$(includedir) |
| Clement Faure | 2096542 | 2023-01-04 15:03:02 +0100 | [diff] [blame] | 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) |
| Etienne Carriere | bbdf665 | 2022-11-10 12:05:24 +0100 | [diff] [blame] | 167 | ifeq ($(WITH_TEEACL),1) |
| Clement Faure | 2096542 | 2023-01-04 15:03:02 +0100 | [diff] [blame] | 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) |
| Etienne Carriere | bbdf665 | 2022-11-10 12:05:24 +0100 | [diff] [blame] | 171 | endif |
| Clement Faure | 2096542 | 2023-01-04 15:03:02 +0100 | [diff] [blame] | 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) |