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
39 include $(INCLUDE_DIR)/package.mk
41 ifneq ($(CONFIG_CCACHE),)
42 HOSTCC=$(HOSTCC_NOCACHE)
43 HOSTCXX=$(HOSTCXX_NOCACHE)
46 define Package/openssl/Default
47 TITLE:=Open source SSL toolkit
48 URL:=http://www.openssl.org/
51 define Package/libopenssl/config
52 source "$(SOURCE)/Config.in"
55 define Package/openssl/Default/description
56 The OpenSSL Project is a collaborative effort to develop a robust,
57 commercial-grade, full-featured, and Open Source toolkit implementing the Secure
58 Sockets Layer (SSL v2/v3) and Transport Layer Security (TLS v1) protocols as well
59 as a full-strength general purpose cryptography library.
62 define Package/libopenssl
63 $(call Package/openssl/Default)
67 DEPENDS:=+OPENSSL_WITH_COMPRESSION:zlib
69 ABI_VERSION:=$(PKG_VERSION)
73 define Package/libopenssl/description
74 $(call Package/openssl/Default/description)
75 This package contains the OpenSSL shared libraries, needed by other programs.
78 define Package/openssl-util
79 $(call Package/openssl/Default)
86 define Package/openssl-util/conffiles
90 define Package/openssl-util/description
91 $(call Package/openssl/Default/description)
92 This package contains the OpenSSL command-line utility.
96 OPENSSL_NO_CIPHERS:= no-idea no-md2 no-mdc2 no-rc5 no-sha0 no-camellia no-krb5
97 OPENSSL_OPTIONS:= shared no-err no-sse2 no-ssl2
99 ifdef CONFIG_OPENSSL_ENGINE_CRYPTO
100 OPENSSL_OPTIONS += -DHAVE_CRYPTODEV
101 ifdef CONFIG_OPENSSL_ENGINE_DIGEST
102 OPENSSL_OPTIONS += -DUSE_CRYPTODEV_DIGESTS
105 OPENSSL_OPTIONS += no-engines
108 ifndef CONFIG_OPENSSL_WITH_EC
109 OPENSSL_OPTIONS += no-ec
112 ifndef CONFIG_OPENSSL_WITH_EC2M
113 OPENSSL_OPTIONS += no-ec2m
116 ifndef CONFIG_OPENSSL_WITH_SSL3
117 OPENSSL_OPTIONS += no-ssl3
120 ifndef CONFIG_OPENSSL_HARDWARE_SUPPORT
121 OPENSSL_OPTIONS += no-hw
124 ifndef CONFIG_OPENSSL_WITH_DEPRECATED
125 OPENSSL_OPTIONS += no-deprecated
128 ifdef CONFIG_OPENSSL_WITH_COMPRESSION
129 OPENSSL_OPTIONS += zlib-dynamic
131 OPENSSL_OPTIONS += no-comp
134 ifeq ($(CONFIG_x86_64),y)
135 OPENSSL_TARGET:=linux-x86_64-openwrt
136 OPENSSL_MAKEFLAGS += LIBDIR=lib
138 OPENSSL_OPTIONS+=no-sse2
139 ifeq ($(CONFIG_mips)$(CONFIG_mipsel),y)
140 OPENSSL_TARGET:=linux-mips-openwrt
141 # else ifeq ($(CONFIG_arm)$(CONFIG_armeb),y)
142 # OPENSSL_TARGET:=linux-armv4-openwrt
144 OPENSSL_TARGET:=linux-generic-openwrt
145 OPENSSL_OPTIONS+=no-perlasm
149 STAMP_CONFIGURED := $(STAMP_CONFIGURED)_$(subst $(space),_,$(OPENSSL_OPTIONS))
151 define Build/Configure
152 [ -f $(STAMP_CONFIGURED) ] || { \
153 rm -f $(PKG_BUILD_DIR)/*.so.* $(PKG_BUILD_DIR)/*.a; \
154 find $(PKG_BUILD_DIR) -name \*.o | xargs rm -f; \
156 (cd $(PKG_BUILD_DIR); \
157 ./Configure $(OPENSSL_TARGET) \
159 --openssldir=/etc/ssl \
161 $(TARGET_LDFLAGS) -ldl \
162 -DOPENSSL_SMALL_FOOTPRINT \
163 $(OPENSSL_NO_CIPHERS) \
166 # XXX: OpenSSL "make depend" will look for installed headers before its own,
167 # so remove installed stuff first
168 -$(SUBMAKE) -j1 clean-staging
169 +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
170 MAKEDEPPROG="$(TARGET_CROSS)gcc" \
171 OPENWRT_OPTIMIZATION_FLAGS="$(TARGET_CFLAGS)" \
172 $(OPENSSL_MAKEFLAGS) \
176 TARGET_CFLAGS += $(FPIC) -I$(CURDIR)/include
179 +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
181 ASFLAGS="$(TARGET_ASFLAGS) -I$(PKG_BUILD_DIR)/crypto -c" \
182 AR="$(TARGET_CROSS)ar r" \
183 RANLIB="$(TARGET_CROSS)ranlib" \
184 OPENWRT_OPTIMIZATION_FLAGS="$(TARGET_CFLAGS)" \
185 $(OPENSSL_MAKEFLAGS) \
187 +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
189 ASFLAGS="$(TARGET_ASFLAGS) -I$(PKG_BUILD_DIR)/crypto -c" \
190 AR="$(TARGET_CROSS)ar r" \
191 RANLIB="$(TARGET_CROSS)ranlib" \
192 OPENWRT_OPTIMIZATION_FLAGS="$(TARGET_CFLAGS)" \
193 $(OPENSSL_MAKEFLAGS) \
195 # Work around openssl build bug to link libssl.so with libcrypto.so.
196 -rm $(PKG_BUILD_DIR)/libssl.so.*.*.*
197 +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
199 OPENWRT_OPTIMIZATION_FLAGS="$(TARGET_CFLAGS)" \
200 $(OPENSSL_MAKEFLAGS) \
202 $(MAKE) -C $(PKG_BUILD_DIR) \
204 INSTALL_PREFIX="$(PKG_INSTALL_DIR)" \
205 $(OPENSSL_MAKEFLAGS) \
209 define Build/InstallDev
210 $(INSTALL_DIR) $(1)/usr/include
211 $(CP) $(PKG_INSTALL_DIR)/usr/include/openssl $(1)/usr/include/
212 $(INSTALL_DIR) $(1)/usr/lib/
213 $(CP) $(PKG_INSTALL_DIR)/usr/lib/lib{crypto,ssl}.{a,so*} $(1)/usr/lib/
214 $(INSTALL_DIR) $(1)/usr/lib/pkgconfig
215 $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/{openssl,libcrypto,libssl}.pc $(1)/usr/lib/pkgconfig/
216 [ -n "$(TARGET_LDFLAGS)" ] && $(SED) 's#$(TARGET_LDFLAGS)##g' $(1)/usr/lib/pkgconfig/{openssl,libcrypto,libssl}.pc || true
219 define Package/libopenssl/install
220 $(INSTALL_DIR) $(1)/usr/lib
221 $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libcrypto.so.* $(1)/usr/lib/
222 $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libssl.so.* $(1)/usr/lib/
225 define Package/openssl-util/install
226 $(INSTALL_DIR) $(1)/etc/ssl
227 $(CP) $(PKG_INSTALL_DIR)/etc/ssl/openssl.cnf $(1)/etc/ssl/
228 $(INSTALL_DIR) $(1)/etc/ssl/certs
229 $(INSTALL_DIR) $(1)/etc/ssl/private
230 chmod 0700 $(1)/etc/ssl/private
231 $(INSTALL_DIR) $(1)/usr/bin
232 $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/openssl $(1)/usr/bin/
235 $(eval $(call BuildPackage,libopenssl))
236 $(eval $(call BuildPackage,openssl-util))