blob: d7aa316af1f2e54ad76ab6d3800be5fe12b37def [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
Pascal Brand04ac4652014-06-03 16:12:38 +020018
Jorge Ramirez-Ortizf4f54e52021-11-03 12:28:47 +010019.PHONY: all build build-libteec build-libckteec build-libseteec install copy_export \
Pascal Brand04ac4652014-06-03 16:12:38 +020020 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
Pascal Brand5e98be72014-07-15 16:00:49 +020025
26all: build install
Pascal Brand04ac4652014-06-03 16:12:38 +020027
28build-libteec:
29 @echo "Building libteec.so"
Igor Opaniuk63106fb2016-11-09 14:06:09 +000030 @$(MAKE) --directory=libteec --no-print-directory --no-builtin-variables \
Yongqin Liub6bfce92018-08-17 12:19:38 +080031 CFG_TEE_BENCHMARK=$(CFG_TEE_BENCHMARK) CFG_TEE_CLIENT_LOG_LEVEL=$(CFG_TEE_CLIENT_LOG_LEVEL)
Igor Opaniuk63106fb2016-11-09 14:06:09 +000032
Jens Wiklander403c9a12017-04-19 13:38:26 +020033build-tee-supplicant: build-libteec
Pascal Brand04ac4652014-06-03 16:12:38 +020034 @echo "Building tee-supplicant"
Yongqin Liub6bfce92018-08-17 12:19:38 +080035 $(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 +020036
Jorge Ramirez-Ortizf4f54e52021-11-03 12:28:47 +010037build: build-libteec build-tee-supplicant build-libckteec build-libseteec
Etienne Carrierefa679fc2019-01-11 10:17:55 +010038
Jerome Forissier2b2f2f62020-02-10 12:59:33 +010039build-libckteec: build-libteec
Etienne Carrierefa679fc2019-01-11 10:17:55 +010040 @echo "Building libckteec.so"
41 @$(MAKE) --directory=libckteec --no-print-directory --no-builtin-variables
Pascal Brand04ac4652014-06-03 16:12:38 +020042
Jorge Ramirez-Ortizf4f54e52021-11-03 12:28:47 +010043build-libseteec: build-libteec
44 @echo "Building libseteec.so"
45 @$(MAKE) --directory=libseteec --no-print-directory --no-builtin-variables
46
Pascal Branda2cacd02015-07-08 10:42:53 +020047install: copy_export
Pascal Brand04ac4652014-06-03 16:12:38 +020048
Jorge Ramirez-Ortizf4f54e52021-11-03 12:28:47 +010049clean: clean-libteec clean-tee-supplicant clean-cscope clean-libckteec clean-libseteec
Pascal Brand04ac4652014-06-03 16:12:38 +020050
51clean-libteec:
52 @$(MAKE) --directory=libteec --no-print-directory clean
53
54clean-tee-supplicant:
55 @$(MAKE) --directory=tee-supplicant --no-print-directory clean
56
Etienne Carrierefa679fc2019-01-11 10:17:55 +010057clean-libckteec:
58 @$(MAKE) --directory=libckteec --no-print-directory clean
59
Jorge Ramirez-Ortizf4f54e52021-11-03 12:28:47 +010060clean-libseteec:
61 @$(MAKE) --directory=libseteec --no-print-directory clean
62
Pascal Brand04ac4652014-06-03 16:12:38 +020063cscope:
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
Jerome Forissier9598e162014-07-30 19:06:52 +0200137copy_export: build
Etienne Carrierec56b7512019-02-07 10:43:36 +0100138 mkdir -p $(DESTDIR)$(SBINDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(INCLUDEDIR)
Ricardo Salveti7c9c4232021-04-27 16:32:18 -0300139 cp config.mk $(DESTDIR)/$(INCLUDEDIR)/optee_client_config.mk
Marc Kleine-Budde44c0d302017-06-12 16:54:50 +0200140 cp -a ${O}/libteec/libteec.so* $(DESTDIR)$(LIBDIR)
Jerome Forissier96816802017-11-13 09:32:07 +0100141 cp -a ${O}/libteec/libteec.a $(DESTDIR)$(LIBDIR)
Etienne Carrierec56b7512019-02-07 10:43:36 +0100142 cp ${O}/tee-supplicant/tee-supplicant $(DESTDIR)$(SBINDIR)
Jerome Forissier4dd96a62016-11-23 15:12:17 +0100143 cp public/*.h $(DESTDIR)$(INCLUDEDIR)
Etienne Carrierefa679fc2019-01-11 10:17:55 +0100144 cp libckteec/include/*.h $(DESTDIR)$(INCLUDEDIR)
145 cp -a ${O}/libckteec/libckteec.so* $(DESTDIR)$(LIBDIR)
146 cp -a ${O}/libckteec/libckteec.a $(DESTDIR)$(LIBDIR)
Jorge Ramirez-Ortizf4f54e52021-11-03 12:28:47 +0100147 cp libseteec/include/*.h $(DESTDIR)$(INCLUDEDIR)
148 cp -a ${O}/libseteec/libseteec.so* $(DESTDIR)$(LIBDIR)
149 cp -a ${O}/libseteec/libseteec.a $(DESTDIR)$(LIBDIR)