openssl: Pass in any TARGET_ASFLAGS
[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 ASFLAGS="$(TARGET_ASFLAGS) -c" \
128 AR="$(TARGET_CROSS)ar r" \
129 RANLIB="$(TARGET_CROSS)ranlib" \
130 OPENWRT_OPTIMIZATION_FLAGS="$(TARGET_CFLAGS)" \
131 $(OPENSSL_MAKEFLAGS) \
132 all
133 $(MAKE) -C $(PKG_BUILD_DIR) \
134 CC="$(TARGET_CC)" \
135 ASFLAGS="$(TARGET_ASFLAGS) -c" \
136 AR="$(TARGET_CROSS)ar r" \
137 RANLIB="$(TARGET_CROSS)ranlib" \
138 OPENWRT_OPTIMIZATION_FLAGS="$(TARGET_CFLAGS)" \
139 $(OPENSSL_MAKEFLAGS) \
140 build-shared
141 # Work around openssl build bug to link libssl.so with libcrypto.so.
142 -rm $(PKG_BUILD_DIR)/libssl.so.*.*.*
143 $(MAKE) -C $(PKG_BUILD_DIR) \
144 CC="$(TARGET_CC)" \
145 OPENWRT_OPTIMIZATION_FLAGS="$(TARGET_CFLAGS)" \
146 $(OPENSSL_MAKEFLAGS) \
147 do_linux-shared
148 $(MAKE) -C $(PKG_BUILD_DIR) \
149 CC="$(TARGET_CC)" \
150 INSTALL_PREFIX="$(PKG_INSTALL_DIR)" \
151 $(OPENSSL_MAKEFLAGS) \
152 install
153 endef
154
155 define Build/InstallDev
156 $(INSTALL_DIR) $(1)/usr/include
157 $(CP) $(PKG_INSTALL_DIR)/usr/include/openssl $(1)/usr/include/
158 $(INSTALL_DIR) $(1)/usr/lib/
159 $(CP) $(PKG_INSTALL_DIR)/usr/lib/lib{crypto,ssl}.{a,so*} $(1)/usr/lib/
160 $(INSTALL_DIR) $(1)/usr/lib/pkgconfig
161 $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/{openssl,libcrypto,libssl}.pc $(1)/usr/lib/pkgconfig/
162 [ -n "$(TARGET_LDFLAGS)" ] && $(SED) 's#$(TARGET_LDFLAGS)##g' $(1)/usr/lib/pkgconfig/{openssl,libcrypto,libssl}.pc || true
163 endef
164
165 define Package/libopenssl/install
166 $(INSTALL_DIR) $(1)/usr/lib
167 $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libcrypto.so.* $(1)/usr/lib/
168 $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libssl.so.* $(1)/usr/lib/
169 endef
170
171 define Package/openssl-util/install
172 $(INSTALL_DIR) $(1)/etc/ssl
173 $(CP) $(PKG_INSTALL_DIR)/etc/ssl/openssl.cnf $(1)/etc/ssl/
174 $(INSTALL_DIR) $(1)/etc/ssl/certs
175 $(INSTALL_DIR) $(1)/etc/ssl/private
176 chmod 0700 $(1)/etc/ssl/private
177 $(INSTALL_DIR) $(1)/usr/bin
178 $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/openssl $(1)/usr/bin/
179 endef
180
181 $(eval $(call BuildPackage,libopenssl))
182 $(eval $(call BuildPackage,openssl-util))