openssl: fixes CVE-2015-4000 CVE-2015-1788 CVE-2015-1789 CVE-2015-1790 CVE-2015-1792...
[openwrt/openwrt.git] / package / libs / openssl / Makefile
1 #
2 # Copyright (C) 2006-2015 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_VERSION:=1.0.2b
12 PKG_RELEASE:=1
13 PKG_USE_MIPS16:=0
14
15 PKG_BUILD_PARALLEL:=1
16
17 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
18 PKG_SOURCE_URL:=http://www.openssl.org/source/ \
19 ftp://ftp.funet.fi/pub/crypt/mirrors/ftp.openssl.org/source \
20 ftp://ftp.sunet.se/pub/security/tools/net/openssl/source/
21 PKG_MD5SUM:=7729b259e2dea7d60b32fc3934d6984b
22
23 PKG_LICENSE:=OpenSSL
24 PKG_LICENSE_FILES:=LICENSE
25 PKG_BUILD_DEPENDS:=ocf-crypto-headers
26 PKG_CONFIG_DEPENDS:= \
27 CONFIG_OPENSSL_ENGINE_CRYPTO \
28 CONFIG_OPENSSL_ENGINE_DIGEST \
29 CONFIG_OPENSSL_WITH_EC \
30 CONFIG_OPENSSL_WITH_EC2M \
31 CONFIG_OPENSSL_WITH_SSL3
32
33 include $(INCLUDE_DIR)/package.mk
34
35 ifneq ($(CONFIG_CCACHE),)
36 HOSTCC=$(HOSTCC_NOCACHE)
37 HOSTCXX=$(HOSTCXX_NOCACHE)
38 endif
39
40 define Package/openssl/Default
41 TITLE:=Open source SSL toolkit
42 URL:=http://www.openssl.org/
43 endef
44
45 define Package/libopenssl/config
46 source "$(SOURCE)/Config.in"
47 endef
48
49 define Package/openssl/Default/description
50 The OpenSSL Project is a collaborative effort to develop a robust,
51 commercial-grade, full-featured, and Open Source toolkit implementing the Secure
52 Sockets Layer (SSL v2/v3) and Transport Layer Security (TLS v1) protocols as well
53 as a full-strength general purpose cryptography library.
54 endef
55
56 define Package/libopenssl
57 $(call Package/openssl/Default)
58 SECTION:=libs
59 SUBMENU:=SSL
60 CATEGORY:=Libraries
61 DEPENDS:=+zlib
62 TITLE+= (libraries)
63 ABI_VERSION:=$(PKG_VERSION)
64 MENU:=1
65 endef
66
67 define Package/libopenssl/description
68 $(call Package/openssl/Default/description)
69 This package contains the OpenSSL shared libraries, needed by other programs.
70 endef
71
72 define Package/openssl-util
73 $(call Package/openssl/Default)
74 SECTION:=utils
75 CATEGORY:=Utilities
76 DEPENDS:=+libopenssl
77 TITLE+= (utility)
78 endef
79
80 define Package/openssl-util/conffiles
81 /etc/ssl/openssl.cnf
82 endef
83
84 define Package/openssl-util/description
85 $(call Package/openssl/Default/description)
86 This package contains the OpenSSL command-line utility.
87 endef
88
89
90 OPENSSL_NO_CIPHERS:= no-idea no-md2 no-mdc2 no-rc5 no-sha0 no-camellia no-krb5
91 OPENSSL_OPTIONS:= shared no-err no-hw zlib-dynamic no-sse2 no-ssl2
92
93 ifdef CONFIG_OPENSSL_ENGINE_CRYPTO
94 OPENSSL_OPTIONS += -DHAVE_CRYPTODEV
95 ifdef CONFIG_OPENSSL_ENGINE_DIGEST
96 OPENSSL_OPTIONS += -DUSE_CRYPTODEV_DIGESTS
97 endif
98 else
99 OPENSSL_OPTIONS += no-engines
100 endif
101
102 ifndef CONFIG_OPENSSL_WITH_EC
103 OPENSSL_OPTIONS += no-ec
104 endif
105
106 ifndef CONFIG_OPENSSL_WITH_EC2M
107 OPENSSL_OPTIONS += no-ec2m
108 endif
109
110 ifndef CONFIG_OPENSSL_WITH_SSL3
111 OPENSSL_OPTIONS += no-ssl3
112 endif
113
114 ifeq ($(CONFIG_x86_64),y)
115 OPENSSL_TARGET:=linux-x86_64-openwrt
116 OPENSSL_MAKEFLAGS += LIBDIR=lib
117 else
118 OPENSSL_OPTIONS+=no-sse2
119 ifeq ($(CONFIG_mips)$(CONFIG_mipsel),y)
120 OPENSSL_TARGET:=linux-mips-openwrt
121 # else ifeq ($(CONFIG_arm)$(CONFIG_armeb),y)
122 # OPENSSL_TARGET:=linux-armv4-openwrt
123 else
124 OPENSSL_TARGET:=linux-generic-openwrt
125 OPENSSL_OPTIONS+=no-perlasm
126 endif
127 endif
128
129 STAMP_CONFIGURED := $(STAMP_CONFIGURED)_$(subst $(space),_,$(OPENSSL_OPTIONS))
130
131 define Build/Configure
132 [ -f $(STAMP_CONFIGURED) ] || { \
133 rm -f $(PKG_BUILD_DIR)/*.so.* $(PKG_BUILD_DIR)/*.a; \
134 find $(PKG_BUILD_DIR) -name \*.o | xargs rm -f; \
135 }
136 (cd $(PKG_BUILD_DIR); \
137 ./Configure $(OPENSSL_TARGET) \
138 --prefix=/usr \
139 --openssldir=/etc/ssl \
140 $(TARGET_CPPFLAGS) \
141 $(TARGET_LDFLAGS) -ldl \
142 -DOPENSSL_SMALL_FOOTPRINT \
143 $(OPENSSL_NO_CIPHERS) \
144 $(OPENSSL_OPTIONS) \
145 )
146 # XXX: OpenSSL "make depend" will look for installed headers before its own,
147 # so remove installed stuff first
148 -$(SUBMAKE) -j1 clean-staging
149 +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
150 MAKEDEPPROG="$(TARGET_CROSS)gcc" \
151 OPENWRT_OPTIMIZATION_FLAGS="$(TARGET_CFLAGS)" \
152 $(OPENSSL_MAKEFLAGS) \
153 depend
154 endef
155
156 TARGET_CFLAGS += $(FPIC)
157
158 define Build/Compile
159 +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
160 CC="$(TARGET_CC)" \
161 ASFLAGS="$(TARGET_ASFLAGS) -I$(PKG_BUILD_DIR)/crypto -c" \
162 AR="$(TARGET_CROSS)ar r" \
163 RANLIB="$(TARGET_CROSS)ranlib" \
164 OPENWRT_OPTIMIZATION_FLAGS="$(TARGET_CFLAGS)" \
165 $(OPENSSL_MAKEFLAGS) \
166 all
167 +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
168 CC="$(TARGET_CC)" \
169 ASFLAGS="$(TARGET_ASFLAGS) -I$(PKG_BUILD_DIR)/crypto -c" \
170 AR="$(TARGET_CROSS)ar r" \
171 RANLIB="$(TARGET_CROSS)ranlib" \
172 OPENWRT_OPTIMIZATION_FLAGS="$(TARGET_CFLAGS)" \
173 $(OPENSSL_MAKEFLAGS) \
174 build-shared
175 # Work around openssl build bug to link libssl.so with libcrypto.so.
176 -rm $(PKG_BUILD_DIR)/libssl.so.*.*.*
177 +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
178 CC="$(TARGET_CC)" \
179 OPENWRT_OPTIMIZATION_FLAGS="$(TARGET_CFLAGS)" \
180 $(OPENSSL_MAKEFLAGS) \
181 do_linux-shared
182 $(MAKE) -C $(PKG_BUILD_DIR) \
183 CC="$(TARGET_CC)" \
184 INSTALL_PREFIX="$(PKG_INSTALL_DIR)" \
185 $(OPENSSL_MAKEFLAGS) \
186 install
187 endef
188
189 define Build/InstallDev
190 $(INSTALL_DIR) $(1)/usr/include
191 $(CP) $(PKG_INSTALL_DIR)/usr/include/openssl $(1)/usr/include/
192 $(INSTALL_DIR) $(1)/usr/lib/
193 $(CP) $(PKG_INSTALL_DIR)/usr/lib/lib{crypto,ssl}.{a,so*} $(1)/usr/lib/
194 $(INSTALL_DIR) $(1)/usr/lib/pkgconfig
195 $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/{openssl,libcrypto,libssl}.pc $(1)/usr/lib/pkgconfig/
196 [ -n "$(TARGET_LDFLAGS)" ] && $(SED) 's#$(TARGET_LDFLAGS)##g' $(1)/usr/lib/pkgconfig/{openssl,libcrypto,libssl}.pc || true
197 endef
198
199 define Package/libopenssl/install
200 $(INSTALL_DIR) $(1)/usr/lib
201 $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libcrypto.so.* $(1)/usr/lib/
202 $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libssl.so.* $(1)/usr/lib/
203 endef
204
205 define Package/openssl-util/install
206 $(INSTALL_DIR) $(1)/etc/ssl
207 $(CP) $(PKG_INSTALL_DIR)/etc/ssl/openssl.cnf $(1)/etc/ssl/
208 $(INSTALL_DIR) $(1)/etc/ssl/certs
209 $(INSTALL_DIR) $(1)/etc/ssl/private
210 chmod 0700 $(1)/etc/ssl/private
211 $(INSTALL_DIR) $(1)/usr/bin
212 $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/openssl $(1)/usr/bin/
213 endef
214
215 $(eval $(call BuildPackage,libopenssl))
216 $(eval $(call BuildPackage,openssl-util))