95e6cff864e16588de7a79d5a5e933b2203b082f
[openwrt/staging/wigyori.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:=n
13 PKG_VERSION:=$(PKG_BASE)$(PKG_BUGFIX)
14 PKG_RELEASE:=1
15 PKG_USE_MIPS16:=0
16
17 PKG_BUILD_PARALLEL:=0
18
19
20 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
21 PKG_SOURCE_URL:= \
22 http://ftp.fi.muni.cz/pub/openssl/source/ \
23 http://ftp.linux.hr/pub/openssl/source/ \
24 http://gd.tuwien.ac.at/infosys/security/openssl/source/ \
25 http://www.openssl.org/source/ \
26 http://www.openssl.org/source/old/$(PKG_BASE)/
27 PKG_HASH:=370babb75f278c39e0c50e8c4e7493bc0f18db6867478341a832a982fd15a8fe
28
29 PKG_LICENSE:=OpenSSL
30 PKG_LICENSE_FILES:=LICENSE
31 PKG_CPE_ID:=cpe:/a:openssl:openssl
32 PKG_CONFIG_DEPENDS:= \
33 CONFIG_OPENSSL_ENGINE_CRYPTO \
34 CONFIG_OPENSSL_ENGINE_DIGEST \
35 CONFIG_OPENSSL_WITH_EC \
36 CONFIG_OPENSSL_WITH_EC2M \
37 CONFIG_OPENSSL_WITH_SSL3 \
38 CONFIG_OPENSSL_HARDWARE_SUPPORT \
39 CONFIG_OPENSSL_WITH_DEPRECATED \
40 CONFIG_OPENSSL_WITH_DTLS \
41 CONFIG_OPENSSL_WITH_COMPRESSION \
42 CONFIG_OPENSSL_WITH_NPN \
43 CONFIG_OPENSSL_WITH_PSK \
44 CONFIG_OPENSSL_WITH_SRP \
45 CONFIG_OPENSSL_OPTIMIZE_SPEED
46
47 include $(INCLUDE_DIR)/package.mk
48
49 ifneq ($(CONFIG_CCACHE),)
50 HOSTCC=$(HOSTCC_NOCACHE)
51 HOSTCXX=$(HOSTCXX_NOCACHE)
52 endif
53
54 define Package/openssl/Default
55 TITLE:=Open source SSL toolkit
56 URL:=http://www.openssl.org/
57 endef
58
59 define Package/libopenssl/config
60 source "$(SOURCE)/Config.in"
61 endef
62
63 define Package/openssl/Default/description
64 The OpenSSL Project is a collaborative effort to develop a robust,
65 commercial-grade, full-featured, and Open Source toolkit implementing the Secure
66 Sockets Layer (SSL v2/v3) and Transport Layer Security (TLS v1) protocols as well
67 as a full-strength general purpose cryptography library.
68 endef
69
70 define Package/libopenssl
71 $(call Package/openssl/Default)
72 SECTION:=libs
73 SUBMENU:=SSL
74 CATEGORY:=Libraries
75 DEPENDS:=+OPENSSL_WITH_COMPRESSION:zlib
76 TITLE+= (libraries)
77 ABI_VERSION:=$(PKG_VERSION)
78 MENU:=1
79 endef
80
81 define Package/libopenssl/description
82 $(call Package/openssl/Default/description)
83 This package contains the OpenSSL shared libraries, needed by other programs.
84 endef
85
86 define Package/openssl-util
87 $(call Package/openssl/Default)
88 SECTION:=utils
89 CATEGORY:=Utilities
90 DEPENDS:=+libopenssl
91 TITLE+= (utility)
92 endef
93
94 define Package/openssl-util/conffiles
95 /etc/ssl/openssl.cnf
96 endef
97
98 define Package/openssl-util/description
99 $(call Package/openssl/Default/description)
100 This package contains the OpenSSL command-line utility.
101 endef
102
103
104 OPENSSL_NO_CIPHERS:= no-idea no-md2 no-mdc2 no-rc5 no-sha0 no-camellia no-krb5 \
105 no-whrlpool no-whirlpool no-seed no-jpake
106 OPENSSL_OPTIONS:= shared no-err no-sse2 no-ssl2 no-ssl2-method no-heartbeats
107
108 ifdef CONFIG_OPENSSL_ENGINE_CRYPTO
109 OPENSSL_OPTIONS += -DHAVE_CRYPTODEV
110 ifdef CONFIG_OPENSSL_ENGINE_DIGEST
111 OPENSSL_OPTIONS += -DUSE_CRYPTODEV_DIGESTS
112 endif
113 else
114 OPENSSL_OPTIONS += no-engines
115 endif
116
117 ifndef CONFIG_OPENSSL_WITH_EC
118 OPENSSL_OPTIONS += no-ec
119 endif
120
121 ifndef CONFIG_OPENSSL_WITH_EC2M
122 OPENSSL_OPTIONS += no-ec2m
123 endif
124
125 ifndef CONFIG_OPENSSL_WITH_SSL3
126 OPENSSL_OPTIONS += no-ssl3 no-ssl3-method
127 endif
128
129 ifndef CONFIG_OPENSSL_HARDWARE_SUPPORT
130 OPENSSL_OPTIONS += no-hw
131 endif
132
133 ifndef CONFIG_OPENSSL_WITH_DEPRECATED
134 OPENSSL_OPTIONS += no-deprecated
135 endif
136
137 ifndef CONFIG_OPENSSL_WITH_DTLS
138 OPENSSL_OPTIONS += no-dtls
139 endif
140
141 ifdef CONFIG_OPENSSL_WITH_COMPRESSION
142 OPENSSL_OPTIONS += zlib-dynamic
143 else
144 OPENSSL_OPTIONS += no-comp
145 endif
146
147 ifndef CONFIG_OPENSSL_WITH_NPN
148 OPENSSL_OPTIONS += no-nextprotoneg
149 endif
150
151 ifndef CONFIG_OPENSSL_WITH_PSK
152 OPENSSL_OPTIONS += no-psk
153 endif
154
155 ifndef CONFIG_OPENSSL_WITH_SRP
156 OPENSSL_OPTIONS += no-srp
157 endif
158
159 ifeq ($(CONFIG_OPENSSL_OPTIMIZE_SPEED),y)
160 TARGET_CFLAGS := $(filter-out -Os,$(TARGET_CFLAGS)) -O3
161 endif
162
163 ifeq ($(CONFIG_x86_64),y)
164 OPENSSL_TARGET:=linux-x86_64-openwrt
165 OPENSSL_MAKEFLAGS += LIBDIR=lib
166 else
167 OPENSSL_OPTIONS+=no-sse2
168 ifeq ($(CONFIG_mips)$(CONFIG_mipsel),y)
169 OPENSSL_TARGET:=linux-mips-openwrt
170 else ifeq ($(CONFIG_aarch64),y)
171 OPENSSL_TARGET:=linux-aarch64-openwrt
172 else ifeq ($(CONFIG_arm)$(CONFIG_armeb),y)
173 OPENSSL_TARGET:=linux-armv4-openwrt
174 else
175 OPENSSL_TARGET:=linux-generic-openwrt
176 OPENSSL_OPTIONS+=no-perlasm
177 endif
178 endif
179
180 STAMP_CONFIGURED := $(STAMP_CONFIGURED)_$(shell echo $(OPENSSL_OPTIONS) | mkhash md5)
181
182 define Build/Configure
183 [ -f $(STAMP_CONFIGURED) ] || { \
184 rm -f $(PKG_BUILD_DIR)/*.so.* $(PKG_BUILD_DIR)/*.a; \
185 find $(PKG_BUILD_DIR) -name \*.o | xargs rm -f; \
186 }
187 (cd $(PKG_BUILD_DIR); \
188 ./Configure $(OPENSSL_TARGET) \
189 --prefix=/usr \
190 --openssldir=/etc/ssl \
191 $(TARGET_CPPFLAGS) \
192 $(TARGET_LDFLAGS) -ldl \
193 $(if $(CONFIG_OPENSSL_OPTIMIZE_SPEED),,-DOPENSSL_SMALL_FOOTPRINT) \
194 $(OPENSSL_NO_CIPHERS) \
195 $(OPENSSL_OPTIONS) \
196 )
197 +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
198 CROSS_COMPILE="$(TARGET_CROSS)" \
199 MAKEDEPPROG="$(TARGET_CROSS)gcc" \
200 OPENWRT_OPTIMIZATION_FLAGS="$(TARGET_CFLAGS)" \
201 $(OPENSSL_MAKEFLAGS) \
202 depend
203 endef
204
205 TARGET_CFLAGS += $(FPIC) -I$(CURDIR)/include -ffunction-sections -fdata-sections
206 TARGET_LDFLAGS += -Wl,--gc-sections
207
208 define Build/Compile
209 +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
210 CROSS_COMPILE="$(TARGET_CROSS)" \
211 CC="$(TARGET_CC)" \
212 ASFLAGS="$(TARGET_ASFLAGS) -I$(PKG_BUILD_DIR)/crypto -c" \
213 AR="$(TARGET_CROSS)ar r" \
214 RANLIB="$(TARGET_CROSS)ranlib" \
215 OPENWRT_OPTIMIZATION_FLAGS="$(TARGET_CFLAGS)" \
216 $(OPENSSL_MAKEFLAGS) \
217 all
218 +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
219 CROSS_COMPILE="$(TARGET_CROSS)" \
220 CC="$(TARGET_CC)" \
221 ASFLAGS="$(TARGET_ASFLAGS) -I$(PKG_BUILD_DIR)/crypto -c" \
222 AR="$(TARGET_CROSS)ar r" \
223 RANLIB="$(TARGET_CROSS)ranlib" \
224 OPENWRT_OPTIMIZATION_FLAGS="$(TARGET_CFLAGS)" \
225 $(OPENSSL_MAKEFLAGS) \
226 build-shared
227 # Work around openssl build bug to link libssl.so with libcrypto.so.
228 -rm $(PKG_BUILD_DIR)/libssl.so.*.*.*
229 +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
230 CROSS_COMPILE="$(TARGET_CROSS)" \
231 CC="$(TARGET_CC)" \
232 OPENWRT_OPTIMIZATION_FLAGS="$(TARGET_CFLAGS)" \
233 $(OPENSSL_MAKEFLAGS) \
234 do_linux-shared
235 $(MAKE) -C $(PKG_BUILD_DIR) \
236 CROSS_COMPILE="$(TARGET_CROSS)" \
237 CC="$(TARGET_CC)" \
238 INSTALL_PREFIX="$(PKG_INSTALL_DIR)" \
239 $(OPENSSL_MAKEFLAGS) \
240 install
241 endef
242
243 define Build/InstallDev
244 $(INSTALL_DIR) $(1)/usr/include
245 $(CP) $(PKG_INSTALL_DIR)/usr/include/openssl $(1)/usr/include/
246 $(INSTALL_DIR) $(1)/usr/lib/
247 $(CP) $(PKG_INSTALL_DIR)/usr/lib/lib{crypto,ssl}.{a,so*} $(1)/usr/lib/
248 $(INSTALL_DIR) $(1)/usr/lib/pkgconfig
249 $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/{openssl,libcrypto,libssl}.pc $(1)/usr/lib/pkgconfig/
250 [ -n "$(TARGET_LDFLAGS)" ] && $(SED) 's#$(TARGET_LDFLAGS)##g' $(1)/usr/lib/pkgconfig/{openssl,libcrypto,libssl}.pc || true
251 endef
252
253 define Package/libopenssl/install
254 $(INSTALL_DIR) $(1)/usr/lib
255 $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libcrypto.so.* $(1)/usr/lib/
256 $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libssl.so.* $(1)/usr/lib/
257 endef
258
259 define Package/openssl-util/install
260 $(INSTALL_DIR) $(1)/etc/ssl
261 $(CP) $(PKG_INSTALL_DIR)/etc/ssl/openssl.cnf $(1)/etc/ssl/
262 $(INSTALL_DIR) $(1)/etc/ssl/certs
263 $(INSTALL_DIR) $(1)/etc/ssl/private
264 chmod 0700 $(1)/etc/ssl/private
265 $(INSTALL_DIR) $(1)/usr/bin
266 $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/openssl $(1)/usr/bin/
267 endef
268
269 $(eval $(call BuildPackage,libopenssl))
270 $(eval $(call BuildPackage,openssl-util))