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)
19 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
20 PKG_SOURCE_URL:=http://www.openssl.org/source/ \
21 ftp://ftp.openssl.org/source/ \
22 http://www.openssl.org/source/old/$(PKG_BASE)/ \
23 ftp://ftp.funet.fi/pub/crypt/mirrors/ftp.openssl.org/source \
24 ftp://ftp.sunet.se/pub/security/tools/net/openssl/source/
25 PKG_MD5SUM:=9392e65072ce4b614c1392eefc1f23d0
28 PKG_LICENSE_FILES:=LICENSE
29 PKG_CONFIG_DEPENDS:= \
30 CONFIG_OPENSSL_ENGINE_CRYPTO \
31 CONFIG_OPENSSL_ENGINE_DIGEST \
32 CONFIG_OPENSSL_WITH_EC \
33 CONFIG_OPENSSL_WITH_EC2M \
34 CONFIG_OPENSSL_WITH_SSL3 \
35 CONFIG_OPENSSL_HARDWARE_SUPPORT \
36 CONFIG_OPENSSL_WITH_DEPRECATED \
37 CONFIG_OPENSSL_WITH_COMPRESSION \
38 CONFIG_OPENSSL_WITH_NPN
40 include $(INCLUDE_DIR)/package.mk
42 ifneq ($(CONFIG_CCACHE),)
43 HOSTCC=$(HOSTCC_NOCACHE)
44 HOSTCXX=$(HOSTCXX_NOCACHE)
47 define Package/openssl/Default
48 TITLE:=Open source SSL toolkit
49 URL:=http://www.openssl.org/
52 define Package/libopenssl/config
53 source "$(SOURCE)/Config.in"
56 define Package/openssl/Default/description
57 The OpenSSL Project is a collaborative effort to develop a robust,
58 commercial-grade, full-featured, and Open Source toolkit implementing the Secure
59 Sockets Layer (SSL v2/v3) and Transport Layer Security (TLS v1) protocols as well
60 as a full-strength general purpose cryptography library.
63 define Package/libopenssl
64 $(call Package/openssl/Default)
68 DEPENDS:=+OPENSSL_WITH_COMPRESSION:zlib
70 ABI_VERSION:=$(PKG_VERSION)
74 define Package/libopenssl/description
75 $(call Package/openssl/Default/description)
76 This package contains the OpenSSL shared libraries, needed by other programs.
79 define Package/openssl-util
80 $(call Package/openssl/Default)
87 define Package/openssl-util/conffiles
91 define Package/openssl-util/description
92 $(call Package/openssl/Default/description)
93 This package contains the OpenSSL command-line utility.
97 OPENSSL_NO_CIPHERS:= no-idea no-md2 no-mdc2 no-rc5 no-sha0 no-camellia no-krb5
98 OPENSSL_OPTIONS:= shared no-err no-sse2 no-ssl2
100 ifdef CONFIG_OPENSSL_ENGINE_CRYPTO
101 OPENSSL_OPTIONS += -DHAVE_CRYPTODEV
102 ifdef CONFIG_OPENSSL_ENGINE_DIGEST
103 OPENSSL_OPTIONS += -DUSE_CRYPTODEV_DIGESTS
106 OPENSSL_OPTIONS += no-engines
109 ifndef CONFIG_OPENSSL_WITH_EC
110 OPENSSL_OPTIONS += no-ec
113 ifndef CONFIG_OPENSSL_WITH_EC2M
114 OPENSSL_OPTIONS += no-ec2m
117 ifndef CONFIG_OPENSSL_WITH_SSL3
118 OPENSSL_OPTIONS += no-ssl3
121 ifndef CONFIG_OPENSSL_HARDWARE_SUPPORT
122 OPENSSL_OPTIONS += no-hw
125 ifndef CONFIG_OPENSSL_WITH_DEPRECATED
126 OPENSSL_OPTIONS += no-deprecated
129 ifdef CONFIG_OPENSSL_WITH_COMPRESSION
130 OPENSSL_OPTIONS += zlib-dynamic
132 OPENSSL_OPTIONS += no-comp
135 ifndef CONFIG_OPENSSL_WITH_NPN
136 OPENSSL_OPTIONS += no-nextprotoneg
139 ifeq ($(CONFIG_x86_64),y)
140 OPENSSL_TARGET:=linux-x86_64-openwrt
141 OPENSSL_MAKEFLAGS += LIBDIR=lib
143 OPENSSL_OPTIONS+=no-sse2
144 ifeq ($(CONFIG_mips)$(CONFIG_mipsel),y)
145 OPENSSL_TARGET:=linux-mips-openwrt
146 # else ifeq ($(CONFIG_arm)$(CONFIG_armeb),y)
147 # OPENSSL_TARGET:=linux-armv4-openwrt
149 OPENSSL_TARGET:=linux-generic-openwrt
150 OPENSSL_OPTIONS+=no-perlasm
154 STAMP_CONFIGURED := $(STAMP_CONFIGURED)_$(subst $(space),_,$(OPENSSL_OPTIONS))
156 define Build/Configure
157 [ -f $(STAMP_CONFIGURED) ] || { \
158 rm -f $(PKG_BUILD_DIR)/*.so.* $(PKG_BUILD_DIR)/*.a; \
159 find $(PKG_BUILD_DIR) -name \*.o | xargs rm -f; \
161 (cd $(PKG_BUILD_DIR); \
162 ./Configure $(OPENSSL_TARGET) \
164 --openssldir=/etc/ssl \
166 $(TARGET_LDFLAGS) -ldl \
167 -DOPENSSL_SMALL_FOOTPRINT \
168 $(OPENSSL_NO_CIPHERS) \
171 # XXX: OpenSSL "make depend" will look for installed headers before its own,
172 # so remove installed stuff first
173 -$(SUBMAKE) -j1 clean-staging
174 +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
175 MAKEDEPPROG="$(TARGET_CROSS)gcc" \
176 OPENWRT_OPTIMIZATION_FLAGS="$(TARGET_CFLAGS)" \
177 $(OPENSSL_MAKEFLAGS) \
181 TARGET_CFLAGS += $(FPIC) -I$(CURDIR)/include
184 +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
186 ASFLAGS="$(TARGET_ASFLAGS) -I$(PKG_BUILD_DIR)/crypto -c" \
187 AR="$(TARGET_CROSS)ar r" \
188 RANLIB="$(TARGET_CROSS)ranlib" \
189 OPENWRT_OPTIMIZATION_FLAGS="$(TARGET_CFLAGS)" \
190 $(OPENSSL_MAKEFLAGS) \
192 +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
194 ASFLAGS="$(TARGET_ASFLAGS) -I$(PKG_BUILD_DIR)/crypto -c" \
195 AR="$(TARGET_CROSS)ar r" \
196 RANLIB="$(TARGET_CROSS)ranlib" \
197 OPENWRT_OPTIMIZATION_FLAGS="$(TARGET_CFLAGS)" \
198 $(OPENSSL_MAKEFLAGS) \
200 # Work around openssl build bug to link libssl.so with libcrypto.so.
201 -rm $(PKG_BUILD_DIR)/libssl.so.*.*.*
202 +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
204 OPENWRT_OPTIMIZATION_FLAGS="$(TARGET_CFLAGS)" \
205 $(OPENSSL_MAKEFLAGS) \
207 $(MAKE) -C $(PKG_BUILD_DIR) \
209 INSTALL_PREFIX="$(PKG_INSTALL_DIR)" \
210 $(OPENSSL_MAKEFLAGS) \
214 define Build/InstallDev
215 $(INSTALL_DIR) $(1)/usr/include
216 $(CP) $(PKG_INSTALL_DIR)/usr/include/openssl $(1)/usr/include/
217 $(INSTALL_DIR) $(1)/usr/lib/
218 $(CP) $(PKG_INSTALL_DIR)/usr/lib/lib{crypto,ssl}.{a,so*} $(1)/usr/lib/
219 $(INSTALL_DIR) $(1)/usr/lib/pkgconfig
220 $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/{openssl,libcrypto,libssl}.pc $(1)/usr/lib/pkgconfig/
221 [ -n "$(TARGET_LDFLAGS)" ] && $(SED) 's#$(TARGET_LDFLAGS)##g' $(1)/usr/lib/pkgconfig/{openssl,libcrypto,libssl}.pc || true
224 define Package/libopenssl/install
225 $(INSTALL_DIR) $(1)/usr/lib
226 $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libcrypto.so.* $(1)/usr/lib/
227 $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libssl.so.* $(1)/usr/lib/
230 define Package/openssl-util/install
231 $(INSTALL_DIR) $(1)/etc/ssl
232 $(CP) $(PKG_INSTALL_DIR)/etc/ssl/openssl.cnf $(1)/etc/ssl/
233 $(INSTALL_DIR) $(1)/etc/ssl/certs
234 $(INSTALL_DIR) $(1)/etc/ssl/private
235 chmod 0700 $(1)/etc/ssl/private
236 $(INSTALL_DIR) $(1)/usr/bin
237 $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/openssl $(1)/usr/bin/
240 $(eval $(call BuildPackage,libopenssl))
241 $(eval $(call BuildPackage,openssl-util))