Makefile 13 KB

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