1DESTDIR=/usr/local 2PREFIX=mbedtls_ 3 4.SILENT: 5 6.PHONY: all no_test programs lib tests install uninstall clean test check covtest lcov apidoc apidoc_clean 7 8all: programs tests 9 $(MAKE) post_build 10 11no_test: programs 12 13programs: lib mbedtls_test 14 $(MAKE) -C programs 15 16lib: 17 $(MAKE) -C library 18 19tests: lib mbedtls_test 20 $(MAKE) -C tests 21 22mbedtls_test: 23 $(MAKE) -C tests mbedtls_test 24 25ifndef WINDOWS 26install: no_test 27 mkdir -p $(DESTDIR)/include/mbedtls 28 cp -rp include/mbedtls $(DESTDIR)/include 29 mkdir -p $(DESTDIR)/include/psa 30 cp -rp include/psa $(DESTDIR)/include 31 32 mkdir -p $(DESTDIR)/lib 33 cp -RP library/libmbedtls.* $(DESTDIR)/lib 34 cp -RP library/libmbedx509.* $(DESTDIR)/lib 35 cp -RP library/libmbedcrypto.* $(DESTDIR)/lib 36 37 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 46uninstall: 47 rm -rf $(DESTDIR)/include/mbedtls 48 rm -rf $(DESTDIR)/include/psa 49 rm -f $(DESTDIR)/lib/libmbedtls.* 50 rm -f $(DESTDIR)/lib/libmbedx509.* 51 rm -f $(DESTDIR)/lib/libmbedcrypto.* 52 53 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 60endif 61 62WARNING_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 69WARNING_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 76# Post build steps 77post_build: 78ifndef WINDOWS 79 80 # If 128-bit keys are configured for CTR_DRBG, display an appropriate warning 81 -scripts/config.py get MBEDTLS_CTR_DRBG_USE_128_BIT_KEY && ([ $$? -eq 0 ]) && \ 82 echo '$(CTR_DRBG_128_BIT_KEY_WARNING)' 83 84 # If NULL Entropy is configured, display an appropriate warning 85 -scripts/config.py get MBEDTLS_TEST_NULL_ENTROPY && ([ $$? -eq 0 ]) && \ 86 echo '$(NULL_ENTROPY_WARNING)' 87endif 88 89clean: 90 $(MAKE) -C library clean 91 $(MAKE) -C programs clean 92 $(MAKE) -C tests clean 93ifndef WINDOWS 94 find . \( -name \*.gcno -o -name \*.gcda -o -name \*.info \) -exec rm {} + 95endif 96 97check: lib tests 98 $(MAKE) -C tests check 99 100test: check 101 102ifndef WINDOWS 103# note: for coverage testing, build with: 104# make CFLAGS='--coverage -g3 -O0' 105covtest: 106 $(MAKE) check 107 programs/test/selftest 108 tests/compat.sh 109 tests/ssl-opt.sh 110 111lcov: 112 rm -rf Coverage 113 lcov --capture --initial --directory library -o files.info 114 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' 117 gendesc tests/Descriptions.txt -o descriptions 118 genhtml --title "mbed TLS" --description-file descriptions --keep-descriptions --legend --branch-coverage -o Coverage final.info 119 rm -f files.info tests.info all.info final.info descriptions 120 121apidoc: 122 mkdir -p apidoc 123 cd doxygen && doxygen mbedtls.doxyfile 124 125apidoc_clean: 126 rm -rf apidoc 127endif 128 129## Editor navigation files 130C_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) 140# Exuberant-ctags invocation. Other ctags implementations may require different options. 141CTAGS = ctags --langmap=c:+.h.function -o 142tags: $(C_SOURCE_FILES) 143 $(CTAGS) $@ $(C_SOURCE_FILES) 144TAGS: $(C_SOURCE_FILES) 145 etags -o $@ $(C_SOURCE_FILES) 146global: GPATH GRTAGS GSYMS GTAGS 147GPATH GRTAGS GSYMS GTAGS: $(C_SOURCE_FILES) 148 ls $(C_SOURCE_FILES) | gtags -f - --gtagsconf .globalrc 149cscope: cscope.in.out cscope.po.out cscope.out 150cscope.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) 152.PHONY: cscope global 153