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