Makefile 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408
  1. #
  2. # Copyright (C) 2006-2016 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:=openssl
  9. PKG_BASE:=1.1.1
  10. PKG_BUGFIX:=k
  11. PKG_VERSION:=$(PKG_BASE)$(PKG_BUGFIX)
  12. PKG_RELEASE:=1
  13. PKG_USE_MIPS16:=0
  14. ENGINES_DIR=engines-1.1
  15. PKG_BUILD_PARALLEL:=1
  16. PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
  17. PKG_SOURCE_URL:= \
  18. http://www.openssl.org/source/ \
  19. http://www.openssl.org/source/old/$(PKG_BASE)/ \
  20. http://ftp.fi.muni.cz/pub/openssl/source/ \
  21. http://ftp.fi.muni.cz/pub/openssl/source/old/$(PKG_BASE)/ \
  22. ftp://ftp.pca.dfn.de/pub/tools/net/openssl/source/ \
  23. ftp://ftp.pca.dfn.de/pub/tools/net/openssl/source/old/$(PKG_BASE)/
  24. PKG_HASH:=892a0875b9872acd04a9fde79b1f943075d5ea162415de3047c327df33fbaee5
  25. PKG_LICENSE:=OpenSSL
  26. PKG_LICENSE_FILES:=LICENSE
  27. PKG_MAINTAINER:=Eneas U de Queiroz <[email protected]>
  28. PKG_CPE_ID:=cpe:/a:openssl:openssl
  29. PKG_CONFIG_DEPENDS:= \
  30. CONFIG_OPENSSL_ENGINE \
  31. CONFIG_OPENSSL_ENGINE_BUILTIN \
  32. CONFIG_OPENSSL_ENGINE_BUILTIN_AFALG \
  33. CONFIG_OPENSSL_ENGINE_BUILTIN_DEVCRYPTO \
  34. CONFIG_OPENSSL_ENGINE_BUILTIN_PADLOCK \
  35. CONFIG_OPENSSL_NO_DEPRECATED \
  36. CONFIG_OPENSSL_OPTIMIZE_SPEED \
  37. CONFIG_OPENSSL_PREFER_CHACHA_OVER_GCM \
  38. CONFIG_OPENSSL_WITH_ARIA \
  39. CONFIG_OPENSSL_WITH_ASM \
  40. CONFIG_OPENSSL_WITH_ASYNC \
  41. CONFIG_OPENSSL_WITH_BLAKE2 \
  42. CONFIG_OPENSSL_WITH_CAMELLIA \
  43. CONFIG_OPENSSL_WITH_CHACHA_POLY1305 \
  44. CONFIG_OPENSSL_WITH_CMS \
  45. CONFIG_OPENSSL_WITH_COMPRESSION \
  46. CONFIG_OPENSSL_WITH_DTLS \
  47. CONFIG_OPENSSL_WITH_EC2M \
  48. CONFIG_OPENSSL_WITH_ERROR_MESSAGES \
  49. CONFIG_OPENSSL_WITH_IDEA \
  50. CONFIG_OPENSSL_WITH_MDC2 \
  51. CONFIG_OPENSSL_WITH_NPN \
  52. CONFIG_OPENSSL_WITH_PSK \
  53. CONFIG_OPENSSL_WITH_RFC3779 \
  54. CONFIG_OPENSSL_WITH_SEED \
  55. CONFIG_OPENSSL_WITH_SM234 \
  56. CONFIG_OPENSSL_WITH_SRP \
  57. CONFIG_OPENSSL_WITH_SSE2 \
  58. CONFIG_OPENSSL_WITH_TLS13 \
  59. CONFIG_OPENSSL_WITH_WHIRLPOOL
  60. include $(INCLUDE_DIR)/package.mk
  61. ifneq ($(CONFIG_CCACHE),)
  62. HOSTCC=$(HOSTCC_NOCACHE)
  63. HOSTCXX=$(HOSTCXX_NOCACHE)
  64. endif
  65. define Package/openssl/Default
  66. TITLE:=Open source SSL toolkit
  67. URL:=http://www.openssl.org/
  68. SECTION:=libs
  69. CATEGORY:=Libraries
  70. endef
  71. define Package/libopenssl/config
  72. source "$(SOURCE)/Config.in"
  73. endef
  74. define Package/openssl/Default/description
  75. The OpenSSL Project is a collaborative effort to develop a robust,
  76. commercial-grade, full-featured, and Open Source toolkit implementing the
  77. Transport Layer Security (TLS) protocol as well as a full-strength
  78. general-purpose cryptography library.
  79. endef
  80. define Package/libopenssl
  81. $(call Package/openssl/Default)
  82. SUBMENU:=SSL
  83. DEPENDS:=+OPENSSL_WITH_COMPRESSION:zlib \
  84. +OPENSSL_ENGINE_BUILTIN_AFALG:kmod-crypto-user \
  85. +OPENSSL_ENGINE_BUILTIN_DEVCRYPTO:kmod-cryptodev \
  86. +OPENSSL_ENGINE_BUILTIN_PADLOCK:kmod-crypto-hw-padlock
  87. TITLE+= (libraries)
  88. ABI_VERSION:=1.1
  89. MENU:=1
  90. endef
  91. define Package/libopenssl/description
  92. $(call Package/openssl/Default/description)
  93. This package contains the OpenSSL shared libraries, needed by other programs.
  94. endef
  95. define Package/openssl-util
  96. $(call Package/openssl/Default)
  97. SECTION:=utils
  98. CATEGORY:=Utilities
  99. DEPENDS:=+libopenssl +libopenssl-conf
  100. TITLE+= (utility)
  101. endef
  102. define Package/openssl-util/description
  103. $(call Package/openssl/Default/description)
  104. This package contains the OpenSSL command-line utility.
  105. endef
  106. define Package/libopenssl-conf
  107. $(call Package/openssl/Default)
  108. SUBMENU:=SSL
  109. TITLE:=/etc/ssl/openssl.cnf config file
  110. DEPENDS:=libopenssl
  111. endef
  112. define Package/libopenssl-conf/conffiles
  113. /etc/ssl/openssl.cnf
  114. endef
  115. define Package/libopenssl-conf/description
  116. $(call Package/openssl/Default/description)
  117. This package installs the OpenSSL configuration file /etc/ssl/openssl.cnf.
  118. endef
  119. define Package/libopenssl-afalg
  120. $(call Package/openssl/Default)
  121. SUBMENU:=SSL
  122. TITLE:=AFALG hardware acceleration engine
  123. DEPENDS:=libopenssl @OPENSSL_ENGINE @KERNEL_AIO \
  124. +PACKAGE_libopenssl-afalg:kmod-crypto-user +libopenssl-conf @!OPENSSL_ENGINE_BUILTIN
  125. endef
  126. define Package/libopenssl-afalg/description
  127. This package adds an engine that enables hardware acceleration
  128. through the AF_ALG kernel interface.
  129. To use it, you need to configure the engine in /etc/ssl/openssl.cnf
  130. See https://www.openssl.org/docs/man1.1.1/man5/config.html#Engine-Configuration-Module
  131. and https://openwrt.org/docs/techref/hardware/cryptographic.hardware.accelerators
  132. The engine_id is "afalg"
  133. endef
  134. define Package/libopenssl-devcrypto
  135. $(call Package/openssl/Default)
  136. SUBMENU:=SSL
  137. TITLE:=/dev/crypto hardware acceleration engine
  138. DEPENDS:=libopenssl @OPENSSL_ENGINE +PACKAGE_libopenssl-devcrypto:kmod-cryptodev +libopenssl-conf \
  139. @!OPENSSL_ENGINE_BUILTIN
  140. endef
  141. define Package/libopenssl-devcrypto/description
  142. This package adds an engine that enables hardware acceleration
  143. through the /dev/crypto kernel interface.
  144. To use it, you need to configure the engine in /etc/ssl/openssl.cnf
  145. See https://www.openssl.org/docs/man1.1.1/man5/config.html#Engine-Configuration-Module
  146. and https://openwrt.org/docs/techref/hardware/cryptographic.hardware.accelerators
  147. The engine_id is "devcrypto"
  148. endef
  149. define Package/libopenssl-padlock
  150. $(call Package/openssl/Default)
  151. SUBMENU:=SSL
  152. TITLE:=VIA Padlock hardware acceleration engine
  153. DEPENDS:=libopenssl @OPENSSL_ENGINE @TARGET_x86 +PACKAGE_libopenssl-padlock:kmod-crypto-hw-padlock \
  154. +libopenssl-conf @!OPENSSL_ENGINE_BUILTIN
  155. endef
  156. define Package/libopenssl-padlock/description
  157. This package adds an engine that enables VIA Padlock hardware acceleration.
  158. To use it, you need to configure it in /etc/ssl/openssl.cnf.
  159. See https://www.openssl.org/docs/man1.1.1/man5/config.html#Engine-Configuration-Module
  160. and https://openwrt.org/docs/techref/hardware/cryptographic.hardware.accelerators
  161. The engine_id is "padlock"
  162. endef
  163. OPENSSL_OPTIONS:= shared
  164. ifndef CONFIG_OPENSSL_WITH_BLAKE2
  165. OPENSSL_OPTIONS += no-blake2
  166. endif
  167. ifndef CONFIG_OPENSSL_WITH_CHACHA_POLY1305
  168. OPENSSL_OPTIONS += no-chacha no-poly1305
  169. else
  170. ifdef CONFIG_OPENSSL_PREFER_CHACHA_OVER_GCM
  171. OPENSSL_OPTIONS += -DOPENSSL_PREFER_CHACHA_OVER_GCM
  172. endif
  173. endif
  174. ifndef CONFIG_OPENSSL_WITH_ASYNC
  175. OPENSSL_OPTIONS += no-async
  176. endif
  177. ifndef CONFIG_OPENSSL_WITH_EC2M
  178. OPENSSL_OPTIONS += no-ec2m
  179. endif
  180. ifndef CONFIG_OPENSSL_WITH_ERROR_MESSAGES
  181. OPENSSL_OPTIONS += no-err
  182. endif
  183. ifndef CONFIG_OPENSSL_WITH_TLS13
  184. OPENSSL_OPTIONS += no-tls1_3
  185. endif
  186. ifndef CONFIG_OPENSSL_WITH_ARIA
  187. OPENSSL_OPTIONS += no-aria
  188. endif
  189. ifndef CONFIG_OPENSSL_WITH_SM234
  190. OPENSSL_OPTIONS += no-sm2 no-sm3 no-sm4
  191. endif
  192. ifndef CONFIG_OPENSSL_WITH_CAMELLIA
  193. OPENSSL_OPTIONS += no-camellia
  194. endif
  195. ifndef CONFIG_OPENSSL_WITH_IDEA
  196. OPENSSL_OPTIONS += no-idea
  197. endif
  198. ifndef CONFIG_OPENSSL_WITH_SEED
  199. OPENSSL_OPTIONS += no-seed
  200. endif
  201. ifndef CONFIG_OPENSSL_WITH_MDC2
  202. OPENSSL_OPTIONS += no-mdc2
  203. endif
  204. ifndef CONFIG_OPENSSL_WITH_WHIRLPOOL
  205. OPENSSL_OPTIONS += no-whirlpool
  206. endif
  207. ifndef CONFIG_OPENSSL_WITH_CMS
  208. OPENSSL_OPTIONS += no-cms
  209. endif
  210. ifndef CONFIG_OPENSSL_WITH_RFC3779
  211. OPENSSL_OPTIONS += no-rfc3779
  212. endif
  213. ifdef CONFIG_OPENSSL_NO_DEPRECATED
  214. OPENSSL_OPTIONS += no-deprecated
  215. endif
  216. ifeq ($(CONFIG_OPENSSL_OPTIMIZE_SPEED),y)
  217. TARGET_CFLAGS := $(filter-out -O%,$(TARGET_CFLAGS)) -O3
  218. else
  219. OPENSSL_OPTIONS += -DOPENSSL_SMALL_FOOTPRINT
  220. endif
  221. ifdef CONFIG_OPENSSL_ENGINE
  222. ifdef CONFIG_OPENSSL_ENGINE_BUILTIN
  223. OPENSSL_OPTIONS += disable-dynamic-engine
  224. ifndef CONFIG_OPENSSL_ENGINE_BUILTIN_AFALG
  225. OPENSSL_OPTIONS += no-afalgeng
  226. endif
  227. ifdef CONFIG_OPENSSL_ENGINE_BUILTIN_DEVCRYPTO
  228. OPENSSL_OPTIONS += enable-devcryptoeng
  229. endif
  230. ifndef CONFIG_OPENSSL_ENGINE_BUILTIN_PADLOCK
  231. OPENSSL_OPTIONS += no-hw-padlock
  232. endif
  233. else
  234. ifdef CONFIG_PACKAGE_libopenssl-devcrypto
  235. OPENSSL_OPTIONS += enable-devcryptoeng
  236. endif
  237. ifndef CONFIG_PACKAGE_libopenssl-afalg
  238. OPENSSL_OPTIONS += no-afalgeng
  239. endif
  240. ifndef CONFIG_PACKAGE_libopenssl-padlock
  241. OPENSSL_OPTIONS += no-hw-padlock
  242. endif
  243. endif
  244. else
  245. OPENSSL_OPTIONS += no-engine
  246. endif
  247. ifndef CONFIG_OPENSSL_WITH_DTLS
  248. OPENSSL_OPTIONS += no-dtls
  249. endif
  250. ifdef CONFIG_OPENSSL_WITH_COMPRESSION
  251. OPENSSL_OPTIONS += zlib-dynamic
  252. else
  253. OPENSSL_OPTIONS += no-comp
  254. endif
  255. ifndef CONFIG_OPENSSL_WITH_NPN
  256. OPENSSL_OPTIONS += no-nextprotoneg
  257. endif
  258. ifndef CONFIG_OPENSSL_WITH_PSK
  259. OPENSSL_OPTIONS += no-psk
  260. endif
  261. ifndef CONFIG_OPENSSL_WITH_SRP
  262. OPENSSL_OPTIONS += no-srp
  263. endif
  264. ifndef CONFIG_OPENSSL_WITH_ASM
  265. OPENSSL_OPTIONS += no-asm
  266. endif
  267. ifdef CONFIG_i386
  268. ifndef CONFIG_OPENSSL_WITH_SSE2
  269. OPENSSL_OPTIONS += no-sse2
  270. endif
  271. endif
  272. OPENSSL_TARGET:=linux-$(call qstrip,$(CONFIG_ARCH))-openwrt
  273. STAMP_CONFIGURED := $(STAMP_CONFIGURED)_$(shell echo $(OPENSSL_OPTIONS) | $(MKHASH) md5)
  274. define Build/Configure
  275. (cd $(PKG_BUILD_DIR); \
  276. ./Configure $(OPENSSL_TARGET) \
  277. --prefix=/usr \
  278. --libdir=lib \
  279. --openssldir=/etc/ssl \
  280. --cross-compile-prefix="$(TARGET_CROSS)" \
  281. $(TARGET_CPPFLAGS) \
  282. $(TARGET_LDFLAGS) \
  283. $(OPENSSL_OPTIONS) && \
  284. { [ -f $(STAMP_CONFIGURED) ] || make clean; } \
  285. )
  286. endef
  287. TARGET_CFLAGS += $(FPIC) -ffunction-sections -fdata-sections
  288. TARGET_LDFLAGS += -Wl,--gc-sections
  289. define Build/Compile
  290. +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
  291. CC="$(TARGET_CC)" \
  292. SOURCE_DATE_EPOCH=$(SOURCE_DATE_EPOCH) \
  293. OPENWRT_OPTIMIZATION_FLAGS="$(TARGET_CFLAGS)" \
  294. $(OPENSSL_MAKEFLAGS) \
  295. all
  296. $(MAKE) -C $(PKG_BUILD_DIR) \
  297. CC="$(TARGET_CC)" \
  298. DESTDIR="$(PKG_INSTALL_DIR)" \
  299. $(OPENSSL_MAKEFLAGS) \
  300. install_sw install_ssldirs
  301. endef
  302. define Build/InstallDev
  303. $(INSTALL_DIR) $(1)/usr/include
  304. $(CP) $(PKG_INSTALL_DIR)/usr/include/openssl $(1)/usr/include/
  305. $(INSTALL_DIR) $(1)/usr/lib/
  306. $(CP) $(PKG_INSTALL_DIR)/usr/lib/lib{crypto,ssl}.{a,so*} $(1)/usr/lib/
  307. $(INSTALL_DIR) $(1)/usr/lib/pkgconfig
  308. $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/{openssl,libcrypto,libssl}.pc $(1)/usr/lib/pkgconfig/
  309. [ -n "$(TARGET_LDFLAGS)" ] && $(SED) 's#$(TARGET_LDFLAGS)##g' $(1)/usr/lib/pkgconfig/{openssl,libcrypto,libssl}.pc || true
  310. endef
  311. define Package/libopenssl/install
  312. $(INSTALL_DIR) $(1)/etc/ssl/certs
  313. $(INSTALL_DIR) $(1)/etc/ssl/private
  314. chmod 0700 $(1)/etc/ssl/private
  315. $(INSTALL_DIR) $(1)/usr/lib
  316. $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libcrypto.so.* $(1)/usr/lib/
  317. $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libssl.so.* $(1)/usr/lib/
  318. $(if $(CONFIG_OPENSSL_ENGINE),$(INSTALL_DIR) $(1)/usr/lib/$(ENGINES_DIR))
  319. endef
  320. define Package/libopenssl-conf/install
  321. $(INSTALL_DIR) $(1)/etc/ssl
  322. $(CP) $(PKG_INSTALL_DIR)/etc/ssl/openssl.cnf $(1)/etc/ssl/
  323. endef
  324. define Package/openssl-util/install
  325. $(INSTALL_DIR) $(1)/usr/bin
  326. $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/openssl $(1)/usr/bin/
  327. endef
  328. define Package/libopenssl-afalg/install
  329. $(INSTALL_DIR) $(1)/usr/lib/$(ENGINES_DIR)
  330. $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/$(ENGINES_DIR)/afalg.so $(1)/usr/lib/$(ENGINES_DIR)
  331. endef
  332. define Package/libopenssl-devcrypto/install
  333. $(INSTALL_DIR) $(1)/usr/lib/$(ENGINES_DIR)
  334. $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/$(ENGINES_DIR)/devcrypto.so $(1)/usr/lib/$(ENGINES_DIR)
  335. endef
  336. define Package/libopenssl-padlock/install
  337. $(INSTALL_DIR) $(1)/usr/lib/$(ENGINES_DIR)
  338. $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/$(ENGINES_DIR)/*padlock.so $(1)/usr/lib/$(ENGINES_DIR)
  339. endef
  340. $(eval $(call BuildPackage,libopenssl))
  341. $(eval $(call BuildPackage,libopenssl-conf))
  342. $(eval $(call BuildPackage,libopenssl-afalg))
  343. $(eval $(call BuildPackage,libopenssl-devcrypto))
  344. $(eval $(call BuildPackage,libopenssl-padlock))
  345. $(eval $(call BuildPackage,openssl-util))