d5dfe6cb08f6022663921e07fb60bdf56507a3dc
[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:=g
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:=b784b1b3907ce39abf4098702dade6365522a253ad1552e267a9a0e89594aa33
26
27 PKG_LICENSE:=OpenSSL
28 PKG_LICENSE_FILES:=LICENSE
29 PKG_BUILD_DEPENDS:=ocf-crypto-headers
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
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 ifeq ($(CONFIG_x86_64),y)
124 OPENSSL_TARGET:=linux-x86_64-openwrt
125 OPENSSL_MAKEFLAGS += LIBDIR=lib
126 else
127 OPENSSL_OPTIONS+=no-sse2
128 ifeq ($(CONFIG_mips)$(CONFIG_mipsel),y)
129 OPENSSL_TARGET:=linux-mips-openwrt
130 # else ifeq ($(CONFIG_arm)$(CONFIG_armeb),y)
131 # OPENSSL_TARGET:=linux-armv4-openwrt
132 else
133 OPENSSL_TARGET:=linux-generic-openwrt
134 OPENSSL_OPTIONS+=no-perlasm
135 endif
136 endif
137
138 STAMP_CONFIGURED := $(STAMP_CONFIGURED)_$(subst $(space),_,$(OPENSSL_OPTIONS))
139
140 define Build/Configure
141 [ -f $(STAMP_CONFIGURED) ] || { \
142 rm -f $(PKG_BUILD_DIR)/*.so.* $(PKG_BUILD_DIR)/*.a; \
143 find $(PKG_BUILD_DIR) -name \*.o | xargs rm -f; \
144 }
145 (cd $(PKG_BUILD_DIR); \
146 ./Configure $(OPENSSL_TARGET) \
147 --prefix=/usr \
148 --openssldir=/etc/ssl \
149 $(TARGET_CPPFLAGS) \
150 $(TARGET_LDFLAGS) -ldl \
151 -DOPENSSL_SMALL_FOOTPRINT \
152 $(OPENSSL_NO_CIPHERS) \
153 $(OPENSSL_OPTIONS) \
154 )
155 # XXX: OpenSSL "make depend" will look for installed headers before its own,
156 # so remove installed stuff first
157 -$(SUBMAKE) -j1 clean-staging
158 +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
159 MAKEDEPPROG="$(TARGET_CROSS)gcc" \
160 OPENWRT_OPTIMIZATION_FLAGS="$(TARGET_CFLAGS)" \
161 $(OPENSSL_MAKEFLAGS) \
162 depend
163 endef
164
165 TARGET_CFLAGS += $(FPIC)
166
167 define Build/Compile
168 +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
169 CC="$(TARGET_CC)" \
170 ASFLAGS="$(TARGET_ASFLAGS) -I$(PKG_BUILD_DIR)/crypto -c" \
171 AR="$(TARGET_CROSS)ar r" \
172 RANLIB="$(TARGET_CROSS)ranlib" \
173 OPENWRT_OPTIMIZATION_FLAGS="$(TARGET_CFLAGS)" \
174 $(OPENSSL_MAKEFLAGS) \
175 all
176 +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
177 CC="$(TARGET_CC)" \
178 ASFLAGS="$(TARGET_ASFLAGS) -I$(PKG_BUILD_DIR)/crypto -c" \
179 AR="$(TARGET_CROSS)ar r" \
180 RANLIB="$(TARGET_CROSS)ranlib" \
181 OPENWRT_OPTIMIZATION_FLAGS="$(TARGET_CFLAGS)" \
182 $(OPENSSL_MAKEFLAGS) \
183 build-shared
184 # Work around openssl build bug to link libssl.so with libcrypto.so.
185 -rm $(PKG_BUILD_DIR)/libssl.so.*.*.*
186 +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
187 CC="$(TARGET_CC)" \
188 OPENWRT_OPTIMIZATION_FLAGS="$(TARGET_CFLAGS)" \
189 $(OPENSSL_MAKEFLAGS) \
190 do_linux-shared
191 $(MAKE) -C $(PKG_BUILD_DIR) \
192 CC="$(TARGET_CC)" \
193 INSTALL_PREFIX="$(PKG_INSTALL_DIR)" \
194 $(OPENSSL_MAKEFLAGS) \
195 install
196 endef
197
198 define Build/InstallDev
199 $(INSTALL_DIR) $(1)/usr/include
200 $(CP) $(PKG_INSTALL_DIR)/usr/include/openssl $(1)/usr/include/
201 $(INSTALL_DIR) $(1)/usr/lib/
202 $(CP) $(PKG_INSTALL_DIR)/usr/lib/lib{crypto,ssl}.{a,so*} $(1)/usr/lib/
203 $(INSTALL_DIR) $(1)/usr/lib/pkgconfig
204 $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/{openssl,libcrypto,libssl}.pc $(1)/usr/lib/pkgconfig/
205 [ -n "$(TARGET_LDFLAGS)" ] && $(SED) 's#$(TARGET_LDFLAGS)##g' $(1)/usr/lib/pkgconfig/{openssl,libcrypto,libssl}.pc || true
206 endef
207
208 define Package/libopenssl/install
209 $(INSTALL_DIR) $(1)/usr/lib
210 $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libcrypto.so.* $(1)/usr/lib/
211 $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libssl.so.* $(1)/usr/lib/
212 endef
213
214 define Package/openssl-util/install
215 $(INSTALL_DIR) $(1)/etc/ssl
216 $(CP) $(PKG_INSTALL_DIR)/etc/ssl/openssl.cnf $(1)/etc/ssl/
217 $(INSTALL_DIR) $(1)/etc/ssl/certs
218 $(INSTALL_DIR) $(1)/etc/ssl/private
219 chmod 0700 $(1)/etc/ssl/private
220 $(INSTALL_DIR) $(1)/usr/bin
221 $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/openssl $(1)/usr/bin/
222 endef
223
224 $(eval $(call BuildPackage,libopenssl))
225 $(eval $(call BuildPackage,openssl-util))