Makefile 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. #
  2. # Copyright (C) 2006-2017 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:=wolfssl
  9. PKG_VERSION:=5.6.6-stable
  10. PKG_RELEASE:=1
  11. PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
  12. PKG_SOURCE_URL:=https://github.com/wolfSSL/wolfssl/archive/v$(PKG_VERSION)
  13. PKG_HASH:=3d2ca672d41c2c2fa667885a80d6fa03c3e91f0f4f72f87aef2bc947e8c87237
  14. PKG_FIXUP:=libtool libtool-abiver
  15. PKG_INSTALL:=1
  16. PKG_BUILD_FLAGS:=no-mips16 lto
  17. PKG_BUILD_PARALLEL:=1
  18. PKG_LICENSE:=GPL-2.0-or-later
  19. PKG_LICENSE_FILES:=LICENSING COPYING
  20. PKG_MAINTAINER:=Eneas U de Queiroz <cotequeiroz@gmail.com>
  21. PKG_CPE_ID:=cpe:/a:wolfssl:wolfssl
  22. PKG_CONFIG_DEPENDS:=\
  23. CONFIG_WOLFSSL_HAS_AES_CCM \
  24. CONFIG_WOLFSSL_HAS_ARC4 \
  25. CONFIG_WOLFSSL_HAS_CERTGEN \
  26. CONFIG_WOLFSSL_HAS_CHACHA_POLY \
  27. CONFIG_WOLFSSL_HAS_DH \
  28. CONFIG_WOLFSSL_HAS_DTLS \
  29. CONFIG_WOLFSSL_HAS_ECC25519 \
  30. CONFIG_WOLFSSL_HAS_ECC448 \
  31. CONFIG_WOLFSSL_HAS_OCSP \
  32. CONFIG_WOLFSSL_HAS_OPENVPN CONFIG_WOLFSSL_ALT_NAMES \
  33. CONFIG_WOLFSSL_HAS_SESSION_TICKET \
  34. CONFIG_WOLFSSL_HAS_TLSV10 \
  35. CONFIG_WOLFSSL_HAS_TLSV13 \
  36. CONFIG_WOLFSSL_HAS_WPAS
  37. PKG_ABI_VERSION:=$(patsubst %-stable,%,$(PKG_VERSION)).$(call version_abbrev,$(call confvar,$(PKG_CONFIG_DEPENDS)))
  38. PKG_CONFIG_DEPENDS+=\
  39. CONFIG_PACKAGE_libwolfssl-benchmark \
  40. CONFIG_WOLFSSL_HAS_AFALG \
  41. CONFIG_WOLFSSL_HAS_DEVCRYPTO_AES \
  42. CONFIG_WOLFSSL_HAS_DEVCRYPTO_CBC \
  43. CONFIG_WOLFSSL_HAS_DEVCRYPTO_FULL
  44. include $(INCLUDE_DIR)/package.mk
  45. define Package/libwolfssl/Default
  46. SECTION:=libs
  47. SUBMENU:=SSL
  48. CATEGORY:=Libraries
  49. URL:=http://www.wolfssl.com/
  50. endef
  51. define Package/libwolfssl
  52. $(call Package/libwolfssl/Default)
  53. TITLE:=wolfSSL library
  54. MENU:=1
  55. PROVIDES:=libcyassl
  56. DEPENDS:=+WOLFSSL_HAS_DEVCRYPTO:kmod-cryptodev +WOLFSSL_HAS_AFALG:kmod-crypto-user
  57. ABI_VERSION:=$(PKG_ABI_VERSION)
  58. VARIANT:=regular
  59. DEFAULT_VARIANT:=1
  60. CONFLICTS:=libwolfsslcpu-crypto
  61. endef
  62. define Package/libwolfssl/description
  63. wolfSSL (formerly CyaSSL) is an SSL library optimized for small
  64. footprint, both on disk and for memory use.
  65. endef
  66. define Package/libwolfssl/config
  67. source "$(SOURCE)/Config.in"
  68. endef
  69. define Package/libwolfsslcpu-crypto
  70. $(call Package/libwolfssl/Default)
  71. TITLE:=wolfSSL library with AES CPU instructions
  72. PROVIDES:=libwolfssl libcyassl
  73. DEPENDS:=@((aarch64||x86_64)&&(m||!TARGET_bcm27xx))
  74. ABI_VERSION:=$(PKG_ABI_VERSION)
  75. VARIANT:=cpu-crypto
  76. endef
  77. define Package/libwolfssl-benchmark
  78. $(call Package/libwolfssl/Default)
  79. TITLE:=wolfSSL Benchmark Utility
  80. DEPENDS:=libwolfssl
  81. endef
  82. define Package/libwolfsslcpu-crypto/description
  83. $(call Package/libwolfssl/description)
  84. This variant uses AES CPU instructions (Intel AESNI or ARMv8 Crypto Extension)
  85. endef
  86. define Package/libwolfsslcpu-crypto/config
  87. if TARGET_armsr && PACKAGE_libwolfsslcpu-crypto = y
  88. comment "You are about to build libwolfsslcpu-crypto into an armsr_64 image."
  89. comment "Ensure all of your installation targets support the Crypto Extension. "
  90. comment "Look for the 'aes' feature in /proc/cpuinfo. This library does not do "
  91. comment "run-time detection and will crash if the CPU does not support it. "
  92. endif
  93. if TARGET_bcm27xx && PACKAGE_libwolfsslcpu-crypto
  94. comment "Beware that libwolfsslcpu-crypto will not run in a bcm27xx target. "
  95. endif
  96. endef
  97. define Package/libwolfssl-benchmark/description
  98. This is the wolfssl benchmark utility.
  99. endef
  100. TARGET_CFLAGS += \
  101. $(FPIC) \
  102. -fomit-frame-pointer \
  103. -DFP_MAX_BITS=8192 \
  104. $(if $(CONFIG_WOLFSSL_ALT_NAMES),-DWOLFSSL_ALT_NAMES)
  105. # --enable-stunnel needed for OpenSSL API compatibility bits
  106. CONFIGURE_ARGS += \
  107. --enable-reproducible-build \
  108. --enable-lighty \
  109. --enable-opensslall \
  110. --enable-opensslextra \
  111. --enable-sni \
  112. --enable-stunnel \
  113. --enable-altcertchains \
  114. --$(if $(CONFIG_PACKAGE_libwolfssl-benchmark),enable,disable)-crypttests \
  115. --disable-examples \
  116. --disable-jobserver \
  117. --$(if $(CONFIG_IPV6),enable,disable)-ipv6 \
  118. --$(if $(CONFIG_WOLFSSL_HAS_AES_CCM),enable,disable)-aesccm \
  119. --$(if $(CONFIG_WOLFSSL_HAS_CERTGEN),enable,disable)-certgen \
  120. --$(if $(CONFIG_WOLFSSL_HAS_CHACHA_POLY),enable,disable)-chacha \
  121. --$(if $(CONFIG_WOLFSSL_HAS_CHACHA_POLY),enable,disable)-poly1305 \
  122. --$(if $(CONFIG_WOLFSSL_HAS_DH),enable,disable)-dh \
  123. --$(if $(CONFIG_WOLFSSL_HAS_ARC4),enable,disable)-arc4 \
  124. --$(if $(CONFIG_WOLFSSL_HAS_TLSV10),enable,disable)-tlsv10 \
  125. --$(if $(CONFIG_WOLFSSL_HAS_TLSV13),enable,disable)-tls13 \
  126. --$(if $(CONFIG_WOLFSSL_HAS_SESSION_TICKET),enable,disable)-session-ticket \
  127. --$(if $(CONFIG_WOLFSSL_HAS_DTLS),enable,disable)-dtls \
  128. --$(if $(CONFIG_WOLFSSL_HAS_ECC25519),enable,disable)-curve25519 \
  129. --$(if $(CONFIG_WOLFSSL_HAS_ECC448),enable,disable)-curve448 \
  130. --$(if $(CONFIG_WOLFSSL_HAS_OPENVPN),enable,disable)-openvpn
  131. define Package/libwolfsslcpu-crypto/preinst-aarch64
  132. #!/bin/sh
  133. exec >&2
  134. printf "[libwolfsslcpu-crypto] Checking for Arm v8-A Cryptographic Extension support: "
  135. if [ -n "$${IPKG_INSTROOT}" ]; then
  136. printf "...[offline]... "
  137. eval "$$(grep '^DISTRIB_TARGET=' "$${IPKG_INSTROOT}/etc/openwrt_release")"
  138. echo "$${DISTRIB_TARGET}" | grep '^bcm27xx/.*' > /dev/null && {
  139. echo "not supported"
  140. echo "Error: Target $${DISTRIB_TARGET} does not support Arm Cryptographic Extension."
  141. echo "Install the regular libwolfssl package instead of libwolfsslcpu-crypto."
  142. exit 1
  143. }
  144. else
  145. grep -q '^Features.*\baes\b' /proc/cpuinfo || {
  146. echo "not supported"
  147. echo "Error: Arm v8-A Cryptographic Extension not supported."
  148. echo "Install the regular libwolfssl package instead of libwolfsslcpu-crypto."
  149. echo "Contents of /proc/cpuinfo:"
  150. cat /proc/cpuinfo
  151. exit 1
  152. }
  153. fi
  154. echo OK
  155. exit 0
  156. endef
  157. ifeq ($(BUILD_VARIANT),regular)
  158. CONFIGURE_ARGS += \
  159. --$(if $(CONFIG_WOLFSSL_HAS_AFALG),enable,disable)-afalg \
  160. --enable-devcrypto=$(if $(CONFIG_WOLFSSL_HAS_DEVCRYPTO_CBC),cbc\
  161. ,$(if $(CONFIG_WOLFSSL_HAS_DEVCRYPTO_AES),aes\
  162. ,$(if $(CONFIG_WOLFSSL_HAS_DEVCRYPTO_FULL),yes,no)))
  163. else ifdef CONFIG_aarch64
  164. CONFIGURE_ARGS += --enable-armasm
  165. TARGET_CFLAGS:=$(TARGET_CFLAGS:-mcpu%=-mcpu%+crypto)
  166. Package/libwolfsslcpu-crypto/preinst=$(Package/libwolfsslcpu-crypto/preinst-aarch64)
  167. else ifdef CONFIG_TARGET_x86_64
  168. CONFIGURE_ARGS += --enable-intelasm
  169. endif
  170. ifeq ($(CONFIG_WOLFSSL_HAS_OCSP),y)
  171. CONFIGURE_ARGS += \
  172. --enable-ocsp --enable-ocspstapling --enable-ocspstapling2
  173. endif
  174. ifeq ($(CONFIG_WOLFSSL_HAS_WPAS),y)
  175. CONFIGURE_ARGS += \
  176. --enable-wpas --enable-fortress --enable-fastmath
  177. endif
  178. define Build/InstallDev
  179. $(INSTALL_DIR) $(1)/usr/include $(1)/usr/lib/pkgconfig
  180. $(CP) $(PKG_INSTALL_DIR)/usr/include/* $(1)/usr/include/
  181. $(INSTALL_DIR) $(1)/usr/lib
  182. $(CP) $(PKG_INSTALL_DIR)/usr/lib/libwolfssl.{so*,la} $(1)/usr/lib/
  183. ln -s libwolfssl.so $(1)/usr/lib/libcyassl.so
  184. ln -s libwolfssl.la $(1)/usr/lib/libcyassl.la
  185. $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/*.pc $(1)/usr/lib/pkgconfig
  186. endef
  187. define Package/libwolfssl/install
  188. $(INSTALL_DIR) $(1)/usr/lib
  189. $(CP) $(PKG_INSTALL_DIR)/usr/lib/libwolfssl.so.* $(1)/usr/lib/
  190. endef
  191. Package/libwolfsslcpu-crypto/install=$(Package/libwolfssl/install)
  192. define Package/libwolfssl-benchmark/install
  193. $(INSTALL_DIR) $(1)/usr/bin
  194. $(CP) $(PKG_BUILD_DIR)/wolfcrypt/benchmark/.libs/benchmark $(1)/usr/bin/wolfssl-benchmark
  195. endef
  196. $(eval $(call BuildPackage,libwolfssl))
  197. $(eval $(call BuildPackage,libwolfsslcpu-crypto))
  198. $(eval $(call BuildPackage,libwolfssl-benchmark))