blob: 5b2ad16cdb7a96d68ff37eaad3e39472909d7c53 [file] [log] [blame]
Paul Bakker5121ce52009-01-03 21:22:43 +00001DESTDIR=/usr/local
Manuel Pégourié-Gonnard52859702015-01-27 14:05:16 +01002PREFIX=mbedtls_
Gilles Peskine687d1ab2021-04-22 01:01:56 +02003PERL ?= perl
Paul Bakker5121ce52009-01-03 21:22:43 +00004
5.SILENT:
6
Manuel Pégourié-Gonnard5c59a4f2015-06-24 13:06:24 +02007.PHONY: all no_test programs lib tests install uninstall clean test check covtest lcov apidoc apidoc_clean
Paul Bakker5121ce52009-01-03 21:22:43 +00008
Andres AG7aa5fa12016-08-25 16:36:16 +01009all: programs tests
10 $(MAKE) post_build
Alon Bar-Lev06f0d262015-02-18 17:18:28 +020011
Manuel Pégourié-Gonnard5c59a4f2015-06-24 13:06:24 +020012no_test: programs
13
Ronald Cronddaf99c2020-06-19 11:27:26 +020014programs: lib mbedtls_test
Alon Bar-Lev06f0d262015-02-18 17:18:28 +020015 $(MAKE) -C programs
Paul Bakkerf9964ab2012-04-05 12:07:50 +000016
17lib:
Alon Bar-Lev06f0d262015-02-18 17:18:28 +020018 $(MAKE) -C library
19
Ronald Cronddaf99c2020-06-19 11:27:26 +020020tests: lib mbedtls_test
Alon Bar-Lev06f0d262015-02-18 17:18:28 +020021 $(MAKE) -C tests
Paul Bakkerf9964ab2012-04-05 12:07:50 +000022
Ronald Cronddaf99c2020-06-19 11:27:26 +020023mbedtls_test:
24 $(MAKE) -C tests mbedtls_test
25
Gilles Peskine687d1ab2021-04-22 01:01:56 +020026library/%:
27 $(MAKE) -C library $*
28programs/%:
29 $(MAKE) -C programs $*
30tests/%:
31 $(MAKE) -C tests $*
32
33.PHONY: generated_files
34generated_files: library/generated_files
35generated_files: programs/generated_files
36generated_files: tests/generated_files
37generated_files: visualc_files
38
39.PHONY: visualc_files
40VISUALC_FILES = visualc/VS2010/mbedTLS.sln visualc/VS2010/mbedTLS.vcxproj
41# TODO: $(app).vcxproj for each $(app) in programs/
42visualc_files: $(VISUALC_FILES)
Gilles Peskine94230ea2021-05-18 15:48:56 +020043
44# Ensure that the .c files that generate_visualc_files.pl enumerates are
Gilles Peskinea13deaf2021-05-19 14:26:37 +020045# present before it runs. It doesn't matter if the files aren't up-to-date,
46# they just need to be present.
47$(VISUALC_FILES): | library/generated_files
Gilles Peskine687d1ab2021-04-22 01:01:56 +020048$(VISUALC_FILES): scripts/generate_visualc_files.pl
49$(VISUALC_FILES): scripts/data_files/vs2010-app-template.vcxproj
50$(VISUALC_FILES): scripts/data_files/vs2010-main-template.vcxproj
51$(VISUALC_FILES): scripts/data_files/vs2010-sln-template.sln
52# TODO: also the list of .c and .h source files, but not their content
53$(VISUALC_FILES):
54 echo " Gen $@ ..."
55 $(PERL) scripts/generate_visualc_files.pl
56
Manuel Pégourié-Gonnard5c59a4f2015-06-24 13:06:24 +020057ifndef WINDOWS
Manuel Pégourié-Gonnard99839932015-08-03 10:34:09 +020058install: no_test
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000059 mkdir -p $(DESTDIR)/include/mbedtls
Ruini Xue5a9cb612018-06-28 23:21:26 +080060 cp -rp include/mbedtls $(DESTDIR)/include
Jaeden Amero3c7cc5e2018-11-15 17:38:58 +000061 mkdir -p $(DESTDIR)/include/psa
62 cp -rp include/psa $(DESTDIR)/include
Darryl Green11999bb2018-03-13 15:22:58 +000063
Paul Bakker5121ce52009-01-03 21:22:43 +000064 mkdir -p $(DESTDIR)/lib
Gilles Peskine722a7e62020-02-26 19:05:19 +010065 cp -RP library/libmbedtls.* $(DESTDIR)/lib
66 cp -RP library/libmbedx509.* $(DESTDIR)/lib
Manuel Pégourié-Gonnard52a50792015-07-27 10:36:12 +020067 cp -RP library/libmbedcrypto.* $(DESTDIR)/lib
Darryl Green11999bb2018-03-13 15:22:58 +000068
Paul Bakker5121ce52009-01-03 21:22:43 +000069 mkdir -p $(DESTDIR)/bin
70 for p in programs/*/* ; do \
71 if [ -x $$p ] && [ ! -d $$p ] ; \
72 then \
73 f=$(PREFIX)`basename $$p` ; \
74 cp $$p $(DESTDIR)/bin/$$f ; \
75 fi \
76 done
77
Paul Bakker9a736322012-11-14 12:39:52 +000078uninstall:
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000079 rm -rf $(DESTDIR)/include/mbedtls
Wu, Jheng-Jhong89b98142020-11-26 09:27:17 +080080 rm -rf $(DESTDIR)/include/psa
Gilles Peskine722a7e62020-02-26 19:05:19 +010081 rm -f $(DESTDIR)/lib/libmbedtls.*
82 rm -f $(DESTDIR)/lib/libmbedx509.*
Manuel Pégourié-Gonnard52a50792015-07-27 10:36:12 +020083 rm -f $(DESTDIR)/lib/libmbedcrypto.*
Darryl Green11999bb2018-03-13 15:22:58 +000084
Paul Bakker9a736322012-11-14 12:39:52 +000085 for p in programs/*/* ; do \
86 if [ -x $$p ] && [ ! -d $$p ] ; \
87 then \
88 f=$(PREFIX)`basename $$p` ; \
89 rm -f $(DESTDIR)/bin/$$f ; \
90 fi \
91 done
Manuel Pégourié-Gonnard5c59a4f2015-06-24 13:06:24 +020092endif
Paul Bakker9a736322012-11-14 12:39:52 +000093
Simon Butcher1ceab6e2016-06-21 10:14:00 +010094
Nir Sonnenscheinb7ebbca2018-08-29 10:20:12 +030095WARNING_BORDER_LONG =**********************************************************************************\n
96CTR_DRBG_128_BIT_KEY_WARN_L1=**** WARNING! MBEDTLS_CTR_DRBG_USE_128_BIT_KEY defined! ****\n
97CTR_DRBG_128_BIT_KEY_WARN_L2=**** Using 128-bit keys for CTR_DRBG limits the security of generated ****\n
98CTR_DRBG_128_BIT_KEY_WARN_L3=**** keys and operations that use random values generated to 128-bit security ****\n
99
100CTR_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)
101
Simon Butcher1ceab6e2016-06-21 10:14:00 +0100102# Post build steps
103post_build:
Simon Butchercff625f2016-06-27 15:15:11 +0100104ifndef WINDOWS
Nir Sonnenscheinb7ebbca2018-08-29 10:20:12 +0300105
106 # If 128-bit keys are configured for CTR_DRBG, display an appropriate warning
Gilles Peskine3bdd4122019-07-27 23:52:53 +0200107 -scripts/config.py get MBEDTLS_CTR_DRBG_USE_128_BIT_KEY && ([ $$? -eq 0 ]) && \
Nir Sonnenscheinb7ebbca2018-08-29 10:20:12 +0300108 echo '$(CTR_DRBG_128_BIT_KEY_WARNING)'
109
Simon Butchercff625f2016-06-27 15:15:11 +0100110endif
Simon Butcher1ceab6e2016-06-21 10:14:00 +0100111
Gilles Peskine687d1ab2021-04-22 01:01:56 +0200112clean: clean_more_on_top
Alon Bar-Lev06f0d262015-02-18 17:18:28 +0200113 $(MAKE) -C library clean
114 $(MAKE) -C programs clean
115 $(MAKE) -C tests clean
Gilles Peskine687d1ab2021-04-22 01:01:56 +0200116
117clean_more_on_top:
Manuel Pégourié-Gonnard5c59a4f2015-06-24 13:06:24 +0200118ifndef WINDOWS
Paul Bakkerbd3b3592016-07-13 16:37:32 +0100119 find . \( -name \*.gcno -o -name \*.gcda -o -name \*.info \) -exec rm {} +
Manuel Pégourié-Gonnard5c59a4f2015-06-24 13:06:24 +0200120endif
Paul Bakker5121ce52009-01-03 21:22:43 +0000121
Gilles Peskine687d1ab2021-04-22 01:01:56 +0200122neat: clean_more_on_top
123 $(MAKE) -C library neat
124 $(MAKE) -C programs neat
125 $(MAKE) -C tests neat
126ifndef WINDOWS
127 rm -f visualc/VS2010/*.vcxproj visualc/VS2010/mbedTLS.sln
128else
129 if exist visualc\VS2010\*.vcxproj del /Q /F visualc\VS2010\*.vcxproj
130 if exist visualc\VS2010\mbedTLS.sln del /Q /F visualc\VS2010\mbedTLS.sln
131endif
132
Andres AGc49b8082016-08-31 16:10:45 +0100133check: lib tests
Alon Bar-Lev06f0d262015-02-18 17:18:28 +0200134 $(MAKE) -C tests check
Paul Bakker37ca75d2011-01-06 12:28:03 +0000135
Manuel Pégourié-Gonnard5c59a4f2015-06-24 13:06:24 +0200136test: check
Manuel Pégourié-Gonnard6529ff02014-01-31 13:41:07 +0100137
Manuel Pégourié-Gonnard85113842015-07-08 21:20:03 +0100138ifndef WINDOWS
Manuel Pégourié-Gonnard720375e2014-02-24 12:39:18 +0100139# note: for coverage testing, build with:
Manuel Pégourié-Gonnard5c59a4f2015-06-24 13:06:24 +0200140# make CFLAGS='--coverage -g3 -O0'
Manuel Pégourié-Gonnard79d090b2014-02-26 19:39:01 +0100141covtest:
Manuel Pégourié-Gonnardfc367082015-06-26 16:50:24 +0200142 $(MAKE) check
Manuel Pégourié-Gonnard61137df2014-02-24 11:57:36 +0100143 programs/test/selftest
Gilles Peskine7dc97042020-02-26 19:48:43 +0100144 tests/compat.sh
145 tests/ssl-opt.sh
Manuel Pégourié-Gonnard61137df2014-02-24 11:57:36 +0100146
Manuel Pégourié-Gonnard546d86c2014-01-31 16:19:43 +0100147lcov:
148 rm -rf Coverage
Manuel Pégourié-Gonnard53c6e962014-06-13 12:22:07 +0200149 lcov --capture --initial --directory library -o files.info
Dan Handleya8b26c22020-05-28 16:20:31 +0100150 lcov --rc lcov_branch_coverage=1 --capture --directory library -o tests.info
151 lcov --rc lcov_branch_coverage=1 --add-tracefile files.info --add-tracefile tests.info -o all.info
152 lcov --rc lcov_branch_coverage=1 --remove all.info -o final.info '*.h'
Manuel Pégourié-Gonnard720375e2014-02-24 12:39:18 +0100153 gendesc tests/Descriptions.txt -o descriptions
Dan Handleya8b26c22020-05-28 16:20:31 +0100154 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 +0200155 rm -f files.info tests.info all.info final.info descriptions
Manuel Pégourié-Gonnard546d86c2014-01-31 16:19:43 +0100156
Paul Bakker37ca75d2011-01-06 12:28:03 +0000157apidoc:
158 mkdir -p apidoc
Krzysztof Stachowiak744a4ac2018-01-22 13:38:31 +0100159 cd doxygen && doxygen mbedtls.doxyfile
Paul Bakker37ca75d2011-01-06 12:28:03 +0000160
161apidoc_clean:
Manuel Pégourié-Gonnard5c59a4f2015-06-24 13:06:24 +0200162 rm -rf apidoc
163endif
Gilles Peskine66c1e2c2018-01-16 14:04:05 +0100164
165## Editor navigation files
Gilles Peskine646ad222020-11-09 21:20:16 +0100166C_SOURCE_FILES = $(wildcard \
167 3rdparty/*/include/*/*.h 3rdparty/*/include/*/*/*.h 3rdparty/*/include/*/*/*/*.h \
168 3rdparty/*/*.c 3rdparty/*/*/*.c 3rdparty/*/*/*/*.c 3rdparty/*/*/*/*/*.c \
169 include/*/*.h \
170 library/*.[hc] \
171 programs/*/*.[hc] \
172 tests/include/*/*.h tests/include/*/*/*.h \
173 tests/src/*.c tests/src/*/*.c \
174 tests/suites/*.function \
175)
Manuel Pégourié-Gonnardc9f89562020-04-02 12:10:45 +0200176# Exuberant-ctags invocation. Other ctags implementations may require different options.
Gilles Peskineb305b002021-01-13 13:45:30 +0100177CTAGS = ctags --langmap=c:+.h.function --line-directives=no -o
Gilles Peskine66c1e2c2018-01-16 14:04:05 +0100178tags: $(C_SOURCE_FILES)
Manuel Pégourié-Gonnardc9f89562020-04-02 12:10:45 +0200179 $(CTAGS) $@ $(C_SOURCE_FILES)
Gilles Peskine66c1e2c2018-01-16 14:04:05 +0100180TAGS: $(C_SOURCE_FILES)
Gilles Peskineb305b002021-01-13 13:45:30 +0100181 etags --no-line-directive -o $@ $(C_SOURCE_FILES)
Gilles Peskine8346c7a2020-11-20 11:50:08 +0100182global: GPATH GRTAGS GSYMS GTAGS
Gilles Peskine66c1e2c2018-01-16 14:04:05 +0100183GPATH GRTAGS GSYMS GTAGS: $(C_SOURCE_FILES)
184 ls $(C_SOURCE_FILES) | gtags -f - --gtagsconf .globalrc
Gilles Peskine8346c7a2020-11-20 11:50:08 +0100185cscope: cscope.in.out cscope.po.out cscope.out
Gilles Peskined0c78012020-11-09 21:21:31 +0100186cscope.in.out cscope.po.out cscope.out: $(C_SOURCE_FILES)
187 cscope -bq -u -Iinclude -Ilibrary $(patsubst %,-I%,$(wildcard 3rdparty/*/include)) -Itests/include $(C_SOURCE_FILES)
Gilles Peskine8346c7a2020-11-20 11:50:08 +0100188.PHONY: cscope global