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