openssl: fix OPENSSL_config bug affecting wget
[openwrt/openwrt.git] / package / libs / openssl / Makefile
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
8 include $(TOPDIR)/rules.mk
9
10 PKG_NAME:=openssl
11 PKG_BASE:=1.1.1
12 PKG_BUGFIX:=b
13 PKG_VERSION:=$(PKG_BASE)$(PKG_BUGFIX)
14 PKG_RELEASE:=5
15 PKG_USE_MIPS16:=0
16 ENGINES_DIR=engines-1.1
17
18 PKG_BUILD_PARALLEL:=1
19
20 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
21 PKG_SOURCE_URL:= \
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
28
29 PKG_LICENSE:=OpenSSL
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
65
66 include $(INCLUDE_DIR)/package.mk
67
68 ifneq ($(CONFIG_CCACHE),)
69 HOSTCC=$(HOSTCC_NOCACHE)
70 HOSTCXX=$(HOSTCXX_NOCACHE)
71 endif
72
73 define Package/openssl/Default
74 TITLE:=Open source SSL toolkit
75 URL:=http://www.openssl.org/
76 SECTION:=libs
77 CATEGORY:=Libraries
78 endef
79
80 define Package/libopenssl/config
81 source "$(SOURCE)/Config.in"
82 endef
83
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.
89 endef
90
91 define Package/libopenssl
92 $(call Package/openssl/Default)
93 SUBMENU:=SSL
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
98 TITLE+= (libraries)
99 ABI_VERSION:=1.1
100 MENU:=1
101 endef
102
103 define Package/libopenssl/description
104 $(call Package/openssl/Default/description)
105 This package contains the OpenSSL shared libraries, needed by other programs.
106 endef
107
108 define Package/openssl-util
109 $(call Package/openssl/Default)
110 SECTION:=utils
111 CATEGORY:=Utilities
112 DEPENDS:=+libopenssl +libopenssl-conf
113 TITLE+= (utility)
114 endef
115
116 define Package/openssl-util/description
117 $(call Package/openssl/Default/description)
118 This package contains the OpenSSL command-line utility.
119 endef
120
121 define Package/libopenssl-conf
122 $(call Package/openssl/Default)
123 SUBMENU:=SSL
124 TITLE:=/etc/ssl/openssl.cnf config file
125 DEPENDS:=libopenssl
126 endef
127
128 define Package/libopenssl-conf/conffiles
129 /etc/ssl/openssl.cnf
130 endef
131
132 define Package/libopenssl-conf/description
133 $(call Package/openssl/Default/description)
134 This package installs the OpenSSL configuration file /etc/ssl/openssl.cnf.
135 endef
136
137 define Package/libopenssl-afalg
138 $(call Package/openssl/Default)
139 SUBMENU:=SSL
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
143 endef
144
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"
152 endef
153
154 define Package/libopenssl-devcrypto
155 $(call Package/openssl/Default)
156 SUBMENU:=SSL
157 TITLE:=/dev/crypto hardware acceleration engine
158 DEPENDS:=libopenssl @OPENSSL_ENGINE +kmod-cryptodev +libopenssl-conf \
159 @!OPENSSL_ENGINE_BUILTIN
160 endef
161
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"
169 endef
170
171 define Package/libopenssl-padlock
172 $(call Package/openssl/Default)
173 SUBMENU:=SSL
174 TITLE:=VIA Padlock hardware acceleration engine
175 DEPENDS:=libopenssl @OPENSSL_ENGINE @TARGET_x86 +kmod-crypto-hw-padlock \
176 +libopenssl-conf @!OPENSSL_ENGINE_BUILTIN
177 endef
178
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"
185 endef
186
187 OPENSSL_OPTIONS:= shared
188
189 ifndef CONFIG_OPENSSL_WITH_BLAKE2
190 OPENSSL_OPTIONS += no-blake2
191 endif
192
193 ifndef CONFIG_OPENSSL_WITH_CHACHA_POLY1305
194 OPENSSL_OPTIONS += no-chacha no-poly1305
195 else
196 ifdef CONFIG_OPENSSL_PREFER_CHACHA_OVER_GCM
197 OPENSSL_OPTIONS += -DOPENSSL_PREFER_CHACHA_OVER_GCM
198 endif
199 endif
200
201 ifndef CONFIG_OPENSSL_WITH_ASYNC
202 OPENSSL_OPTIONS += no-async
203 endif
204
205 ifndef CONFIG_OPENSSL_WITH_EC
206 OPENSSL_OPTIONS += no-ec
207 endif
208
209 ifndef CONFIG_OPENSSL_WITH_EC2M
210 OPENSSL_OPTIONS += no-ec2m
211 endif
212
213 ifndef CONFIG_OPENSSL_WITH_ERROR_MESSAGES
214 OPENSSL_OPTIONS += no-err
215 endif
216
217 ifndef CONFIG_OPENSSL_WITH_TLS13
218 OPENSSL_OPTIONS += no-tls1_3
219 endif
220
221 ifndef CONFIG_OPENSSL_WITH_ARIA
222 OPENSSL_OPTIONS += no-aria
223 endif
224
225 ifndef CONFIG_OPENSSL_WITH_SM234
226 OPENSSL_OPTIONS += no-sm2 no-sm3 no-sm4
227 endif
228
229 ifndef CONFIG_OPENSSL_WITH_CAMELLIA
230 OPENSSL_OPTIONS += no-camellia
231 endif
232
233 ifndef CONFIG_OPENSSL_WITH_IDEA
234 OPENSSL_OPTIONS += no-idea
235 endif
236
237 ifndef CONFIG_OPENSSL_WITH_SEED
238 OPENSSL_OPTIONS += no-seed
239 endif
240
241 ifndef CONFIG_OPENSSL_WITH_MDC2
242 OPENSSL_OPTIONS += no-mdc2
243 endif
244
245 ifndef CONFIG_OPENSSL_WITH_WHIRLPOOL
246 OPENSSL_OPTIONS += no-whirlpool
247 endif
248
249 ifndef CONFIG_OPENSSL_WITH_CMS
250 OPENSSL_OPTIONS += no-cms
251 endif
252
253 ifndef CONFIG_OPENSSL_WITH_RFC3779
254 OPENSSL_OPTIONS += no-rfc3779
255 endif
256
257 ifdef CONFIG_OPENSSL_NO_DEPRECATED
258 OPENSSL_OPTIONS += no-deprecated
259 endif
260
261 ifeq ($(CONFIG_OPENSSL_OPTIMIZE_SPEED),y)
262 TARGET_CFLAGS := $(filter-out -O%,$(TARGET_CFLAGS)) -O3
263 else
264 OPENSSL_OPTIONS += -DOPENSSL_SMALL_FOOTPRINT
265 endif
266
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
272 endif
273 ifdef CONFIG_OPENSSL_ENGINE_BUILTIN_DEVCRYPTO
274 OPENSSL_OPTIONS += enable-devcryptoeng
275 endif
276 ifndef CONFIG_OPENSSL_ENGINE_BUILTIN_PADLOCK
277 OPENSSL_OPTIONS += no-hw-padlock
278 endif
279 else
280 ifdef CONFIG_PACKAGE_libopenssl-devcrypto
281 OPENSSL_OPTIONS += enable-devcryptoeng
282 endif
283 ifndef CONFIG_PACKAGE_libopenssl-afalg
284 OPENSSL_OPTIONS += no-afalgeng
285 endif
286 ifndef CONFIG_PACKAGE_libopenssl-padlock
287 OPENSSL_OPTIONS += no-hw-padlock
288 endif
289 endif
290 else
291 OPENSSL_OPTIONS += no-engine
292 endif
293
294 ifndef CONFIG_OPENSSL_WITH_GOST
295 OPENSSL_OPTIONS += no-gost
296 endif
297
298 ifndef CONFIG_OPENSSL_WITH_DTLS
299 OPENSSL_OPTIONS += no-dtls
300 endif
301
302 ifdef CONFIG_OPENSSL_WITH_COMPRESSION
303 OPENSSL_OPTIONS += zlib-dynamic
304 else
305 OPENSSL_OPTIONS += no-comp
306 endif
307
308 ifndef CONFIG_OPENSSL_WITH_NPN
309 OPENSSL_OPTIONS += no-nextprotoneg
310 endif
311
312 ifndef CONFIG_OPENSSL_WITH_PSK
313 OPENSSL_OPTIONS += no-psk
314 endif
315
316 ifndef CONFIG_OPENSSL_WITH_SRP
317 OPENSSL_OPTIONS += no-srp
318 endif
319
320 ifndef CONFIG_OPENSSL_WITH_ASM
321 OPENSSL_OPTIONS += no-asm
322 endif
323
324 ifdef CONFIG_i386
325 ifndef CONFIG_OPENSSL_WITH_SSE2
326 OPENSSL_OPTIONS += no-sse2
327 endif
328 endif
329
330 OPENSSL_TARGET:=linux-$(call qstrip,$(CONFIG_ARCH))-openwrt
331
332 STAMP_CONFIGURED := $(STAMP_CONFIGURED)_$(shell echo $(OPENSSL_OPTIONS) | mkhash md5)
333
334 define Build/Configure
335 (cd $(PKG_BUILD_DIR); \
336 ./Configure $(OPENSSL_TARGET) \
337 --prefix=/usr \
338 --libdir=lib \
339 --openssldir=/etc/ssl \
340 $(TARGET_CPPFLAGS) \
341 $(TARGET_LDFLAGS) \
342 $(OPENSSL_OPTIONS) && \
343 { [ -f $(STAMP_CONFIGURED) ] || make clean; } \
344 )
345 endef
346
347 TARGET_CFLAGS += $(FPIC) -ffunction-sections -fdata-sections
348 TARGET_LDFLAGS += -Wl,--gc-sections
349
350 define Build/Compile
351 +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
352 CROSS_COMPILE="$(TARGET_CROSS)" \
353 CC="$(TARGET_CC)" \
354 SOURCE_DATE_EPOCH=$(SOURCE_DATE_EPOCH) \
355 OPENWRT_OPTIMIZATION_FLAGS="$(TARGET_CFLAGS)" \
356 $(OPENSSL_MAKEFLAGS) \
357 all
358 $(MAKE) -C $(PKG_BUILD_DIR) \
359 CROSS_COMPILE="$(TARGET_CROSS)" \
360 CC="$(TARGET_CC)" \
361 DESTDIR="$(PKG_INSTALL_DIR)" \
362 $(OPENSSL_MAKEFLAGS) \
363 install_sw install_ssldirs
364 endef
365
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
374 endef
375
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))
384 endef
385
386 define Package/libopenssl-conf/install
387 $(INSTALL_DIR) $(1)/etc/ssl
388 $(CP) $(PKG_INSTALL_DIR)/etc/ssl/openssl.cnf $(1)/etc/ssl/
389 endef
390
391 define Package/openssl-util/install
392 $(INSTALL_DIR) $(1)/usr/bin
393 $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/openssl $(1)/usr/bin/
394 endef
395
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)
399 endef
400
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)
404 endef
405
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)
409 endef
410
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))