openssl: add package for openssl.cnf, misc changes
[openwrt/staging/jogo.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:=a
13 PKG_VERSION:=$(PKG_BASE)$(PKG_BUGFIX)
14 PKG_RELEASE:=2
15 PKG_USE_MIPS16:=0
16 ENGINES_DIR=engines-1.1
17
18 PKG_BUILD_PARALLEL:=0
19 PKG_BUILD_DEPENDS:=cryptodev-linux
20
21 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
22 PKG_SOURCE_URL:= \
23 http://ftp.fi.muni.cz/pub/openssl/source/ \
24 http://ftp.linux.hr/pub/openssl/source/ \
25 ftp://ftp.pca.dfn.de/pub/tools/net/openssl/source/ \
26 http://www.openssl.org/source/ \
27 http://www.openssl.org/source/old/$(PKG_BASE)/
28 PKG_HASH:=fc20130f8b7cbd2fb918b2f14e2f429e109c31ddd0fb38fc5d71d9ffed3f9f41
29
30 PKG_LICENSE:=OpenSSL
31 PKG_LICENSE_FILES:=LICENSE
32 PKG_CPE_ID:=cpe:/a:openssl:openssl
33 PKG_CONFIG_DEPENDS:= \
34 CONFIG_OPENSSL_ENGINE \
35 CONFIG_OPENSSL_ENGINE_CRYPTO \
36 CONFIG_OPENSSL_NO_DEPRECATED \
37 CONFIG_OPENSSL_OPTIMIZE_SPEED \
38 CONFIG_OPENSSL_PREFER_CHACHA_OVER_GCM \
39 CONFIG_OPENSSL_WITH_ARIA \
40 CONFIG_OPENSSL_WITH_ASM \
41 CONFIG_OPENSSL_WITH_ASYNC \
42 CONFIG_OPENSSL_WITH_BLAKE2 \
43 CONFIG_OPENSSL_WITH_CAMELLIA \
44 CONFIG_OPENSSL_WITH_CHACHA_POLY1305 \
45 CONFIG_OPENSSL_WITH_CMS \
46 CONFIG_OPENSSL_WITH_COMPRESSION \
47 CONFIG_OPENSSL_WITH_DTLS \
48 CONFIG_OPENSSL_WITH_EC \
49 CONFIG_OPENSSL_WITH_EC2M \
50 CONFIG_OPENSSL_WITH_ERROR_MESSAGES \
51 CONFIG_OPENSSL_WITH_GOST \
52 CONFIG_OPENSSL_WITH_IDEA \
53 CONFIG_OPENSSL_WITH_MDC2 \
54 CONFIG_OPENSSL_WITH_NPN \
55 CONFIG_OPENSSL_WITH_PSK \
56 CONFIG_OPENSSL_WITH_RFC3779 \
57 CONFIG_OPENSSL_WITH_SEED \
58 CONFIG_OPENSSL_WITH_SM234 \
59 CONFIG_OPENSSL_WITH_SRP \
60 CONFIG_OPENSSL_WITH_SSE2 \
61 CONFIG_OPENSSL_WITH_TLS13 \
62 CONFIG_OPENSSL_WITH_WHIRLPOOL
63
64 include $(INCLUDE_DIR)/package.mk
65
66 ifneq ($(CONFIG_CCACHE),)
67 HOSTCC=$(HOSTCC_NOCACHE)
68 HOSTCXX=$(HOSTCXX_NOCACHE)
69 endif
70
71 define Package/openssl/Default
72 TITLE:=Open source SSL toolkit
73 URL:=http://www.openssl.org/
74 SECTION:=libs
75 CATEGORY:=Libraries
76 endef
77
78 define Package/libopenssl/config
79 source "$(SOURCE)/Config.in"
80 endef
81
82 define Package/openssl/Default/description
83 The OpenSSL Project is a collaborative effort to develop a robust,
84 commercial-grade, full-featured, and Open Source toolkit implementing the
85 Transport Layer Security (TLS) protocol as well as a full-strength
86 general-purpose cryptography library.
87 endef
88
89 define Package/libopenssl
90 $(call Package/openssl/Default)
91 SUBMENU:=SSL
92 DEPENDS:=+OPENSSL_WITH_COMPRESSION:zlib
93 TITLE+= (libraries)
94 ABI_VERSION:=1.1
95 MENU:=1
96 endef
97
98 define Package/libopenssl/description
99 $(call Package/openssl/Default/description)
100 This package contains the OpenSSL shared libraries, needed by other programs.
101 endef
102
103 define Package/openssl-util
104 $(call Package/openssl/Default)
105 SECTION:=utils
106 CATEGORY:=Utilities
107 DEPENDS:=+libopenssl +libopenssl-conf
108 TITLE+= (utility)
109 endef
110
111 define Package/openssl-util/description
112 $(call Package/openssl/Default/description)
113 This package contains the OpenSSL command-line utility.
114 endef
115
116 define Package/libopenssl-conf
117 $(call Package/openssl/Default)
118 SUBMENU:=SSL
119 TITLE:=/etc/ssl/openssl.cnf config file
120 DEPENDS:=libopenssl
121 endef
122
123 define Package/libopenssl-conf/conffiles
124 /etc/ssl/openssl.cnf
125 endef
126
127 define Package/libopenssl-conf/description
128 $(call Package/openssl/Default/description)
129 This package installs the OpenSSL configuration file /etc/ssl/openssl.cnf.
130 endef
131
132 define Package/libopenssl-afalg
133 $(call Package/openssl/Default)
134 SUBMENU:=SSL
135 TITLE:=AFALG hardware acceleration engine
136 DEPENDS:=libopenssl @OPENSSL_ENGINE @KERNEL_AIO @!LINUX_3_18 +kmod-crypto-user \
137 +libopenssl-conf
138 endef
139
140 define Package/libopenssl-afalg/description
141 This package adds an engine that enables hardware acceleration
142 through the AF_ALG kernel interface.
143 To use it, you need to configure the engine in /etc/ssl/openssl.cnf
144 See https://www.openssl.org/docs/man1.1.1/man5/config.html#Engine-Configuration-Module
145 The engine_id is "afalg"
146 endef
147
148 define Package/libopenssl-padlock
149 $(call Package/openssl/Default)
150 SUBMENU:=SSL
151 TITLE:=VIA Padlock hardware acceleration engine
152 DEPENDS:=libopenssl @OPENSSL_ENGINE @TARGET_x86 +kmod-crypto-hw-padlock \
153 +libopenssl-conf
154 endef
155
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 The engine_id is "padlock"
161 endef
162
163 OPENSSL_OPTIONS:= shared
164
165 ifndef CONFIG_OPENSSL_WITH_BLAKE2
166 OPENSSL_OPTIONS += no-blake2
167 endif
168
169 ifndef CONFIG_OPENSSL_WITH_CHACHA_POLY1305
170 OPENSSL_OPTIONS += no-chacha no-poly1305
171 else
172 ifdef CONFIG_OPENSSL_PREFER_CHACHA_OVER_GCM
173 OPENSSL_OPTIONS += -DOPENSSL_PREFER_CHACHA_OVER_GCM
174 endif
175 endif
176
177 ifndef CONFIG_OPENSSL_WITH_ASYNC
178 OPENSSL_OPTIONS += no-async
179 endif
180
181 ifndef CONFIG_OPENSSL_WITH_EC
182 OPENSSL_OPTIONS += no-ec
183 endif
184
185 ifndef CONFIG_OPENSSL_WITH_EC2M
186 OPENSSL_OPTIONS += no-ec2m
187 endif
188
189 ifndef CONFIG_OPENSSL_WITH_ERROR_MESSAGES
190 OPENSSL_OPTIONS += no-err
191 endif
192
193 ifndef CONFIG_OPENSSL_WITH_TLS13
194 OPENSSL_OPTIONS += no-tls1_3
195 endif
196
197 ifndef CONFIG_OPENSSL_WITH_ARIA
198 OPENSSL_OPTIONS += no-aria
199 endif
200
201 ifndef CONFIG_OPENSSL_WITH_SM234
202 OPENSSL_OPTIONS += no-sm2 no-sm3 no-sm4
203 endif
204
205 ifndef CONFIG_OPENSSL_WITH_CAMELLIA
206 OPENSSL_OPTIONS += no-camellia
207 endif
208
209 ifndef CONFIG_OPENSSL_WITH_IDEA
210 OPENSSL_OPTIONS += no-idea
211 endif
212
213 ifndef CONFIG_OPENSSL_WITH_SEED
214 OPENSSL_OPTIONS += no-seed
215 endif
216
217 ifndef CONFIG_OPENSSL_WITH_MDC2
218 OPENSSL_OPTIONS += no-mdc2
219 endif
220
221 ifndef CONFIG_OPENSSL_WITH_WHIRLPOOL
222 OPENSSL_OPTIONS += no-whirlpool
223 endif
224
225 ifndef CONFIG_OPENSSL_WITH_CMS
226 OPENSSL_OPTIONS += no-cms
227 endif
228
229 ifndef CONFIG_OPENSSL_WITH_RFC3779
230 OPENSSL_OPTIONS += no-rfc3779
231 endif
232
233 ifdef CONFIG_OPENSSL_NO_DEPRECATED
234 OPENSSL_OPTIONS += no-deprecated
235 endif
236
237 ifeq ($(CONFIG_OPENSSL_OPTIMIZE_SPEED),y)
238 TARGET_CFLAGS := $(filter-out -O%,$(TARGET_CFLAGS)) -O3
239 else
240 OPENSSL_OPTIONS += -DOPENSSL_SMALL_FOOTPRINT
241 endif
242
243 ifdef CONFIG_OPENSSL_ENGINE
244 ifdef CONFIG_OPENSSL_ENGINE_CRYPTO
245 OPENSSL_OPTIONS += enable-devcryptoeng
246 endif
247 ifndef CONFIG_PACKAGE_libopenssl-afalg
248 OPENSSL_OPTIONS += no-afalgeng
249 endif
250 ifndef CONFIG_PACKAGE_libopenssl-padlock
251 OPENSSL_OPTIONS += no-hw-padlock
252 endif
253 else
254 OPENSSL_OPTIONS += no-engine
255 endif
256
257 ifndef CONFIG_OPENSSL_WITH_GOST
258 OPENSSL_OPTIONS += no-gost
259 endif
260
261 ifndef CONFIG_OPENSSL_WITH_DTLS
262 OPENSSL_OPTIONS += no-dtls
263 endif
264
265 ifdef CONFIG_OPENSSL_WITH_COMPRESSION
266 OPENSSL_OPTIONS += zlib-dynamic
267 else
268 OPENSSL_OPTIONS += no-comp
269 endif
270
271 ifndef CONFIG_OPENSSL_WITH_NPN
272 OPENSSL_OPTIONS += no-nextprotoneg
273 endif
274
275 ifndef CONFIG_OPENSSL_WITH_PSK
276 OPENSSL_OPTIONS += no-psk
277 endif
278
279 ifndef CONFIG_OPENSSL_WITH_SRP
280 OPENSSL_OPTIONS += no-srp
281 endif
282
283 ifndef CONFIG_OPENSSL_WITH_ASM
284 OPENSSL_OPTIONS += no-asm
285 endif
286
287 ifdef CONFIG_i386
288 ifndef CONFIG_OPENSSL_WITH_SSE2
289 OPENSSL_OPTIONS += no-sse2
290 endif
291 endif
292
293 OPENSSL_TARGET:=linux-$(call qstrip,$(CONFIG_ARCH))-openwrt
294
295 STAMP_CONFIGURED := $(STAMP_CONFIGURED)_$(shell echo $(OPENSSL_OPTIONS) | mkhash md5)
296
297 define Build/Configure
298 [ -f $(STAMP_CONFIGURED) ] || { \
299 rm -f $(PKG_BUILD_DIR)/*.so.* $(PKG_BUILD_DIR)/*.a; \
300 find $(PKG_BUILD_DIR) -name \*.o | xargs rm -f; \
301 }
302 (cd $(PKG_BUILD_DIR); \
303 ./Configure $(OPENSSL_TARGET) \
304 --prefix=/usr \
305 --libdir=lib \
306 --openssldir=/etc/ssl \
307 $(TARGET_CPPFLAGS) \
308 $(TARGET_LDFLAGS) \
309 $(OPENSSL_OPTIONS) \
310 )
311 endef
312
313 TARGET_CFLAGS += $(FPIC) -ffunction-sections -fdata-sections
314 TARGET_LDFLAGS += -Wl,--gc-sections
315
316 define Build/Compile
317 +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
318 CROSS_COMPILE="$(TARGET_CROSS)" \
319 CC="$(TARGET_CC)" \
320 SOURCE_DATE_EPOCH=$(SOURCE_DATE_EPOCH) \
321 OPENWRT_OPTIMIZATION_FLAGS="$(TARGET_CFLAGS)" \
322 $(OPENSSL_MAKEFLAGS) \
323 all
324 $(MAKE) -C $(PKG_BUILD_DIR) \
325 CROSS_COMPILE="$(TARGET_CROSS)" \
326 CC="$(TARGET_CC)" \
327 DESTDIR="$(PKG_INSTALL_DIR)" \
328 $(OPENSSL_MAKEFLAGS) \
329 install_sw install_ssldirs
330 endef
331
332 define Build/InstallDev
333 $(INSTALL_DIR) $(1)/usr/include
334 $(CP) $(PKG_INSTALL_DIR)/usr/include/openssl $(1)/usr/include/
335 $(INSTALL_DIR) $(1)/usr/lib/
336 $(CP) $(PKG_INSTALL_DIR)/usr/lib/lib{crypto,ssl}.{a,so*} $(1)/usr/lib/
337 $(INSTALL_DIR) $(1)/usr/lib/pkgconfig
338 $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/{openssl,libcrypto,libssl}.pc $(1)/usr/lib/pkgconfig/
339 [ -n "$(TARGET_LDFLAGS)" ] && $(SED) 's#$(TARGET_LDFLAGS)##g' $(1)/usr/lib/pkgconfig/{openssl,libcrypto,libssl}.pc || true
340 endef
341
342 define Package/libopenssl/install
343 $(INSTALL_DIR) $(1)/etc/ssl/certs
344 $(INSTALL_DIR) $(1)/etc/ssl/private
345 chmod 0700 $(1)/etc/ssl/private
346 $(INSTALL_DIR) $(1)/usr/lib
347 $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libcrypto.so.* $(1)/usr/lib/
348 $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libssl.so.* $(1)/usr/lib/
349 $(if $(CONFIG_OPENSSL_ENGINE),$(INSTALL_DIR) $(1)/usr/lib/$(ENGINES_DIR))
350 endef
351
352 define Package/libopenssl-conf/install
353 $(INSTALL_DIR) $(1)/etc/ssl
354 $(CP) $(PKG_INSTALL_DIR)/etc/ssl/openssl.cnf $(1)/etc/ssl/
355 endef
356
357 define Package/openssl-util/install
358 $(INSTALL_DIR) $(1)/usr/bin
359 $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/openssl $(1)/usr/bin/
360 endef
361
362 define Package/libopenssl-afalg/install
363 $(INSTALL_DIR) $(1)/usr/lib/$(ENGINES_DIR)
364 $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/$(ENGINES_DIR)/afalg.so $(1)/usr/lib/$(ENGINES_DIR)
365 endef
366
367 define Package/libopenssl-padlock/install
368 $(INSTALL_DIR) $(1)/usr/lib/$(ENGINES_DIR)
369 $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/$(ENGINES_DIR)/*padlock.so $(1)/usr/lib/$(ENGINES_DIR)
370 endef
371
372 $(eval $(call BuildPackage,libopenssl))
373 $(eval $(call BuildPackage,libopenssl-conf))
374 $(eval $(call BuildPackage,libopenssl-afalg))
375 $(eval $(call BuildPackage,libopenssl-padlock))
376 $(eval $(call BuildPackage,openssl-util))