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