add CPE ids to package and tools
[openwrt/staging/lynxis.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:=l
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:=ce07195b659e75f4e1db43552860070061f156a98bb37b672b101ba6e3ddf30c
28
29 PKG_LICENSE:=OpenSSL
30 PKG_LICENSE_FILES:=LICENSE
31 PKG_CPE=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 no-ssl3-method
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_arm)$(CONFIG_armeb),y)
166 OPENSSL_TARGET:=linux-armv4-openwrt
167 else
168 OPENSSL_TARGET:=linux-generic-openwrt
169 OPENSSL_OPTIONS+=no-perlasm
170 endif
171 endif
172
173 STAMP_CONFIGURED := $(STAMP_CONFIGURED)_$(shell echo $(OPENSSL_OPTIONS) | mkhash md5)
174
175 define Build/Configure
176 [ -f $(STAMP_CONFIGURED) ] || { \
177 rm -f $(PKG_BUILD_DIR)/*.so.* $(PKG_BUILD_DIR)/*.a; \
178 find $(PKG_BUILD_DIR) -name \*.o | xargs rm -f; \
179 }
180 (cd $(PKG_BUILD_DIR); \
181 ./Configure $(OPENSSL_TARGET) \
182 --prefix=/usr \
183 --openssldir=/etc/ssl \
184 $(TARGET_CPPFLAGS) \
185 $(TARGET_LDFLAGS) -ldl \
186 -DOPENSSL_SMALL_FOOTPRINT \
187 $(OPENSSL_NO_CIPHERS) \
188 $(OPENSSL_OPTIONS) \
189 )
190 # XXX: OpenSSL "make depend" will look for installed headers before its own,
191 # so remove installed stuff first
192 -$(SUBMAKE) -j1 clean-staging
193 +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
194 MAKEDEPPROG="$(TARGET_CROSS)gcc" \
195 OPENWRT_OPTIMIZATION_FLAGS="$(TARGET_CFLAGS)" \
196 $(OPENSSL_MAKEFLAGS) \
197 depend
198 endef
199
200 TARGET_CFLAGS += $(FPIC) -I$(CURDIR)/include -ffunction-sections -fdata-sections
201 TARGET_LDFLAGS += -Wl,--gc-sections
202
203 define Build/Compile
204 +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
205 CC="$(TARGET_CC)" \
206 ASFLAGS="$(TARGET_ASFLAGS) -I$(PKG_BUILD_DIR)/crypto -c" \
207 AR="$(TARGET_CROSS)ar r" \
208 RANLIB="$(TARGET_CROSS)ranlib" \
209 OPENWRT_OPTIMIZATION_FLAGS="$(TARGET_CFLAGS)" \
210 $(OPENSSL_MAKEFLAGS) \
211 all
212 +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
213 CC="$(TARGET_CC)" \
214 ASFLAGS="$(TARGET_ASFLAGS) -I$(PKG_BUILD_DIR)/crypto -c" \
215 AR="$(TARGET_CROSS)ar r" \
216 RANLIB="$(TARGET_CROSS)ranlib" \
217 OPENWRT_OPTIMIZATION_FLAGS="$(TARGET_CFLAGS)" \
218 $(OPENSSL_MAKEFLAGS) \
219 build-shared
220 # Work around openssl build bug to link libssl.so with libcrypto.so.
221 -rm $(PKG_BUILD_DIR)/libssl.so.*.*.*
222 +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
223 CC="$(TARGET_CC)" \
224 OPENWRT_OPTIMIZATION_FLAGS="$(TARGET_CFLAGS)" \
225 $(OPENSSL_MAKEFLAGS) \
226 do_linux-shared
227 $(MAKE) -C $(PKG_BUILD_DIR) \
228 CC="$(TARGET_CC)" \
229 INSTALL_PREFIX="$(PKG_INSTALL_DIR)" \
230 $(OPENSSL_MAKEFLAGS) \
231 install
232 endef
233
234 define Build/InstallDev
235 $(INSTALL_DIR) $(1)/usr/include
236 $(CP) $(PKG_INSTALL_DIR)/usr/include/openssl $(1)/usr/include/
237 $(INSTALL_DIR) $(1)/usr/lib/
238 $(CP) $(PKG_INSTALL_DIR)/usr/lib/lib{crypto,ssl}.{a,so*} $(1)/usr/lib/
239 $(INSTALL_DIR) $(1)/usr/lib/pkgconfig
240 $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/{openssl,libcrypto,libssl}.pc $(1)/usr/lib/pkgconfig/
241 [ -n "$(TARGET_LDFLAGS)" ] && $(SED) 's#$(TARGET_LDFLAGS)##g' $(1)/usr/lib/pkgconfig/{openssl,libcrypto,libssl}.pc || true
242 endef
243
244 define Package/libopenssl/install
245 $(INSTALL_DIR) $(1)/usr/lib
246 $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libcrypto.so.* $(1)/usr/lib/
247 $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libssl.so.* $(1)/usr/lib/
248 endef
249
250 define Package/openssl-util/install
251 $(INSTALL_DIR) $(1)/etc/ssl
252 $(CP) $(PKG_INSTALL_DIR)/etc/ssl/openssl.cnf $(1)/etc/ssl/
253 $(INSTALL_DIR) $(1)/etc/ssl/certs
254 $(INSTALL_DIR) $(1)/etc/ssl/private
255 chmod 0700 $(1)/etc/ssl/private
256 $(INSTALL_DIR) $(1)/usr/bin
257 $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/openssl $(1)/usr/bin/
258 endef
259
260 $(eval $(call BuildPackage,libopenssl))
261 $(eval $(call BuildPackage,openssl-util))