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