2009-01-03 21:22:43 +00:00
DESTDIR=/usr/local
2015-01-27 14:05:16 +01:00
PREFIX=mbedtls_
2021-04-22 01:01:56 +02:00
PERL ?= perl
2009-01-03 21:22:43 +00:00
2024-03-04 16:42:54 +01: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.
2024-12-10 09:58:23 +00:00
ifneq (,$(wildcard .git))
2024-10-28 14:05:23 +00:00
define error_message
2024-11-04 12:16:50 +00:00
${MBEDTLS_PATH}/framework/exported.make not found (and does appear to be a git checkout). Run `git submodule update --init` from the source tree to fetch the submodule contents.
2024-09-17 15:12:11 +01:00
This is a fatal error
2024-11-04 11:37:05 +00:00
endef
2024-09-17 15:12:11 +01:00
else
2024-11-04 11:37:05 +00:00
define error_message
2024-11-04 12:16:50 +00:00
${MBEDTLS_PATH}/framework/exported.make not found (and does not appear to be a git checkout). Please ensure you have downloaded the right archive from the release page on GitHub.
2024-11-04 11:37:05 +00:00
endef
2024-09-17 15:12:11 +01:00
endif
2024-03-04 16:42:54 +01:00
$(error $(error_message))
endif
include framework/exported.make
endif
2024-02-29 18:19:56 +01:00
2009-01-03 21:22:43 +00:00
.SILENT:
2022-12-08 22:18:31 +01: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 16:36:16 +01:00
all: programs tests
2015-02-18 17:18:28 +02:00
2015-06-24 13:06:24 +02:00
no_test: programs
2020-06-19 11:27:26 +02:00
programs: lib mbedtls_test
2015-02-18 17:18:28 +02:00
$(MAKE) -C programs
2012-04-05 12:07:50 +00:00
2024-09-14 13:05:51 +02:00
ssl-opt: lib mbedtls_test
$(MAKE) -C programs ssl-opt
2024-09-25 10:27:47 +02:00
$(MAKE) -C tests ssl-opt
2024-09-14 13:05:51 +02:00
2012-04-05 12:07:50 +00:00
lib:
2015-02-18 17:18:28 +02:00
$(MAKE) -C library
2024-06-27 08:00:54 +02:00
ifndef PSASIM
tests: lib
endif
tests: mbedtls_test
2015-02-18 17:18:28 +02:00
$(MAKE) -C tests
2012-04-05 12:07:50 +00:00
2020-06-19 11:27:26 +02:00
mbedtls_test:
$(MAKE) -C tests mbedtls_test
2024-11-21 22:06:39 +01:00
.PHONY: FORCE
FORCE:
library/%: FORCE
2021-04-22 01:01:56 +02:00
$(MAKE) -C library $*
2024-11-21 22:06:39 +01:00
programs/%: FORCE
2021-04-22 01:01:56 +02:00
$(MAKE) -C programs $*
2024-11-21 22:06:39 +01:00
tests/%: FORCE
2021-04-22 01:01:56 +02:00
$(MAKE) -C tests $*
.PHONY: generated_files
generated_files: library/generated_files
generated_files: programs/generated_files
generated_files: tests/generated_files
2023-09-08 16:19:13 +02: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 21:26:05 +02: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 16:19:13 +02:00
gen_file_dep = |
endif
2015-06-24 13:06:24 +02:00
ifndef WINDOWS
2015-08-03 10:34:09 +02:00
install: no_test
2015-03-09 17:05:11 +00:00
mkdir -p $(DESTDIR)/include/mbedtls
2018-06-28 23:21:26 +08:00
cp -rp include/mbedtls $(DESTDIR)/include
2024-06-17 14:25:26 +02: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 16:05:53 +02: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 19:05:19 +01:00
cp -RP library/libmbedtls.* $(DESTDIR)/lib
cp -RP library/libmbedx509.* $(DESTDIR)/lib
2015-07-27 10:36:12 +02: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 09:27:17 +08:00
rm -rf $(DESTDIR)/include/psa
2020-02-26 19:05:19 +01:00
rm -f $(DESTDIR)/lib/libmbedtls.*
rm -f $(DESTDIR)/lib/libmbedx509.*
2015-07-27 10:36:12 +02: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 13:06:24 +02:00
endif
2012-11-14 12:39:52 +00:00
2021-04-22 01:01:56 +02:00
clean: clean_more_on_top
2015-02-18 17:18:28 +02:00
$(MAKE) -C library clean
$(MAKE) -C programs clean
$(MAKE) -C tests clean
2021-04-22 01:01:56 +02:00
clean_more_on_top:
2015-06-24 13:06:24 +02:00
ifndef WINDOWS
2016-07-13 16:37:32 +01:00
find . \( -name \*.gcno -o -name \*.gcda -o -name \*.info \) -exec rm {} +
2015-06-24 13:06:24 +02:00
endif
2009-01-03 21:22:43 +00:00
2021-04-22 01:01:56 +02:00
neat: clean_more_on_top
$(MAKE) -C library neat
$(MAKE) -C programs neat
$(MAKE) -C tests neat
2024-06-27 08:00:54 +02:00
ifndef PSASIM
check: lib
endif
check: tests
2015-02-18 17:18:28 +02:00
$(MAKE) -C tests check
2011-01-06 12:28:03 +00:00
2015-06-24 13:06:24 +02:00
test: check
2014-01-31 13:41:07 +01:00
2015-07-08 21:20:03 +01:00
ifndef WINDOWS
2022-12-08 22:18:31 +01: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
2025-10-17 08:47:52 +01:00
# 3. Run framework/scripts/lcov.sh to generate an HTML report.
2014-01-31 16:19:43 +01:00
lcov:
2025-10-17 08:47:52 +01:00
framework/scripts/lcov.sh
2014-01-31 16:19:43 +01:00
2011-01-06 12:28:03 +00:00
apidoc:
mkdir -p apidoc
2018-01-22 13:38:31 +01:00
cd doxygen && doxygen mbedtls.doxyfile
2011-01-06 12:28:03 +00:00
apidoc_clean:
2015-06-24 13:06:24 +02:00
rm -rf apidoc
endif
2018-01-16 14:04:05 +01:00
## Editor navigation files
2020-11-09 21:20:16 +01:00
C_SOURCE_FILES = $(wildcard \
include/*/*.h \
library/*.[hc] \
2024-07-02 07:55:03 +02:00
tf-psa-crypto/core/*.[hc] \
2024-06-10 15:58:23 +02:00
tf-psa-crypto/include/*/*.h \
2024-07-02 08:50:56 +02:00
tf-psa-crypto/drivers/*/include/*/*.h \
tf-psa-crypto/drivers/*/include/*/*/*.h \
tf-psa-crypto/drivers/*/include/*/*/*/*.h \
2024-07-02 07:55:03 +02:00
tf-psa-crypto/drivers/builtin/src/*.[hc] \
2024-07-02 08:50:56 +02:00
tf-psa-crypto/drivers/*/*.c \
tf-psa-crypto/drivers/*/*/*.c \
tf-psa-crypto/drivers/*/*/*/*.c \
tf-psa-crypto/drivers/*/*/*/*/*.c \
2026-02-14 10:49:40 +01:00
tf-psa-crypto/dispatch/*.[hc] \
tf-psa-crypto/extras/*.[hc] \
tf-psa-crypto/platform/*.[hc] \
tf-psa-crypto/utilities/*.[hc] \
2020-11-09 21:20:16 +01:00
programs/*/*.[hc] \
2024-10-31 15:36:05 +00:00
framework/tests/include/*/*.h framework/tests/include/*/*/*.h \
framework/tests/src/*.c framework/tests/src/*/*.c \
2020-11-09 21:20:16 +01:00
tests/suites/*.function \
2024-07-11 12:03:51 +02:00
tf-psa-crypto/tests/suites/*.function \
2020-11-09 21:20:16 +01:00
)
2020-04-02 12:10:45 +02:00
# Exuberant-ctags invocation. Other ctags implementations may require different options.
2021-01-13 13:45:30 +01:00
CTAGS = ctags --langmap=c:+.h.function --line-directives=no -o
2018-01-16 14:04:05 +01:00
tags: $(C_SOURCE_FILES)
2020-04-02 12:10:45 +02:00
$(CTAGS) $@ $(C_SOURCE_FILES)
2018-01-16 14:04:05 +01:00
TAGS: $(C_SOURCE_FILES)
2021-01-13 13:45:30 +01:00
etags --no-line-directive -o $@ $(C_SOURCE_FILES)
2020-11-20 11:50:08 +01:00
global: GPATH GRTAGS GSYMS GTAGS
2018-01-16 14:04:05 +01:00
GPATH GRTAGS GSYMS GTAGS: $(C_SOURCE_FILES)
ls $(C_SOURCE_FILES) | gtags -f - --gtagsconf .globalrc
2020-11-20 11:50:08 +01:00
cscope: cscope.in.out cscope.po.out cscope.out
2020-11-09 21:21:31 +01:00
cscope.in.out cscope.po.out cscope.out: $(C_SOURCE_FILES)
2024-07-02 07:55:03 +02:00
cscope -bq -u -Iinclude -Ilibrary -Itf-psa-crypto/core \
-Itf-psa-crypto/include \
-Itf-psa-crypto/drivers/builtin/src \
2026-02-14 10:49:40 +01:00
-Itf-psa-crypto/dispatch \
-Itf-psa-crypto/extras \
-Itf-psa-crypto/platform \
-Itf-psa-crypto/utilities \
2024-10-31 15:36:05 +00:00
$(patsubst %,-I%,$(wildcard tf-psa-crypto/drivers/*/include)) -Iframework/tests/include $(C_SOURCE_FILES)
2020-11-20 11:50:08 +01:00
.PHONY: cscope global