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