openssl: update OpenSSL to 1.0.1e, fix Cisco DTLS.
[openwrt/staging/mkresin.git] / package / libs / openssl / Makefile
1 #
2 # Copyright (C) 2006-2012 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.1e
12 PKG_RELEASE:=1
13
14 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
15 PKG_SOURCE_URL:=http://www.openssl.org/source/ \
16 ftp://ftp.funet.fi/pub/crypt/mirrors/ftp.openssl.org/source \
17 ftp://ftp.sunet.se/pub/security/tools/net/openssl/source/
18 PKG_MD5SUM:=66bf6f10f060d561929de96f9dfe5b8c
19
20 PKG_LICENSE:=SSLEAY OPENSSL
21 PKG_LICENSE_FILES:=LICENSE
22 PKG_BUILD_DEPENDS:=ocf-crypto-headers
23 PKG_CONFIG_DEPENDS:=CONFIG_OPENSSL_ENGINE_CRYPTO CONFIG_OPENSSL_ENGINE_DIGEST
24
25 include $(INCLUDE_DIR)/package.mk
26
27 define Package/openssl/Default
28 TITLE:=Open source SSL toolkit
29 URL:=http://www.openssl.org/
30 endef
31
32 define Package/libopenssl/config
33 source "$(SOURCE)/Config.in"
34 endef
35
36 define Package/openssl/Default/description
37 The OpenSSL Project is a collaborative effort to develop a robust,
38 commercial-grade, full-featured, and Open Source toolkit implementing the Secure
39 Sockets Layer (SSL v2/v3) and Transport Layer Security (TLS v1) protocols as well
40 as a full-strength general purpose cryptography library.
41 endef
42
43 define Package/libopenssl
44 $(call Package/openssl/Default)
45 SECTION:=libs
46 SUBMENU:=SSL
47 CATEGORY:=Libraries
48 DEPENDS:=+zlib
49 TITLE+= (libraries)
50 MENU:=1
51 endef
52
53 define Package/libopenssl/description
54 $(call Package/openssl/Default/description)
55 This package contains the OpenSSL shared libraries, needed by other programs.
56 endef
57
58 define Package/openssl-util
59 $(call Package/openssl/Default)
60 SECTION:=utils
61 CATEGORY:=Utilities
62 DEPENDS:=+libopenssl
63 TITLE+= (utility)
64 endef
65
66 define Package/openssl-util/conffiles
67 /etc/ssl/openssl.cnf
68 endef
69
70 define Package/openssl-util/description
71 $(call Package/openssl/Default/description)
72 This package contains the OpenSSL command-line utility.
73 endef
74
75
76 OPENSSL_NO_CIPHERS:= no-idea no-md2 no-mdc2 no-rc5 no-sha0 no-smime \
77 no-rmd160 no-aes192 no-ripemd no-camellia no-ans1 no-krb5
78 OPENSSL_OPTIONS:= shared no-ec no-err no-hw no-threads zlib-dynamic no-sse2
79
80 ifdef CONFIG_OPENSSL_ENGINE_CRYPTO
81 OPENSSL_OPTIONS += -DHAVE_CRYPTODEV
82 ifdef CONFIG_OPENSSL_ENGINE_DIGEST
83 OPENSSL_OPTIONS += -DUSE_CRYPTODEV_DIGESTS
84 endif
85 else
86 OPENSSL_OPTIONS += no-engines
87 endif
88
89 ifeq ($(CONFIG_x86_64),y)
90 OPENSSL_TARGET:=linux-x86_64
91 else
92 OPENSSL_OPTIONS+=no-sse2
93 ifeq ($(CONFIG_mips)$(CONFIG_mipsel),y)
94 OPENSSL_TARGET:=linux-mips-openwrt
95 else
96 OPENSSL_TARGET:=linux-generic-openwrt
97 OPENSSL_OPTIONS+=no-perlasm
98 endif
99 endif
100
101 define Build/Configure
102 (cd $(PKG_BUILD_DIR); \
103 ./Configure $(OPENSSL_TARGET) \
104 --prefix=/usr \
105 --openssldir=/etc/ssl \
106 $(TARGET_CPPFLAGS) \
107 $(TARGET_LDFLAGS) -ldl \
108 -DOPENSSL_SMALL_FOOTPRINT \
109 $(OPENSSL_NO_CIPHERS) \
110 $(OPENSSL_OPTIONS) \
111 )
112 endef
113
114 TARGET_CFLAGS += $(FPIC)
115
116 define Build/Compile
117 # XXX: OpenSSL "make depend" will look for installed headers before its own,
118 # so remove installed stuff first
119 -$(SUBMAKE) -j1 clean-staging
120 $(MAKE) -C $(PKG_BUILD_DIR) \
121 MAKEDEPPROG="$(TARGET_CROSS)gcc" \
122 OPENWRT_OPTIMIZATION_FLAGS="$(TARGET_CFLAGS)" \
123 $(OPENSSL_MAKEFLAGS) \
124 depend
125 $(_SINGLE)$(MAKE) -C $(PKG_BUILD_DIR) \
126 CC="$(TARGET_CC)" \
127 AR="$(TARGET_CROSS)ar r" \
128 RANLIB="$(TARGET_CROSS)ranlib" \
129 OPENWRT_OPTIMIZATION_FLAGS="$(TARGET_CFLAGS)" \
130 $(OPENSSL_MAKEFLAGS) \
131 all
132 $(MAKE) -C $(PKG_BUILD_DIR) \
133 CC="$(TARGET_CC)" \
134 AR="$(TARGET_CROSS)ar r" \
135 RANLIB="$(TARGET_CROSS)ranlib" \
136 OPENWRT_OPTIMIZATION_FLAGS="$(TARGET_CFLAGS)" \
137 $(OPENSSL_MAKEFLAGS) \
138 build-shared
139 # Work around openssl build bug to link libssl.so with libcrypto.so.
140 -rm $(PKG_BUILD_DIR)/libssl.so.*.*.*
141 $(MAKE) -C $(PKG_BUILD_DIR) \
142 CC="$(TARGET_CC)" \
143 OPENWRT_OPTIMIZATION_FLAGS="$(TARGET_CFLAGS)" \
144 $(OPENSSL_MAKEFLAGS) \
145 do_linux-shared
146 $(MAKE) -C $(PKG_BUILD_DIR) \
147 CC="$(TARGET_CC)" \
148 INSTALL_PREFIX="$(PKG_INSTALL_DIR)" \
149 $(OPENSSL_MAKEFLAGS) \
150 install
151 endef
152
153 define Build/InstallDev
154 $(INSTALL_DIR) $(1)/usr/include
155 $(CP) $(PKG_INSTALL_DIR)/usr/include/openssl $(1)/usr/include/
156 $(INSTALL_DIR) $(1)/usr/lib/
157 $(CP) $(PKG_INSTALL_DIR)/usr/lib/lib{crypto,ssl}.{a,so*} $(1)/usr/lib/
158 $(INSTALL_DIR) $(1)/usr/lib/pkgconfig
159 $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/{openssl,libcrypto,libssl}.pc $(1)/usr/lib/pkgconfig/
160 [ -n "$(TARGET_LDFLAGS)" ] && $(SED) 's#$(TARGET_LDFLAGS)##g' $(1)/usr/lib/pkgconfig/{openssl,libcrypto,libssl}.pc || true
161 endef
162
163 define Package/libopenssl/install
164 $(INSTALL_DIR) $(1)/usr/lib
165 $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libcrypto.so.* $(1)/usr/lib/
166 $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libssl.so.* $(1)/usr/lib/
167 endef
168
169 define Package/openssl-util/install
170 $(INSTALL_DIR) $(1)/etc/ssl
171 $(CP) $(PKG_INSTALL_DIR)/etc/ssl/openssl.cnf $(1)/etc/ssl/
172 $(INSTALL_DIR) $(1)/etc/ssl/certs
173 $(INSTALL_DIR) $(1)/etc/ssl/private
174 chmod 0700 $(1)/etc/ssl/private
175 $(INSTALL_DIR) $(1)/usr/bin
176 $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/openssl $(1)/usr/bin/
177 endef
178
179 $(eval $(call BuildPackage,libopenssl))
180 $(eval $(call BuildPackage,openssl-util))