2
0

Makefile 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412
  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_BASE:=1.1.1
  10. PKG_BUGFIX:=f
  11. PKG_VERSION:=$(PKG_BASE)$(PKG_BUGFIX)
  12. PKG_RELEASE:=1
  13. PKG_USE_MIPS16:=0
  14. ENGINES_DIR=engines-1.1
  15. PKG_BUILD_PARALLEL:=1
  16. PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
  17. PKG_SOURCE_URL:= \
  18. http://ftp.fi.muni.cz/pub/openssl/source/ \
  19. http://ftp.linux.hr/pub/openssl/source/ \
  20. ftp://ftp.pca.dfn.de/pub/tools/net/openssl/source/ \
  21. http://www.openssl.org/source/ \
  22. http://www.openssl.org/source/old/$(PKG_BASE)/
  23. PKG_HASH:=186c6bfe6ecfba7a5b48c47f8a1673d0f3b0e5ba2e25602dd23b629975da3f35
  24. PKG_LICENSE:=OpenSSL
  25. PKG_LICENSE_FILES:=LICENSE
  26. PKG_MAINTAINER:=Eneas U de Queiroz <cotequeiroz@gmail.com>
  27. PKG_CPE_ID:=cpe:/a:openssl:openssl
  28. PKG_CONFIG_DEPENDS:= \
  29. CONFIG_OPENSSL_ENGINE \
  30. CONFIG_OPENSSL_ENGINE_BUILTIN \
  31. CONFIG_OPENSSL_ENGINE_BUILTIN_AFALG \
  32. CONFIG_OPENSSL_ENGINE_BUILTIN_DEVCRYPTO \
  33. CONFIG_OPENSSL_ENGINE_BUILTIN_PADLOCK \
  34. CONFIG_OPENSSL_NO_DEPRECATED \
  35. CONFIG_OPENSSL_OPTIMIZE_SPEED \
  36. CONFIG_OPENSSL_PREFER_CHACHA_OVER_GCM \
  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_GOST \
  49. CONFIG_OPENSSL_WITH_IDEA \
  50. CONFIG_OPENSSL_WITH_MDC2 \
  51. CONFIG_OPENSSL_WITH_NPN \
  52. CONFIG_OPENSSL_WITH_PSK \
  53. CONFIG_OPENSSL_WITH_RFC3779 \
  54. CONFIG_OPENSSL_WITH_SEED \
  55. CONFIG_OPENSSL_WITH_SM234 \
  56. CONFIG_OPENSSL_WITH_SRP \
  57. CONFIG_OPENSSL_WITH_SSE2 \
  58. CONFIG_OPENSSL_WITH_TLS13 \
  59. CONFIG_OPENSSL_WITH_WHIRLPOOL
  60. include $(INCLUDE_DIR)/package.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. TITLE+= (libraries)
  88. ABI_VERSION:=1.1
  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. 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. define Package/libopenssl-afalg
  120. $(call Package/openssl/Default)
  121. SUBMENU:=SSL
  122. TITLE:=AFALG hardware acceleration engine
  123. DEPENDS:=libopenssl @OPENSSL_ENGINE @KERNEL_AIO \
  124. +PACKAGE_libopenssl-afalg:kmod-crypto-user +libopenssl-conf @!OPENSSL_ENGINE_BUILTIN
  125. endef
  126. define Package/libopenssl-afalg/description
  127. This package adds an engine that enables hardware acceleration
  128. through the AF_ALG kernel interface.
  129. To use it, you need to configure the engine in /etc/ssl/openssl.cnf
  130. See https://www.openssl.org/docs/man1.1.1/man5/config.html#Engine-Configuration-Module
  131. and https://openwrt.org/docs/techref/hardware/cryptographic.hardware.accelerators
  132. The engine_id is "afalg"
  133. endef
  134. define Package/libopenssl-devcrypto
  135. $(call Package/openssl/Default)
  136. SUBMENU:=SSL
  137. TITLE:=/dev/crypto hardware acceleration engine
  138. DEPENDS:=libopenssl @OPENSSL_ENGINE +PACKAGE_libopenssl-devcrypto:kmod-cryptodev +libopenssl-conf \
  139. @!OPENSSL_ENGINE_BUILTIN
  140. endef
  141. define Package/libopenssl-devcrypto/description
  142. This package adds an engine that enables hardware acceleration
  143. through the /dev/crypto kernel interface.
  144. To use it, you need to configure the engine in /etc/ssl/openssl.cnf
  145. See https://www.openssl.org/docs/man1.1.1/man5/config.html#Engine-Configuration-Module
  146. and https://openwrt.org/docs/techref/hardware/cryptographic.hardware.accelerators
  147. The engine_id is "devcrypto"
  148. endef
  149. define Package/libopenssl-padlock
  150. $(call Package/openssl/Default)
  151. SUBMENU:=SSL
  152. TITLE:=VIA Padlock hardware acceleration engine
  153. DEPENDS:=libopenssl @OPENSSL_ENGINE @TARGET_x86 +PACKAGE_libopenssl-padlock:kmod-crypto-hw-padlock \
  154. +libopenssl-conf @!OPENSSL_ENGINE_BUILTIN
  155. endef
  156. define Package/libopenssl-padlock/description
  157. This package adds an engine that enables VIA Padlock hardware acceleration.
  158. To use it, you need to configure it in /etc/ssl/openssl.cnf.
  159. See https://www.openssl.org/docs/man1.1.1/man5/config.html#Engine-Configuration-Module
  160. and https://openwrt.org/docs/techref/hardware/cryptographic.hardware.accelerators
  161. The engine_id is "padlock"
  162. endef
  163. OPENSSL_OPTIONS:= shared
  164. ifndef CONFIG_OPENSSL_WITH_BLAKE2
  165. OPENSSL_OPTIONS += no-blake2
  166. endif
  167. ifndef CONFIG_OPENSSL_WITH_CHACHA_POLY1305
  168. OPENSSL_OPTIONS += no-chacha no-poly1305
  169. else
  170. ifdef CONFIG_OPENSSL_PREFER_CHACHA_OVER_GCM
  171. OPENSSL_OPTIONS += -DOPENSSL_PREFER_CHACHA_OVER_GCM
  172. endif
  173. endif
  174. ifndef CONFIG_OPENSSL_WITH_ASYNC
  175. OPENSSL_OPTIONS += no-async
  176. endif
  177. ifndef CONFIG_OPENSSL_WITH_EC2M
  178. OPENSSL_OPTIONS += no-ec2m
  179. endif
  180. ifndef CONFIG_OPENSSL_WITH_ERROR_MESSAGES
  181. OPENSSL_OPTIONS += no-err
  182. endif
  183. ifndef CONFIG_OPENSSL_WITH_TLS13
  184. OPENSSL_OPTIONS += no-tls1_3
  185. endif
  186. ifndef CONFIG_OPENSSL_WITH_ARIA
  187. OPENSSL_OPTIONS += no-aria
  188. endif
  189. ifndef CONFIG_OPENSSL_WITH_SM234
  190. OPENSSL_OPTIONS += no-sm2 no-sm3 no-sm4
  191. endif
  192. ifndef CONFIG_OPENSSL_WITH_CAMELLIA
  193. OPENSSL_OPTIONS += no-camellia
  194. endif
  195. ifndef CONFIG_OPENSSL_WITH_IDEA
  196. OPENSSL_OPTIONS += no-idea
  197. endif
  198. ifndef CONFIG_OPENSSL_WITH_SEED
  199. OPENSSL_OPTIONS += no-seed
  200. endif
  201. ifndef CONFIG_OPENSSL_WITH_MDC2
  202. OPENSSL_OPTIONS += no-mdc2
  203. endif
  204. ifndef CONFIG_OPENSSL_WITH_WHIRLPOOL
  205. OPENSSL_OPTIONS += no-whirlpool
  206. endif
  207. ifndef CONFIG_OPENSSL_WITH_CMS
  208. OPENSSL_OPTIONS += no-cms
  209. endif
  210. ifndef CONFIG_OPENSSL_WITH_RFC3779
  211. OPENSSL_OPTIONS += no-rfc3779
  212. endif
  213. ifdef CONFIG_OPENSSL_NO_DEPRECATED
  214. OPENSSL_OPTIONS += no-deprecated
  215. endif
  216. ifeq ($(CONFIG_OPENSSL_OPTIMIZE_SPEED),y)
  217. TARGET_CFLAGS := $(filter-out -O%,$(TARGET_CFLAGS)) -O3
  218. else
  219. OPENSSL_OPTIONS += -DOPENSSL_SMALL_FOOTPRINT
  220. endif
  221. ifdef CONFIG_OPENSSL_ENGINE
  222. ifdef CONFIG_OPENSSL_ENGINE_BUILTIN
  223. OPENSSL_OPTIONS += disable-dynamic-engine
  224. ifndef CONFIG_OPENSSL_ENGINE_BUILTIN_AFALG
  225. OPENSSL_OPTIONS += no-afalgeng
  226. endif
  227. ifdef CONFIG_OPENSSL_ENGINE_BUILTIN_DEVCRYPTO
  228. OPENSSL_OPTIONS += enable-devcryptoeng
  229. endif
  230. ifndef CONFIG_OPENSSL_ENGINE_BUILTIN_PADLOCK
  231. OPENSSL_OPTIONS += no-hw-padlock
  232. endif
  233. else
  234. ifdef CONFIG_PACKAGE_libopenssl-devcrypto
  235. OPENSSL_OPTIONS += enable-devcryptoeng
  236. endif
  237. ifndef CONFIG_PACKAGE_libopenssl-afalg
  238. OPENSSL_OPTIONS += no-afalgeng
  239. endif
  240. ifndef CONFIG_PACKAGE_libopenssl-padlock
  241. OPENSSL_OPTIONS += no-hw-padlock
  242. endif
  243. endif
  244. else
  245. OPENSSL_OPTIONS += no-engine
  246. endif
  247. ifndef CONFIG_OPENSSL_WITH_GOST
  248. OPENSSL_OPTIONS += no-gost
  249. endif
  250. ifndef CONFIG_OPENSSL_WITH_DTLS
  251. OPENSSL_OPTIONS += no-dtls
  252. endif
  253. ifdef CONFIG_OPENSSL_WITH_COMPRESSION
  254. OPENSSL_OPTIONS += zlib-dynamic
  255. else
  256. OPENSSL_OPTIONS += no-comp
  257. endif
  258. ifndef CONFIG_OPENSSL_WITH_NPN
  259. OPENSSL_OPTIONS += no-nextprotoneg
  260. endif
  261. ifndef CONFIG_OPENSSL_WITH_PSK
  262. OPENSSL_OPTIONS += no-psk
  263. endif
  264. ifndef CONFIG_OPENSSL_WITH_SRP
  265. OPENSSL_OPTIONS += no-srp
  266. endif
  267. ifndef CONFIG_OPENSSL_WITH_ASM
  268. OPENSSL_OPTIONS += no-asm
  269. endif
  270. ifdef CONFIG_i386
  271. ifndef CONFIG_OPENSSL_WITH_SSE2
  272. OPENSSL_OPTIONS += no-sse2
  273. endif
  274. endif
  275. OPENSSL_TARGET:=linux-$(call qstrip,$(CONFIG_ARCH))-librecmc
  276. STAMP_CONFIGURED := $(STAMP_CONFIGURED)_$(shell echo $(OPENSSL_OPTIONS) | mkhash md5)
  277. define Build/Configure
  278. (cd $(PKG_BUILD_DIR); \
  279. ./Configure $(OPENSSL_TARGET) \
  280. --prefix=/usr \
  281. --libdir=lib \
  282. --openssldir=/etc/ssl \
  283. $(TARGET_CPPFLAGS) \
  284. $(TARGET_LDFLAGS) \
  285. $(OPENSSL_OPTIONS) && \
  286. { [ -f $(STAMP_CONFIGURED) ] || make clean; } \
  287. )
  288. endef
  289. TARGET_CFLAGS += $(FPIC) -ffunction-sections -fdata-sections
  290. TARGET_LDFLAGS += -Wl,--gc-sections
  291. define Build/Compile
  292. +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
  293. CROSS_COMPILE="$(TARGET_CROSS)" \
  294. CC="$(TARGET_CC)" \
  295. SOURCE_DATE_EPOCH=$(SOURCE_DATE_EPOCH) \
  296. LIBRECMC_OPTIMIZATION_FLAGS="$(TARGET_CFLAGS)" \
  297. $(OPENSSL_MAKEFLAGS) \
  298. all
  299. $(MAKE) -C $(PKG_BUILD_DIR) \
  300. CROSS_COMPILE="$(TARGET_CROSS)" \
  301. CC="$(TARGET_CC)" \
  302. DESTDIR="$(PKG_INSTALL_DIR)" \
  303. $(OPENSSL_MAKEFLAGS) \
  304. install_sw install_ssldirs
  305. endef
  306. define Build/InstallDev
  307. $(INSTALL_DIR) $(1)/usr/include
  308. $(CP) $(PKG_INSTALL_DIR)/usr/include/openssl $(1)/usr/include/
  309. $(INSTALL_DIR) $(1)/usr/lib/
  310. $(CP) $(PKG_INSTALL_DIR)/usr/lib/lib{crypto,ssl}.{a,so*} $(1)/usr/lib/
  311. $(INSTALL_DIR) $(1)/usr/lib/pkgconfig
  312. $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/{openssl,libcrypto,libssl}.pc $(1)/usr/lib/pkgconfig/
  313. [ -n "$(TARGET_LDFLAGS)" ] && $(SED) 's#$(TARGET_LDFLAGS)##g' $(1)/usr/lib/pkgconfig/{openssl,libcrypto,libssl}.pc || true
  314. endef
  315. define Package/libopenssl/install
  316. $(INSTALL_DIR) $(1)/etc/ssl/certs
  317. $(INSTALL_DIR) $(1)/etc/ssl/private
  318. chmod 0700 $(1)/etc/ssl/private
  319. $(INSTALL_DIR) $(1)/usr/lib
  320. $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libcrypto.so.* $(1)/usr/lib/
  321. $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libssl.so.* $(1)/usr/lib/
  322. $(if $(CONFIG_OPENSSL_ENGINE),$(INSTALL_DIR) $(1)/usr/lib/$(ENGINES_DIR))
  323. endef
  324. define Package/libopenssl-conf/install
  325. $(INSTALL_DIR) $(1)/etc/ssl
  326. $(CP) $(PKG_INSTALL_DIR)/etc/ssl/openssl.cnf $(1)/etc/ssl/
  327. endef
  328. define Package/openssl-util/install
  329. $(INSTALL_DIR) $(1)/usr/bin
  330. $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/openssl $(1)/usr/bin/
  331. endef
  332. define Package/libopenssl-afalg/install
  333. $(INSTALL_DIR) $(1)/usr/lib/$(ENGINES_DIR)
  334. $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/$(ENGINES_DIR)/afalg.so $(1)/usr/lib/$(ENGINES_DIR)
  335. endef
  336. define Package/libopenssl-devcrypto/install
  337. $(INSTALL_DIR) $(1)/usr/lib/$(ENGINES_DIR)
  338. $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/$(ENGINES_DIR)/devcrypto.so $(1)/usr/lib/$(ENGINES_DIR)
  339. endef
  340. define Package/libopenssl-padlock/install
  341. $(INSTALL_DIR) $(1)/usr/lib/$(ENGINES_DIR)
  342. $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/$(ENGINES_DIR)/*padlock.so $(1)/usr/lib/$(ENGINES_DIR)
  343. endef
  344. $(eval $(call BuildPackage,libopenssl))
  345. $(eval $(call BuildPackage,libopenssl-conf))
  346. $(eval $(call BuildPackage,libopenssl-afalg))
  347. $(eval $(call BuildPackage,libopenssl-devcrypto))
  348. $(eval $(call BuildPackage,libopenssl-padlock))
  349. $(eval $(call BuildPackage,openssl-util))