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