Makefile 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. #
  2. # Copyright (C) 2011-2015 OpenWrt.org
  3. #
  4. # This is free software, licensed under the GNU General Public License v2.
  5. # See /LICENSE for more information.
  6. #
  7. include $(TOPDIR)/rules.mk
  8. PKG_NAME:=mbedtls
  9. PKG_VERSION:=2.16.9
  10. PKG_RELEASE:=1
  11. PKG_USE_MIPS16:=0
  12. PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
  13. PKG_SOURCE_URL:=https://codeload.github.com/ARMmbed/mbedtls/tar.gz/v$(PKG_VERSION)?
  14. PKG_HASH:=fc17ff7d8c11d08f23ae2800a18269408ad2c24ea6bb8b9363e41a01c2425697
  15. PKG_BUILD_PARALLEL:=1
  16. PKG_LICENSE:=GPL-2.0-or-later
  17. PKG_LICENSE_FILES:=gpl-2.0.txt
  18. PKG_CPE_ID:=cpe:/a:arm:mbed_tls
  19. PKG_CONFIG_DEPENDS := \
  20. CONFIG_LIBMBEDTLS_DEBUG_C \
  21. CONFIG_LIBMBEDTLS_HKDF_C
  22. include $(INCLUDE_DIR)/package.mk
  23. include $(INCLUDE_DIR)/cmake.mk
  24. define Package/mbedtls/Default
  25. TITLE:=Embedded SSL
  26. URL:=https://tls.mbed.org
  27. endef
  28. define Package/mbedtls/Default/description
  29. The aim of the mbedtls project is to provide a quality, open-source
  30. cryptographic library written in C and targeted at embedded systems.
  31. endef
  32. define Package/libmbedtls
  33. $(call Package/mbedtls/Default)
  34. SECTION:=libs
  35. CATEGORY:=Libraries
  36. SUBMENU:=SSL
  37. TITLE+= (library)
  38. ABI_VERSION:=12
  39. endef
  40. define Package/libmbedtls/config
  41. config LIBMBEDTLS_DEBUG_C
  42. depends on PACKAGE_libmbedtls
  43. bool "Enable debug functions"
  44. default n
  45. help
  46. This option enables mbedtls library's debug functions.
  47. It increases the uncompressed libmbedtls binary size
  48. by around 60 KiB (for an ARMv5 platform).
  49. Usually, you don't need this, so don't select this if you're unsure.
  50. config LIBMBEDTLS_HKDF_C
  51. depends on PACKAGE_libmbedtls
  52. bool "Enable the HKDF algorithm (RFC 5869)"
  53. default n
  54. help
  55. This option adds support for the Hashed Message Authentication Code
  56. (HMAC)-based key derivation function (HKDF).
  57. endef
  58. define Package/mbedtls-util
  59. $(call Package/mbedtls/Default)
  60. SECTION:=utils
  61. CATEGORY:=Utilities
  62. TITLE+= (utilities)
  63. DEPENDS:=+libmbedtls
  64. endef
  65. define Package/libmbedtls/description
  66. $(call Package/mbedtls/Default/description)
  67. This package contains the mbedtls library.
  68. endef
  69. define Package/mbedtls-util/description
  70. $(call Package/mbedtls/Default/description)
  71. This package contains mbedtls helper programs for private key and
  72. CSR generation (gen_key, cert_req)
  73. endef
  74. PKG_INSTALL:=1
  75. TARGET_CFLAGS += -ffunction-sections -fdata-sections
  76. TARGET_CFLAGS := $(filter-out -O%,$(TARGET_CFLAGS))
  77. CMAKE_OPTIONS += \
  78. -DUSE_SHARED_MBEDTLS_LIBRARY:Bool=ON \
  79. -DENABLE_TESTING:Bool=OFF \
  80. -DENABLE_PROGRAMS:Bool=ON
  81. define Build/Configure
  82. $(Build/Configure/Default)
  83. awk 'BEGIN { rc = 1 } \
  84. /#define MBEDTLS_DEBUG_C/ { $$$$0 = "$(if $(CONFIG_LIBMBEDTLS_DEBUG_C),,// )#define MBEDTLS_DEBUG_C"; rc = 0 } \
  85. { print } \
  86. END { exit(rc) }' $(PKG_BUILD_DIR)/include/mbedtls/config.h \
  87. >$(PKG_BUILD_DIR)/include/mbedtls/config.h.new && \
  88. mv $(PKG_BUILD_DIR)/include/mbedtls/config.h.new $(PKG_BUILD_DIR)/include/mbedtls/config.h
  89. awk 'BEGIN { rc = 1 } \
  90. /#define MBEDTLS_HKDF_C/ { $$$$0 = "$(if $(CONFIG_LIBMBEDTLS_HKDF_C),,// )#define MBEDTLS_HKDF_C"; rc = 0 } \
  91. { print } \
  92. END { exit(rc) }' $(PKG_BUILD_DIR)/include/mbedtls/config.h \
  93. >$(PKG_BUILD_DIR)/include/mbedtls/config.h.new && \
  94. mv $(PKG_BUILD_DIR)/include/mbedtls/config.h.new $(PKG_BUILD_DIR)/include/mbedtls/config.h
  95. endef
  96. define Build/InstallDev
  97. $(INSTALL_DIR) $(1)/usr/include
  98. $(CP) $(PKG_INSTALL_DIR)/usr/include/mbedtls $(1)/usr/include/
  99. $(INSTALL_DIR) $(1)/usr/lib
  100. $(CP) $(PKG_INSTALL_DIR)/usr/lib/lib*.so* $(1)/usr/lib/
  101. $(CP) $(PKG_INSTALL_DIR)/usr/lib/lib*.a $(1)/usr/lib/
  102. endef
  103. define Package/libmbedtls/install
  104. $(INSTALL_DIR) $(1)/usr/lib
  105. $(CP) $(PKG_INSTALL_DIR)/usr/lib/lib*.so.* $(1)/usr/lib/
  106. endef
  107. define Package/mbedtls-util/install
  108. $(INSTALL_DIR) $(1)/usr/bin
  109. $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/gen_key $(1)/usr/bin/
  110. $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/cert_req $(1)/usr/bin/
  111. endef
  112. $(eval $(call BuildPackage,libmbedtls))
  113. $(eval $(call BuildPackage,mbedtls-util))