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