openssl: add config option for no_hw support
[openwrt.git] / package / libs / openssl / Makefile
1 #
2 # Copyright (C) 2006-2015 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_VERSION:=1.0.2e
12 PKG_RELEASE:=1
13 PKG_USE_MIPS16:=0
14
15 PKG_BUILD_PARALLEL:=0
16
17 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
18 PKG_SOURCE_URL:=http://www.openssl.org/source/ \
19         ftp://ftp.openssl.org/source/ \
20         ftp://ftp.funet.fi/pub/crypt/mirrors/ftp.openssl.org/source \
21         ftp://ftp.sunet.se/pub/security/tools/net/openssl/source/
22 PKG_MD5SUM:=5262bfa25b60ed9de9f28d5d52d77fc5
23
24 PKG_LICENSE:=OpenSSL
25 PKG_LICENSE_FILES:=LICENSE
26 PKG_BUILD_DEPENDS:=ocf-crypto-headers
27 PKG_CONFIG_DEPENDS:= \
28         CONFIG_OPENSSL_ENGINE_CRYPTO \
29         CONFIG_OPENSSL_ENGINE_DIGEST \
30         CONFIG_OPENSSL_WITH_EC \
31         CONFIG_OPENSSL_WITH_EC2M \
32         CONFIG_OPENSSL_WITH_SSL3 \
33         CONFIG_OPENSSL_HARDWARE_SUPPORT
34
35 include $(INCLUDE_DIR)/package.mk
36
37 ifneq ($(CONFIG_CCACHE),)
38 HOSTCC=$(HOSTCC_NOCACHE)
39 HOSTCXX=$(HOSTCXX_NOCACHE)
40 endif
41
42 define Package/openssl/Default
43   TITLE:=Open source SSL toolkit
44   URL:=http://www.openssl.org/
45 endef
46
47 define Package/libopenssl/config
48 source "$(SOURCE)/Config.in"
49 endef
50
51 define Package/openssl/Default/description
52 The OpenSSL Project is a collaborative effort to develop a robust,
53 commercial-grade, full-featured, and Open Source toolkit implementing the Secure
54 Sockets Layer (SSL v2/v3) and Transport Layer Security (TLS v1) protocols as well
55 as a full-strength general purpose cryptography library.
56 endef
57
58 define Package/libopenssl
59 $(call Package/openssl/Default)
60   SECTION:=libs
61   SUBMENU:=SSL
62   CATEGORY:=Libraries
63   DEPENDS:=+zlib
64   TITLE+= (libraries)
65   ABI_VERSION:=$(PKG_VERSION)
66   MENU:=1
67 endef
68
69 define Package/libopenssl/description
70 $(call Package/openssl/Default/description)
71 This package contains the OpenSSL shared libraries, needed by other programs.
72 endef
73
74 define Package/openssl-util
75   $(call Package/openssl/Default)
76   SECTION:=utils
77   CATEGORY:=Utilities
78   DEPENDS:=+libopenssl
79   TITLE+= (utility)
80 endef
81
82 define Package/openssl-util/conffiles
83 /etc/ssl/openssl.cnf
84 endef
85
86 define Package/openssl-util/description
87 $(call Package/openssl/Default/description)
88 This package contains the OpenSSL command-line utility.
89 endef
90
91
92 OPENSSL_NO_CIPHERS:= no-idea no-md2 no-mdc2 no-rc5 no-sha0 no-camellia no-krb5
93 OPENSSL_OPTIONS:= shared no-err zlib-dynamic no-sse2 no-ssl2
94
95 ifdef CONFIG_OPENSSL_ENGINE_CRYPTO
96   OPENSSL_OPTIONS += -DHAVE_CRYPTODEV
97   ifdef CONFIG_OPENSSL_ENGINE_DIGEST
98     OPENSSL_OPTIONS += -DUSE_CRYPTODEV_DIGESTS
99   endif
100 else
101   OPENSSL_OPTIONS += no-engines
102 endif
103
104 ifndef CONFIG_OPENSSL_WITH_EC
105   OPENSSL_OPTIONS += no-ec
106 endif
107
108 ifndef CONFIG_OPENSSL_WITH_EC2M
109   OPENSSL_OPTIONS += no-ec2m
110 endif
111
112 ifndef CONFIG_OPENSSL_WITH_SSL3
113   OPENSSL_OPTIONS += no-ssl3
114 endif
115
116 ifndef CONFIG_OPENSSL_HARDWARE_SUPPORT
117   OPENSSL_OPTIONS += no-hw
118 endif
119
120 ifeq ($(CONFIG_x86_64),y)
121   OPENSSL_TARGET:=linux-x86_64-openwrt
122   OPENSSL_MAKEFLAGS += LIBDIR=lib
123 else
124   OPENSSL_OPTIONS+=no-sse2
125   ifeq ($(CONFIG_mips)$(CONFIG_mipsel),y)
126     OPENSSL_TARGET:=linux-mips-openwrt
127 #  else ifeq ($(CONFIG_arm)$(CONFIG_armeb),y)
128 #    OPENSSL_TARGET:=linux-armv4-openwrt
129   else
130     OPENSSL_TARGET:=linux-generic-openwrt
131     OPENSSL_OPTIONS+=no-perlasm
132   endif
133 endif
134
135 STAMP_CONFIGURED := $(STAMP_CONFIGURED)_$(subst $(space),_,$(OPENSSL_OPTIONS))
136
137 define Build/Configure
138         [ -f $(STAMP_CONFIGURED) ] || { \
139                 rm -f $(PKG_BUILD_DIR)/*.so.* $(PKG_BUILD_DIR)/*.a; \
140                 find $(PKG_BUILD_DIR) -name \*.o | xargs rm -f; \
141         }
142         (cd $(PKG_BUILD_DIR); \
143                 ./Configure $(OPENSSL_TARGET) \
144                         --prefix=/usr \
145                         --openssldir=/etc/ssl \
146                         $(TARGET_CPPFLAGS) \
147                         $(TARGET_LDFLAGS) -ldl \
148                         -DOPENSSL_SMALL_FOOTPRINT \
149                         $(OPENSSL_NO_CIPHERS) \
150                         $(OPENSSL_OPTIONS) \
151         )
152         # XXX: OpenSSL "make depend" will look for installed headers before its own,
153         # so remove installed stuff first
154         -$(SUBMAKE) -j1 clean-staging
155         +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
156                 MAKEDEPPROG="$(TARGET_CROSS)gcc" \
157                 OPENWRT_OPTIMIZATION_FLAGS="$(TARGET_CFLAGS)" \
158                 $(OPENSSL_MAKEFLAGS) \
159                 depend
160 endef
161
162 TARGET_CFLAGS += $(FPIC)
163
164 define Build/Compile
165         +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
166                 CC="$(TARGET_CC)" \
167                 ASFLAGS="$(TARGET_ASFLAGS) -I$(PKG_BUILD_DIR)/crypto -c" \
168                 AR="$(TARGET_CROSS)ar r" \
169                 RANLIB="$(TARGET_CROSS)ranlib" \
170                 OPENWRT_OPTIMIZATION_FLAGS="$(TARGET_CFLAGS)" \
171                 $(OPENSSL_MAKEFLAGS) \
172                 all
173         +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
174                 CC="$(TARGET_CC)" \
175                 ASFLAGS="$(TARGET_ASFLAGS) -I$(PKG_BUILD_DIR)/crypto -c" \
176                 AR="$(TARGET_CROSS)ar r" \
177                 RANLIB="$(TARGET_CROSS)ranlib" \
178                 OPENWRT_OPTIMIZATION_FLAGS="$(TARGET_CFLAGS)" \
179                 $(OPENSSL_MAKEFLAGS) \
180                 build-shared
181         # Work around openssl build bug to link libssl.so with libcrypto.so.
182         -rm $(PKG_BUILD_DIR)/libssl.so.*.*.*
183         +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
184                 CC="$(TARGET_CC)" \
185                 OPENWRT_OPTIMIZATION_FLAGS="$(TARGET_CFLAGS)" \
186                 $(OPENSSL_MAKEFLAGS) \
187                 do_linux-shared
188         $(MAKE) -C $(PKG_BUILD_DIR) \
189                 CC="$(TARGET_CC)" \
190                 INSTALL_PREFIX="$(PKG_INSTALL_DIR)" \
191                 $(OPENSSL_MAKEFLAGS) \
192                 install
193 endef
194
195 define Build/InstallDev
196         $(INSTALL_DIR) $(1)/usr/include
197         $(CP) $(PKG_INSTALL_DIR)/usr/include/openssl $(1)/usr/include/
198         $(INSTALL_DIR) $(1)/usr/lib/
199         $(CP) $(PKG_INSTALL_DIR)/usr/lib/lib{crypto,ssl}.{a,so*} $(1)/usr/lib/
200         $(INSTALL_DIR) $(1)/usr/lib/pkgconfig
201         $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/{openssl,libcrypto,libssl}.pc $(1)/usr/lib/pkgconfig/
202         [ -n "$(TARGET_LDFLAGS)" ] && $(SED) 's#$(TARGET_LDFLAGS)##g' $(1)/usr/lib/pkgconfig/{openssl,libcrypto,libssl}.pc || true
203 endef
204
205 define Package/libopenssl/install
206         $(INSTALL_DIR) $(1)/usr/lib
207         $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libcrypto.so.* $(1)/usr/lib/
208         $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libssl.so.* $(1)/usr/lib/
209 endef
210
211 define Package/openssl-util/install
212         $(INSTALL_DIR) $(1)/etc/ssl
213         $(CP) $(PKG_INSTALL_DIR)/etc/ssl/openssl.cnf $(1)/etc/ssl/
214         $(INSTALL_DIR) $(1)/etc/ssl/certs
215         $(INSTALL_DIR) $(1)/etc/ssl/private
216         chmod 0700 $(1)/etc/ssl/private
217         $(INSTALL_DIR) $(1)/usr/bin
218         $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/openssl $(1)/usr/bin/
219 endef
220
221 $(eval $(call BuildPackage,libopenssl))
222 $(eval $(call BuildPackage,openssl-util))