Makefile 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. DESTDIR=/usr/local
  2. PREFIX=mbedtls_
  3. .SILENT:
  4. .PHONY: all no_test programs lib tests install uninstall clean test check covtest lcov apidoc apidoc_clean
  5. all: programs tests
  6. $(MAKE) post_build
  7. no_test: programs
  8. programs: lib mbedtls_test
  9. $(MAKE) -C programs
  10. lib:
  11. $(MAKE) -C library
  12. tests: lib mbedtls_test
  13. $(MAKE) -C tests
  14. mbedtls_test:
  15. $(MAKE) -C tests mbedtls_test
  16. ifndef WINDOWS
  17. install: no_test
  18. mkdir -p $(DESTDIR)/include/mbedtls
  19. cp -rp include/mbedtls $(DESTDIR)/include
  20. mkdir -p $(DESTDIR)/include/psa
  21. cp -rp include/psa $(DESTDIR)/include
  22. mkdir -p $(DESTDIR)/lib
  23. cp -RP library/libmbedtls.* $(DESTDIR)/lib
  24. cp -RP library/libmbedx509.* $(DESTDIR)/lib
  25. cp -RP library/libmbedcrypto.* $(DESTDIR)/lib
  26. mkdir -p $(DESTDIR)/bin
  27. for p in programs/*/* ; do \
  28. if [ -x $$p ] && [ ! -d $$p ] ; \
  29. then \
  30. f=$(PREFIX)`basename $$p` ; \
  31. cp $$p $(DESTDIR)/bin/$$f ; \
  32. fi \
  33. done
  34. uninstall:
  35. rm -rf $(DESTDIR)/include/mbedtls
  36. rm -rf $(DESTDIR)/include/psa
  37. rm -f $(DESTDIR)/lib/libmbedtls.*
  38. rm -f $(DESTDIR)/lib/libmbedx509.*
  39. rm -f $(DESTDIR)/lib/libmbedcrypto.*
  40. for p in programs/*/* ; do \
  41. if [ -x $$p ] && [ ! -d $$p ] ; \
  42. then \
  43. f=$(PREFIX)`basename $$p` ; \
  44. rm -f $(DESTDIR)/bin/$$f ; \
  45. fi \
  46. done
  47. endif
  48. WARNING_BORDER =*******************************************************\n
  49. NULL_ENTROPY_WARN_L1=**** WARNING! MBEDTLS_TEST_NULL_ENTROPY defined! ****\n
  50. NULL_ENTROPY_WARN_L2=**** THIS BUILD HAS NO DEFINED ENTROPY SOURCES ****\n
  51. NULL_ENTROPY_WARN_L3=**** AND IS *NOT* SUITABLE FOR PRODUCTION USE ****\n
  52. NULL_ENTROPY_WARNING=\n$(WARNING_BORDER)$(NULL_ENTROPY_WARN_L1)$(NULL_ENTROPY_WARN_L2)$(NULL_ENTROPY_WARN_L3)$(WARNING_BORDER)
  53. WARNING_BORDER_LONG =**********************************************************************************\n
  54. CTR_DRBG_128_BIT_KEY_WARN_L1=**** WARNING! MBEDTLS_CTR_DRBG_USE_128_BIT_KEY defined! ****\n
  55. CTR_DRBG_128_BIT_KEY_WARN_L2=**** Using 128-bit keys for CTR_DRBG limits the security of generated ****\n
  56. CTR_DRBG_128_BIT_KEY_WARN_L3=**** keys and operations that use random values generated to 128-bit security ****\n
  57. 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)
  58. # Post build steps
  59. post_build:
  60. ifndef WINDOWS
  61. # If 128-bit keys are configured for CTR_DRBG, display an appropriate warning
  62. -scripts/config.py get MBEDTLS_CTR_DRBG_USE_128_BIT_KEY && ([ $$? -eq 0 ]) && \
  63. echo '$(CTR_DRBG_128_BIT_KEY_WARNING)'
  64. # If NULL Entropy is configured, display an appropriate warning
  65. -scripts/config.py get MBEDTLS_TEST_NULL_ENTROPY && ([ $$? -eq 0 ]) && \
  66. echo '$(NULL_ENTROPY_WARNING)'
  67. endif
  68. clean:
  69. $(MAKE) -C library clean
  70. $(MAKE) -C programs clean
  71. $(MAKE) -C tests clean
  72. ifndef WINDOWS
  73. find . \( -name \*.gcno -o -name \*.gcda -o -name \*.info \) -exec rm {} +
  74. endif
  75. check: lib tests
  76. $(MAKE) -C tests check
  77. test: check
  78. ifndef WINDOWS
  79. # note: for coverage testing, build with:
  80. # make CFLAGS='--coverage -g3 -O0'
  81. covtest:
  82. $(MAKE) check
  83. programs/test/selftest
  84. tests/compat.sh
  85. tests/ssl-opt.sh
  86. lcov:
  87. rm -rf Coverage
  88. lcov --capture --initial --directory library -o files.info
  89. lcov --rc lcov_branch_coverage=1 --capture --directory library -o tests.info
  90. lcov --rc lcov_branch_coverage=1 --add-tracefile files.info --add-tracefile tests.info -o all.info
  91. lcov --rc lcov_branch_coverage=1 --remove all.info -o final.info '*.h'
  92. gendesc tests/Descriptions.txt -o descriptions
  93. genhtml --title "mbed TLS" --description-file descriptions --keep-descriptions --legend --branch-coverage -o Coverage final.info
  94. rm -f files.info tests.info all.info final.info descriptions
  95. apidoc:
  96. mkdir -p apidoc
  97. cd doxygen && doxygen mbedtls.doxyfile
  98. apidoc_clean:
  99. rm -rf apidoc
  100. endif
  101. ## Editor navigation files
  102. C_SOURCE_FILES = $(wildcard \
  103. 3rdparty/*/include/*/*.h 3rdparty/*/include/*/*/*.h 3rdparty/*/include/*/*/*/*.h \
  104. 3rdparty/*/*.c 3rdparty/*/*/*.c 3rdparty/*/*/*/*.c 3rdparty/*/*/*/*/*.c \
  105. include/*/*.h \
  106. library/*.[hc] \
  107. programs/*/*.[hc] \
  108. tests/include/*/*.h tests/include/*/*/*.h \
  109. tests/src/*.c tests/src/*/*.c \
  110. tests/suites/*.function \
  111. )
  112. # Exuberant-ctags invocation. Other ctags implementations may require different options.
  113. CTAGS = ctags --langmap=c:+.h.function --line-directives=no -o
  114. tags: $(C_SOURCE_FILES)
  115. $(CTAGS) $@ $(C_SOURCE_FILES)
  116. TAGS: $(C_SOURCE_FILES)
  117. etags --no-line-directive -o $@ $(C_SOURCE_FILES)
  118. global: GPATH GRTAGS GSYMS GTAGS
  119. GPATH GRTAGS GSYMS GTAGS: $(C_SOURCE_FILES)
  120. ls $(C_SOURCE_FILES) | gtags -f - --gtagsconf .globalrc
  121. cscope: cscope.in.out cscope.po.out cscope.out
  122. cscope.in.out cscope.po.out cscope.out: $(C_SOURCE_FILES)
  123. cscope -bq -u -Iinclude -Ilibrary $(patsubst %,-I%,$(wildcard 3rdparty/*/include)) -Itests/include $(C_SOURCE_FILES)
  124. .PHONY: cscope global