blob: 6a8b230077367013e217efc4c1272111c1d99d1e [file] [log] [blame]
Paul Bakker5121ce52009-01-03 21:22:43 +00001DESTDIR=/usr/local
Manuel Pégourié-Gonnard52859702015-01-27 14:05:16 +01002PREFIX=mbedtls_
Paul Bakker5121ce52009-01-03 21:22:43 +00003
4.SILENT:
5
Manuel Pégourié-Gonnard5c59a4f2015-06-24 13:06:24 +02006.PHONY: all no_test programs lib tests install uninstall clean test check covtest lcov apidoc apidoc_clean
Paul Bakker5121ce52009-01-03 21:22:43 +00007
Andres AG7aa5fa12016-08-25 16:36:16 +01008all: programs tests
9 $(MAKE) post_build
Alon Bar-Lev06f0d262015-02-18 17:18:28 +020010
Manuel Pégourié-Gonnard5c59a4f2015-06-24 13:06:24 +020011no_test: programs
12
Ronald Cronddaf99c2020-06-19 11:27:26 +020013programs: lib mbedtls_test
Alon Bar-Lev06f0d262015-02-18 17:18:28 +020014 $(MAKE) -C programs
Paul Bakkerf9964ab2012-04-05 12:07:50 +000015
16lib:
Alon Bar-Lev06f0d262015-02-18 17:18:28 +020017 $(MAKE) -C library
18
Ronald Cronddaf99c2020-06-19 11:27:26 +020019tests: lib mbedtls_test
Alon Bar-Lev06f0d262015-02-18 17:18:28 +020020 $(MAKE) -C tests
Paul Bakkerf9964ab2012-04-05 12:07:50 +000021
Ronald Cronddaf99c2020-06-19 11:27:26 +020022mbedtls_test:
23 $(MAKE) -C tests mbedtls_test
24
Manuel Pégourié-Gonnard5c59a4f2015-06-24 13:06:24 +020025ifndef WINDOWS
Manuel Pégourié-Gonnard99839932015-08-03 10:34:09 +020026install: no_test
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000027 mkdir -p $(DESTDIR)/include/mbedtls
Ruini Xue5a9cb612018-06-28 23:21:26 +080028 cp -rp include/mbedtls $(DESTDIR)/include
Jaeden Amero3c7cc5e2018-11-15 17:38:58 +000029 mkdir -p $(DESTDIR)/include/psa
30 cp -rp include/psa $(DESTDIR)/include
Darryl Green11999bb2018-03-13 15:22:58 +000031
Paul Bakker5121ce52009-01-03 21:22:43 +000032 mkdir -p $(DESTDIR)/lib
Gilles Peskine722a7e62020-02-26 19:05:19 +010033 cp -RP library/libmbedtls.* $(DESTDIR)/lib
34 cp -RP library/libmbedx509.* $(DESTDIR)/lib
Manuel Pégourié-Gonnard52a50792015-07-27 10:36:12 +020035 cp -RP library/libmbedcrypto.* $(DESTDIR)/lib
Darryl Green11999bb2018-03-13 15:22:58 +000036
Paul Bakker5121ce52009-01-03 21:22:43 +000037 mkdir -p $(DESTDIR)/bin
38 for p in programs/*/* ; do \
39 if [ -x $$p ] && [ ! -d $$p ] ; \
40 then \
41 f=$(PREFIX)`basename $$p` ; \
42 cp $$p $(DESTDIR)/bin/$$f ; \
43 fi \
44 done
45
Paul Bakker9a736322012-11-14 12:39:52 +000046uninstall:
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000047 rm -rf $(DESTDIR)/include/mbedtls
Wu, Jheng-Jhong89b98142020-11-26 09:27:17 +080048 rm -rf $(DESTDIR)/include/psa
Gilles Peskine722a7e62020-02-26 19:05:19 +010049 rm -f $(DESTDIR)/lib/libmbedtls.*
50 rm -f $(DESTDIR)/lib/libmbedx509.*
Manuel Pégourié-Gonnard52a50792015-07-27 10:36:12 +020051 rm -f $(DESTDIR)/lib/libmbedcrypto.*
Darryl Green11999bb2018-03-13 15:22:58 +000052
Paul Bakker9a736322012-11-14 12:39:52 +000053 for p in programs/*/* ; do \
54 if [ -x $$p ] && [ ! -d $$p ] ; \
55 then \
56 f=$(PREFIX)`basename $$p` ; \
57 rm -f $(DESTDIR)/bin/$$f ; \
58 fi \
59 done
Manuel Pégourié-Gonnard5c59a4f2015-06-24 13:06:24 +020060endif
Paul Bakker9a736322012-11-14 12:39:52 +000061
Simon Butcher1ceab6e2016-06-21 10:14:00 +010062WARNING_BORDER =*******************************************************\n
63NULL_ENTROPY_WARN_L1=**** WARNING! MBEDTLS_TEST_NULL_ENTROPY defined! ****\n
64NULL_ENTROPY_WARN_L2=**** THIS BUILD HAS NO DEFINED ENTROPY SOURCES ****\n
65NULL_ENTROPY_WARN_L3=**** AND IS *NOT* SUITABLE FOR PRODUCTION USE ****\n
66
67NULL_ENTROPY_WARNING=\n$(WARNING_BORDER)$(NULL_ENTROPY_WARN_L1)$(NULL_ENTROPY_WARN_L2)$(NULL_ENTROPY_WARN_L3)$(WARNING_BORDER)
68
Nir Sonnenscheinb7ebbca2018-08-29 10:20:12 +030069WARNING_BORDER_LONG =**********************************************************************************\n
70CTR_DRBG_128_BIT_KEY_WARN_L1=**** WARNING! MBEDTLS_CTR_DRBG_USE_128_BIT_KEY defined! ****\n
71CTR_DRBG_128_BIT_KEY_WARN_L2=**** Using 128-bit keys for CTR_DRBG limits the security of generated ****\n
72CTR_DRBG_128_BIT_KEY_WARN_L3=**** keys and operations that use random values generated to 128-bit security ****\n
73
74CTR_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)
75
Simon Butcher1ceab6e2016-06-21 10:14:00 +010076# Post build steps
77post_build:
Simon Butchercff625f2016-06-27 15:15:11 +010078ifndef WINDOWS
Nir Sonnenscheinb7ebbca2018-08-29 10:20:12 +030079
80 # If 128-bit keys are configured for CTR_DRBG, display an appropriate warning
Gilles Peskine3bdd4122019-07-27 23:52:53 +020081 -scripts/config.py get MBEDTLS_CTR_DRBG_USE_128_BIT_KEY && ([ $$? -eq 0 ]) && \
Nir Sonnenscheinb7ebbca2018-08-29 10:20:12 +030082 echo '$(CTR_DRBG_128_BIT_KEY_WARNING)'
83
Simon Butcher1ceab6e2016-06-21 10:14:00 +010084 # If NULL Entropy is configured, display an appropriate warning
Gilles Peskine3bdd4122019-07-27 23:52:53 +020085 -scripts/config.py get MBEDTLS_TEST_NULL_ENTROPY && ([ $$? -eq 0 ]) && \
Simon Butcher1ceab6e2016-06-21 10:14:00 +010086 echo '$(NULL_ENTROPY_WARNING)'
Simon Butchercff625f2016-06-27 15:15:11 +010087endif
Simon Butcher1ceab6e2016-06-21 10:14:00 +010088
Paul Bakker5121ce52009-01-03 21:22:43 +000089clean:
Alon Bar-Lev06f0d262015-02-18 17:18:28 +020090 $(MAKE) -C library clean
91 $(MAKE) -C programs clean
92 $(MAKE) -C tests clean
Manuel Pégourié-Gonnard5c59a4f2015-06-24 13:06:24 +020093ifndef WINDOWS
Paul Bakkerbd3b3592016-07-13 16:37:32 +010094 find . \( -name \*.gcno -o -name \*.gcda -o -name \*.info \) -exec rm {} +
Manuel Pégourié-Gonnard5c59a4f2015-06-24 13:06:24 +020095endif
Paul Bakker5121ce52009-01-03 21:22:43 +000096
Andres AGc49b8082016-08-31 16:10:45 +010097check: lib tests
Alon Bar-Lev06f0d262015-02-18 17:18:28 +020098 $(MAKE) -C tests check
Paul Bakker37ca75d2011-01-06 12:28:03 +000099
Manuel Pégourié-Gonnard5c59a4f2015-06-24 13:06:24 +0200100test: check
Manuel Pégourié-Gonnard6529ff02014-01-31 13:41:07 +0100101
Manuel Pégourié-Gonnard85113842015-07-08 21:20:03 +0100102ifndef WINDOWS
Manuel Pégourié-Gonnard720375e2014-02-24 12:39:18 +0100103# note: for coverage testing, build with:
Manuel Pégourié-Gonnard5c59a4f2015-06-24 13:06:24 +0200104# make CFLAGS='--coverage -g3 -O0'
Manuel Pégourié-Gonnard79d090b2014-02-26 19:39:01 +0100105covtest:
Manuel Pégourié-Gonnardfc367082015-06-26 16:50:24 +0200106 $(MAKE) check
Manuel Pégourié-Gonnard61137df2014-02-24 11:57:36 +0100107 programs/test/selftest
Gilles Peskine7dc97042020-02-26 19:48:43 +0100108 tests/compat.sh
109 tests/ssl-opt.sh
Manuel Pégourié-Gonnard61137df2014-02-24 11:57:36 +0100110
Manuel Pégourié-Gonnard546d86c2014-01-31 16:19:43 +0100111lcov:
112 rm -rf Coverage
Manuel Pégourié-Gonnard53c6e962014-06-13 12:22:07 +0200113 lcov --capture --initial --directory library -o files.info
Dan Handleya8b26c22020-05-28 16:20:31 +0100114 lcov --rc lcov_branch_coverage=1 --capture --directory library -o tests.info
115 lcov --rc lcov_branch_coverage=1 --add-tracefile files.info --add-tracefile tests.info -o all.info
116 lcov --rc lcov_branch_coverage=1 --remove all.info -o final.info '*.h'
Manuel Pégourié-Gonnard720375e2014-02-24 12:39:18 +0100117 gendesc tests/Descriptions.txt -o descriptions
Dan Handleya8b26c22020-05-28 16:20:31 +0100118 genhtml --title "mbed TLS" --description-file descriptions --keep-descriptions --legend --branch-coverage -o Coverage final.info
Manuel Pégourié-Gonnarde41072e2014-06-16 16:24:24 +0200119 rm -f files.info tests.info all.info final.info descriptions
Manuel Pégourié-Gonnard546d86c2014-01-31 16:19:43 +0100120
Paul Bakker37ca75d2011-01-06 12:28:03 +0000121apidoc:
122 mkdir -p apidoc
Krzysztof Stachowiak744a4ac2018-01-22 13:38:31 +0100123 cd doxygen && doxygen mbedtls.doxyfile
Paul Bakker37ca75d2011-01-06 12:28:03 +0000124
125apidoc_clean:
Manuel Pégourié-Gonnard5c59a4f2015-06-24 13:06:24 +0200126 rm -rf apidoc
127endif
Gilles Peskine66c1e2c2018-01-16 14:04:05 +0100128
129## Editor navigation files
Gilles Peskine646ad222020-11-09 21:20:16 +0100130C_SOURCE_FILES = $(wildcard \
131 3rdparty/*/include/*/*.h 3rdparty/*/include/*/*/*.h 3rdparty/*/include/*/*/*/*.h \
132 3rdparty/*/*.c 3rdparty/*/*/*.c 3rdparty/*/*/*/*.c 3rdparty/*/*/*/*/*.c \
133 include/*/*.h \
134 library/*.[hc] \
135 programs/*/*.[hc] \
136 tests/include/*/*.h tests/include/*/*/*.h \
137 tests/src/*.c tests/src/*/*.c \
138 tests/suites/*.function \
139)
Manuel Pégourié-Gonnardc9f89562020-04-02 12:10:45 +0200140# Exuberant-ctags invocation. Other ctags implementations may require different options.
Gilles Peskineb305b002021-01-13 13:45:30 +0100141CTAGS = ctags --langmap=c:+.h.function --line-directives=no -o
Gilles Peskine66c1e2c2018-01-16 14:04:05 +0100142tags: $(C_SOURCE_FILES)
Manuel Pégourié-Gonnardc9f89562020-04-02 12:10:45 +0200143 $(CTAGS) $@ $(C_SOURCE_FILES)
Gilles Peskine66c1e2c2018-01-16 14:04:05 +0100144TAGS: $(C_SOURCE_FILES)
Gilles Peskineb305b002021-01-13 13:45:30 +0100145 etags --no-line-directive -o $@ $(C_SOURCE_FILES)
Gilles Peskine8346c7a2020-11-20 11:50:08 +0100146global: GPATH GRTAGS GSYMS GTAGS
Gilles Peskine66c1e2c2018-01-16 14:04:05 +0100147GPATH GRTAGS GSYMS GTAGS: $(C_SOURCE_FILES)
148 ls $(C_SOURCE_FILES) | gtags -f - --gtagsconf .globalrc
Gilles Peskine8346c7a2020-11-20 11:50:08 +0100149cscope: cscope.in.out cscope.po.out cscope.out
Gilles Peskined0c78012020-11-09 21:21:31 +0100150cscope.in.out cscope.po.out cscope.out: $(C_SOURCE_FILES)
151 cscope -bq -u -Iinclude -Ilibrary $(patsubst %,-I%,$(wildcard 3rdparty/*/include)) -Itests/include $(C_SOURCE_FILES)
Gilles Peskine8346c7a2020-11-20 11:50:08 +0100152.PHONY: cscope global