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