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