2 # Copyright (C) 2006-2016 OpenWrt.org
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
8 include $(TOPDIR)/rules.mk
13 PKG_VERSION:=$(PKG_BASE)$(PKG_BUGFIX)
16 ENGINES_DIR=engines-1.1
20 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
22 http://ftp.fi.muni.cz/pub/openssl/source/ \
23 http://ftp.linux.hr/pub/openssl/source/ \
24 ftp://ftp.pca.dfn.de/pub/tools/net/openssl/source/ \
25 http://www.openssl.org/source/ \
26 http://www.openssl.org/source/old/$(PKG_BASE)/
27 PKG_HASH:=5c557b023230413dfb0756f3137a13e6d726838ccd1430888ad15bfb2b43ea4b
30 PKG_LICENSE_FILES:=LICENSE
31 PKG_CPE_ID:=cpe:/a:openssl:openssl
32 PKG_CONFIG_DEPENDS:= \
33 CONFIG_OPENSSL_ENGINE \
34 CONFIG_OPENSSL_ENGINE_BUILTIN \
35 CONFIG_OPENSSL_ENGINE_BUILTIN_AFALG \
36 CONFIG_OPENSSL_ENGINE_BUILTIN_DEVCRYPTO \
37 CONFIG_OPENSSL_ENGINE_BUILTIN_PADLOCK \
38 CONFIG_OPENSSL_NO_DEPRECATED \
39 CONFIG_OPENSSL_OPTIMIZE_SPEED \
40 CONFIG_OPENSSL_PREFER_CHACHA_OVER_GCM \
41 CONFIG_OPENSSL_WITH_ARIA \
42 CONFIG_OPENSSL_WITH_ASM \
43 CONFIG_OPENSSL_WITH_ASYNC \
44 CONFIG_OPENSSL_WITH_BLAKE2 \
45 CONFIG_OPENSSL_WITH_CAMELLIA \
46 CONFIG_OPENSSL_WITH_CHACHA_POLY1305 \
47 CONFIG_OPENSSL_WITH_CMS \
48 CONFIG_OPENSSL_WITH_COMPRESSION \
49 CONFIG_OPENSSL_WITH_DTLS \
50 CONFIG_OPENSSL_WITH_EC \
51 CONFIG_OPENSSL_WITH_EC2M \
52 CONFIG_OPENSSL_WITH_ERROR_MESSAGES \
53 CONFIG_OPENSSL_WITH_GOST \
54 CONFIG_OPENSSL_WITH_IDEA \
55 CONFIG_OPENSSL_WITH_MDC2 \
56 CONFIG_OPENSSL_WITH_NPN \
57 CONFIG_OPENSSL_WITH_PSK \
58 CONFIG_OPENSSL_WITH_RFC3779 \
59 CONFIG_OPENSSL_WITH_SEED \
60 CONFIG_OPENSSL_WITH_SM234 \
61 CONFIG_OPENSSL_WITH_SRP \
62 CONFIG_OPENSSL_WITH_SSE2 \
63 CONFIG_OPENSSL_WITH_TLS13 \
64 CONFIG_OPENSSL_WITH_WHIRLPOOL
66 include $(INCLUDE_DIR)/package.mk
68 ifneq ($(CONFIG_CCACHE),)
69 HOSTCC=$(HOSTCC_NOCACHE)
70 HOSTCXX=$(HOSTCXX_NOCACHE)
73 define Package/openssl/Default
74 TITLE:=Open source SSL toolkit
75 URL:=http://www.openssl.org/
80 define Package/libopenssl/config
81 source "$(SOURCE)/Config.in"
84 define Package/openssl/Default/description
85 The OpenSSL Project is a collaborative effort to develop a robust,
86 commercial-grade, full-featured, and Open Source toolkit implementing the
87 Transport Layer Security (TLS) protocol as well as a full-strength
88 general-purpose cryptography library.
91 define Package/libopenssl
92 $(call Package/openssl/Default)
94 DEPENDS:=+OPENSSL_WITH_COMPRESSION:zlib \
95 +OPENSSL_ENGINE_BUILTIN_AFALG:kmod-crypto-user \
96 +OPENSSL_ENGINE_BUILTIN_DEVCRYPTO:kmod-cryptodev \
97 +OPENSSL_ENGINE_BUILTIN_PADLOCK:kmod-crypto-hw-padlock
103 define Package/libopenssl/description
104 $(call Package/openssl/Default/description)
105 This package contains the OpenSSL shared libraries, needed by other programs.
108 define Package/openssl-util
109 $(call Package/openssl/Default)
112 DEPENDS:=+libopenssl +libopenssl-conf
116 define Package/openssl-util/description
117 $(call Package/openssl/Default/description)
118 This package contains the OpenSSL command-line utility.
121 define Package/libopenssl-conf
122 $(call Package/openssl/Default)
124 TITLE:=/etc/ssl/openssl.cnf config file
128 define Package/libopenssl-conf/conffiles
132 define Package/libopenssl-conf/description
133 $(call Package/openssl/Default/description)
134 This package installs the OpenSSL configuration file /etc/ssl/openssl.cnf.
137 define Package/libopenssl-afalg
138 $(call Package/openssl/Default)
140 TITLE:=AFALG hardware acceleration engine
141 DEPENDS:=libopenssl @OPENSSL_ENGINE @KERNEL_AIO @!LINUX_3_18 +kmod-crypto-user \
142 +libopenssl-conf @!OPENSSL_ENGINE_BUILTIN
145 define Package/libopenssl-afalg/description
146 This package adds an engine that enables hardware acceleration
147 through the AF_ALG kernel interface.
148 To use it, you need to configure the engine in /etc/ssl/openssl.cnf
149 See https://www.openssl.org/docs/man1.1.1/man5/config.html#Engine-Configuration-Module
150 and https://openwrt.org/docs/techref/hardware/cryptographic.hardware.accelerators
151 The engine_id is "afalg"
154 define Package/libopenssl-devcrypto
155 $(call Package/openssl/Default)
157 TITLE:=/dev/crypto hardware acceleration engine
158 DEPENDS:=libopenssl @OPENSSL_ENGINE +kmod-cryptodev +libopenssl-conf \
159 @!OPENSSL_ENGINE_BUILTIN
162 define Package/libopenssl-devcrypto/description
163 This package adds an engine that enables hardware acceleration
164 through the /dev/crypto kernel interface.
165 To use it, you need to configure the engine in /etc/ssl/openssl.cnf
166 See https://www.openssl.org/docs/man1.1.1/man5/config.html#Engine-Configuration-Module
167 and https://openwrt.org/docs/techref/hardware/cryptographic.hardware.accelerators
168 The engine_id is "devcrypto"
171 define Package/libopenssl-padlock
172 $(call Package/openssl/Default)
174 TITLE:=VIA Padlock hardware acceleration engine
175 DEPENDS:=libopenssl @OPENSSL_ENGINE @TARGET_x86 +kmod-crypto-hw-padlock \
176 +libopenssl-conf @!OPENSSL_ENGINE_BUILTIN
179 define Package/libopenssl-padlock/description
180 This package adds an engine that enables VIA Padlock hardware acceleration.
181 To use it, you need to configure it in /etc/ssl/openssl.cnf.
182 See https://www.openssl.org/docs/man1.1.1/man5/config.html#Engine-Configuration-Module
183 and https://openwrt.org/docs/techref/hardware/cryptographic.hardware.accelerators
184 The engine_id is "padlock"
187 OPENSSL_OPTIONS:= shared
189 ifndef CONFIG_OPENSSL_WITH_BLAKE2
190 OPENSSL_OPTIONS += no-blake2
193 ifndef CONFIG_OPENSSL_WITH_CHACHA_POLY1305
194 OPENSSL_OPTIONS += no-chacha no-poly1305
196 ifdef CONFIG_OPENSSL_PREFER_CHACHA_OVER_GCM
197 OPENSSL_OPTIONS += -DOPENSSL_PREFER_CHACHA_OVER_GCM
201 ifndef CONFIG_OPENSSL_WITH_ASYNC
202 OPENSSL_OPTIONS += no-async
205 ifndef CONFIG_OPENSSL_WITH_EC
206 OPENSSL_OPTIONS += no-ec
209 ifndef CONFIG_OPENSSL_WITH_EC2M
210 OPENSSL_OPTIONS += no-ec2m
213 ifndef CONFIG_OPENSSL_WITH_ERROR_MESSAGES
214 OPENSSL_OPTIONS += no-err
217 ifndef CONFIG_OPENSSL_WITH_TLS13
218 OPENSSL_OPTIONS += no-tls1_3
221 ifndef CONFIG_OPENSSL_WITH_ARIA
222 OPENSSL_OPTIONS += no-aria
225 ifndef CONFIG_OPENSSL_WITH_SM234
226 OPENSSL_OPTIONS += no-sm2 no-sm3 no-sm4
229 ifndef CONFIG_OPENSSL_WITH_CAMELLIA
230 OPENSSL_OPTIONS += no-camellia
233 ifndef CONFIG_OPENSSL_WITH_IDEA
234 OPENSSL_OPTIONS += no-idea
237 ifndef CONFIG_OPENSSL_WITH_SEED
238 OPENSSL_OPTIONS += no-seed
241 ifndef CONFIG_OPENSSL_WITH_MDC2
242 OPENSSL_OPTIONS += no-mdc2
245 ifndef CONFIG_OPENSSL_WITH_WHIRLPOOL
246 OPENSSL_OPTIONS += no-whirlpool
249 ifndef CONFIG_OPENSSL_WITH_CMS
250 OPENSSL_OPTIONS += no-cms
253 ifndef CONFIG_OPENSSL_WITH_RFC3779
254 OPENSSL_OPTIONS += no-rfc3779
257 ifdef CONFIG_OPENSSL_NO_DEPRECATED
258 OPENSSL_OPTIONS += no-deprecated
261 ifeq ($(CONFIG_OPENSSL_OPTIMIZE_SPEED),y)
262 TARGET_CFLAGS := $(filter-out -O%,$(TARGET_CFLAGS)) -O3
264 OPENSSL_OPTIONS += -DOPENSSL_SMALL_FOOTPRINT
267 ifdef CONFIG_OPENSSL_ENGINE
268 ifdef CONFIG_OPENSSL_ENGINE_BUILTIN
269 OPENSSL_OPTIONS += disable-dynamic-engine
270 ifndef CONFIG_OPENSSL_ENGINE_BUILTIN_AFALG
271 OPENSSL_OPTIONS += no-afalgeng
273 ifdef CONFIG_OPENSSL_ENGINE_BUILTIN_DEVCRYPTO
274 OPENSSL_OPTIONS += enable-devcryptoeng
276 ifndef CONFIG_OPENSSL_ENGINE_BUILTIN_PADLOCK
277 OPENSSL_OPTIONS += no-hw-padlock
280 ifdef CONFIG_PACKAGE_libopenssl-devcrypto
281 OPENSSL_OPTIONS += enable-devcryptoeng
283 ifndef CONFIG_PACKAGE_libopenssl-afalg
284 OPENSSL_OPTIONS += no-afalgeng
286 ifndef CONFIG_PACKAGE_libopenssl-padlock
287 OPENSSL_OPTIONS += no-hw-padlock
291 OPENSSL_OPTIONS += no-engine
294 ifndef CONFIG_OPENSSL_WITH_GOST
295 OPENSSL_OPTIONS += no-gost
298 ifndef CONFIG_OPENSSL_WITH_DTLS
299 OPENSSL_OPTIONS += no-dtls
302 ifdef CONFIG_OPENSSL_WITH_COMPRESSION
303 OPENSSL_OPTIONS += zlib-dynamic
305 OPENSSL_OPTIONS += no-comp
308 ifndef CONFIG_OPENSSL_WITH_NPN
309 OPENSSL_OPTIONS += no-nextprotoneg
312 ifndef CONFIG_OPENSSL_WITH_PSK
313 OPENSSL_OPTIONS += no-psk
316 ifndef CONFIG_OPENSSL_WITH_SRP
317 OPENSSL_OPTIONS += no-srp
320 ifndef CONFIG_OPENSSL_WITH_ASM
321 OPENSSL_OPTIONS += no-asm
325 ifndef CONFIG_OPENSSL_WITH_SSE2
326 OPENSSL_OPTIONS += no-sse2
330 OPENSSL_TARGET:=linux-$(call qstrip,$(CONFIG_ARCH))-openwrt
332 STAMP_CONFIGURED := $(STAMP_CONFIGURED)_$(shell echo $(OPENSSL_OPTIONS) | mkhash md5)
334 define Build/Configure
335 (cd $(PKG_BUILD_DIR); \
336 ./Configure $(OPENSSL_TARGET) \
339 --openssldir=/etc/ssl \
342 $(OPENSSL_OPTIONS) && \
343 { [ -f $(STAMP_CONFIGURED) ] || make clean; } \
347 TARGET_CFLAGS += $(FPIC) -ffunction-sections -fdata-sections
348 TARGET_LDFLAGS += -Wl,--gc-sections
351 +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
352 CROSS_COMPILE="$(TARGET_CROSS)" \
354 SOURCE_DATE_EPOCH=$(SOURCE_DATE_EPOCH) \
355 OPENWRT_OPTIMIZATION_FLAGS="$(TARGET_CFLAGS)" \
356 $(OPENSSL_MAKEFLAGS) \
358 $(MAKE) -C $(PKG_BUILD_DIR) \
359 CROSS_COMPILE="$(TARGET_CROSS)" \
361 DESTDIR="$(PKG_INSTALL_DIR)" \
362 $(OPENSSL_MAKEFLAGS) \
363 install_sw install_ssldirs
366 define Build/InstallDev
367 $(INSTALL_DIR) $(1)/usr/include
368 $(CP) $(PKG_INSTALL_DIR)/usr/include/openssl $(1)/usr/include/
369 $(INSTALL_DIR) $(1)/usr/lib/
370 $(CP) $(PKG_INSTALL_DIR)/usr/lib/lib{crypto,ssl}.{a,so*} $(1)/usr/lib/
371 $(INSTALL_DIR) $(1)/usr/lib/pkgconfig
372 $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/{openssl,libcrypto,libssl}.pc $(1)/usr/lib/pkgconfig/
373 [ -n "$(TARGET_LDFLAGS)" ] && $(SED) 's#$(TARGET_LDFLAGS)##g' $(1)/usr/lib/pkgconfig/{openssl,libcrypto,libssl}.pc || true
376 define Package/libopenssl/install
377 $(INSTALL_DIR) $(1)/etc/ssl/certs
378 $(INSTALL_DIR) $(1)/etc/ssl/private
379 chmod 0700 $(1)/etc/ssl/private
380 $(INSTALL_DIR) $(1)/usr/lib
381 $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libcrypto.so.* $(1)/usr/lib/
382 $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libssl.so.* $(1)/usr/lib/
383 $(if $(CONFIG_OPENSSL_ENGINE),$(INSTALL_DIR) $(1)/usr/lib/$(ENGINES_DIR))
386 define Package/libopenssl-conf/install
387 $(INSTALL_DIR) $(1)/etc/ssl
388 $(CP) $(PKG_INSTALL_DIR)/etc/ssl/openssl.cnf $(1)/etc/ssl/
391 define Package/openssl-util/install
392 $(INSTALL_DIR) $(1)/usr/bin
393 $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/openssl $(1)/usr/bin/
396 define Package/libopenssl-afalg/install
397 $(INSTALL_DIR) $(1)/usr/lib/$(ENGINES_DIR)
398 $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/$(ENGINES_DIR)/afalg.so $(1)/usr/lib/$(ENGINES_DIR)
401 define Package/libopenssl-devcrypto/install
402 $(INSTALL_DIR) $(1)/usr/lib/$(ENGINES_DIR)
403 $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/$(ENGINES_DIR)/devcrypto.so $(1)/usr/lib/$(ENGINES_DIR)
406 define Package/libopenssl-padlock/install
407 $(INSTALL_DIR) $(1)/usr/lib/$(ENGINES_DIR)
408 $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/$(ENGINES_DIR)/*padlock.so $(1)/usr/lib/$(ENGINES_DIR)
411 $(eval $(call BuildPackage,libopenssl))
412 $(eval $(call BuildPackage,libopenssl-conf))
413 $(eval $(call BuildPackage,libopenssl-afalg))
414 $(eval $(call BuildPackage,libopenssl-devcrypto))
415 $(eval $(call BuildPackage,libopenssl-padlock))
416 $(eval $(call BuildPackage,openssl-util))