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