blob: 8a1a86af4f34d6fcdef6aaf384eba9f7a6fc98f1 [file] [log] [blame]
Pascal Brand04ac4652014-06-03 16:12:38 +02001# Public variables are stored in config.mk
Pascal Brand5e98be72014-07-15 16:00:49 +02002include ./config.mk
Pascal Brand04ac4652014-06-03 16:12:38 +02003
4#########################################################################
5# Set Internal Variables #
6# May be modified to match your setup #
7#########################################################################
Jerome Forissier0048dab2016-08-17 09:04:37 +02008ifneq ($(V),1)
9VPREFIX := @
Pascal Brand04ac4652014-06-03 16:12:38 +020010endif
11export VPREFIX
12
Pascal Brand5e98be72014-07-15 16:00:49 +020013EXPORT_DIR ?= $(O)/export
Jerome Forissier4dd96a62016-11-23 15:12:17 +010014DESTDIR ?= $(EXPORT_DIR)
Etienne Carrierec56b7512019-02-07 10:43:36 +010015SBINDIR ?= /usr/sbin
Etienne Carriere3f285572019-02-07 10:44:28 +010016LIBDIR ?= /usr/lib
17INCLUDEDIR ?= /usr/include
Clement Faure20965422023-01-04 15:03:02 +010018sbindir ?= $(SBINDIR)
19libdir ?= $(LIBDIR)
20includedir ?= $(INCLUDEDIR)
Pascal Brand04ac4652014-06-03 16:12:38 +020021
Etienne Carrierebbdf6652022-11-10 12:05:24 +010022WITH_TEEACL ?= 1
23
Eero Aaltonene58b1582022-09-02 11:54:14 +030024.PHONY: all build build-libteec build-libckteec build-libseteec \
Baocheng Sudd2d39b2022-11-07 20:19:29 +080025 build-libteeacl install copy_export clean cscope \
Eero Aaltonen15605822020-11-27 14:39:57 +020026 clean-cscope \
Pascal Brand04ac4652014-06-03 16:12:38 +020027 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 Brand5e98be72014-07-15 16:00:49 +020031
32all: build install
Pascal Brand04ac4652014-06-03 16:12:38 +020033
34build-libteec:
35 @echo "Building libteec.so"
Igor Opaniuk63106fb2016-11-09 14:06:09 +000036 @$(MAKE) --directory=libteec --no-print-directory --no-builtin-variables \
Igor Opaniukbfe37712024-01-16 17:15:11 +010037 CFG_TEE_CLIENT_LOG_LEVEL=$(CFG_TEE_CLIENT_LOG_LEVEL)
Igor Opaniuk63106fb2016-11-09 14:06:09 +000038
Jens Wiklander403c9a12017-04-19 13:38:26 +020039build-tee-supplicant: build-libteec
Pascal Brand04ac4652014-06-03 16:12:38 +020040 @echo "Building tee-supplicant"
Yongqin Liub6bfce92018-08-17 12:19:38 +080041 $(MAKE) --directory=tee-supplicant --no-print-directory --no-builtin-variables CFG_TEE_SUPP_LOG_LEVEL=$(CFG_TEE_SUPP_LOG_LEVEL)
Pascal Brand04ac4652014-06-03 16:12:38 +020042
Etienne Carrierebbdf6652022-11-10 12:05:24 +010043build: build-libteec build-tee-supplicant build-libckteec build-libseteec
44ifeq ($(WITH_TEEACL),1)
45build: build-libteeacl
46endif
Etienne Carrierefa679fc2019-01-11 10:17:55 +010047
Jerome Forissier2b2f2f62020-02-10 12:59:33 +010048build-libckteec: build-libteec
Etienne Carrierefa679fc2019-01-11 10:17:55 +010049 @echo "Building libckteec.so"
50 @$(MAKE) --directory=libckteec --no-print-directory --no-builtin-variables
Pascal Brand04ac4652014-06-03 16:12:38 +020051
Jorge Ramirez-Ortizf4f54e52021-11-03 12:28:47 +010052build-libseteec: build-libteec
53 @echo "Building libseteec.so"
54 @$(MAKE) --directory=libseteec --no-print-directory --no-builtin-variables
55
Baocheng Sudd2d39b2022-11-07 20:19:29 +080056build-libteeacl:
Eero Aaltonene58b1582022-09-02 11:54:14 +030057 @echo "Building libteeacl.so"
58 @$(MAKE) --directory=libteeacl --no-print-directory --no-builtin-variables
59
Pascal Branda2cacd02015-07-08 10:42:53 +020060install: copy_export
Pascal Brand04ac4652014-06-03 16:12:38 +020061
Eero Aaltonene58b1582022-09-02 11:54:14 +030062clean: clean-libteec clean-tee-supplicant clean-cscope clean-libckteec \
Etienne Carrierebbdf6652022-11-10 12:05:24 +010063 clean-libseteec
64ifeq ($(WITH_TEEACL),1)
65clean: clean-libteeacl
66endif
Pascal Brand04ac4652014-06-03 16:12:38 +020067
68clean-libteec:
69 @$(MAKE) --directory=libteec --no-print-directory clean
70
71clean-tee-supplicant:
72 @$(MAKE) --directory=tee-supplicant --no-print-directory clean
73
Etienne Carrierefa679fc2019-01-11 10:17:55 +010074clean-libckteec:
75 @$(MAKE) --directory=libckteec --no-print-directory clean
76
Jorge Ramirez-Ortizf4f54e52021-11-03 12:28:47 +010077clean-libseteec:
78 @$(MAKE) --directory=libseteec --no-print-directory clean
79
Eero Aaltonene58b1582022-09-02 11:54:14 +030080clean-libteeacl:
81 @$(MAKE) --directory=libteeacl --no-print-directory clean
82
Pascal Brand04ac4652014-06-03 16:12:38 +020083cscope:
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
Jerome Forissier9598e162014-07-30 19:06:52 +0200157copy_export: build
Clement Faure20965422023-01-04 15:03:02 +0100158 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 Aaltonen3ac968e2023-08-10 15:37:40 +0300163 cp libteec/include/*.h $(DESTDIR)$(includedir)
Clement Faure20965422023-01-04 15:03:02 +0100164 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 Carrierebbdf6652022-11-10 12:05:24 +0100167ifeq ($(WITH_TEEACL),1)
Clement Faure20965422023-01-04 15:03:02 +0100168 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 Carrierebbdf6652022-11-10 12:05:24 +0100171endif
Clement Faure20965422023-01-04 15:03:02 +0100172 cp libseteec/include/*.h $(DESTDIR)$(includedir)
173 cp -d ${O}/libseteec/libseteec.so* $(DESTDIR)$(libdir)
174 cp -d ${O}/libseteec/libseteec.a $(DESTDIR)$(libdir)