Makefile 13 KB

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