component.mk 2.4 KB

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