Makefile 13 KB

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