2 # Copyright (C) 2006-2015 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
17 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
18 PKG_SOURCE_URL:=http://www.openssl.org/source/ \
19 ftp://ftp.funet.fi/pub/crypt/mirrors/ftp.openssl.org/source \
20 ftp://ftp.sunet.se/pub/security/tools/net/openssl/source/
21 PKG_MD5SUM:=38373013fc85c790aabf8837969c5eba
24 PKG_LICENSE_FILES:=LICENSE
25 PKG_BUILD_DEPENDS:=ocf-crypto-headers
26 PKG_CONFIG_DEPENDS:= \
27 CONFIG_OPENSSL_ENGINE_CRYPTO \
28 CONFIG_OPENSSL_ENGINE_DIGEST \
29 CONFIG_OPENSSL_WITH_EC \
30 CONFIG_OPENSSL_WITH_EC2M \
31 CONFIG_OPENSSL_WITH_SSL3
33 include $(INCLUDE_DIR)/package.mk
35 ifneq ($(CONFIG_CCACHE),)
36 HOSTCC=$(HOSTCC_NOCACHE)
37 HOSTCXX=$(HOSTCXX_NOCACHE)
40 define Package/openssl/Default
41 TITLE:=Open source SSL toolkit
42 URL:=http://www.openssl.org/
45 define Package/libopenssl/config
46 source "$(SOURCE)/Config.in"
49 define Package/openssl/Default/description
50 The OpenSSL Project is a collaborative effort to develop a robust,
51 commercial-grade, full-featured, and Open Source toolkit implementing the Secure
52 Sockets Layer (SSL v2/v3) and Transport Layer Security (TLS v1) protocols as well
53 as a full-strength general purpose cryptography library.
56 define Package/libopenssl
57 $(call Package/openssl/Default)
63 ABI_VERSION:=$(PKG_VERSION)
67 define Package/libopenssl/description
68 $(call Package/openssl/Default/description)
69 This package contains the OpenSSL shared libraries, needed by other programs.
72 define Package/openssl-util
73 $(call Package/openssl/Default)
80 define Package/openssl-util/conffiles
84 define Package/openssl-util/description
85 $(call Package/openssl/Default/description)
86 This package contains the OpenSSL command-line utility.
90 OPENSSL_NO_CIPHERS:= no-idea no-md2 no-mdc2 no-rc5 no-sha0 no-camellia no-krb5
91 OPENSSL_OPTIONS:= shared no-err no-hw zlib-dynamic no-sse2 no-ssl2
93 ifdef CONFIG_OPENSSL_ENGINE_CRYPTO
94 OPENSSL_OPTIONS += -DHAVE_CRYPTODEV
95 ifdef CONFIG_OPENSSL_ENGINE_DIGEST
96 OPENSSL_OPTIONS += -DUSE_CRYPTODEV_DIGESTS
99 OPENSSL_OPTIONS += no-engines
102 ifndef CONFIG_OPENSSL_WITH_EC
103 OPENSSL_OPTIONS += no-ec
106 ifndef CONFIG_OPENSSL_WITH_EC2M
107 OPENSSL_OPTIONS += no-ec2m
110 ifndef CONFIG_OPENSSL_WITH_SSL3
111 OPENSSL_OPTIONS += no-ssl3
114 ifeq ($(CONFIG_x86_64),y)
115 OPENSSL_TARGET:=linux-x86_64-openwrt
116 OPENSSL_MAKEFLAGS += LIBDIR=lib
118 OPENSSL_OPTIONS+=no-sse2
119 ifeq ($(CONFIG_mips)$(CONFIG_mipsel),y)
120 OPENSSL_TARGET:=linux-mips-openwrt
122 OPENSSL_TARGET:=linux-generic-openwrt
123 OPENSSL_OPTIONS+=no-perlasm
127 STAMP_CONFIGURED := $(STAMP_CONFIGURED)_$(subst $(space),_,$(OPENSSL_OPTIONS))
129 define Build/Configure
130 [ -f $(STAMP_CONFIGURED) ] || { \
131 rm -f $(PKG_BUILD_DIR)/*.so.* $(PKG_BUILD_DIR)/*.a; \
132 find $(PKG_BUILD_DIR) -name \*.o | xargs rm -f; \
134 (cd $(PKG_BUILD_DIR); \
135 ./Configure $(OPENSSL_TARGET) \
137 --openssldir=/etc/ssl \
139 $(TARGET_LDFLAGS) -ldl \
140 -DOPENSSL_SMALL_FOOTPRINT \
141 $(OPENSSL_NO_CIPHERS) \
144 # XXX: OpenSSL "make depend" will look for installed headers before its own,
145 # so remove installed stuff first
146 -$(SUBMAKE) -j1 clean-staging
147 +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
148 MAKEDEPPROG="$(TARGET_CROSS)gcc" \
149 OPENWRT_OPTIMIZATION_FLAGS="$(TARGET_CFLAGS)" \
150 $(OPENSSL_MAKEFLAGS) \
154 TARGET_CFLAGS += $(FPIC)
157 +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
159 ASFLAGS="$(TARGET_ASFLAGS) -c" \
160 AR="$(TARGET_CROSS)ar r" \
161 RANLIB="$(TARGET_CROSS)ranlib" \
162 OPENWRT_OPTIMIZATION_FLAGS="$(TARGET_CFLAGS)" \
163 $(OPENSSL_MAKEFLAGS) \
165 +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
167 ASFLAGS="$(TARGET_ASFLAGS) -c" \
168 AR="$(TARGET_CROSS)ar r" \
169 RANLIB="$(TARGET_CROSS)ranlib" \
170 OPENWRT_OPTIMIZATION_FLAGS="$(TARGET_CFLAGS)" \
171 $(OPENSSL_MAKEFLAGS) \
173 # Work around openssl build bug to link libssl.so with libcrypto.so.
174 -rm $(PKG_BUILD_DIR)/libssl.so.*.*.*
175 +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
177 OPENWRT_OPTIMIZATION_FLAGS="$(TARGET_CFLAGS)" \
178 $(OPENSSL_MAKEFLAGS) \
180 $(MAKE) -C $(PKG_BUILD_DIR) \
182 INSTALL_PREFIX="$(PKG_INSTALL_DIR)" \
183 $(OPENSSL_MAKEFLAGS) \
187 define Build/InstallDev
188 $(INSTALL_DIR) $(1)/usr/include
189 $(CP) $(PKG_INSTALL_DIR)/usr/include/openssl $(1)/usr/include/
190 $(INSTALL_DIR) $(1)/usr/lib/
191 $(CP) $(PKG_INSTALL_DIR)/usr/lib/lib{crypto,ssl}.{a,so*} $(1)/usr/lib/
192 $(INSTALL_DIR) $(1)/usr/lib/pkgconfig
193 $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/{openssl,libcrypto,libssl}.pc $(1)/usr/lib/pkgconfig/
194 [ -n "$(TARGET_LDFLAGS)" ] && $(SED) 's#$(TARGET_LDFLAGS)##g' $(1)/usr/lib/pkgconfig/{openssl,libcrypto,libssl}.pc || true
197 define Package/libopenssl/install
198 $(INSTALL_DIR) $(1)/usr/lib
199 $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libcrypto.so.* $(1)/usr/lib/
200 $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libssl.so.* $(1)/usr/lib/
203 define Package/openssl-util/install
204 $(INSTALL_DIR) $(1)/etc/ssl
205 $(CP) $(PKG_INSTALL_DIR)/etc/ssl/openssl.cnf $(1)/etc/ssl/
206 $(INSTALL_DIR) $(1)/etc/ssl/certs
207 $(INSTALL_DIR) $(1)/etc/ssl/private
208 chmod 0700 $(1)/etc/ssl/private
209 $(INSTALL_DIR) $(1)/usr/bin
210 $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/openssl $(1)/usr/bin/
213 $(eval $(call BuildPackage,libopenssl))
214 $(eval $(call BuildPackage,openssl-util))