Makefile 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417
  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:=c
  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:=f6fb3079ad15076154eda9413fed42877d668e7069d9b87396d0804fdb3f4c90
  24. PKG_LICENSE:=OpenSSL
  25. PKG_LICENSE_FILES:=LICENSE
  26. PKG_MAINTAINER:=Eneas U de Queiroz <[email protected]>
  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_EC \
  47. CONFIG_OPENSSL_WITH_EC2M \
  48. CONFIG_OPENSSL_WITH_ERROR_MESSAGES \
  49. CONFIG_OPENSSL_WITH_GOST \
  50. CONFIG_OPENSSL_WITH_IDEA \
  51. CONFIG_OPENSSL_WITH_MDC2 \
  52. CONFIG_OPENSSL_WITH_NPN \
  53. CONFIG_OPENSSL_WITH_PSK \
  54. CONFIG_OPENSSL_WITH_RFC3779 \
  55. CONFIG_OPENSSL_WITH_SEED \
  56. CONFIG_OPENSSL_WITH_SM234 \
  57. CONFIG_OPENSSL_WITH_SRP \
  58. CONFIG_OPENSSL_WITH_SSE2 \
  59. CONFIG_OPENSSL_WITH_TLS13 \
  60. CONFIG_OPENSSL_WITH_WHIRLPOOL
  61. include $(INCLUDE_DIR)/package.mk
  62. ifneq ($(CONFIG_CCACHE),)
  63. HOSTCC=$(HOSTCC_NOCACHE)
  64. HOSTCXX=$(HOSTCXX_NOCACHE)
  65. endif
  66. define Package/openssl/Default
  67. TITLE:=Open source SSL toolkit
  68. URL:=http://www.openssl.org/
  69. SECTION:=libs
  70. CATEGORY:=Libraries
  71. endef
  72. define Package/libopenssl/config
  73. source "$(SOURCE)/Config.in"
  74. endef
  75. define Package/openssl/Default/description
  76. The OpenSSL Project is a collaborative effort to develop a robust,
  77. commercial-grade, full-featured, and Open Source toolkit implementing the
  78. Transport Layer Security (TLS) protocol as well as a full-strength
  79. general-purpose cryptography library.
  80. endef
  81. define Package/libopenssl
  82. $(call Package/openssl/Default)
  83. SUBMENU:=SSL
  84. DEPENDS:=+OPENSSL_WITH_COMPRESSION:zlib \
  85. +OPENSSL_ENGINE_BUILTIN_AFALG:kmod-crypto-user \
  86. +OPENSSL_ENGINE_BUILTIN_DEVCRYPTO:kmod-cryptodev \
  87. +OPENSSL_ENGINE_BUILTIN_PADLOCK:kmod-crypto-hw-padlock
  88. TITLE+= (libraries)
  89. ABI_VERSION:=1.1
  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. endef
  116. define Package/libopenssl-conf/description
  117. $(call Package/openssl/Default/description)
  118. This package installs the OpenSSL configuration file /etc/ssl/openssl.cnf.
  119. endef
  120. define Package/libopenssl-afalg
  121. $(call Package/openssl/Default)
  122. SUBMENU:=SSL
  123. TITLE:=AFALG hardware acceleration engine
  124. DEPENDS:=libopenssl @OPENSSL_ENGINE @KERNEL_AIO \
  125. +PACKAGE_libopenssl-afalg:kmod-crypto-user +libopenssl-conf @!OPENSSL_ENGINE_BUILTIN
  126. endef
  127. define Package/libopenssl-afalg/description
  128. This package adds an engine that enables hardware acceleration
  129. through the AF_ALG kernel interface.
  130. To use it, you need to configure the engine in /etc/ssl/openssl.cnf
  131. See https://www.openssl.org/docs/man1.1.1/man5/config.html#Engine-Configuration-Module
  132. and https://openwrt.org/docs/techref/hardware/cryptographic.hardware.accelerators
  133. The engine_id is "afalg"
  134. endef
  135. define Package/libopenssl-devcrypto
  136. $(call Package/openssl/Default)
  137. SUBMENU:=SSL
  138. TITLE:=/dev/crypto hardware acceleration engine
  139. DEPENDS:=libopenssl @OPENSSL_ENGINE +PACKAGE_libopenssl-devcrypto:kmod-cryptodev +libopenssl-conf \
  140. @!OPENSSL_ENGINE_BUILTIN
  141. endef
  142. define Package/libopenssl-devcrypto/description
  143. This package adds an engine that enables hardware acceleration
  144. through the /dev/crypto kernel interface.
  145. To use it, you need to configure the engine in /etc/ssl/openssl.cnf
  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. define Package/libopenssl-padlock
  151. $(call Package/openssl/Default)
  152. SUBMENU:=SSL
  153. TITLE:=VIA Padlock hardware acceleration engine
  154. DEPENDS:=libopenssl @OPENSSL_ENGINE @TARGET_x86 +PACKAGE_libopenssl-padlock:kmod-crypto-hw-padlock \
  155. +libopenssl-conf @!OPENSSL_ENGINE_BUILTIN
  156. endef
  157. define Package/libopenssl-padlock/description
  158. This package adds an engine that enables VIA Padlock hardware acceleration.
  159. To use it, you need to configure it in /etc/ssl/openssl.cnf.
  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
  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_EC
  179. OPENSSL_OPTIONS += no-ec
  180. endif
  181. ifndef CONFIG_OPENSSL_WITH_EC2M
  182. OPENSSL_OPTIONS += no-ec2m
  183. endif
  184. ifndef CONFIG_OPENSSL_WITH_ERROR_MESSAGES
  185. OPENSSL_OPTIONS += no-err
  186. endif
  187. ifndef CONFIG_OPENSSL_WITH_TLS13
  188. OPENSSL_OPTIONS += no-tls1_3
  189. endif
  190. ifndef CONFIG_OPENSSL_WITH_ARIA
  191. OPENSSL_OPTIONS += no-aria
  192. endif
  193. ifndef CONFIG_OPENSSL_WITH_SM234
  194. OPENSSL_OPTIONS += no-sm2 no-sm3 no-sm4
  195. endif
  196. ifndef CONFIG_OPENSSL_WITH_CAMELLIA
  197. OPENSSL_OPTIONS += no-camellia
  198. endif
  199. ifndef CONFIG_OPENSSL_WITH_IDEA
  200. OPENSSL_OPTIONS += no-idea
  201. endif
  202. ifndef CONFIG_OPENSSL_WITH_SEED
  203. OPENSSL_OPTIONS += no-seed
  204. endif
  205. ifndef CONFIG_OPENSSL_WITH_MDC2
  206. OPENSSL_OPTIONS += no-mdc2
  207. endif
  208. ifndef CONFIG_OPENSSL_WITH_WHIRLPOOL
  209. OPENSSL_OPTIONS += no-whirlpool
  210. endif
  211. ifndef CONFIG_OPENSSL_WITH_CMS
  212. OPENSSL_OPTIONS += no-cms
  213. endif
  214. ifndef CONFIG_OPENSSL_WITH_RFC3779
  215. OPENSSL_OPTIONS += no-rfc3779
  216. endif
  217. ifdef CONFIG_OPENSSL_NO_DEPRECATED
  218. OPENSSL_OPTIONS += no-deprecated
  219. endif
  220. ifeq ($(CONFIG_OPENSSL_OPTIMIZE_SPEED),y)
  221. TARGET_CFLAGS := $(filter-out -O%,$(TARGET_CFLAGS)) -O3
  222. else
  223. OPENSSL_OPTIONS += -DOPENSSL_SMALL_FOOTPRINT
  224. endif
  225. ifdef CONFIG_OPENSSL_ENGINE
  226. ifdef CONFIG_OPENSSL_ENGINE_BUILTIN
  227. OPENSSL_OPTIONS += disable-dynamic-engine
  228. ifndef CONFIG_OPENSSL_ENGINE_BUILTIN_AFALG
  229. OPENSSL_OPTIONS += no-afalgeng
  230. endif
  231. ifdef CONFIG_OPENSSL_ENGINE_BUILTIN_DEVCRYPTO
  232. OPENSSL_OPTIONS += enable-devcryptoeng
  233. endif
  234. ifndef CONFIG_OPENSSL_ENGINE_BUILTIN_PADLOCK
  235. OPENSSL_OPTIONS += no-hw-padlock
  236. endif
  237. else
  238. ifdef CONFIG_PACKAGE_libopenssl-devcrypto
  239. OPENSSL_OPTIONS += enable-devcryptoeng
  240. endif
  241. ifndef CONFIG_PACKAGE_libopenssl-afalg
  242. OPENSSL_OPTIONS += no-afalgeng
  243. endif
  244. ifndef CONFIG_PACKAGE_libopenssl-padlock
  245. OPENSSL_OPTIONS += no-hw-padlock
  246. endif
  247. endif
  248. else
  249. OPENSSL_OPTIONS += no-engine
  250. endif
  251. ifndef CONFIG_OPENSSL_WITH_GOST
  252. OPENSSL_OPTIONS += no-gost
  253. endif
  254. ifndef CONFIG_OPENSSL_WITH_DTLS
  255. OPENSSL_OPTIONS += no-dtls
  256. endif
  257. ifdef CONFIG_OPENSSL_WITH_COMPRESSION
  258. OPENSSL_OPTIONS += zlib-dynamic
  259. else
  260. OPENSSL_OPTIONS += no-comp
  261. endif
  262. ifndef CONFIG_OPENSSL_WITH_NPN
  263. OPENSSL_OPTIONS += no-nextprotoneg
  264. endif
  265. ifndef CONFIG_OPENSSL_WITH_PSK
  266. OPENSSL_OPTIONS += no-psk
  267. endif
  268. ifndef CONFIG_OPENSSL_WITH_SRP
  269. OPENSSL_OPTIONS += no-srp
  270. endif
  271. ifndef CONFIG_OPENSSL_WITH_ASM
  272. OPENSSL_OPTIONS += no-asm
  273. endif
  274. ifdef CONFIG_i386
  275. ifndef CONFIG_OPENSSL_WITH_SSE2
  276. OPENSSL_OPTIONS += no-sse2
  277. endif
  278. endif
  279. OPENSSL_TARGET:=linux-$(call qstrip,$(CONFIG_ARCH))-openwrt
  280. STAMP_CONFIGURED := $(STAMP_CONFIGURED)_$(shell echo $(OPENSSL_OPTIONS) | mkhash md5)
  281. define Build/Configure
  282. (cd $(PKG_BUILD_DIR); \
  283. ./Configure $(OPENSSL_TARGET) \
  284. --prefix=/usr \
  285. --libdir=lib \
  286. --openssldir=/etc/ssl \
  287. $(TARGET_CPPFLAGS) \
  288. $(TARGET_LDFLAGS) \
  289. $(OPENSSL_OPTIONS) && \
  290. { [ -f $(STAMP_CONFIGURED) ] || make clean; } \
  291. )
  292. endef
  293. TARGET_CFLAGS += $(FPIC) -ffunction-sections -fdata-sections
  294. TARGET_LDFLAGS += -Wl,--gc-sections
  295. define Build/Compile
  296. +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
  297. CROSS_COMPILE="$(TARGET_CROSS)" \
  298. CC="$(TARGET_CC)" \
  299. SOURCE_DATE_EPOCH=$(SOURCE_DATE_EPOCH) \
  300. OPENWRT_OPTIMIZATION_FLAGS="$(TARGET_CFLAGS)" \
  301. $(OPENSSL_MAKEFLAGS) \
  302. all
  303. $(MAKE) -C $(PKG_BUILD_DIR) \
  304. CROSS_COMPILE="$(TARGET_CROSS)" \
  305. CC="$(TARGET_CC)" \
  306. DESTDIR="$(PKG_INSTALL_DIR)" \
  307. $(OPENSSL_MAKEFLAGS) \
  308. install_sw install_ssldirs
  309. endef
  310. define Build/InstallDev
  311. $(INSTALL_DIR) $(1)/usr/include
  312. $(CP) $(PKG_INSTALL_DIR)/usr/include/openssl $(1)/usr/include/
  313. $(INSTALL_DIR) $(1)/usr/lib/
  314. $(CP) $(PKG_INSTALL_DIR)/usr/lib/lib{crypto,ssl}.{a,so*} $(1)/usr/lib/
  315. $(INSTALL_DIR) $(1)/usr/lib/pkgconfig
  316. $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/{openssl,libcrypto,libssl}.pc $(1)/usr/lib/pkgconfig/
  317. [ -n "$(TARGET_LDFLAGS)" ] && $(SED) 's#$(TARGET_LDFLAGS)##g' $(1)/usr/lib/pkgconfig/{openssl,libcrypto,libssl}.pc || true
  318. endef
  319. define Package/libopenssl/install
  320. $(INSTALL_DIR) $(1)/etc/ssl/certs
  321. $(INSTALL_DIR) $(1)/etc/ssl/private
  322. chmod 0700 $(1)/etc/ssl/private
  323. $(INSTALL_DIR) $(1)/usr/lib
  324. $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libcrypto.so.* $(1)/usr/lib/
  325. $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libssl.so.* $(1)/usr/lib/
  326. $(if $(CONFIG_OPENSSL_ENGINE),$(INSTALL_DIR) $(1)/usr/lib/$(ENGINES_DIR))
  327. endef
  328. define Package/libopenssl-conf/install
  329. $(INSTALL_DIR) $(1)/etc/ssl
  330. $(CP) $(PKG_INSTALL_DIR)/etc/ssl/openssl.cnf $(1)/etc/ssl/
  331. endef
  332. define Package/openssl-util/install
  333. $(INSTALL_DIR) $(1)/usr/bin
  334. $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/openssl $(1)/usr/bin/
  335. endef
  336. define Package/libopenssl-afalg/install
  337. $(INSTALL_DIR) $(1)/usr/lib/$(ENGINES_DIR)
  338. $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/$(ENGINES_DIR)/afalg.so $(1)/usr/lib/$(ENGINES_DIR)
  339. endef
  340. define Package/libopenssl-devcrypto/install
  341. $(INSTALL_DIR) $(1)/usr/lib/$(ENGINES_DIR)
  342. $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/$(ENGINES_DIR)/devcrypto.so $(1)/usr/lib/$(ENGINES_DIR)
  343. endef
  344. define Package/libopenssl-padlock/install
  345. $(INSTALL_DIR) $(1)/usr/lib/$(ENGINES_DIR)
  346. $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/$(ENGINES_DIR)/*padlock.so $(1)/usr/lib/$(ENGINES_DIR)
  347. endef
  348. $(eval $(call BuildPackage,libopenssl))
  349. $(eval $(call BuildPackage,libopenssl-conf))
  350. $(eval $(call BuildPackage,libopenssl-afalg))
  351. $(eval $(call BuildPackage,libopenssl-devcrypto))
  352. $(eval $(call BuildPackage,libopenssl-padlock))
  353. $(eval $(call BuildPackage,openssl-util))