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