2009-01-03 21:22:43 +00:00
|
|
|
DESTDIR=/usr/local
|
2015-01-27 13:05:16 +00:00
|
|
|
PREFIX=mbedtls_
|
2021-04-21 23:01:56 +00:00
|
|
|
PERL ?= perl
|
2009-01-03 21:22:43 +00:00
|
|
|
|
2024-03-04 15:42:54 +00:00
|
|
|
ifneq (,$(filter-out lib library/%,$(or $(MAKECMDGOALS),all)))
|
|
|
|
ifeq (,$(wildcard framework/exported.make))
|
|
|
|
# Use the define keyword to get a multi-line message.
|
|
|
|
# GNU make appends ". Stop.", so tweak the ending of our message accordingly.
|
|
|
|
define error_message
|
|
|
|
$(MBEDTLS_PATH)/framework/exported.make not found.
|
|
|
|
Run `git submodule update --init` to fetch the submodule contents.
|
|
|
|
This is a fatal error
|
|
|
|
endef
|
|
|
|
$(error $(error_message))
|
|
|
|
endif
|
|
|
|
include framework/exported.make
|
|
|
|
endif
|
2024-02-29 17:19:56 +00:00
|
|
|
|
2009-01-03 21:22:43 +00:00
|
|
|
.SILENT:
|
|
|
|
|
2022-12-08 21:18:31 +00:00
|
|
|
.PHONY: all no_test programs lib tests install uninstall clean test check lcov apidoc apidoc_clean
|
2009-01-03 21:22:43 +00:00
|
|
|
|
2016-08-25 15:36:16 +00:00
|
|
|
all: programs tests
|
|
|
|
$(MAKE) post_build
|
2015-02-18 15:18:28 +00:00
|
|
|
|
2015-06-24 11:06:24 +00:00
|
|
|
no_test: programs
|
|
|
|
|
2020-06-19 09:27:26 +00:00
|
|
|
programs: lib mbedtls_test
|
2015-02-18 15:18:28 +00:00
|
|
|
$(MAKE) -C programs
|
2012-04-05 12:07:50 +00:00
|
|
|
|
|
|
|
lib:
|
2015-02-18 15:18:28 +00:00
|
|
|
$(MAKE) -C library
|
|
|
|
|
2024-06-27 06:00:54 +00:00
|
|
|
ifndef PSASIM
|
|
|
|
tests: lib
|
|
|
|
endif
|
|
|
|
tests: mbedtls_test
|
2015-02-18 15:18:28 +00:00
|
|
|
$(MAKE) -C tests
|
2012-04-05 12:07:50 +00:00
|
|
|
|
2020-06-19 09:27:26 +00:00
|
|
|
mbedtls_test:
|
|
|
|
$(MAKE) -C tests mbedtls_test
|
|
|
|
|
2021-04-21 23:01:56 +00:00
|
|
|
library/%:
|
|
|
|
$(MAKE) -C library $*
|
|
|
|
programs/%:
|
|
|
|
$(MAKE) -C programs $*
|
|
|
|
tests/%:
|
|
|
|
$(MAKE) -C tests $*
|
|
|
|
|
|
|
|
.PHONY: generated_files
|
|
|
|
generated_files: library/generated_files
|
|
|
|
generated_files: programs/generated_files
|
|
|
|
generated_files: tests/generated_files
|
|
|
|
generated_files: visualc_files
|
|
|
|
|
2023-09-08 14:19:13 +00:00
|
|
|
# Set GEN_FILES to the empty string to disable dependencies on generated
|
|
|
|
# source files. Then `make generated_files` will only build files that
|
|
|
|
# are missing, it will not rebuilt files that are present but out of date.
|
|
|
|
# This is useful, for example, if you have a source tree where
|
|
|
|
# `make generated_files` has already run and file timestamps reflect the
|
|
|
|
# time the files were copied or extracted, and you are now in an environment
|
|
|
|
# that lacks some of the necessary tools to re-generate the files.
|
|
|
|
# If $(GEN_FILES) is non-empty, the generated source files' dependencies
|
|
|
|
# are treated ordinarily, based on file timestamps.
|
|
|
|
GEN_FILES ?= yes
|
|
|
|
|
|
|
|
# In dependencies where the target is a configuration-independent generated
|
|
|
|
# file, use `TARGET: $(gen_file_dep) DEPENDENCY1 DEPENDENCY2 ...`
|
|
|
|
# rather than directly `TARGET: DEPENDENCY1 DEPENDENCY2 ...`. This
|
|
|
|
# enables the re-generation to be turned off when GEN_FILES is disabled.
|
|
|
|
ifdef GEN_FILES
|
|
|
|
gen_file_dep =
|
|
|
|
else
|
2023-09-09 19:26:05 +00:00
|
|
|
# Order-only dependency: generate the target if it's absent, but don't
|
|
|
|
# re-generate it if it's present but older than its dependencies.
|
2023-09-08 14:19:13 +00:00
|
|
|
gen_file_dep = |
|
|
|
|
endif
|
|
|
|
|
2021-04-21 23:01:56 +00:00
|
|
|
.PHONY: visualc_files
|
2024-03-12 15:38:23 +00:00
|
|
|
VISUALC_FILES = visualc/VS2017/mbedTLS.sln visualc/VS2017/mbedTLS.vcxproj
|
2021-04-21 23:01:56 +00:00
|
|
|
# TODO: $(app).vcxproj for each $(app) in programs/
|
|
|
|
visualc_files: $(VISUALC_FILES)
|
2021-05-18 13:48:56 +00:00
|
|
|
|
|
|
|
# Ensure that the .c files that generate_visualc_files.pl enumerates are
|
2021-05-19 12:26:37 +00:00
|
|
|
# present before it runs. It doesn't matter if the files aren't up-to-date,
|
|
|
|
# they just need to be present.
|
|
|
|
$(VISUALC_FILES): | library/generated_files
|
2023-09-08 14:19:13 +00:00
|
|
|
$(VISUALC_FILES): $(gen_file_dep) scripts/generate_visualc_files.pl
|
2024-03-12 15:38:23 +00:00
|
|
|
$(VISUALC_FILES): $(gen_file_dep) scripts/data_files/vs2017-app-template.vcxproj
|
|
|
|
$(VISUALC_FILES): $(gen_file_dep) scripts/data_files/vs2017-main-template.vcxproj
|
|
|
|
$(VISUALC_FILES): $(gen_file_dep) scripts/data_files/vs2017-sln-template.sln
|
2021-04-21 23:01:56 +00:00
|
|
|
# TODO: also the list of .c and .h source files, but not their content
|
|
|
|
$(VISUALC_FILES):
|
|
|
|
echo " Gen $@ ..."
|
|
|
|
$(PERL) scripts/generate_visualc_files.pl
|
|
|
|
|
2015-06-24 11:06:24 +00:00
|
|
|
ifndef WINDOWS
|
2015-08-03 08:34:09 +00:00
|
|
|
install: no_test
|
2015-03-09 17:05:11 +00:00
|
|
|
mkdir -p $(DESTDIR)/include/mbedtls
|
2018-06-28 15:21:26 +00:00
|
|
|
cp -rp include/mbedtls $(DESTDIR)/include
|
2024-06-17 12:25:26 +00:00
|
|
|
cp -rp tf-psa-crypto/drivers/builtin/include/mbedtls $(DESTDIR)/include
|
2018-11-15 17:38:58 +00:00
|
|
|
mkdir -p $(DESTDIR)/include/psa
|
2024-06-10 14:05:53 +00:00
|
|
|
cp -rp tf-psa-crypto/include/psa $(DESTDIR)/include
|
2018-03-13 15:22:58 +00:00
|
|
|
|
2009-01-03 21:22:43 +00:00
|
|
|
mkdir -p $(DESTDIR)/lib
|
2020-02-26 18:05:19 +00:00
|
|
|
cp -RP library/libmbedtls.* $(DESTDIR)/lib
|
|
|
|
cp -RP library/libmbedx509.* $(DESTDIR)/lib
|
2015-07-27 08:36:12 +00:00
|
|
|
cp -RP library/libmbedcrypto.* $(DESTDIR)/lib
|
2018-03-13 15:22:58 +00:00
|
|
|
|
2009-01-03 21:22:43 +00:00
|
|
|
mkdir -p $(DESTDIR)/bin
|
|
|
|
for p in programs/*/* ; do \
|
|
|
|
if [ -x $$p ] && [ ! -d $$p ] ; \
|
|
|
|
then \
|
|
|
|
f=$(PREFIX)`basename $$p` ; \
|
|
|
|
cp $$p $(DESTDIR)/bin/$$f ; \
|
|
|
|
fi \
|
|
|
|
done
|
|
|
|
|
2012-11-14 12:39:52 +00:00
|
|
|
uninstall:
|
2015-03-09 17:05:11 +00:00
|
|
|
rm -rf $(DESTDIR)/include/mbedtls
|
2020-11-26 01:27:17 +00:00
|
|
|
rm -rf $(DESTDIR)/include/psa
|
2020-02-26 18:05:19 +00:00
|
|
|
rm -f $(DESTDIR)/lib/libmbedtls.*
|
|
|
|
rm -f $(DESTDIR)/lib/libmbedx509.*
|
2015-07-27 08:36:12 +00:00
|
|
|
rm -f $(DESTDIR)/lib/libmbedcrypto.*
|
2018-03-13 15:22:58 +00:00
|
|
|
|
2012-11-14 12:39:52 +00:00
|
|
|
for p in programs/*/* ; do \
|
|
|
|
if [ -x $$p ] && [ ! -d $$p ] ; \
|
|
|
|
then \
|
|
|
|
f=$(PREFIX)`basename $$p` ; \
|
|
|
|
rm -f $(DESTDIR)/bin/$$f ; \
|
|
|
|
fi \
|
|
|
|
done
|
2015-06-24 11:06:24 +00:00
|
|
|
endif
|
2012-11-14 12:39:52 +00:00
|
|
|
|
2016-06-21 09:14:00 +00:00
|
|
|
|
2018-08-29 07:20:12 +00:00
|
|
|
WARNING_BORDER_LONG =**********************************************************************************\n
|
|
|
|
CTR_DRBG_128_BIT_KEY_WARN_L1=**** WARNING! MBEDTLS_CTR_DRBG_USE_128_BIT_KEY defined! ****\n
|
|
|
|
CTR_DRBG_128_BIT_KEY_WARN_L2=**** Using 128-bit keys for CTR_DRBG limits the security of generated ****\n
|
|
|
|
CTR_DRBG_128_BIT_KEY_WARN_L3=**** keys and operations that use random values generated to 128-bit security ****\n
|
|
|
|
|
|
|
|
CTR_DRBG_128_BIT_KEY_WARNING=\n$(WARNING_BORDER_LONG)$(CTR_DRBG_128_BIT_KEY_WARN_L1)$(CTR_DRBG_128_BIT_KEY_WARN_L2)$(CTR_DRBG_128_BIT_KEY_WARN_L3)$(WARNING_BORDER_LONG)
|
|
|
|
|
2016-06-21 09:14:00 +00:00
|
|
|
# Post build steps
|
|
|
|
post_build:
|
2016-06-27 14:15:11 +00:00
|
|
|
ifndef WINDOWS
|
2018-08-29 07:20:12 +00:00
|
|
|
|
|
|
|
# If 128-bit keys are configured for CTR_DRBG, display an appropriate warning
|
2019-07-27 21:52:53 +00:00
|
|
|
-scripts/config.py get MBEDTLS_CTR_DRBG_USE_128_BIT_KEY && ([ $$? -eq 0 ]) && \
|
2018-08-29 07:20:12 +00:00
|
|
|
echo '$(CTR_DRBG_128_BIT_KEY_WARNING)'
|
|
|
|
|
2016-06-27 14:15:11 +00:00
|
|
|
endif
|
2016-06-21 09:14:00 +00:00
|
|
|
|
2021-04-21 23:01:56 +00:00
|
|
|
clean: clean_more_on_top
|
2015-02-18 15:18:28 +00:00
|
|
|
$(MAKE) -C library clean
|
|
|
|
$(MAKE) -C programs clean
|
|
|
|
$(MAKE) -C tests clean
|
2021-04-21 23:01:56 +00:00
|
|
|
|
|
|
|
clean_more_on_top:
|
2015-06-24 11:06:24 +00:00
|
|
|
ifndef WINDOWS
|
2016-07-13 15:37:32 +00:00
|
|
|
find . \( -name \*.gcno -o -name \*.gcda -o -name \*.info \) -exec rm {} +
|
2015-06-24 11:06:24 +00:00
|
|
|
endif
|
2009-01-03 21:22:43 +00:00
|
|
|
|
2021-04-21 23:01:56 +00:00
|
|
|
neat: clean_more_on_top
|
|
|
|
$(MAKE) -C library neat
|
|
|
|
$(MAKE) -C programs neat
|
|
|
|
$(MAKE) -C tests neat
|
|
|
|
ifndef WINDOWS
|
2024-03-12 15:38:23 +00:00
|
|
|
rm -f visualc/VS2017/*.vcxproj visualc/VS2017/mbedTLS.sln
|
2021-04-21 23:01:56 +00:00
|
|
|
else
|
2024-03-12 15:38:23 +00:00
|
|
|
if exist visualc\VS2017\*.vcxproj del /Q /F visualc\VS2017\*.vcxproj
|
|
|
|
if exist visualc\VS2017\mbedTLS.sln del /Q /F visualc\VS2017\mbedTLS.sln
|
2021-04-21 23:01:56 +00:00
|
|
|
endif
|
|
|
|
|
2024-06-27 06:00:54 +00:00
|
|
|
ifndef PSASIM
|
|
|
|
check: lib
|
|
|
|
endif
|
|
|
|
check: tests
|
2015-02-18 15:18:28 +00:00
|
|
|
$(MAKE) -C tests check
|
2011-01-06 12:28:03 +00:00
|
|
|
|
2015-06-24 11:06:24 +00:00
|
|
|
test: check
|
2014-01-31 12:41:07 +00:00
|
|
|
|
2015-07-08 20:20:03 +00:00
|
|
|
ifndef WINDOWS
|
2022-12-08 21:18:31 +00:00
|
|
|
# For coverage testing:
|
|
|
|
# 1. Build with:
|
|
|
|
# make CFLAGS='--coverage -g3 -O0' LDFLAGS='--coverage'
|
|
|
|
# 2. Run the relevant tests for the part of the code you're interested in.
|
|
|
|
# For the reference coverage measurement, see
|
|
|
|
# tests/scripts/basic-build-test.sh
|
|
|
|
# 3. Run scripts/lcov.sh to generate an HTML report.
|
2014-01-31 15:19:43 +00:00
|
|
|
lcov:
|
2022-11-30 16:35:44 +00:00
|
|
|
scripts/lcov.sh
|
2014-01-31 15:19:43 +00:00
|
|
|
|
2011-01-06 12:28:03 +00:00
|
|
|
apidoc:
|
|
|
|
mkdir -p apidoc
|
2018-01-22 12:38:31 +00:00
|
|
|
cd doxygen && doxygen mbedtls.doxyfile
|
2011-01-06 12:28:03 +00:00
|
|
|
|
|
|
|
apidoc_clean:
|
2015-06-24 11:06:24 +00:00
|
|
|
rm -rf apidoc
|
|
|
|
endif
|
2018-01-16 13:04:05 +00:00
|
|
|
|
|
|
|
## Editor navigation files
|
2020-11-09 20:20:16 +00:00
|
|
|
C_SOURCE_FILES = $(wildcard \
|
|
|
|
include/*/*.h \
|
|
|
|
library/*.[hc] \
|
2024-07-02 05:55:03 +00:00
|
|
|
tf-psa-crypto/core/*.[hc] \
|
2024-06-10 13:58:23 +00:00
|
|
|
tf-psa-crypto/include/*/*.h \
|
2024-07-02 06:50:56 +00:00
|
|
|
tf-psa-crypto/drivers/*/include/*/*.h \
|
|
|
|
tf-psa-crypto/drivers/*/include/*/*/*.h \
|
|
|
|
tf-psa-crypto/drivers/*/include/*/*/*/*.h \
|
2024-07-02 05:55:03 +00:00
|
|
|
tf-psa-crypto/drivers/builtin/src/*.[hc] \
|
2024-07-02 06:50:56 +00:00
|
|
|
tf-psa-crypto/drivers/*/*.c \
|
|
|
|
tf-psa-crypto/drivers/*/*/*.c \
|
|
|
|
tf-psa-crypto/drivers/*/*/*/*.c \
|
|
|
|
tf-psa-crypto/drivers/*/*/*/*/*.c \
|
2020-11-09 20:20:16 +00:00
|
|
|
programs/*/*.[hc] \
|
|
|
|
tests/include/*/*.h tests/include/*/*/*.h \
|
|
|
|
tests/src/*.c tests/src/*/*.c \
|
|
|
|
tests/suites/*.function \
|
2024-07-11 10:03:51 +00:00
|
|
|
tf-psa-crypto/tests/suites/*.function \
|
2020-11-09 20:20:16 +00:00
|
|
|
)
|
2020-04-02 10:10:45 +00:00
|
|
|
# Exuberant-ctags invocation. Other ctags implementations may require different options.
|
2021-01-13 12:45:30 +00:00
|
|
|
CTAGS = ctags --langmap=c:+.h.function --line-directives=no -o
|
2018-01-16 13:04:05 +00:00
|
|
|
tags: $(C_SOURCE_FILES)
|
2020-04-02 10:10:45 +00:00
|
|
|
$(CTAGS) $@ $(C_SOURCE_FILES)
|
2018-01-16 13:04:05 +00:00
|
|
|
TAGS: $(C_SOURCE_FILES)
|
2021-01-13 12:45:30 +00:00
|
|
|
etags --no-line-directive -o $@ $(C_SOURCE_FILES)
|
2020-11-20 10:50:08 +00:00
|
|
|
global: GPATH GRTAGS GSYMS GTAGS
|
2018-01-16 13:04:05 +00:00
|
|
|
GPATH GRTAGS GSYMS GTAGS: $(C_SOURCE_FILES)
|
|
|
|
ls $(C_SOURCE_FILES) | gtags -f - --gtagsconf .globalrc
|
2020-11-20 10:50:08 +00:00
|
|
|
cscope: cscope.in.out cscope.po.out cscope.out
|
2020-11-09 20:21:31 +00:00
|
|
|
cscope.in.out cscope.po.out cscope.out: $(C_SOURCE_FILES)
|
2024-07-02 05:55:03 +00:00
|
|
|
cscope -bq -u -Iinclude -Ilibrary -Itf-psa-crypto/core \
|
|
|
|
-Itf-psa-crypto/include \
|
|
|
|
-Itf-psa-crypto/drivers/builtin/src \
|
2024-07-02 06:50:56 +00:00
|
|
|
$(patsubst %,-I%,$(wildcard tf-psa-crypto/drivers/*/include)) -Itests/include $(C_SOURCE_FILES)
|
2020-11-20 10:50:08 +00:00
|
|
|
.PHONY: cscope global
|