openssl: another day another bug fix update
[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.1i
12 PKG_RELEASE:=1
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:=c8dc151a671b9b92ff3e4c118b174972
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 CONFIG_OPENSSL_WITH_EC CONFIG_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-aes192 no-camellia no-ans1 no-krb5
82 OPENSSL_OPTIONS:= shared no-err no-hw 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 OPENSSL_MAKEFLAGS += LIBDIR=lib
104 else
105 OPENSSL_OPTIONS+=no-sse2
106 ifeq ($(CONFIG_mips)$(CONFIG_mipsel),y)
107 OPENSSL_TARGET:=linux-mips-openwrt
108 else
109 OPENSSL_TARGET:=linux-generic-openwrt
110 OPENSSL_OPTIONS+=no-perlasm
111 endif
112 endif
113
114 STAMP_CONFIGURED := $(STAMP_CONFIGURED)_$(subst $(space),_,$(OPENSSL_OPTIONS))
115
116 define Build/Configure
117 [ -f $(STAMP_CONFIGURED) ] || { \
118 rm -f $(PKG_BUILD_DIR)/*.so.* $(PKG_BUILD_DIR)/*.a; \
119 find $(PKG_BUILD_DIR) -name \*.o | xargs rm -f; \
120 }
121 (cd $(PKG_BUILD_DIR); \
122 ./Configure $(OPENSSL_TARGET) \
123 --prefix=/usr \
124 --openssldir=/etc/ssl \
125 $(TARGET_CPPFLAGS) \
126 $(TARGET_LDFLAGS) -ldl \
127 -DOPENSSL_SMALL_FOOTPRINT \
128 $(OPENSSL_NO_CIPHERS) \
129 $(OPENSSL_OPTIONS) \
130 )
131 # XXX: OpenSSL "make depend" will look for installed headers before its own,
132 # so remove installed stuff first
133 -$(SUBMAKE) -j1 clean-staging
134 +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
135 MAKEDEPPROG="$(TARGET_CROSS)gcc" \
136 OPENWRT_OPTIMIZATION_FLAGS="$(TARGET_CFLAGS)" \
137 $(OPENSSL_MAKEFLAGS) \
138 depend
139 endef
140
141 TARGET_CFLAGS += $(FPIC)
142
143 define Build/Compile
144 +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
145 CC="$(TARGET_CC)" \
146 ASFLAGS="$(TARGET_ASFLAGS) -c" \
147 AR="$(TARGET_CROSS)ar r" \
148 RANLIB="$(TARGET_CROSS)ranlib" \
149 OPENWRT_OPTIMIZATION_FLAGS="$(TARGET_CFLAGS)" \
150 $(OPENSSL_MAKEFLAGS) \
151 all
152 +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
153 CC="$(TARGET_CC)" \
154 ASFLAGS="$(TARGET_ASFLAGS) -c" \
155 AR="$(TARGET_CROSS)ar r" \
156 RANLIB="$(TARGET_CROSS)ranlib" \
157 OPENWRT_OPTIMIZATION_FLAGS="$(TARGET_CFLAGS)" \
158 $(OPENSSL_MAKEFLAGS) \
159 build-shared
160 # Work around openssl build bug to link libssl.so with libcrypto.so.
161 -rm $(PKG_BUILD_DIR)/libssl.so.*.*.*
162 +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
163 CC="$(TARGET_CC)" \
164 OPENWRT_OPTIMIZATION_FLAGS="$(TARGET_CFLAGS)" \
165 $(OPENSSL_MAKEFLAGS) \
166 do_linux-shared
167 $(MAKE) -C $(PKG_BUILD_DIR) \
168 CC="$(TARGET_CC)" \
169 INSTALL_PREFIX="$(PKG_INSTALL_DIR)" \
170 $(OPENSSL_MAKEFLAGS) \
171 install
172 endef
173
174 define Build/InstallDev
175 $(INSTALL_DIR) $(1)/usr/include
176 $(CP) $(PKG_INSTALL_DIR)/usr/include/openssl $(1)/usr/include/
177 $(INSTALL_DIR) $(1)/usr/lib/
178 $(CP) $(PKG_INSTALL_DIR)/usr/lib/lib{crypto,ssl}.{a,so*} $(1)/usr/lib/
179 $(INSTALL_DIR) $(1)/usr/lib/pkgconfig
180 $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/{openssl,libcrypto,libssl}.pc $(1)/usr/lib/pkgconfig/
181 [ -n "$(TARGET_LDFLAGS)" ] && $(SED) 's#$(TARGET_LDFLAGS)##g' $(1)/usr/lib/pkgconfig/{openssl,libcrypto,libssl}.pc || true
182 endef
183
184 define Package/libopenssl/install
185 $(INSTALL_DIR) $(1)/usr/lib
186 $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libcrypto.so.* $(1)/usr/lib/
187 $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libssl.so.* $(1)/usr/lib/
188 endef
189
190 define Package/openssl-util/install
191 $(INSTALL_DIR) $(1)/etc/ssl
192 $(CP) $(PKG_INSTALL_DIR)/etc/ssl/openssl.cnf $(1)/etc/ssl/
193 $(INSTALL_DIR) $(1)/etc/ssl/certs
194 $(INSTALL_DIR) $(1)/etc/ssl/private
195 chmod 0700 $(1)/etc/ssl/private
196 $(INSTALL_DIR) $(1)/usr/bin
197 $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/openssl $(1)/usr/bin/
198 endef
199
200 $(eval $(call BuildPackage,libopenssl))
201 $(eval $(call BuildPackage,openssl-util))