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