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