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