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)
20 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
21 PKG_SOURCE_URL:=http://www.openssl.org/source/ \
22 http://www.openssl.org/source/old/$(PKG_BASE)/ \
24 PKG_HASH:=ce07195b659e75f4e1db43552860070061f156a98bb37b672b101ba6e3ddf30c
27 PKG_LICENSE_FILES:=LICENSE
28 PKG_CONFIG_DEPENDS:= \
29 CONFIG_OPENSSL_ENGINE_CRYPTO \
30 CONFIG_OPENSSL_ENGINE_DIGEST \
31 CONFIG_OPENSSL_WITH_EC \
32 CONFIG_OPENSSL_WITH_EC2M \
33 CONFIG_OPENSSL_WITH_SSL3 \
34 CONFIG_OPENSSL_HARDWARE_SUPPORT \
35 CONFIG_OPENSSL_WITH_DEPRECATED \
36 CONFIG_OPENSSL_WITH_DTLS \
37 CONFIG_OPENSSL_WITH_COMPRESSION \
38 CONFIG_OPENSSL_WITH_NPN \
39 CONFIG_OPENSSL_WITH_PSK \
40 CONFIG_OPENSSL_WITH_SRP
42 include $(INCLUDE_DIR)/package.mk
44 ifneq ($(CONFIG_CCACHE),)
45 HOSTCC=$(HOSTCC_NOCACHE)
46 HOSTCXX=$(HOSTCXX_NOCACHE)
49 define Package/openssl/Default
50 TITLE:=Open source SSL toolkit
51 URL:=http://www.openssl.org/
54 define Package/libopenssl/config
55 source "$(SOURCE)/Config.in"
58 define Package/openssl/Default/description
59 The OpenSSL Project is a collaborative effort to develop a robust,
60 commercial-grade, full-featured, and Open Source toolkit implementing the Secure
61 Sockets Layer (SSL v2/v3) and Transport Layer Security (TLS v1) protocols as well
62 as a full-strength general purpose cryptography library.
65 define Package/libopenssl
66 $(call Package/openssl/Default)
70 DEPENDS:=+OPENSSL_WITH_COMPRESSION:zlib
72 ABI_VERSION:=$(PKG_VERSION)
76 define Package/libopenssl/description
77 $(call Package/openssl/Default/description)
78 This package contains the OpenSSL shared libraries, needed by other programs.
81 define Package/openssl-util
82 $(call Package/openssl/Default)
89 define Package/openssl-util/conffiles
93 define Package/openssl-util/description
94 $(call Package/openssl/Default/description)
95 This package contains the OpenSSL command-line utility.
99 OPENSSL_NO_CIPHERS:= no-idea no-md2 no-mdc2 no-rc5 no-sha0 no-camellia no-krb5 \
100 no-whrlpool no-whirlpool no-seed no-jpake
101 OPENSSL_OPTIONS:= shared no-err no-sse2 no-ssl2 no-ssl2-method no-heartbeats
103 ifdef CONFIG_OPENSSL_ENGINE_CRYPTO
104 OPENSSL_OPTIONS += -DHAVE_CRYPTODEV
105 ifdef CONFIG_OPENSSL_ENGINE_DIGEST
106 OPENSSL_OPTIONS += -DUSE_CRYPTODEV_DIGESTS
109 OPENSSL_OPTIONS += no-engines
112 ifndef CONFIG_OPENSSL_WITH_EC
113 OPENSSL_OPTIONS += no-ec
116 ifndef CONFIG_OPENSSL_WITH_EC2M
117 OPENSSL_OPTIONS += no-ec2m
120 ifndef CONFIG_OPENSSL_WITH_SSL3
121 OPENSSL_OPTIONS += no-ssl3 no-ssl3-method
124 ifndef CONFIG_OPENSSL_HARDWARE_SUPPORT
125 OPENSSL_OPTIONS += no-hw
128 ifndef CONFIG_OPENSSL_WITH_DEPRECATED
129 OPENSSL_OPTIONS += no-deprecated
132 ifndef CONFIG_OPENSSL_WITH_DTLS
133 OPENSSL_OPTIONS += no-dtls
136 ifdef CONFIG_OPENSSL_WITH_COMPRESSION
137 OPENSSL_OPTIONS += zlib-dynamic
139 OPENSSL_OPTIONS += no-comp
142 ifndef CONFIG_OPENSSL_WITH_NPN
143 OPENSSL_OPTIONS += no-nextprotoneg
146 ifndef CONFIG_OPENSSL_WITH_PSK
147 OPENSSL_OPTIONS += no-psk
150 ifndef CONFIG_OPENSSL_WITH_SRP
151 OPENSSL_OPTIONS += no-srp
154 ifeq ($(CONFIG_x86_64),y)
155 OPENSSL_TARGET:=linux-x86_64-openwrt
156 OPENSSL_MAKEFLAGS += LIBDIR=lib
158 OPENSSL_OPTIONS+=no-sse2
159 ifeq ($(CONFIG_mips)$(CONFIG_mipsel),y)
160 OPENSSL_TARGET:=linux-mips-openwrt
161 else ifeq ($(CONFIG_arm)$(CONFIG_armeb),y)
162 OPENSSL_TARGET:=linux-armv4-openwrt
164 OPENSSL_TARGET:=linux-generic-openwrt
165 OPENSSL_OPTIONS+=no-perlasm
169 STAMP_CONFIGURED := $(STAMP_CONFIGURED)_$(subst $(space),_,$(OPENSSL_OPTIONS))
171 define Build/Configure
172 [ -f $(STAMP_CONFIGURED) ] || { \
173 rm -f $(PKG_BUILD_DIR)/*.so.* $(PKG_BUILD_DIR)/*.a; \
174 find $(PKG_BUILD_DIR) -name \*.o | xargs rm -f; \
176 (cd $(PKG_BUILD_DIR); \
177 ./Configure $(OPENSSL_TARGET) \
179 --openssldir=/etc/ssl \
181 $(TARGET_LDFLAGS) -ldl \
182 -DOPENSSL_SMALL_FOOTPRINT \
183 $(OPENSSL_NO_CIPHERS) \
186 # XXX: OpenSSL "make depend" will look for installed headers before its own,
187 # so remove installed stuff first
188 -$(SUBMAKE) -j1 clean-staging
189 +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
190 MAKEDEPPROG="$(TARGET_CROSS)gcc" \
191 OPENWRT_OPTIMIZATION_FLAGS="$(TARGET_CFLAGS)" \
192 $(OPENSSL_MAKEFLAGS) \
196 TARGET_CFLAGS += $(FPIC) -I$(CURDIR)/include -ffunction-sections -fdata-sections
197 TARGET_LDFLAGS += -Wl,--gc-sections
200 +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
202 ASFLAGS="$(TARGET_ASFLAGS) -I$(PKG_BUILD_DIR)/crypto -c" \
203 AR="$(TARGET_CROSS)ar r" \
204 RANLIB="$(TARGET_CROSS)ranlib" \
205 OPENWRT_OPTIMIZATION_FLAGS="$(TARGET_CFLAGS)" \
206 $(OPENSSL_MAKEFLAGS) \
208 +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
210 ASFLAGS="$(TARGET_ASFLAGS) -I$(PKG_BUILD_DIR)/crypto -c" \
211 AR="$(TARGET_CROSS)ar r" \
212 RANLIB="$(TARGET_CROSS)ranlib" \
213 OPENWRT_OPTIMIZATION_FLAGS="$(TARGET_CFLAGS)" \
214 $(OPENSSL_MAKEFLAGS) \
216 # Work around openssl build bug to link libssl.so with libcrypto.so.
217 -rm $(PKG_BUILD_DIR)/libssl.so.*.*.*
218 +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
220 OPENWRT_OPTIMIZATION_FLAGS="$(TARGET_CFLAGS)" \
221 $(OPENSSL_MAKEFLAGS) \
223 $(MAKE) -C $(PKG_BUILD_DIR) \
225 INSTALL_PREFIX="$(PKG_INSTALL_DIR)" \
226 $(OPENSSL_MAKEFLAGS) \
230 define Build/InstallDev
231 $(INSTALL_DIR) $(1)/usr/include
232 $(CP) $(PKG_INSTALL_DIR)/usr/include/openssl $(1)/usr/include/
233 $(INSTALL_DIR) $(1)/usr/lib/
234 $(CP) $(PKG_INSTALL_DIR)/usr/lib/lib{crypto,ssl}.{a,so*} $(1)/usr/lib/
235 $(INSTALL_DIR) $(1)/usr/lib/pkgconfig
236 $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/{openssl,libcrypto,libssl}.pc $(1)/usr/lib/pkgconfig/
237 [ -n "$(TARGET_LDFLAGS)" ] && $(SED) 's#$(TARGET_LDFLAGS)##g' $(1)/usr/lib/pkgconfig/{openssl,libcrypto,libssl}.pc || true
240 define Package/libopenssl/install
241 $(INSTALL_DIR) $(1)/usr/lib
242 $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libcrypto.so.* $(1)/usr/lib/
243 $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libssl.so.* $(1)/usr/lib/
246 define Package/openssl-util/install
247 $(INSTALL_DIR) $(1)/etc/ssl
248 $(CP) $(PKG_INSTALL_DIR)/etc/ssl/openssl.cnf $(1)/etc/ssl/
249 $(INSTALL_DIR) $(1)/etc/ssl/certs
250 $(INSTALL_DIR) $(1)/etc/ssl/private
251 chmod 0700 $(1)/etc/ssl/private
252 $(INSTALL_DIR) $(1)/usr/bin
253 $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/openssl $(1)/usr/bin/
256 $(eval $(call BuildPackage,libopenssl))
257 $(eval $(call BuildPackage,openssl-util))