Makefile 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402
  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:=4
  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_WITH_ARIA \
  37. CONFIG_OPENSSL_WITH_ASM \
  38. CONFIG_OPENSSL_WITH_ASYNC \
  39. CONFIG_OPENSSL_WITH_BLAKE2 \
  40. CONFIG_OPENSSL_WITH_CAMELLIA \
  41. CONFIG_OPENSSL_WITH_CHACHA_POLY1305 \
  42. CONFIG_OPENSSL_WITH_CMS \
  43. CONFIG_OPENSSL_WITH_COMPRESSION \
  44. CONFIG_OPENSSL_WITH_DTLS \
  45. CONFIG_OPENSSL_WITH_EC2M \
  46. CONFIG_OPENSSL_WITH_ERROR_MESSAGES \
  47. CONFIG_OPENSSL_WITH_IDEA \
  48. CONFIG_OPENSSL_WITH_MDC2 \
  49. CONFIG_OPENSSL_WITH_NPN \
  50. CONFIG_OPENSSL_WITH_PSK \
  51. CONFIG_OPENSSL_WITH_RFC3779 \
  52. CONFIG_OPENSSL_WITH_SEED \
  53. CONFIG_OPENSSL_WITH_SM234 \
  54. CONFIG_OPENSSL_WITH_SRP \
  55. CONFIG_OPENSSL_WITH_SSE2 \
  56. CONFIG_OPENSSL_WITH_TLS13 \
  57. CONFIG_OPENSSL_WITH_WHIRLPOOL
  58. include $(INCLUDE_DIR)/package.mk
  59. include $(INCLUDE_DIR)/openssl-engine.mk
  60. ifneq ($(CONFIG_CCACHE),)
  61. HOSTCC=$(HOSTCC_NOCACHE)
  62. HOSTCXX=$(HOSTCXX_NOCACHE)
  63. endif
  64. define Package/openssl/Default
  65. TITLE:=Open source SSL toolkit
  66. URL:=http://www.openssl.org/
  67. SECTION:=libs
  68. CATEGORY:=Libraries
  69. endef
  70. define Package/libopenssl/config
  71. source "$(SOURCE)/Config.in"
  72. endef
  73. define Package/openssl/Default/description
  74. The OpenSSL Project is a collaborative effort to develop a robust,
  75. commercial-grade, full-featured, and Open Source toolkit implementing the
  76. Transport Layer Security (TLS) protocol as well as a full-strength
  77. general-purpose cryptography library.
  78. endef
  79. define Package/libopenssl
  80. $(call Package/openssl/Default)
  81. SUBMENU:=SSL
  82. DEPENDS:=+OPENSSL_WITH_COMPRESSION:zlib \
  83. +OPENSSL_ENGINE_BUILTIN_AFALG:kmod-crypto-user \
  84. +OPENSSL_ENGINE_BUILTIN_DEVCRYPTO:kmod-cryptodev \
  85. +OPENSSL_ENGINE_BUILTIN_PADLOCK:kmod-crypto-hw-padlock \
  86. +(arm||armeb||mips||mipsel||powerpc||arc):libatomic
  87. TITLE+= (libraries)
  88. ABI_VERSION:=$(firstword $(subst .,$(space),$(PKG_VERSION)))
  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. $(if $(CONFIG_OPENSSL_ENGINE_BUILTIN_DEVCRYPTO),/etc/ssl/engines.cnf.d/devcrypto.cnf)
  115. $(if $(CONFIG_OPENSSL_ENGINE_BUILTIN_PADLOCK),/etc/ssl/engines.cnf.d/padlock.cnf)
  116. endef
  117. define Package/libopenssl-conf/description
  118. $(call Package/openssl/Default/description)
  119. This package installs the OpenSSL configuration file /etc/ssl/openssl.cnf.
  120. endef
  121. $(eval $(call Package/openssl/add-engine,afalg))
  122. define Package/libopenssl-afalg
  123. $(call Package/openssl/Default)
  124. $(call Package/openssl/engine/Default)
  125. TITLE:=AFALG hardware acceleration engine
  126. DEPENDS += @KERNEL_AIO +PACKAGE_libopenssl-afalg:kmod-crypto-user \
  127. @!OPENSSL_ENGINE_BUILTIN
  128. endef
  129. define Package/libopenssl-afalg/description
  130. This package adds an engine that enables hardware acceleration
  131. through the AF_ALG kernel interface.
  132. See https://www.openssl.org/docs/man1.1.1/man5/config.html#Engine-Configuration-Module
  133. and https://openwrt.org/docs/techref/hardware/cryptographic.hardware.accelerators
  134. The engine_id is "afalg"
  135. endef
  136. $(eval $(call Package/openssl/add-engine,devcrypto))
  137. define Package/libopenssl-devcrypto
  138. $(call Package/openssl/Default)
  139. $(call Package/openssl/engine/Default)
  140. TITLE:=/dev/crypto hardware acceleration engine
  141. DEPENDS += +PACKAGE_libopenssl-devcrypto:kmod-cryptodev @!OPENSSL_ENGINE_BUILTIN
  142. endef
  143. define Package/libopenssl-devcrypto/description
  144. This package adds an engine that enables hardware acceleration
  145. through the /dev/crypto kernel interface.
  146. See https://www.openssl.org/docs/man1.1.1/man5/config.html#Engine-Configuration-Module
  147. and https://openwrt.org/docs/techref/hardware/cryptographic.hardware.accelerators
  148. The engine_id is "devcrypto"
  149. endef
  150. $(eval $(call Package/openssl/add-engine,padlock))
  151. define Package/libopenssl-padlock
  152. $(call Package/openssl/Default)
  153. $(call Package/openssl/engine/Default)
  154. TITLE:=VIA Padlock hardware acceleration engine
  155. DEPENDS += @TARGET_x86 +PACKAGE_libopenssl-padlock:kmod-crypto-hw-padlock \
  156. @!OPENSSL_ENGINE_BUILTIN
  157. endef
  158. define Package/libopenssl-padlock/description
  159. This package adds an engine that enables VIA Padlock hardware acceleration.
  160. See https://www.openssl.org/docs/man1.1.1/man5/config.html#Engine-Configuration-Module
  161. and https://openwrt.org/docs/techref/hardware/cryptographic.hardware.accelerators
  162. The engine_id is "padlock"
  163. endef
  164. OPENSSL_OPTIONS:= shared no-tests
  165. ifndef CONFIG_OPENSSL_WITH_BLAKE2
  166. OPENSSL_OPTIONS += no-blake2
  167. endif
  168. ifndef CONFIG_OPENSSL_WITH_CHACHA_POLY1305
  169. OPENSSL_OPTIONS += no-chacha no-poly1305
  170. else
  171. ifdef CONFIG_OPENSSL_PREFER_CHACHA_OVER_GCM
  172. OPENSSL_OPTIONS += -DOPENSSL_PREFER_CHACHA_OVER_GCM
  173. endif
  174. endif
  175. ifndef CONFIG_OPENSSL_WITH_ASYNC
  176. OPENSSL_OPTIONS += no-async
  177. endif
  178. ifndef CONFIG_OPENSSL_WITH_EC2M
  179. OPENSSL_OPTIONS += no-ec2m
  180. endif
  181. ifndef CONFIG_OPENSSL_WITH_ERROR_MESSAGES
  182. OPENSSL_OPTIONS += no-err
  183. endif
  184. ifndef CONFIG_OPENSSL_WITH_TLS13
  185. OPENSSL_OPTIONS += no-tls1_3
  186. endif
  187. ifndef CONFIG_OPENSSL_WITH_ARIA
  188. OPENSSL_OPTIONS += no-aria
  189. endif
  190. ifndef CONFIG_OPENSSL_WITH_SM234
  191. OPENSSL_OPTIONS += no-sm2 no-sm3 no-sm4
  192. endif
  193. ifndef CONFIG_OPENSSL_WITH_CAMELLIA
  194. OPENSSL_OPTIONS += no-camellia
  195. endif
  196. ifndef CONFIG_OPENSSL_WITH_IDEA
  197. OPENSSL_OPTIONS += no-idea
  198. endif
  199. ifndef CONFIG_OPENSSL_WITH_SEED
  200. OPENSSL_OPTIONS += no-seed
  201. endif
  202. ifndef CONFIG_OPENSSL_WITH_MDC2
  203. OPENSSL_OPTIONS += no-mdc2
  204. endif
  205. ifndef CONFIG_OPENSSL_WITH_WHIRLPOOL
  206. OPENSSL_OPTIONS += no-whirlpool
  207. endif
  208. ifndef CONFIG_OPENSSL_WITH_CMS
  209. OPENSSL_OPTIONS += no-cms
  210. endif
  211. ifndef CONFIG_OPENSSL_WITH_RFC3779
  212. OPENSSL_OPTIONS += no-rfc3779
  213. endif
  214. ifdef CONFIG_OPENSSL_NO_DEPRECATED
  215. OPENSSL_OPTIONS += no-deprecated
  216. endif
  217. ifeq ($(CONFIG_OPENSSL_OPTIMIZE_SPEED),y)
  218. TARGET_CFLAGS := $(filter-out -O%,$(TARGET_CFLAGS)) -O3
  219. else
  220. OPENSSL_OPTIONS += -DOPENSSL_SMALL_FOOTPRINT
  221. endif
  222. ifdef CONFIG_OPENSSL_ENGINE
  223. ifdef CONFIG_OPENSSL_ENGINE_BUILTIN
  224. OPENSSL_OPTIONS += disable-dynamic-engine
  225. ifndef CONFIG_OPENSSL_ENGINE_BUILTIN_AFALG
  226. OPENSSL_OPTIONS += no-afalgeng
  227. endif
  228. ifdef CONFIG_OPENSSL_ENGINE_BUILTIN_DEVCRYPTO
  229. OPENSSL_OPTIONS += enable-devcryptoeng
  230. endif
  231. ifndef CONFIG_OPENSSL_ENGINE_BUILTIN_PADLOCK
  232. OPENSSL_OPTIONS += no-padlockeng
  233. endif
  234. else
  235. ifdef CONFIG_PACKAGE_libopenssl-devcrypto
  236. OPENSSL_OPTIONS += enable-devcryptoeng
  237. endif
  238. ifndef CONFIG_PACKAGE_libopenssl-afalg
  239. OPENSSL_OPTIONS += no-afalgeng
  240. endif
  241. ifndef CONFIG_PACKAGE_libopenssl-padlock
  242. OPENSSL_OPTIONS += no-padlockeng
  243. endif
  244. endif
  245. else
  246. OPENSSL_OPTIONS += no-engine
  247. endif
  248. ifndef CONFIG_OPENSSL_WITH_DTLS
  249. OPENSSL_OPTIONS += no-dtls
  250. endif
  251. ifdef CONFIG_OPENSSL_WITH_COMPRESSION
  252. OPENSSL_OPTIONS += zlib-dynamic
  253. else
  254. OPENSSL_OPTIONS += no-comp
  255. endif
  256. ifndef CONFIG_OPENSSL_WITH_NPN
  257. OPENSSL_OPTIONS += no-nextprotoneg
  258. endif
  259. ifndef CONFIG_OPENSSL_WITH_PSK
  260. OPENSSL_OPTIONS += no-psk
  261. endif
  262. ifndef CONFIG_OPENSSL_WITH_SRP
  263. OPENSSL_OPTIONS += no-srp
  264. endif
  265. ifndef CONFIG_OPENSSL_WITH_ASM
  266. OPENSSL_OPTIONS += no-asm
  267. endif
  268. ifdef CONFIG_i386
  269. ifndef CONFIG_OPENSSL_WITH_SSE2
  270. OPENSSL_OPTIONS += no-sse2
  271. endif
  272. endif
  273. OPENSSL_TARGET:=linux-$(call qstrip,$(CONFIG_ARCH))-openwrt
  274. STAMP_CONFIGURED := $(STAMP_CONFIGURED)_$(shell echo $(OPENSSL_OPTIONS) | $(MKHASH) md5)
  275. define Build/Configure
  276. (cd $(PKG_BUILD_DIR); \
  277. ./Configure $(OPENSSL_TARGET) \
  278. --prefix=/usr \
  279. --libdir=lib \
  280. --openssldir=/etc/ssl \
  281. --cross-compile-prefix="$(TARGET_CROSS)" \
  282. $(TARGET_CPPFLAGS) \
  283. $(TARGET_LDFLAGS) \
  284. $(OPENSSL_OPTIONS) && \
  285. { [ -f $(STAMP_CONFIGURED) ] || make clean; } \
  286. )
  287. endef
  288. TARGET_CFLAGS += $(FPIC)
  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/engines.cnf.d $(1)/etc/config $(1)/etc/init.d
  322. $(CP) $(PKG_INSTALL_DIR)/etc/ssl/openssl.cnf $(1)/etc/ssl/
  323. $(INSTALL_BIN) ./files/openssl.init $(1)/etc/init.d/openssl
  324. $(SED) 's!%ENGINES_DIR%!/usr/lib/$(ENGINES_DIR)!' $(1)/etc/init.d/openssl
  325. touch $(1)/etc/config/openssl
  326. $(if $(CONFIG_OPENSSL_ENGINE_BUILTIN_DEVCRYPTO),
  327. $(CP) ./files/devcrypto.cnf $(1)/etc/ssl/engines.cnf.d/
  328. echo -e "config engine 'devcrypto'\n\toption enabled '1'" >> $(1)/etc/config/openssl)
  329. $(if $(CONFIG_OPENSSL_ENGINE_BUILTIN_PADLOCK),
  330. $(CP) ./files/padlock.cnf $(1)/etc/ssl/engines.cnf.d/
  331. echo -e "\nconfig engine 'padlock'\n\toption enabled '1'" >> $(1)/etc/config/openssl)
  332. endef
  333. define Package/openssl-util/install
  334. $(INSTALL_DIR) $(1)/usr/bin
  335. $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/openssl $(1)/usr/bin/
  336. endef
  337. $(eval $(call BuildPackage,libopenssl))
  338. $(eval $(call BuildPackage,libopenssl-conf))
  339. $(eval $(call BuildPackage,libopenssl-afalg))
  340. $(eval $(call BuildPackage,libopenssl-devcrypto))
  341. $(eval $(call BuildPackage,libopenssl-padlock))
  342. $(eval $(call BuildPackage,openssl-util))