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