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