| Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 1 | DESTDIR=/usr/local | 
| Manuel Pégourié-Gonnard | 5285970 | 2015-01-27 14:05:16 +0100 | [diff] [blame] | 2 | PREFIX=mbedtls_ | 
| Gilles Peskine | 687d1ab | 2021-04-22 01:01:56 +0200 | [diff] [blame] | 3 | PERL ?= perl | 
| Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 4 |  | 
|  | 5 | .SILENT: | 
|  | 6 |  | 
| Manuel Pégourié-Gonnard | 5c59a4f | 2015-06-24 13:06:24 +0200 | [diff] [blame] | 7 | .PHONY: all no_test programs lib tests install uninstall clean test check covtest lcov apidoc apidoc_clean | 
| Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 8 |  | 
| Andres AG | 7aa5fa1 | 2016-08-25 16:36:16 +0100 | [diff] [blame] | 9 | all: programs tests | 
|  | 10 | $(MAKE) post_build | 
| Alon Bar-Lev | 06f0d26 | 2015-02-18 17:18:28 +0200 | [diff] [blame] | 11 |  | 
| Manuel Pégourié-Gonnard | 5c59a4f | 2015-06-24 13:06:24 +0200 | [diff] [blame] | 12 | no_test: programs | 
|  | 13 |  | 
| Ronald Cron | ddaf99c | 2020-06-19 11:27:26 +0200 | [diff] [blame] | 14 | programs: lib mbedtls_test | 
| Alon Bar-Lev | 06f0d26 | 2015-02-18 17:18:28 +0200 | [diff] [blame] | 15 | $(MAKE) -C programs | 
| Paul Bakker | f9964ab | 2012-04-05 12:07:50 +0000 | [diff] [blame] | 16 |  | 
|  | 17 | lib: | 
| Alon Bar-Lev | 06f0d26 | 2015-02-18 17:18:28 +0200 | [diff] [blame] | 18 | $(MAKE) -C library | 
|  | 19 |  | 
| Ronald Cron | ddaf99c | 2020-06-19 11:27:26 +0200 | [diff] [blame] | 20 | tests: lib mbedtls_test | 
| Alon Bar-Lev | 06f0d26 | 2015-02-18 17:18:28 +0200 | [diff] [blame] | 21 | $(MAKE) -C tests | 
| Paul Bakker | f9964ab | 2012-04-05 12:07:50 +0000 | [diff] [blame] | 22 |  | 
| Ronald Cron | ddaf99c | 2020-06-19 11:27:26 +0200 | [diff] [blame] | 23 | mbedtls_test: | 
|  | 24 | $(MAKE) -C tests mbedtls_test | 
|  | 25 |  | 
| Gilles Peskine | 687d1ab | 2021-04-22 01:01:56 +0200 | [diff] [blame] | 26 | library/%: | 
|  | 27 | $(MAKE) -C library $* | 
|  | 28 | programs/%: | 
|  | 29 | $(MAKE) -C programs $* | 
|  | 30 | tests/%: | 
|  | 31 | $(MAKE) -C tests $* | 
|  | 32 |  | 
|  | 33 | .PHONY: generated_files | 
|  | 34 | generated_files: library/generated_files | 
|  | 35 | generated_files: programs/generated_files | 
|  | 36 | generated_files: tests/generated_files | 
|  | 37 | generated_files: visualc_files | 
|  | 38 |  | 
|  | 39 | .PHONY: visualc_files | 
|  | 40 | VISUALC_FILES = visualc/VS2010/mbedTLS.sln visualc/VS2010/mbedTLS.vcxproj | 
|  | 41 | # TODO: $(app).vcxproj for each $(app) in programs/ | 
|  | 42 | visualc_files: $(VISUALC_FILES) | 
| Gilles Peskine | 94230ea | 2021-05-18 15:48:56 +0200 | [diff] [blame] | 43 |  | 
|  | 44 | # Ensure that the .c files that generate_visualc_files.pl enumerates are | 
| Gilles Peskine | a13deaf | 2021-05-19 14:26:37 +0200 | [diff] [blame] | 45 | # 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 Peskine | 687d1ab | 2021-04-22 01:01:56 +0200 | [diff] [blame] | 48 | $(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é-Gonnard | 5c59a4f | 2015-06-24 13:06:24 +0200 | [diff] [blame] | 57 | ifndef WINDOWS | 
| Manuel Pégourié-Gonnard | 9983993 | 2015-08-03 10:34:09 +0200 | [diff] [blame] | 58 | install: no_test | 
| Manuel Pégourié-Gonnard | 7f80997 | 2015-03-09 17:05:11 +0000 | [diff] [blame] | 59 | mkdir -p $(DESTDIR)/include/mbedtls | 
| Ruini Xue | 5a9cb61 | 2018-06-28 23:21:26 +0800 | [diff] [blame] | 60 | cp -rp include/mbedtls $(DESTDIR)/include | 
| Jaeden Amero | 3c7cc5e | 2018-11-15 17:38:58 +0000 | [diff] [blame] | 61 | mkdir -p $(DESTDIR)/include/psa | 
|  | 62 | cp -rp include/psa $(DESTDIR)/include | 
| Darryl Green | 11999bb | 2018-03-13 15:22:58 +0000 | [diff] [blame] | 63 |  | 
| Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 64 | mkdir -p $(DESTDIR)/lib | 
| Gilles Peskine | 722a7e6 | 2020-02-26 19:05:19 +0100 | [diff] [blame] | 65 | cp -RP library/libmbedtls.*    $(DESTDIR)/lib | 
|  | 66 | cp -RP library/libmbedx509.*   $(DESTDIR)/lib | 
| Manuel Pégourié-Gonnard | 52a5079 | 2015-07-27 10:36:12 +0200 | [diff] [blame] | 67 | cp -RP library/libmbedcrypto.* $(DESTDIR)/lib | 
| Darryl Green | 11999bb | 2018-03-13 15:22:58 +0000 | [diff] [blame] | 68 |  | 
| Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 69 | 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 Bakker | 9a73632 | 2012-11-14 12:39:52 +0000 | [diff] [blame] | 78 | uninstall: | 
| Manuel Pégourié-Gonnard | 7f80997 | 2015-03-09 17:05:11 +0000 | [diff] [blame] | 79 | rm -rf $(DESTDIR)/include/mbedtls | 
| Wu, Jheng-Jhong | 89b9814 | 2020-11-26 09:27:17 +0800 | [diff] [blame] | 80 | rm -rf $(DESTDIR)/include/psa | 
| Gilles Peskine | 722a7e6 | 2020-02-26 19:05:19 +0100 | [diff] [blame] | 81 | rm -f $(DESTDIR)/lib/libmbedtls.* | 
|  | 82 | rm -f $(DESTDIR)/lib/libmbedx509.* | 
| Manuel Pégourié-Gonnard | 52a5079 | 2015-07-27 10:36:12 +0200 | [diff] [blame] | 83 | rm -f $(DESTDIR)/lib/libmbedcrypto.* | 
| Darryl Green | 11999bb | 2018-03-13 15:22:58 +0000 | [diff] [blame] | 84 |  | 
| Paul Bakker | 9a73632 | 2012-11-14 12:39:52 +0000 | [diff] [blame] | 85 | 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é-Gonnard | 5c59a4f | 2015-06-24 13:06:24 +0200 | [diff] [blame] | 92 | endif | 
| Paul Bakker | 9a73632 | 2012-11-14 12:39:52 +0000 | [diff] [blame] | 93 |  | 
| Simon Butcher | 1ceab6e | 2016-06-21 10:14:00 +0100 | [diff] [blame] | 94 |  | 
| Nir Sonnenschein | b7ebbca | 2018-08-29 10:20:12 +0300 | [diff] [blame] | 95 | WARNING_BORDER_LONG      =**********************************************************************************\n | 
|  | 96 | CTR_DRBG_128_BIT_KEY_WARN_L1=****  WARNING!  MBEDTLS_CTR_DRBG_USE_128_BIT_KEY defined!                      ****\n | 
|  | 97 | CTR_DRBG_128_BIT_KEY_WARN_L2=****  Using 128-bit keys for CTR_DRBG limits the security of generated         ****\n | 
|  | 98 | CTR_DRBG_128_BIT_KEY_WARN_L3=****  keys and operations that use random values generated to 128-bit security ****\n | 
|  | 99 |  | 
|  | 100 | 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) | 
|  | 101 |  | 
| Simon Butcher | 1ceab6e | 2016-06-21 10:14:00 +0100 | [diff] [blame] | 102 | # Post build steps | 
|  | 103 | post_build: | 
| Simon Butcher | cff625f | 2016-06-27 15:15:11 +0100 | [diff] [blame] | 104 | ifndef WINDOWS | 
| Nir Sonnenschein | b7ebbca | 2018-08-29 10:20:12 +0300 | [diff] [blame] | 105 |  | 
|  | 106 | # If 128-bit keys are configured for CTR_DRBG, display an appropriate warning | 
| Gilles Peskine | 3bdd412 | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 107 | -scripts/config.py get MBEDTLS_CTR_DRBG_USE_128_BIT_KEY && ([ $$? -eq 0 ]) && \ | 
| Nir Sonnenschein | b7ebbca | 2018-08-29 10:20:12 +0300 | [diff] [blame] | 108 | echo '$(CTR_DRBG_128_BIT_KEY_WARNING)' | 
|  | 109 |  | 
| Simon Butcher | cff625f | 2016-06-27 15:15:11 +0100 | [diff] [blame] | 110 | endif | 
| Simon Butcher | 1ceab6e | 2016-06-21 10:14:00 +0100 | [diff] [blame] | 111 |  | 
| Gilles Peskine | 687d1ab | 2021-04-22 01:01:56 +0200 | [diff] [blame] | 112 | clean: clean_more_on_top | 
| Alon Bar-Lev | 06f0d26 | 2015-02-18 17:18:28 +0200 | [diff] [blame] | 113 | $(MAKE) -C library clean | 
|  | 114 | $(MAKE) -C programs clean | 
|  | 115 | $(MAKE) -C tests clean | 
| Gilles Peskine | 687d1ab | 2021-04-22 01:01:56 +0200 | [diff] [blame] | 116 |  | 
|  | 117 | clean_more_on_top: | 
| Manuel Pégourié-Gonnard | 5c59a4f | 2015-06-24 13:06:24 +0200 | [diff] [blame] | 118 | ifndef WINDOWS | 
| Paul Bakker | bd3b359 | 2016-07-13 16:37:32 +0100 | [diff] [blame] | 119 | find . \( -name \*.gcno -o -name \*.gcda -o -name \*.info \) -exec rm {} + | 
| Manuel Pégourié-Gonnard | 5c59a4f | 2015-06-24 13:06:24 +0200 | [diff] [blame] | 120 | endif | 
| Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 121 |  | 
| Gilles Peskine | 687d1ab | 2021-04-22 01:01:56 +0200 | [diff] [blame] | 122 | neat: clean_more_on_top | 
|  | 123 | $(MAKE) -C library neat | 
|  | 124 | $(MAKE) -C programs neat | 
|  | 125 | $(MAKE) -C tests neat | 
|  | 126 | ifndef WINDOWS | 
|  | 127 | rm -f visualc/VS2010/*.vcxproj visualc/VS2010/mbedTLS.sln | 
|  | 128 | else | 
|  | 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 | 
|  | 131 | endif | 
|  | 132 |  | 
| Andres AG | c49b808 | 2016-08-31 16:10:45 +0100 | [diff] [blame] | 133 | check: lib tests | 
| Alon Bar-Lev | 06f0d26 | 2015-02-18 17:18:28 +0200 | [diff] [blame] | 134 | $(MAKE) -C tests check | 
| Paul Bakker | 37ca75d | 2011-01-06 12:28:03 +0000 | [diff] [blame] | 135 |  | 
| Manuel Pégourié-Gonnard | 5c59a4f | 2015-06-24 13:06:24 +0200 | [diff] [blame] | 136 | test: check | 
| Manuel Pégourié-Gonnard | 6529ff0 | 2014-01-31 13:41:07 +0100 | [diff] [blame] | 137 |  | 
| Manuel Pégourié-Gonnard | 8511384 | 2015-07-08 21:20:03 +0100 | [diff] [blame] | 138 | ifndef WINDOWS | 
| Manuel Pégourié-Gonnard | 720375e | 2014-02-24 12:39:18 +0100 | [diff] [blame] | 139 | # note: for coverage testing, build with: | 
| Manuel Pégourié-Gonnard | 5c59a4f | 2015-06-24 13:06:24 +0200 | [diff] [blame] | 140 | # make CFLAGS='--coverage -g3 -O0' | 
| Manuel Pégourié-Gonnard | 79d090b | 2014-02-26 19:39:01 +0100 | [diff] [blame] | 141 | covtest: | 
| Manuel Pégourié-Gonnard | fc36708 | 2015-06-26 16:50:24 +0200 | [diff] [blame] | 142 | $(MAKE) check | 
| Manuel Pégourié-Gonnard | 61137df | 2014-02-24 11:57:36 +0100 | [diff] [blame] | 143 | programs/test/selftest | 
| Gilles Peskine | 7dc9704 | 2020-02-26 19:48:43 +0100 | [diff] [blame] | 144 | tests/compat.sh | 
|  | 145 | tests/ssl-opt.sh | 
| Manuel Pégourié-Gonnard | 61137df | 2014-02-24 11:57:36 +0100 | [diff] [blame] | 146 |  | 
| Manuel Pégourié-Gonnard | 546d86c | 2014-01-31 16:19:43 +0100 | [diff] [blame] | 147 | lcov: | 
|  | 148 | rm -rf Coverage | 
| Manuel Pégourié-Gonnard | 53c6e96 | 2014-06-13 12:22:07 +0200 | [diff] [blame] | 149 | lcov --capture --initial --directory library -o files.info | 
| Dan Handley | a8b26c2 | 2020-05-28 16:20:31 +0100 | [diff] [blame] | 150 | 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é-Gonnard | 720375e | 2014-02-24 12:39:18 +0100 | [diff] [blame] | 153 | gendesc tests/Descriptions.txt -o descriptions | 
| Dan Handley | a8b26c2 | 2020-05-28 16:20:31 +0100 | [diff] [blame] | 154 | genhtml --title "mbed TLS" --description-file descriptions --keep-descriptions --legend --branch-coverage -o Coverage final.info | 
| Manuel Pégourié-Gonnard | e41072e | 2014-06-16 16:24:24 +0200 | [diff] [blame] | 155 | rm -f files.info tests.info all.info final.info descriptions | 
| Manuel Pégourié-Gonnard | 546d86c | 2014-01-31 16:19:43 +0100 | [diff] [blame] | 156 |  | 
| Paul Bakker | 37ca75d | 2011-01-06 12:28:03 +0000 | [diff] [blame] | 157 | apidoc: | 
|  | 158 | mkdir -p apidoc | 
| Krzysztof Stachowiak | 744a4ac | 2018-01-22 13:38:31 +0100 | [diff] [blame] | 159 | cd doxygen && doxygen mbedtls.doxyfile | 
| Paul Bakker | 37ca75d | 2011-01-06 12:28:03 +0000 | [diff] [blame] | 160 |  | 
|  | 161 | apidoc_clean: | 
| Manuel Pégourié-Gonnard | 5c59a4f | 2015-06-24 13:06:24 +0200 | [diff] [blame] | 162 | rm -rf apidoc | 
|  | 163 | endif | 
| Gilles Peskine | 66c1e2c | 2018-01-16 14:04:05 +0100 | [diff] [blame] | 164 |  | 
|  | 165 | ## Editor navigation files | 
| Gilles Peskine | 646ad22 | 2020-11-09 21:20:16 +0100 | [diff] [blame] | 166 | C_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é-Gonnard | c9f8956 | 2020-04-02 12:10:45 +0200 | [diff] [blame] | 176 | # Exuberant-ctags invocation. Other ctags implementations may require different options. | 
| Gilles Peskine | b305b00 | 2021-01-13 13:45:30 +0100 | [diff] [blame] | 177 | CTAGS = ctags --langmap=c:+.h.function --line-directives=no -o | 
| Gilles Peskine | 66c1e2c | 2018-01-16 14:04:05 +0100 | [diff] [blame] | 178 | tags: $(C_SOURCE_FILES) | 
| Manuel Pégourié-Gonnard | c9f8956 | 2020-04-02 12:10:45 +0200 | [diff] [blame] | 179 | $(CTAGS) $@ $(C_SOURCE_FILES) | 
| Gilles Peskine | 66c1e2c | 2018-01-16 14:04:05 +0100 | [diff] [blame] | 180 | TAGS: $(C_SOURCE_FILES) | 
| Gilles Peskine | b305b00 | 2021-01-13 13:45:30 +0100 | [diff] [blame] | 181 | etags --no-line-directive -o $@ $(C_SOURCE_FILES) | 
| Gilles Peskine | 8346c7a | 2020-11-20 11:50:08 +0100 | [diff] [blame] | 182 | global: GPATH GRTAGS GSYMS GTAGS | 
| Gilles Peskine | 66c1e2c | 2018-01-16 14:04:05 +0100 | [diff] [blame] | 183 | GPATH GRTAGS GSYMS GTAGS: $(C_SOURCE_FILES) | 
|  | 184 | ls $(C_SOURCE_FILES) | gtags -f - --gtagsconf .globalrc | 
| Gilles Peskine | 8346c7a | 2020-11-20 11:50:08 +0100 | [diff] [blame] | 185 | cscope: cscope.in.out cscope.po.out cscope.out | 
| Gilles Peskine | d0c7801 | 2020-11-09 21:21:31 +0100 | [diff] [blame] | 186 | cscope.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 Peskine | 8346c7a | 2020-11-20 11:50:08 +0100 | [diff] [blame] | 188 | .PHONY: cscope global |