Gilles Peskine | 1c13aa7 | 2024-03-04 11:06:56 +0100 | [diff] [blame] | 1 | ifndef MBEDTLS_PATH |
| 2 | MBEDTLS_PATH := .. |
| 3 | endif |
| 4 | |
Ronald Cron | c29afb6 | 2024-07-01 14:50:54 +0200 | [diff] [blame] | 5 | TF_PSA_CRYPTO_CORE_PATH = $(MBEDTLS_PATH)/tf-psa-crypto/core |
| 6 | TF_PSA_CRYPTO_DRIVERS_BUILTIN_SRC_PATH = $(MBEDTLS_PATH)/tf-psa-crypto/drivers/builtin/src |
| 7 | |
Gilles Peskine | b53b443 | 2025-07-31 21:50:35 +0200 | [diff] [blame] | 8 | # List the generated files without running a script, so that this |
| 9 | # works with no tooling dependencies when GEN_FILES is disabled. |
Gilles Peskine | 48230e8 | 2024-03-04 16:42:54 +0100 | [diff] [blame] | 10 | GENERATED_FILES := \ |
Gilles Peskine | b53b443 | 2025-07-31 21:50:35 +0200 | [diff] [blame] | 11 | mbedtls_config_check_before.h \ |
| 12 | mbedtls_config_check_final.h \ |
| 13 | mbedtls_config_check_user.h \ |
Harry Ramsey | 798d8b6 | 2024-10-11 17:09:18 +0100 | [diff] [blame] | 14 | error.c \ |
Harry Ramsey | 468c0ae | 2024-09-27 14:38:53 +0100 | [diff] [blame] | 15 | version_features.c \ |
Gilles Peskine | 67b115c | 2025-07-31 21:50:45 +0200 | [diff] [blame] | 16 | ssl_debug_helpers_generated.c |
| 17 | |
| 18 | # Also list the generated files from crypto that are needed in the build, |
| 19 | # because we don't have the list in a consumable form. |
| 20 | GENERATED_FILES += \ |
Ronald Cron | c29afb6 | 2024-07-01 14:50:54 +0200 | [diff] [blame] | 21 | $(TF_PSA_CRYPTO_CORE_PATH)/psa_crypto_driver_wrappers.h \ |
Gilles Peskine | 67b115c | 2025-07-31 21:50:45 +0200 | [diff] [blame] | 22 | $(TF_PSA_CRYPTO_CORE_PATH)/psa_crypto_driver_wrappers_no_static.c \ |
| 23 | $(TF_PSA_CRYPTO_CORE_PATH)/tf_psa_crypto_config_check_before.h \ |
| 24 | $(TF_PSA_CRYPTO_CORE_PATH)/tf_psa_crypto_config_check_final.h \ |
| 25 | $(TF_PSA_CRYPTO_CORE_PATH)/tf_psa_crypto_config_check_user.h |
Gilles Peskine | 48230e8 | 2024-03-04 16:42:54 +0100 | [diff] [blame] | 26 | |
| 27 | ifneq ($(GENERATED_FILES),$(wildcard $(GENERATED_FILES))) |
| 28 | ifeq (,$(wildcard $(MBEDTLS_PATH)/framework/exported.make)) |
| 29 | # Use the define keyword to get a multi-line message. |
| 30 | # GNU make appends ". Stop.", so tweak the ending of our message accordingly. |
| 31 | define error_message |
Gilles Peskine | f9bbe0d | 2024-03-04 16:25:14 +0100 | [diff] [blame] | 32 | $(MBEDTLS_PATH)/framework/exported.make not found. |
| 33 | Run `git submodule update --init` to fetch the submodule contents. |
| 34 | This is a fatal error |
Gilles Peskine | 48230e8 | 2024-03-04 16:42:54 +0100 | [diff] [blame] | 35 | endef |
| 36 | $(error $(error_message)) |
| 37 | endif |
| 38 | include $(MBEDTLS_PATH)/framework/exported.make |
Gilles Peskine | f9bbe0d | 2024-03-04 16:25:14 +0100 | [diff] [blame] | 39 | endif |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 40 | |
Bence Szépkúti | bb0cfeb | 2021-05-28 09:42:25 +0200 | [diff] [blame] | 41 | # Also see "include/mbedtls/mbedtls_config.h" |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 42 | |
Alon Bar-Lev | f7a9f30 | 2015-02-18 17:55:05 +0200 | [diff] [blame] | 43 | CFLAGS ?= -O2 |
Paul Elliott | 9e3256a | 2020-12-17 18:17:32 +0000 | [diff] [blame] | 44 | WARNING_CFLAGS ?= -Wall -Wextra -Wformat=2 -Wno-format-nonliteral |
Alon Bar-Lev | ada4105 | 2015-02-18 17:47:52 +0200 | [diff] [blame] | 45 | LDFLAGS ?= |
Alon Bar-Lev | f7a9f30 | 2015-02-18 17:55:05 +0200 | [diff] [blame] | 46 | |
Ronald Cron | 3d817ad | 2024-06-14 08:43:28 +0200 | [diff] [blame] | 47 | # Include ../include, ../tf-psa-crypto/include and |
Ronald Cron | c29afb6 | 2024-07-01 14:50:54 +0200 | [diff] [blame] | 48 | # ../tf-psa-crypto/drivers/builtin/include for public headers and ., |
| 49 | # ../tf-psa-crypto/core and ../tf-psa-crypto/drivers/builtin/src for |
| 50 | # private headers. |
| 51 | LOCAL_CFLAGS = $(WARNING_CFLAGS) -I. -I../tf-psa-crypto/core \ |
| 52 | -I../tf-psa-crypto/drivers/builtin/src \ |
| 53 | -I../include -I../tf-psa-crypto/include \ |
Ronald Cron | 3d817ad | 2024-06-14 08:43:28 +0200 | [diff] [blame] | 54 | -I../tf-psa-crypto/drivers/builtin/include -D_FILE_OFFSET_BITS=64 |
Alon Bar-Lev | ada4105 | 2015-02-18 17:47:52 +0200 | [diff] [blame] | 55 | LOCAL_LDFLAGS = |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 56 | |
Paul Bakker | c7ffd36 | 2012-04-05 12:08:29 +0000 | [diff] [blame] | 57 | ifdef DEBUG |
Alon Bar-Lev | f7a9f30 | 2015-02-18 17:55:05 +0200 | [diff] [blame] | 58 | LOCAL_CFLAGS += -g3 |
Paul Bakker | c7ffd36 | 2012-04-05 12:08:29 +0000 | [diff] [blame] | 59 | endif |
| 60 | |
Paul Bakker | ad7eca2 | 2010-03-24 06:46:47 +0000 | [diff] [blame] | 61 | # MicroBlaze specific options: |
| 62 | # CFLAGS += -mno-xl-soft-mul -mxl-barrel-shift |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 63 | |
Paul Bakker | ad7eca2 | 2010-03-24 06:46:47 +0000 | [diff] [blame] | 64 | # To compile on Plan9: |
| 65 | # CFLAGS += -D_BSD_EXTENSION |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 66 | |
Gilles Peskine | 687d1ab | 2021-04-22 01:01:56 +0200 | [diff] [blame] | 67 | PERL ?= perl |
| 68 | |
Jerry Yu | e78ee99 | 2021-09-22 15:42:14 +0800 | [diff] [blame] | 69 | ifdef WINDOWS |
| 70 | PYTHON ?= python |
| 71 | else |
| 72 | PYTHON ?= $(shell if type python3 >/dev/null 2>/dev/null; then echo python3; else echo python; fi) |
| 73 | endif |
| 74 | |
Manuel Pégourié-Gonnard | 02ba578 | 2015-02-18 13:42:26 +0000 | [diff] [blame] | 75 | # if were running on Windows build for Windows |
| 76 | ifdef WINDOWS |
| 77 | WINDOWS_BUILD=1 |
Andres Amaya Garcia | c471cd7 | 2018-06-13 09:28:04 +0100 | [diff] [blame] | 78 | else ifeq ($(shell uname -s),Darwin) |
Andres Amaya Garcia | e3402ce | 2018-06-20 10:43:21 +0100 | [diff] [blame] | 79 | ifeq ($(AR),ar) |
Andres Amaya Garcia | 1d93759 | 2018-06-13 10:04:58 +0100 | [diff] [blame] | 80 | APPLE_BUILD ?= 1 |
Manuel Pégourié-Gonnard | 02ba578 | 2015-02-18 13:42:26 +0000 | [diff] [blame] | 81 | endif |
Manuel Pégourié-Gonnard | 02ba578 | 2015-02-18 13:42:26 +0000 | [diff] [blame] | 82 | endif |
| 83 | |
Minos Galanakis | 24a1c16 | 2023-08-11 14:37:24 +0100 | [diff] [blame] | 84 | ifdef WINDOWS_BUILD |
| 85 | LOCAL_LDFLAGS += -lbcrypt |
| 86 | endif |
| 87 | |
Paul Bakker | ad7eca2 | 2010-03-24 06:46:47 +0000 | [diff] [blame] | 88 | # To compile as a shared library: |
Paul Bakker | 9a73632 | 2012-11-14 12:39:52 +0000 | [diff] [blame] | 89 | ifdef SHARED |
Manuel Pégourié-Gonnard | 3cfb345 | 2015-02-13 13:34:08 +0000 | [diff] [blame] | 90 | # all code is position-indep with mingw, avoid warning about useless flag |
Manuel Pégourié-Gonnard | 02ba578 | 2015-02-18 13:42:26 +0000 | [diff] [blame] | 91 | ifndef WINDOWS_BUILD |
Alon Bar-Lev | f7a9f30 | 2015-02-18 17:55:05 +0200 | [diff] [blame] | 92 | LOCAL_CFLAGS += -fPIC -fpic |
Paul Bakker | 9a73632 | 2012-11-14 12:39:52 +0000 | [diff] [blame] | 93 | endif |
Manuel Pégourié-Gonnard | 3cfb345 | 2015-02-13 13:34:08 +0000 | [diff] [blame] | 94 | endif |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 95 | |
Minos Galanakis | 4492dbd | 2024-03-21 15:52:49 +0000 | [diff] [blame] | 96 | SOEXT_TLS?=so.21 |
Minos Galanakis | 09dc57d | 2025-06-27 09:29:32 +0100 | [diff] [blame] | 97 | SOEXT_X509?=so.8 |
Minos Galanakis | 4492dbd | 2024-03-21 15:52:49 +0000 | [diff] [blame] | 98 | SOEXT_CRYPTO?=so.16 |
Paul Bakker | 33aac37 | 2011-08-13 11:47:41 +0000 | [diff] [blame] | 99 | |
Antonin Décimo | 36e89b5 | 2019-01-23 15:24:37 +0100 | [diff] [blame] | 100 | # Set AR_DASH= (empty string) to use an ar implementation that does not accept |
Andres Amaya Garcia | ceed91b | 2018-03-25 23:48:39 +0100 | [diff] [blame] | 101 | # the - prefix for command line options (e.g. llvm-ar) |
| 102 | AR_DASH ?= - |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 103 | |
Andres Amaya Garcia | c51d613 | 2018-06-19 17:25:34 +0100 | [diff] [blame] | 104 | ARFLAGS = $(AR_DASH)src |
Andres Amaya Garcia | 0e98e88 | 2018-05-23 09:19:54 +0100 | [diff] [blame] | 105 | ifdef APPLE_BUILD |
Andres Amaya Garcia | c51d613 | 2018-06-19 17:25:34 +0100 | [diff] [blame] | 106 | ifneq ($(APPLE_BUILD),0) |
Andres Amaya Garcia | 0e98e88 | 2018-05-23 09:19:54 +0100 | [diff] [blame] | 107 | ARFLAGS = $(AR_DASH)Src |
| 108 | RLFLAGS = -no_warning_for_no_symbols -c |
| 109 | RL ?= ranlib |
Andres Amaya Garcia | c51d613 | 2018-06-19 17:25:34 +0100 | [diff] [blame] | 110 | endif |
Andres Amaya Garcia | 0e98e88 | 2018-05-23 09:19:54 +0100 | [diff] [blame] | 111 | endif |
| 112 | |
Andres Amaya Garcia | c51d613 | 2018-06-19 17:25:34 +0100 | [diff] [blame] | 113 | DLEXT ?= so |
Alon Bar-Lev | 18ba0cc | 2015-02-14 01:04:58 +0200 | [diff] [blame] | 114 | ifdef WINDOWS_BUILD |
Andres Amaya Garcia | 0e98e88 | 2018-05-23 09:19:54 +0100 | [diff] [blame] | 115 | # Windows shared library extension: |
| 116 | DLEXT = dll |
| 117 | else ifdef APPLE_BUILD |
Andres Amaya Garcia | c51d613 | 2018-06-19 17:25:34 +0100 | [diff] [blame] | 118 | ifneq ($(APPLE_BUILD),0) |
Andres Amaya Garcia | 0e98e88 | 2018-05-23 09:19:54 +0100 | [diff] [blame] | 119 | # Mac OS X shared library extension: |
| 120 | DLEXT = dylib |
Paul Bakker | cd5b529 | 2012-05-10 20:49:10 +0000 | [diff] [blame] | 121 | endif |
Paul Bakker | 6083fd2 | 2011-12-03 21:45:14 +0000 | [diff] [blame] | 122 | endif |
Paul Bakker | bdb912d | 2012-02-13 23:11:30 +0000 | [diff] [blame] | 123 | |
Valerio Setti | 06d64ad | 2025-06-20 12:00:16 +0200 | [diff] [blame] | 124 | OBJS_CRYPTO = $(patsubst %.c, %.o,$(wildcard $(TF_PSA_CRYPTO_CORE_PATH)/*.c $(TF_PSA_CRYPTO_DRIVERS_BUILTIN_SRC_PATH)/*.c)) |
| 125 | GENERATED_OBJS_CRYPTO = $(TF_PSA_CRYPTO_CORE_PATH)/psa_crypto_driver_wrappers_no_static.o |
| 126 | OBJS_CRYPTO := $(filter-out $(GENERATED_OBJS_CRYPTO),$(OBJS_CRYPTO)) |
| 127 | OBJS_CRYPTO += $(GENERATED_OBJS_CRYPTO) |
Jaeden Amero | 30b340a | 2018-10-25 17:37:00 +0100 | [diff] [blame] | 128 | |
Ronald Cron | aef8cf3 | 2024-07-01 18:33:24 +0200 | [diff] [blame] | 129 | THIRDPARTY_DIR := $(MBEDTLS_PATH)/tf-psa-crypto/drivers |
| 130 | include $(MBEDTLS_PATH)/tf-psa-crypto/drivers/everest/Makefile.inc |
| 131 | include $(MBEDTLS_PATH)/tf-psa-crypto/drivers/p256-m/Makefile.inc |
Christoph M. Wintersteiger | 62dddd0 | 2018-12-14 13:07:50 +0000 | [diff] [blame] | 132 | LOCAL_CFLAGS+=$(THIRDPARTY_INCLUDES) |
Christoph M. Wintersteiger | 2d4725f | 2019-02-15 13:35:04 +0000 | [diff] [blame] | 133 | OBJS_CRYPTO+=$(THIRDPARTY_CRYPTO_OBJECTS) |
Manuel Pégourié-Gonnard | 463e09d | 2015-06-24 11:54:19 +0200 | [diff] [blame] | 134 | |
Manuel Pégourié-Gonnard | 10a5b53 | 2020-04-03 11:50:59 +0200 | [diff] [blame] | 135 | OBJS_X509= \ |
Gilles Peskine | 018e098 | 2025-07-09 16:16:45 +0200 | [diff] [blame] | 136 | mbedtls_config.o \ |
Manuel Pégourié-Gonnard | 10a5b53 | 2020-04-03 11:50:59 +0200 | [diff] [blame] | 137 | x509.o \ |
| 138 | x509_create.o \ |
| 139 | x509_crl.o \ |
| 140 | x509_crt.o \ |
| 141 | x509_csr.o \ |
Gilles Peskine | d2fe51c | 2025-05-07 20:36:20 +0200 | [diff] [blame] | 142 | x509_oid.o \ |
Gilles Peskine | 0b62b7a | 2023-09-08 16:19:13 +0200 | [diff] [blame] | 143 | x509write.o \ |
Manuel Pégourié-Gonnard | 10a5b53 | 2020-04-03 11:50:59 +0200 | [diff] [blame] | 144 | x509write_crt.o \ |
| 145 | x509write_csr.o \ |
Nayna Jain | c9deb18 | 2020-11-16 19:03:12 +0000 | [diff] [blame] | 146 | pkcs7.o \ |
Harry Ramsey | 331f084 | 2024-10-22 10:27:08 +0100 | [diff] [blame] | 147 | error.o \ |
Manuel Pégourié-Gonnard | 10a5b53 | 2020-04-03 11:50:59 +0200 | [diff] [blame] | 148 | # This line is intentionally left blank |
Manuel Pégourié-Gonnard | 463e09d | 2015-06-24 11:54:19 +0200 | [diff] [blame] | 149 | |
Manuel Pégourié-Gonnard | 10a5b53 | 2020-04-03 11:50:59 +0200 | [diff] [blame] | 150 | OBJS_TLS= \ |
| 151 | debug.o \ |
Gilles Peskine | 89e31ad | 2022-11-26 14:18:45 +0100 | [diff] [blame] | 152 | mps_reader.o \ |
| 153 | mps_trace.o \ |
Manuel Pégourié-Gonnard | 10a5b53 | 2020-04-03 11:50:59 +0200 | [diff] [blame] | 154 | net_sockets.o \ |
| 155 | ssl_cache.o \ |
| 156 | ssl_ciphersuites.o \ |
Ronald Cron | 3d580bf | 2022-02-18 17:24:56 +0100 | [diff] [blame] | 157 | ssl_client.o \ |
Manuel Pégourié-Gonnard | 10a5b53 | 2020-04-03 11:50:59 +0200 | [diff] [blame] | 158 | ssl_cookie.o \ |
Gilles Peskine | 898db6b | 2022-11-26 14:15:32 +0100 | [diff] [blame] | 159 | ssl_debug_helpers_generated.o \ |
Manuel Pégourié-Gonnard | 10a5b53 | 2020-04-03 11:50:59 +0200 | [diff] [blame] | 160 | ssl_msg.o \ |
Manuel Pégourié-Gonnard | 10a5b53 | 2020-04-03 11:50:59 +0200 | [diff] [blame] | 161 | ssl_ticket.o \ |
| 162 | ssl_tls.o \ |
Ronald Cron | de1adee | 2022-03-07 16:20:30 +0100 | [diff] [blame] | 163 | ssl_tls12_client.o \ |
| 164 | ssl_tls12_server.o \ |
Hanno Becker | be9d664 | 2020-08-21 13:20:06 +0100 | [diff] [blame] | 165 | ssl_tls13_keys.o \ |
Jerry Yu | 3cc4c2a | 2021-08-06 16:29:08 +0800 | [diff] [blame] | 166 | ssl_tls13_client.o \ |
| 167 | ssl_tls13_server.o \ |
Jerry Yu | 65dd2cc | 2021-08-18 16:38:40 +0800 | [diff] [blame] | 168 | ssl_tls13_generic.o \ |
Ronald Cron | 6924564 | 2024-11-12 18:14:23 +0100 | [diff] [blame] | 169 | timing.o \ |
Harry Ramsey | 468c0ae | 2024-09-27 14:38:53 +0100 | [diff] [blame] | 170 | version.o \ |
| 171 | version_features.o \ |
Manuel Pégourié-Gonnard | 10a5b53 | 2020-04-03 11:50:59 +0200 | [diff] [blame] | 172 | # This line is intentionally left blank |
Manuel Pégourié-Gonnard | 463e09d | 2015-06-24 11:54:19 +0200 | [diff] [blame] | 173 | |
Paul Bakker | ad7eca2 | 2010-03-24 06:46:47 +0000 | [diff] [blame] | 174 | .SILENT: |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 175 | |
Manuel Pégourié-Gonnard | 5c59a4f | 2015-06-24 13:06:24 +0200 | [diff] [blame] | 176 | .PHONY: all static shared clean |
| 177 | |
Paul Bakker | 9a73632 | 2012-11-14 12:39:52 +0000 | [diff] [blame] | 178 | ifndef SHARED |
Paul Bakker | 3783d6d | 2011-07-13 11:25:36 +0000 | [diff] [blame] | 179 | all: static |
Paul Bakker | 9a73632 | 2012-11-14 12:39:52 +0000 | [diff] [blame] | 180 | else |
Manuel Pégourié-Gonnard | 04a81d5 | 2015-01-27 11:24:05 +0100 | [diff] [blame] | 181 | all: shared static |
Paul Bakker | 9a73632 | 2012-11-14 12:39:52 +0000 | [diff] [blame] | 182 | endif |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 183 | |
Manuel Pégourié-Gonnard | 5c59a4f | 2015-06-24 13:06:24 +0200 | [diff] [blame] | 184 | static: libmbedcrypto.a libmbedx509.a libmbedtls.a |
Andrzej Kurek | 9387b7b | 2022-10-04 08:06:59 -0400 | [diff] [blame] | 185 | cd ../tests && echo "This is a seedfile that contains 64 bytes (65 on Windows)......" > seedfile |
Ronald Cron | 901a675 | 2024-07-09 14:24:16 +0200 | [diff] [blame] | 186 | cd ../tf-psa-crypto/tests && echo "This is a seedfile that contains 64 bytes (65 on Windows)......" > seedfile |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 187 | |
Manuel Pégourié-Gonnard | 5c59a4f | 2015-06-24 13:06:24 +0200 | [diff] [blame] | 188 | shared: libmbedcrypto.$(DLEXT) libmbedx509.$(DLEXT) libmbedtls.$(DLEXT) |
Manuel Pégourié-Gonnard | c26a092 | 2015-01-23 12:51:33 +0000 | [diff] [blame] | 189 | |
Tom Cosgrove | 0eedd36 | 2021-11-10 11:15:46 +0000 | [diff] [blame] | 190 | # Windows builds under Mingw can fail if make tries to create archives in the same |
| 191 | # directory at the same time - see https://bugs.launchpad.net/gcc-arm-embedded/+bug/1848002. |
| 192 | # This forces builds of the .a files to be serialised. |
| 193 | ifdef WINDOWS |
| 194 | libmbedtls.a: | libmbedx509.a |
| 195 | libmbedx509.a: | libmbedcrypto.a |
| 196 | endif |
| 197 | |
Manuel Pégourié-Gonnard | 5c59a4f | 2015-06-24 13:06:24 +0200 | [diff] [blame] | 198 | # tls |
| 199 | libmbedtls.a: $(OBJS_TLS) |
Paul Bakker | ad7eca2 | 2010-03-24 06:46:47 +0000 | [diff] [blame] | 200 | echo " AR $@" |
Andres Amaya Garcia | 0e98e88 | 2018-05-23 09:19:54 +0100 | [diff] [blame] | 201 | $(AR) $(ARFLAGS) $@ $(OBJS_TLS) |
| 202 | ifdef APPLE_BUILD |
Andres Amaya Garcia | c51d613 | 2018-06-19 17:25:34 +0100 | [diff] [blame] | 203 | ifneq ($(APPLE_BUILD),0) |
Paul Bakker | ad7eca2 | 2010-03-24 06:46:47 +0000 | [diff] [blame] | 204 | echo " RL $@" |
Andres Amaya Garcia | 0e98e88 | 2018-05-23 09:19:54 +0100 | [diff] [blame] | 205 | $(RL) $(RLFLAGS) $@ |
| 206 | endif |
Andres Amaya Garcia | c51d613 | 2018-06-19 17:25:34 +0100 | [diff] [blame] | 207 | endif |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 208 | |
Manuel Pégourié-Gonnard | ed46c43 | 2015-08-10 10:17:32 +0200 | [diff] [blame] | 209 | libmbedtls.$(SOEXT_TLS): $(OBJS_TLS) libmbedx509.so |
Paul Bakker | ad7eca2 | 2010-03-24 06:46:47 +0000 | [diff] [blame] | 210 | echo " LD $@" |
Harmen Stoppels | fcb4fb7 | 2021-11-04 17:33:51 +0100 | [diff] [blame] | 211 | $(CC) -shared -Wl,-soname,$@ -o $@ $(OBJS_TLS) -L. -lmbedx509 -lmbedcrypto $(LOCAL_LDFLAGS) $(LDFLAGS) |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 212 | |
Mansour Moufid | 6a86730 | 2022-06-29 17:28:03 -0400 | [diff] [blame] | 213 | ifneq ($(SOEXT_TLS),so) |
Manuel Pégourié-Gonnard | 752c501 | 2015-06-25 11:54:52 +0200 | [diff] [blame] | 214 | libmbedtls.so: libmbedtls.$(SOEXT_TLS) |
| 215 | echo " LN $@ -> $<" |
| 216 | ln -sf $< $@ |
Mansour Moufid | 6a86730 | 2022-06-29 17:28:03 -0400 | [diff] [blame] | 217 | endif |
Paul Bakker | b076314 | 2013-11-05 11:27:12 +0100 | [diff] [blame] | 218 | |
Mitsuhiro Nakamura | 5ff2ee5 | 2018-02-20 11:58:19 +0900 | [diff] [blame] | 219 | libmbedtls.dylib: $(OBJS_TLS) libmbedx509.dylib |
Paul Bakker | ad7eca2 | 2010-03-24 06:46:47 +0000 | [diff] [blame] | 220 | echo " LD $@" |
Harmen Stoppels | fcb4fb7 | 2021-11-04 17:33:51 +0100 | [diff] [blame] | 221 | $(CC) -dynamiclib -o $@ $(OBJS_TLS) -L. -lmbedx509 -lmbedcrypto $(LOCAL_LDFLAGS) $(LDFLAGS) |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 222 | |
Manuel Pégourié-Gonnard | 111ce9f | 2015-08-07 12:07:16 +0200 | [diff] [blame] | 223 | libmbedtls.dll: $(OBJS_TLS) libmbedx509.dll |
Paul Bakker | b076314 | 2013-11-05 11:27:12 +0100 | [diff] [blame] | 224 | echo " LD $@" |
Harmen Stoppels | fcb4fb7 | 2021-11-04 17:33:51 +0100 | [diff] [blame] | 225 | $(CC) -shared -Wl,-soname,$@ -Wl,--out-implib,$@.a -o $@ $(OBJS_TLS) -lws2_32 -lwinmm -lgdi32 -L. -lmbedx509 -lmbedcrypto -static-libgcc $(LOCAL_LDFLAGS) $(LDFLAGS) |
Manuel Pégourié-Gonnard | 5c59a4f | 2015-06-24 13:06:24 +0200 | [diff] [blame] | 226 | |
| 227 | # x509 |
| 228 | libmbedx509.a: $(OBJS_X509) |
| 229 | echo " AR $@" |
Andres Amaya Garcia | 0e98e88 | 2018-05-23 09:19:54 +0100 | [diff] [blame] | 230 | $(AR) $(ARFLAGS) $@ $(OBJS_X509) |
| 231 | ifdef APPLE_BUILD |
Andres Amaya Garcia | c51d613 | 2018-06-19 17:25:34 +0100 | [diff] [blame] | 232 | ifneq ($(APPLE_BUILD),0) |
Manuel Pégourié-Gonnard | 5c59a4f | 2015-06-24 13:06:24 +0200 | [diff] [blame] | 233 | echo " RL $@" |
Andres Amaya Garcia | 0e98e88 | 2018-05-23 09:19:54 +0100 | [diff] [blame] | 234 | $(RL) $(RLFLAGS) $@ |
| 235 | endif |
Andres Amaya Garcia | c51d613 | 2018-06-19 17:25:34 +0100 | [diff] [blame] | 236 | endif |
Manuel Pégourié-Gonnard | 5c59a4f | 2015-06-24 13:06:24 +0200 | [diff] [blame] | 237 | |
Gilles Peskine | 722a7e6 | 2020-02-26 19:05:19 +0100 | [diff] [blame] | 238 | libmbedx509.$(SOEXT_X509): $(OBJS_X509) libmbedcrypto.so |
Manuel Pégourié-Gonnard | 5c59a4f | 2015-06-24 13:06:24 +0200 | [diff] [blame] | 239 | echo " LD $@" |
Harmen Stoppels | 01ef723 | 2021-11-03 00:53:05 +0100 | [diff] [blame] | 240 | $(CC) -shared -Wl,-soname,$@ -o $@ $(OBJS_X509) -L. -lmbedcrypto $(LOCAL_LDFLAGS) $(LDFLAGS) |
Manuel Pégourié-Gonnard | 5c59a4f | 2015-06-24 13:06:24 +0200 | [diff] [blame] | 241 | |
Mansour Moufid | 6a86730 | 2022-06-29 17:28:03 -0400 | [diff] [blame] | 242 | ifneq ($(SOEXT_X509),so) |
Manuel Pégourié-Gonnard | 752c501 | 2015-06-25 11:54:52 +0200 | [diff] [blame] | 243 | libmbedx509.so: libmbedx509.$(SOEXT_X509) |
| 244 | echo " LN $@ -> $<" |
| 245 | ln -sf $< $@ |
Mansour Moufid | 6a86730 | 2022-06-29 17:28:03 -0400 | [diff] [blame] | 246 | endif |
Manuel Pégourié-Gonnard | 5c59a4f | 2015-06-24 13:06:24 +0200 | [diff] [blame] | 247 | |
Gilles Peskine | 722a7e6 | 2020-02-26 19:05:19 +0100 | [diff] [blame] | 248 | libmbedx509.dylib: $(OBJS_X509) libmbedcrypto.dylib |
Manuel Pégourié-Gonnard | 5c59a4f | 2015-06-24 13:06:24 +0200 | [diff] [blame] | 249 | echo " LD $@" |
Harmen Stoppels | 01ef723 | 2021-11-03 00:53:05 +0100 | [diff] [blame] | 250 | $(CC) -dynamiclib -o $@ $(OBJS_X509) -L. -lmbedcrypto $(LOCAL_LDFLAGS) $(LDFLAGS) |
Manuel Pégourié-Gonnard | 5c59a4f | 2015-06-24 13:06:24 +0200 | [diff] [blame] | 251 | |
Gilles Peskine | 722a7e6 | 2020-02-26 19:05:19 +0100 | [diff] [blame] | 252 | libmbedx509.dll: $(OBJS_X509) libmbedcrypto.dll |
Manuel Pégourié-Gonnard | 5c59a4f | 2015-06-24 13:06:24 +0200 | [diff] [blame] | 253 | echo " LD $@" |
Manuel Pégourié-Gonnard | 111ce9f | 2015-08-07 12:07:16 +0200 | [diff] [blame] | 254 | $(CC) -shared -Wl,-soname,$@ -Wl,--out-implib,$@.a -o $@ $(OBJS_X509) -lws2_32 -lwinmm -lgdi32 -L. -lmbedcrypto -static-libgcc $(LOCAL_LDFLAGS) $(LDFLAGS) |
Manuel Pégourié-Gonnard | 5c59a4f | 2015-06-24 13:06:24 +0200 | [diff] [blame] | 255 | |
| 256 | # crypto |
| 257 | libmbedcrypto.a: $(OBJS_CRYPTO) |
| 258 | echo " AR $@" |
Andres Amaya Garcia | 0e98e88 | 2018-05-23 09:19:54 +0100 | [diff] [blame] | 259 | $(AR) $(ARFLAGS) $@ $(OBJS_CRYPTO) |
| 260 | ifdef APPLE_BUILD |
Andres Amaya Garcia | c51d613 | 2018-06-19 17:25:34 +0100 | [diff] [blame] | 261 | ifneq ($(APPLE_BUILD),0) |
Manuel Pégourié-Gonnard | 5c59a4f | 2015-06-24 13:06:24 +0200 | [diff] [blame] | 262 | echo " RL $@" |
Andres Amaya Garcia | 0e98e88 | 2018-05-23 09:19:54 +0100 | [diff] [blame] | 263 | $(RL) $(RLFLAGS) $@ |
| 264 | endif |
Andres Amaya Garcia | c51d613 | 2018-06-19 17:25:34 +0100 | [diff] [blame] | 265 | endif |
Paul Bakker | a585beb | 2011-06-21 08:59:44 +0000 | [diff] [blame] | 266 | |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 267 | libmbedcrypto.$(SOEXT_CRYPTO): $(OBJS_CRYPTO) |
Paul Bakker | 62f88dc | 2012-05-10 21:26:28 +0000 | [diff] [blame] | 268 | echo " LD $@" |
Harmen Stoppels | 01ef723 | 2021-11-03 00:53:05 +0100 | [diff] [blame] | 269 | $(CC) -shared -Wl,-soname,$@ -o $@ $(OBJS_CRYPTO) $(LOCAL_LDFLAGS) $(LDFLAGS) |
Andrzej Kurek | 8af3923 | 2019-10-07 09:19:18 -0400 | [diff] [blame] | 270 | |
Mansour Moufid | 6a86730 | 2022-06-29 17:28:03 -0400 | [diff] [blame] | 271 | ifneq ($(SOEXT_CRYPTO),so) |
Paul Bakker | 62f88dc | 2012-05-10 21:26:28 +0000 | [diff] [blame] | 272 | libmbedcrypto.so: libmbedcrypto.$(SOEXT_CRYPTO) |
Manuel Pégourié-Gonnard | c26a092 | 2015-01-23 12:51:33 +0000 | [diff] [blame] | 273 | echo " LN $@ -> $<" |
Paul Bakker | 62f88dc | 2012-05-10 21:26:28 +0000 | [diff] [blame] | 274 | ln -sf $< $@ |
Mansour Moufid | 6a86730 | 2022-06-29 17:28:03 -0400 | [diff] [blame] | 275 | endif |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 276 | |
| 277 | libmbedcrypto.dylib: $(OBJS_CRYPTO) |
| 278 | echo " LD $@" |
Harmen Stoppels | 01ef723 | 2021-11-03 00:53:05 +0100 | [diff] [blame] | 279 | $(CC) -dynamiclib -o $@ $(OBJS_CRYPTO) $(LOCAL_LDFLAGS) $(LDFLAGS) |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 280 | |
| 281 | libmbedcrypto.dll: $(OBJS_CRYPTO) |
| 282 | echo " LD $@" |
Minos Galanakis | 24a1c16 | 2023-08-11 14:37:24 +0100 | [diff] [blame] | 283 | $(CC) -shared -Wl,-soname,$@ -Wl,--out-implib,$@.a -o $@ $(OBJS_CRYPTO) -lws2_32 -lwinmm -lgdi32 -static-libgcc $(LOCAL_LDFLAGS) $(LDFLAGS) |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 284 | |
| 285 | .c.o: |
| 286 | echo " CC $<" |
Christoph M. Wintersteiger | 977d89a | 2018-10-25 12:47:03 +0100 | [diff] [blame] | 287 | $(CC) $(LOCAL_CFLAGS) $(CFLAGS) -o $@ -c $< |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 288 | |
Gilles Peskine | f6b3c62 | 2024-06-19 14:15:12 +0200 | [diff] [blame] | 289 | .c.s: |
| 290 | echo " CC $<" |
| 291 | $(CC) $(LOCAL_CFLAGS) $(CFLAGS) -S -o $@ -c $< |
| 292 | |
Gilles Peskine | 687d1ab | 2021-04-22 01:01:56 +0200 | [diff] [blame] | 293 | .PHONY: generated_files |
Gilles Peskine | 687d1ab | 2021-04-22 01:01:56 +0200 | [diff] [blame] | 294 | generated_files: $(GENERATED_FILES) |
| 295 | |
Gilles Peskine | 0b62b7a | 2023-09-08 16:19:13 +0200 | [diff] [blame] | 296 | # See root Makefile |
Minos Galanakis | 9860056 | 2024-03-27 13:51:15 +0000 | [diff] [blame] | 297 | GEN_FILES ?= yes |
Gilles Peskine | 0b62b7a | 2023-09-08 16:19:13 +0200 | [diff] [blame] | 298 | ifdef GEN_FILES |
| 299 | gen_file_dep = |
| 300 | else |
| 301 | gen_file_dep = | |
| 302 | endif |
| 303 | |
Harry Ramsey | 798d8b6 | 2024-10-11 17:09:18 +0100 | [diff] [blame] | 304 | error.c: $(gen_file_dep) ../scripts/generate_errors.pl |
| 305 | error.c: $(gen_file_dep) ../scripts/data_files/error.fmt |
| 306 | error.c: $(gen_file_dep) $(filter-out %config%,$(wildcard ../include/mbedtls/*.h)) |
| 307 | error.c: |
Gilles Peskine | 687d1ab | 2021-04-22 01:01:56 +0200 | [diff] [blame] | 308 | echo " Gen $@" |
| 309 | $(PERL) ../scripts/generate_errors.pl |
| 310 | |
Elena Uziunaite | 09fee36 | 2024-10-07 17:40:21 +0100 | [diff] [blame] | 311 | ssl_debug_helpers_generated.c: $(gen_file_dep) ../framework/scripts/generate_ssl_debug_helpers.py |
Gilles Peskine | 0b62b7a | 2023-09-08 16:19:13 +0200 | [diff] [blame] | 312 | ssl_debug_helpers_generated.c: $(gen_file_dep) $(filter-out %config%,$(wildcard ../include/mbedtls/*.h)) |
Gilles Peskine | ccbc318 | 2021-12-15 12:55:37 +0100 | [diff] [blame] | 313 | ssl_debug_helpers_generated.c: |
Jerry Yu | e78ee99 | 2021-09-22 15:42:14 +0800 | [diff] [blame] | 314 | echo " Gen $@" |
Elena Uziunaite | 09fee36 | 2024-10-07 17:40:21 +0100 | [diff] [blame] | 315 | $(PYTHON) ../framework/scripts/generate_ssl_debug_helpers.py --mbedtls-root .. . |
Jerry Yu | e78ee99 | 2021-09-22 15:42:14 +0800 | [diff] [blame] | 316 | |
Harry Ramsey | 468c0ae | 2024-09-27 14:38:53 +0100 | [diff] [blame] | 317 | version_features.c: $(gen_file_dep) ../scripts/generate_features.pl |
| 318 | version_features.c: $(gen_file_dep) ../scripts/data_files/version_features.fmt |
Bence Szépkúti | bb0cfeb | 2021-05-28 09:42:25 +0200 | [diff] [blame] | 319 | ## The generated file only depends on the options that are present in mbedtls_config.h, |
Gilles Peskine | 1411c7c | 2021-04-22 14:50:16 +0200 | [diff] [blame] | 320 | ## not on which options are set. To avoid regenerating this file all the time |
Bence Szépkúti | bb0cfeb | 2021-05-28 09:42:25 +0200 | [diff] [blame] | 321 | ## when switching between configurations, don't declare mbedtls_config.h as a |
Gilles Peskine | 1411c7c | 2021-04-22 14:50:16 +0200 | [diff] [blame] | 322 | ## dependency. Remove this file from your working tree if you've just added or |
Bence Szépkúti | bb0cfeb | 2021-05-28 09:42:25 +0200 | [diff] [blame] | 323 | ## removed an option in mbedtls_config.h. |
| 324 | #version_features.c: ../include/mbedtls/mbedtls_config.h |
Harry Ramsey | 468c0ae | 2024-09-27 14:38:53 +0100 | [diff] [blame] | 325 | version_features.c: |
Gilles Peskine | 687d1ab | 2021-04-22 01:01:56 +0200 | [diff] [blame] | 326 | echo " Gen $@" |
| 327 | $(PERL) ../scripts/generate_features.pl |
| 328 | |
Xiaokang Qian | 54a4fdf | 2023-09-11 02:39:27 +0000 | [diff] [blame] | 329 | GENERATED_WRAPPER_FILES = \ |
Ronald Cron | c29afb6 | 2024-07-01 14:50:54 +0200 | [diff] [blame] | 330 | $(TF_PSA_CRYPTO_CORE_PATH)/psa_crypto_driver_wrappers.h \ |
| 331 | $(TF_PSA_CRYPTO_CORE_PATH)/psa_crypto_driver_wrappers_no_static.c |
Ronald Cron | 6a2cbe7 | 2024-11-13 09:20:30 +0100 | [diff] [blame] | 332 | $(GENERATED_WRAPPER_FILES): ../tf-psa-crypto/scripts/generate_driver_wrappers.py |
| 333 | $(GENERATED_WRAPPER_FILES): ../tf-psa-crypto/scripts/data_files/driver_templates/psa_crypto_driver_wrappers.h.jinja |
| 334 | $(GENERATED_WRAPPER_FILES): ../tf-psa-crypto/scripts/data_files/driver_templates/psa_crypto_driver_wrappers_no_static.c.jinja |
Xiaokang Qian | 54a4fdf | 2023-09-11 02:39:27 +0000 | [diff] [blame] | 335 | $(GENERATED_WRAPPER_FILES): |
| 336 | echo " Gen $(GENERATED_WRAPPER_FILES)" |
Ronald Cron | 6a2cbe7 | 2024-11-13 09:20:30 +0100 | [diff] [blame] | 337 | $(PYTHON) ../tf-psa-crypto/scripts/generate_driver_wrappers.py $(TF_PSA_CRYPTO_CORE_PATH) |
Archana | 1f1a34a | 2021-11-17 08:44:07 +0530 | [diff] [blame] | 338 | |
Ronald Cron | c29afb6 | 2024-07-01 14:50:54 +0200 | [diff] [blame] | 339 | $(TF_PSA_CRYPTO_CORE_PATH)/psa_crypto.o:$(TF_PSA_CRYPTO_CORE_PATH)/psa_crypto_driver_wrappers.h |
Xiaokang Qian | 0e5b53c | 2023-09-12 10:31:20 +0000 | [diff] [blame] | 340 | |
Gilles Peskine | b53b443 | 2025-07-31 21:50:35 +0200 | [diff] [blame] | 341 | GENERATED_CONFIG_CHECK_FILES = $(shell $(PYTHON) ../scripts/generate_config_checks.py --list .) |
| 342 | $(GENERATED_CONFIG_CHECK_FILES): $(gen_file_dep) \ |
| 343 | $(TF_PSA_CRYPTO_CORE_PATH)/../scripts/generate_config_checks.py \ |
| 344 | ../framework/scripts/mbedtls_framework/config_checks_generator.py |
| 345 | $(GENERATED_CONFIG_CHECK_FILES): |
| 346 | echo " Gen $(GENERATED_CONFIG_CHECK_FILES)" |
| 347 | $(PYTHON) ../scripts/generate_config_checks.py |
| 348 | |
Gilles Peskine | 67b115c | 2025-07-31 21:50:45 +0200 | [diff] [blame] | 349 | TF_PSA_CRYPTO_GENERATED_CONFIG_CHECK_FILES = $(shell $(PYTHON) \ |
| 350 | $(TF_PSA_CRYPTO_CORE_PATH)/../scripts/generate_config_checks.py \ |
| 351 | --list $(TF_PSA_CRYPTO_CORE_PATH)) |
| 352 | $(TF_PSA_CRYPTO_GENERATED_CONFIG_CHECK_FILES): $(gen_file_dep) \ |
| 353 | ../scripts/generate_config_checks.py \ |
| 354 | ../framework/scripts/mbedtls_framework/config_checks_generator.py |
| 355 | $(TF_PSA_CRYPTO_GENERATED_CONFIG_CHECK_FILES): |
| 356 | echo " Gen $(TF_PSA_CRYPTO_GENERATED_CONFIG_CHECK_FILES)" |
| 357 | $(PYTHON) $(TF_PSA_CRYPTO_CORE_PATH)/../scripts/generate_config_checks.py |
| 358 | |
Gilles Peskine | d57a098 | 2025-09-22 15:51:35 +0200 | [diff] [blame] | 359 | $(TF_PSA_CRYPTO_CORE_PATH)/tf_psa_crypto_config.o: $(TF_PSA_CRYPTO_GENERATED_CONFIG_CHECK_FILES) |
| 360 | |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 361 | clean: |
| 362 | ifndef WINDOWS |
Gilles Peskine | 10f1a24 | 2024-06-20 18:17:55 +0200 | [diff] [blame] | 363 | rm -f *.o *.s libmbed* |
| 364 | rm -f $(OBJS_CRYPTO) $(OBJS_CRYPTO:.o=.s) |
Manuel Pégourié-Gonnard | 5c59a4f | 2015-06-24 13:06:24 +0200 | [diff] [blame] | 365 | else |
Darryl Green | 9b9a790 | 2019-08-30 14:51:55 +0100 | [diff] [blame] | 366 | if exist *.o del /Q /F *.o |
Gilles Peskine | 10f1a24 | 2024-06-20 18:17:55 +0200 | [diff] [blame] | 367 | if exist *.s del /Q /F *.s |
Darryl Green | 9b9a790 | 2019-08-30 14:51:55 +0100 | [diff] [blame] | 368 | if exist libmbed* del /Q /F libmbed* |
Ronald Cron | 088a1ab | 2024-07-12 08:02:49 +0200 | [diff] [blame] | 369 | del /Q /F del_errors_out_if_the_file_list_is_empty_but_not_if_a_file_does_not_exist $(subst /,\,$(OBJS_CRYPTO)) |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 370 | endif |
Gilles Peskine | 687d1ab | 2021-04-22 01:01:56 +0200 | [diff] [blame] | 371 | |
| 372 | neat: clean |
| 373 | ifndef WINDOWS |
| 374 | rm -f $(GENERATED_FILES) |
| 375 | else |
| 376 | for %f in ($(subst /,\,$(GENERATED_FILES))) if exist %f del /Q /F %f |
| 377 | endif |