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