openssl: add option for NPN support
[openwrt/openwrt.git] / package / libs / openssl / Makefile
1 #
2 # Copyright (C) 2006-2016 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_BASE:=1.0.2
12 PKG_BUGFIX:=h
13 PKG_VERSION:=$(PKG_BASE)$(PKG_BUGFIX)
14 PKG_RELEASE:=1
15 PKG_USE_MIPS16:=0
16
17 PKG_BUILD_PARALLEL:=0
18
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
26
27 PKG_LICENSE:=OpenSSL
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
39
40 include $(INCLUDE_DIR)/package.mk
41
42 ifneq ($(CONFIG_CCACHE),)
43 HOSTCC=$(HOSTCC_NOCACHE)
44 HOSTCXX=$(HOSTCXX_NOCACHE)
45 endif
46
47 define Package/openssl/Default
48 TITLE:=Open source SSL toolkit
49 URL:=http://www.openssl.org/
50 endef
51
52 define Package/libopenssl/config
53 source "$(SOURCE)/Config.in"
54 endef
55
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.
61 endef
62
63 define Package/libopenssl
64 $(call Package/openssl/Default)
65 SECTION:=libs
66 SUBMENU:=SSL
67 CATEGORY:=Libraries
68 DEPENDS:=+OPENSSL_WITH_COMPRESSION:zlib
69 TITLE+= (libraries)
70 ABI_VERSION:=$(PKG_VERSION)
71 MENU:=1
72 endef
73
74 define Package/libopenssl/description
75 $(call Package/openssl/Default/description)
76 This package contains the OpenSSL shared libraries, needed by other programs.
77 endef
78
79 define Package/openssl-util
80 $(call Package/openssl/Default)
81 SECTION:=utils
82 CATEGORY:=Utilities
83 DEPENDS:=+libopenssl
84 TITLE+= (utility)
85 endef
86
87 define Package/openssl-util/conffiles
88 /etc/ssl/openssl.cnf
89 endef
90
91 define Package/openssl-util/description
92 $(call Package/openssl/Default/description)
93 This package contains the OpenSSL command-line utility.
94 endef
95
96
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
99
100 ifdef CONFIG_OPENSSL_ENGINE_CRYPTO
101 OPENSSL_OPTIONS += -DHAVE_CRYPTODEV
102 ifdef CONFIG_OPENSSL_ENGINE_DIGEST
103 OPENSSL_OPTIONS += -DUSE_CRYPTODEV_DIGESTS
104 endif
105 else
106 OPENSSL_OPTIONS += no-engines
107 endif
108
109 ifndef CONFIG_OPENSSL_WITH_EC
110 OPENSSL_OPTIONS += no-ec
111 endif
112
113 ifndef CONFIG_OPENSSL_WITH_EC2M
114 OPENSSL_OPTIONS += no-ec2m
115 endif
116
117 ifndef CONFIG_OPENSSL_WITH_SSL3
118 OPENSSL_OPTIONS += no-ssl3
119 endif
120
121 ifndef CONFIG_OPENSSL_HARDWARE_SUPPORT
122 OPENSSL_OPTIONS += no-hw
123 endif
124
125 ifndef CONFIG_OPENSSL_WITH_DEPRECATED
126 OPENSSL_OPTIONS += no-deprecated
127 endif
128
129 ifdef CONFIG_OPENSSL_WITH_COMPRESSION
130 OPENSSL_OPTIONS += zlib-dynamic
131 else
132 OPENSSL_OPTIONS += no-comp
133 endif
134
135 ifndef CONFIG_OPENSSL_WITH_NPN
136 OPENSSL_OPTIONS += no-nextprotoneg
137 endif
138
139 ifeq ($(CONFIG_x86_64),y)
140 OPENSSL_TARGET:=linux-x86_64-openwrt
141 OPENSSL_MAKEFLAGS += LIBDIR=lib
142 else
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
148 else
149 OPENSSL_TARGET:=linux-generic-openwrt
150 OPENSSL_OPTIONS+=no-perlasm
151 endif
152 endif
153
154 STAMP_CONFIGURED := $(STAMP_CONFIGURED)_$(subst $(space),_,$(OPENSSL_OPTIONS))
155
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; \
160 }
161 (cd $(PKG_BUILD_DIR); \
162 ./Configure $(OPENSSL_TARGET) \
163 --prefix=/usr \
164 --openssldir=/etc/ssl \
165 $(TARGET_CPPFLAGS) \
166 $(TARGET_LDFLAGS) -ldl \
167 -DOPENSSL_SMALL_FOOTPRINT \
168 $(OPENSSL_NO_CIPHERS) \
169 $(OPENSSL_OPTIONS) \
170 )
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) \
178 depend
179 endef
180
181 TARGET_CFLAGS += $(FPIC) -I$(CURDIR)/include
182
183 define Build/Compile
184 +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
185 CC="$(TARGET_CC)" \
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) \
191 all
192 +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
193 CC="$(TARGET_CC)" \
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) \
199 build-shared
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) \
203 CC="$(TARGET_CC)" \
204 OPENWRT_OPTIMIZATION_FLAGS="$(TARGET_CFLAGS)" \
205 $(OPENSSL_MAKEFLAGS) \
206 do_linux-shared
207 $(MAKE) -C $(PKG_BUILD_DIR) \
208 CC="$(TARGET_CC)" \
209 INSTALL_PREFIX="$(PKG_INSTALL_DIR)" \
210 $(OPENSSL_MAKEFLAGS) \
211 install
212 endef
213
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
222 endef
223
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/
228 endef
229
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/
238 endef
239
240 $(eval $(call BuildPackage,libopenssl))
241 $(eval $(call BuildPackage,openssl-util))