component.mk 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. #
  2. # Component Makefile
  3. #
  4. COMPONENT_ADD_INCLUDEDIRS := port/include mbedtls/include esp_crt_bundle/include
  5. COMPONENT_PRIV_INCLUDEDIRS := mbedtls/library
  6. COMPONENT_SRCDIRS := mbedtls/library port port/$(IDF_TARGET) port/sha port/sha/parallel_engine port/aes port/aes/block port/md esp_crt_bundle
  7. COMPONENT_OBJEXCLUDE := mbedtls/library/net_sockets.o
  8. ifdef CONFIG_MBEDTLS_SSL_PROTO_GMTSSL1_1
  9. COMPONENT_OBJEXCLUDE += \
  10. mbedtls/library/ssl_ciphersuites.o \
  11. mbedtls/library/ecp.o \
  12. mbedtls/library/cipher_wrap.o \
  13. mbedtls/library/oid.o \
  14. mbedtls/library/ecp_curves.o \
  15. mbedtls/library/pk_wrap.o \
  16. mbedtls/library/ecdsa.o \
  17. mbedtls/library/x509_crt.o \
  18. mbedtls/library/ssl_tls.o \
  19. mbedtls/library/ssl_cli.o
  20. endif
  21. COMPONENT_SUBMODULES += mbedtls
  22. # Note: some mbedTLS hardware acceleration can be enabled/disabled by config.
  23. #
  24. # We don't need to exclude aes.o as these functions use a different prefix (esp_aes_x) and the
  25. # config option only changes the prefixes in the header so mbedtls_aes_x compiles to esp_aes_x
  26. #
  27. # The other port-specific files don't override internal mbedTLS functions, they just add new functions.
  28. ifndef CONFIG_MBEDTLS_HARDWARE_MPI
  29. COMPONENT_OBJEXCLUDE += port/esp_bignum.o port/$(IDF_TARGET)/bignum.o
  30. endif
  31. ifndef CONFIG_MBEDTLS_HARDWARE_SHA
  32. COMPONENT_OBJEXCLUDE += port/parallel_engine/esp_sha1.o port/parallel_engine/esp_sha256.o port/parallel_engine/esp_sha512.o
  33. endif
  34. ifdef CONFIG_MBEDTLS_CERTIFICATE_BUNDLE
  35. GEN_CRT_BUNDLEPY := $(PYTHON) $(COMPONENT_PATH)/esp_crt_bundle/gen_crt_bundle.py
  36. DEFAULT_CRT_DIR := ${COMPONENT_PATH}/esp_crt_bundle
  37. X509_CERTIFICATE_BUNDLE := $(abspath x509_crt_bundle)
  38. CUSTOM_BUNDLE_PATH := $(PROJECT_PATH)/$(CONFIG_MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE_PATH)
  39. ifdef CONFIG_MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE
  40. CRT_PATHS += $(CUSTOM_BUNDLE_PATH)
  41. endif
  42. ifdef CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_FULL
  43. CRT_PATHS += ${DEFAULT_CRT_DIR}/cacrt_all.pem
  44. endif
  45. ifdef CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_CMN
  46. CRT_PATHS += ${DEFAULT_CRT_DIR}/cacrt_all.pem
  47. ARGS += --filter ${DEFAULT_CRT_DIR}/cmn_crt_authorities.csv
  48. endif
  49. ARGS += --input $(CRT_PATHS) -q
  50. # Generate certificate bundle using generate_cert_bundle.py
  51. $(X509_CERTIFICATE_BUNDLE) : $(SDKCONFIG_MAKEFILE)
  52. $(GEN_CRT_BUNDLEPY) $(ARGS)
  53. COMPONENT_EXTRA_CLEAN += $(X509_CERTIFICATE_BUNDLE)
  54. COMPONENT_EMBED_FILES := $(X509_CERTIFICATE_BUNDLE)
  55. endif
  56. ifdef CONFIG_MBEDTLS_DYNAMIC_BUFFER
  57. WRAP_FUNCTIONS = mbedtls_ssl_handshake_client_step \
  58. mbedtls_ssl_handshake_server_step \
  59. mbedtls_ssl_read \
  60. mbedtls_ssl_write \
  61. mbedtls_ssl_session_reset \
  62. mbedtls_ssl_free \
  63. mbedtls_ssl_setup \
  64. mbedtls_ssl_send_alert_message \
  65. mbedtls_ssl_close_notify
  66. COMPONENT_SRCDIRS += port/dynamic
  67. endif
  68. ifneq ($(origin WRAP_FUNCTIONS),undefined)
  69. WRAP_ARGUMENT := -Wl,--wrap=
  70. COMPONENT_ADD_LDFLAGS = -l$(COMPONENT_NAME) $(addprefix $(WRAP_ARGUMENT),$(WRAP_FUNCTIONS))
  71. endif