1
0

Makefile 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438
  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.13
  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. 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:=88525753f79d3bec27d2fa7c66aa0b92b3aa9498dafd93d7cfa4b3780cdae313
  23. PKG_LICENSE:=Apache-2.0
  24. PKG_LICENSE_FILES:=LICENSE
  25. PKG_MAINTAINER:=Eneas U de Queiroz <cotequeiroz@gmail.com>
  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. add_engine_config() {
  126. if [ -z "$${IPKG_INSTROOT}" ] && uci -q get "openssl.$$1" >/dev/null; then
  127. [ "$$(uci -q get "openssl.$$1.builtin")" = 1 ] && return
  128. uci set "openssl.$$1.builtin=1" && uci commit openssl
  129. return
  130. fi
  131. }
  132. $(if $(CONFIG_OPENSSL_ENGINE_BUILTIN_DEVCRYPTO),add_engine_config devcrypto)
  133. $(if $(CONFIG_OPENSSL_ENGINE_BUILTIN_PADLOCK),add_engine_config padlock)
  134. endef
  135. endif
  136. $(eval $(call Package/openssl/add-provider,legacy))
  137. define Package/libopenssl-legacy
  138. $(call Package/openssl/Default)
  139. $(call Package/openssl/module/Default)
  140. TITLE:=OpenSSL legacy provider
  141. endef
  142. define Package/libopenssl-legacy/description
  143. The OpenSSL legacy provider supplies OpenSSL implementations of algorithms that
  144. have been deemed legacy. Such algorithms have commonly fallen out of use, have
  145. been deemed insecure by the cryptography community, or something similar. See
  146. https://www.openssl.org/docs/man3.0/man7/OSSL_PROVIDER-legacy.html
  147. endef
  148. $(eval $(call Package/openssl/add-engine,afalg))
  149. define Package/libopenssl-afalg
  150. $(call Package/openssl/Default)
  151. $(call Package/openssl/engine/Default)
  152. TITLE:=AFALG hardware acceleration engine
  153. DEPENDS += @KERNEL_AIO +PACKAGE_libopenssl-afalg:kmod-crypto-user \
  154. @!OPENSSL_ENGINE_BUILTIN
  155. endef
  156. define Package/libopenssl-afalg/description
  157. This package adds an engine that enables hardware acceleration
  158. through the AF_ALG kernel interface.
  159. See https://www.openssl.org/docs/man3.0/man5/config.html#Engine-Configuration
  160. and https://openwrt.org/docs/techref/hardware/cryptographic.hardware.accelerators
  161. The engine_id is "afalg"
  162. endef
  163. $(eval $(call Package/openssl/add-engine,devcrypto))
  164. define Package/libopenssl-devcrypto
  165. $(call Package/openssl/Default)
  166. $(call Package/openssl/engine/Default)
  167. TITLE:=/dev/crypto hardware acceleration engine
  168. DEPENDS += +PACKAGE_libopenssl-devcrypto:kmod-cryptodev @!OPENSSL_ENGINE_BUILTIN
  169. endef
  170. define Package/libopenssl-devcrypto/description
  171. This package adds an engine that enables hardware acceleration
  172. through the /dev/crypto kernel interface.
  173. See https://www.openssl.org/docs/man3.0/man5/config.html#Engine-Configuration
  174. and https://openwrt.org/docs/techref/hardware/cryptographic.hardware.accelerators
  175. The engine_id is "devcrypto"
  176. endef
  177. $(eval $(call Package/openssl/add-engine,padlock))
  178. define Package/libopenssl-padlock
  179. $(call Package/openssl/Default)
  180. $(call Package/openssl/engine/Default)
  181. TITLE:=VIA Padlock hardware acceleration engine
  182. DEPENDS += @TARGET_x86 +PACKAGE_libopenssl-padlock:kmod-crypto-hw-padlock \
  183. @!OPENSSL_ENGINE_BUILTIN
  184. endef
  185. define Package/libopenssl-padlock/description
  186. This package adds an engine that enables VIA Padlock hardware acceleration.
  187. See https://www.openssl.org/docs/man3.0/man5/config.html#Engine-Configuration
  188. and https://openwrt.org/docs/techref/hardware/cryptographic.hardware.accelerators
  189. The engine_id is "padlock"
  190. endef
  191. OPENSSL_OPTIONS:= shared no-tests
  192. ifndef CONFIG_OPENSSL_WITH_BLAKE2
  193. OPENSSL_OPTIONS += no-blake2
  194. endif
  195. ifndef CONFIG_OPENSSL_WITH_CHACHA_POLY1305
  196. OPENSSL_OPTIONS += no-chacha no-poly1305
  197. else
  198. ifdef CONFIG_OPENSSL_PREFER_CHACHA_OVER_GCM
  199. OPENSSL_OPTIONS += -DOPENSSL_PREFER_CHACHA_OVER_GCM
  200. endif
  201. endif
  202. ifndef CONFIG_OPENSSL_WITH_ASYNC
  203. OPENSSL_OPTIONS += no-async
  204. endif
  205. ifndef CONFIG_OPENSSL_WITH_EC2M
  206. OPENSSL_OPTIONS += no-ec2m
  207. endif
  208. ifndef CONFIG_OPENSSL_WITH_ERROR_MESSAGES
  209. OPENSSL_OPTIONS += no-err
  210. endif
  211. ifndef CONFIG_OPENSSL_WITH_TLS13
  212. OPENSSL_OPTIONS += no-tls1_3
  213. endif
  214. ifndef CONFIG_OPENSSL_WITH_ARIA
  215. OPENSSL_OPTIONS += no-aria
  216. endif
  217. ifndef CONFIG_OPENSSL_WITH_SM234
  218. OPENSSL_OPTIONS += no-sm2 no-sm3 no-sm4
  219. endif
  220. ifndef CONFIG_OPENSSL_WITH_CAMELLIA
  221. OPENSSL_OPTIONS += no-camellia
  222. endif
  223. ifndef CONFIG_OPENSSL_WITH_IDEA
  224. OPENSSL_OPTIONS += no-idea
  225. endif
  226. ifndef CONFIG_OPENSSL_WITH_SEED
  227. OPENSSL_OPTIONS += no-seed
  228. endif
  229. ifndef CONFIG_OPENSSL_WITH_MDC2
  230. OPENSSL_OPTIONS += no-mdc2
  231. endif
  232. ifndef CONFIG_OPENSSL_WITH_WHIRLPOOL
  233. OPENSSL_OPTIONS += no-whirlpool
  234. endif
  235. ifndef CONFIG_OPENSSL_WITH_CMS
  236. OPENSSL_OPTIONS += no-cms
  237. endif
  238. ifndef CONFIG_OPENSSL_WITH_RFC3779
  239. OPENSSL_OPTIONS += no-rfc3779
  240. endif
  241. ifdef CONFIG_OPENSSL_NO_DEPRECATED
  242. OPENSSL_OPTIONS += no-deprecated
  243. endif
  244. ifeq ($(CONFIG_OPENSSL_OPTIMIZE_SPEED),y)
  245. TARGET_CFLAGS := $(filter-out -O%,$(TARGET_CFLAGS)) -O3
  246. endif
  247. ifeq ($(CONFIG_OPENSSL_SMALL_FOOTPRINT),y)
  248. OPENSSL_OPTIONS += -DOPENSSL_SMALL_FOOTPRINT
  249. endif
  250. ifdef CONFIG_OPENSSL_ENGINE
  251. ifdef CONFIG_OPENSSL_ENGINE_BUILTIN
  252. OPENSSL_OPTIONS += disable-dynamic-engine
  253. ifndef CONFIG_OPENSSL_ENGINE_BUILTIN_AFALG
  254. OPENSSL_OPTIONS += no-afalgeng
  255. endif
  256. ifdef CONFIG_OPENSSL_ENGINE_BUILTIN_DEVCRYPTO
  257. OPENSSL_OPTIONS += enable-devcryptoeng
  258. endif
  259. ifndef CONFIG_OPENSSL_ENGINE_BUILTIN_PADLOCK
  260. OPENSSL_OPTIONS += no-padlockeng
  261. endif
  262. else
  263. ifdef CONFIG_PACKAGE_libopenssl-devcrypto
  264. OPENSSL_OPTIONS += enable-devcryptoeng
  265. endif
  266. ifndef CONFIG_PACKAGE_libopenssl-afalg
  267. OPENSSL_OPTIONS += no-afalgeng
  268. endif
  269. ifndef CONFIG_PACKAGE_libopenssl-padlock
  270. OPENSSL_OPTIONS += no-padlockeng
  271. endif
  272. endif
  273. else
  274. OPENSSL_OPTIONS += no-engine
  275. endif
  276. ifndef CONFIG_OPENSSL_WITH_DTLS
  277. OPENSSL_OPTIONS += no-dtls
  278. endif
  279. ifdef CONFIG_OPENSSL_WITH_COMPRESSION
  280. OPENSSL_OPTIONS += zlib-dynamic
  281. else
  282. OPENSSL_OPTIONS += no-comp
  283. endif
  284. ifndef CONFIG_OPENSSL_WITH_NPN
  285. OPENSSL_OPTIONS += no-nextprotoneg
  286. endif
  287. ifndef CONFIG_OPENSSL_WITH_PSK
  288. OPENSSL_OPTIONS += no-psk
  289. endif
  290. ifndef CONFIG_OPENSSL_WITH_SRP
  291. OPENSSL_OPTIONS += no-srp
  292. endif
  293. ifndef CONFIG_OPENSSL_WITH_ASM
  294. OPENSSL_OPTIONS += no-asm
  295. endif
  296. ifdef CONFIG_i386
  297. ifndef CONFIG_OPENSSL_WITH_SSE2
  298. OPENSSL_OPTIONS += no-sse2
  299. endif
  300. endif
  301. OPENSSL_TARGET:=linux-$(call qstrip,$(CONFIG_ARCH))-librecmc
  302. STAMP_CONFIGURED := $(STAMP_CONFIGURED)_$(shell echo $(OPENSSL_OPTIONS) | $(MKHASH) md5)
  303. define Build/Configure
  304. (cd $(PKG_BUILD_DIR); \
  305. ./Configure $(OPENSSL_TARGET) \
  306. --prefix=/usr \
  307. --libdir=lib \
  308. --openssldir=/etc/ssl \
  309. --cross-compile-prefix="$(TARGET_CROSS)" \
  310. $(TARGET_CFLAGS) \
  311. $(TARGET_CPPFLAGS) \
  312. $(TARGET_LDFLAGS) \
  313. $(OPENSSL_OPTIONS) && \
  314. { [ -f $(STAMP_CONFIGURED) ] || make clean; } \
  315. )
  316. endef
  317. TARGET_CFLAGS += $(FPIC)
  318. define Build/Compile
  319. +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
  320. CC="$(TARGET_CC)" \
  321. SOURCE_DATE_EPOCH=$(SOURCE_DATE_EPOCH) \
  322. LIBRECMC_OPTIMIZATION_FLAGS="$(TARGET_CFLAGS)" \
  323. $(OPENSSL_MAKEFLAGS) \
  324. all
  325. $(MAKE) -C $(PKG_BUILD_DIR) \
  326. CC="$(TARGET_CC)" \
  327. DESTDIR="$(PKG_INSTALL_DIR)" \
  328. $(OPENSSL_MAKEFLAGS) \
  329. install_sw install_ssldirs
  330. endef
  331. define Build/InstallDev
  332. $(INSTALL_DIR) $(1)/usr/include
  333. $(CP) $(PKG_INSTALL_DIR)/usr/include/openssl $(1)/usr/include/
  334. $(INSTALL_DIR) $(1)/usr/lib/
  335. $(CP) $(PKG_INSTALL_DIR)/usr/lib/lib{crypto,ssl}.{a,so*} $(1)/usr/lib/
  336. $(INSTALL_DIR) $(1)/usr/lib/pkgconfig
  337. $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/{openssl,libcrypto,libssl}.pc $(1)/usr/lib/pkgconfig/
  338. [ -n "$(TARGET_LDFLAGS)" ] && $(SED) 's#$(TARGET_LDFLAGS)##g' $(1)/usr/lib/pkgconfig/{openssl,libcrypto,libssl}.pc || true
  339. endef
  340. define Package/libopenssl/install
  341. $(INSTALL_DIR) $(1)/etc/ssl/certs
  342. $(INSTALL_DIR) $(1)/etc/ssl/private
  343. chmod 0700 $(1)/etc/ssl/private
  344. $(INSTALL_DIR) $(1)/usr/lib
  345. $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libcrypto.so.* $(1)/usr/lib/
  346. $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libssl.so.* $(1)/usr/lib/
  347. $(if $(CONFIG_OPENSSL_ENGINE),$(INSTALL_DIR) $(1)/usr/lib/$(ENGINES_DIR))
  348. endef
  349. define Package/libopenssl-conf/install
  350. $(INSTALL_DIR) $(1)/etc/ssl/modules.cnf.d $(1)/etc/config $(1)/etc/init.d
  351. $(CP) $(PKG_INSTALL_DIR)/etc/ssl/openssl.cnf $(1)/etc/ssl/
  352. $(INSTALL_BIN) ./files/openssl.init $(1)/etc/init.d/openssl
  353. $(SED) 's!%ENGINES_DIR%!/usr/lib/$(ENGINES_DIR)!' $(1)/etc/init.d/openssl
  354. touch $(1)/etc/config/openssl
  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))