123f393d5a47e754055808770ca2ab78745b1c9f
[openwrt/svn-archive/archive.git] / package / 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.1c
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:=ae412727c8c15b67880aef7bd2999b2e
20
21 PKG_BUILD_DEPENDS:=ocf-crypto-headers
22 PKG_CONFIG_DEPENDS:=CONFIG_OPENSSL_ENGINE_CRYPTO CONFIG_OPENSSL_ENGINE_DIGEST
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 Secure
38 Sockets Layer (SSL v2/v3) and Transport Layer Security (TLS v1) protocols as well
39 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 MENU:=1
50 endef
51
52 define Package/libopenssl/description
53 $(call Package/openssl/Default/description)
54 This package contains the OpenSSL shared libraries, needed by other programs.
55 endef
56
57 define Package/openssl-util
58 $(call Package/openssl/Default)
59 SECTION:=utils
60 CATEGORY:=Utilities
61 DEPENDS:=+libopenssl +libpthread
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_CRYPTO
80 OPENSSL_OPTIONS += -DHAVE_CRYPTODEV
81 ifdef CONFIG_OPENSSL_ENGINE_DIGEST
82 OPENSSL_OPTIONS += -DUSE_CRYPTODEV_DIGESTS
83 endif
84 else
85 OPENSSL_OPTIONS += no-engines
86 endif
87
88 ifeq ($(CONFIG_x86_64),y)
89 OPENSSL_TARGET:=linux-x86_64
90 else
91 OPENSSL_TARGET:=linux-openwrt
92 OPENSSL_OPTIONS+=no-perlasm no-sse2
93 endif
94
95 define Build/Configure
96 (cd $(PKG_BUILD_DIR); \
97 ./Configure $(OPENSSL_TARGET) \
98 --prefix=/usr \
99 --openssldir=/etc/ssl \
100 $(TARGET_CPPFLAGS) \
101 $(TARGET_LDFLAGS) -ldl \
102 -DOPENSSL_SMALL_FOOTPRINT \
103 $(OPENSSL_NO_CIPHERS) \
104 $(OPENSSL_OPTIONS) \
105 )
106 endef
107
108 TARGET_CFLAGS += $(FPIC) -DOPENSSL_THREADS -pthread -D_REENTRANT -D_THREAD_SAFE -D_THREADSAFE
109
110 define Build/Compile
111 # XXX: OpenSSL "make depend" will look for installed headers before its own,
112 # so remove installed stuff first
113 -$(SUBMAKE) -j1 clean-staging
114 $(MAKE) -C $(PKG_BUILD_DIR) \
115 MAKEDEPPROG="$(TARGET_CROSS)gcc" \
116 OPENWRT_OPTIMIZATION_FLAGS="$(TARGET_CFLAGS)" \
117 $(OPENSSL_MAKEFLAGS) \
118 depend
119 $(_SINGLE)$(MAKE) -C $(PKG_BUILD_DIR) \
120 CC="$(TARGET_CC)" \
121 AR="$(TARGET_CROSS)ar r" \
122 RANLIB="$(TARGET_CROSS)ranlib" \
123 OPENWRT_OPTIMIZATION_FLAGS="$(TARGET_CFLAGS)" \
124 $(OPENSSL_MAKEFLAGS) \
125 all
126 $(MAKE) -C $(PKG_BUILD_DIR) \
127 CC="$(TARGET_CC)" \
128 AR="$(TARGET_CROSS)ar r" \
129 RANLIB="$(TARGET_CROSS)ranlib" \
130 OPENWRT_OPTIMIZATION_FLAGS="$(TARGET_CFLAGS)" \
131 $(OPENSSL_MAKEFLAGS) \
132 build-shared
133 # Work around openssl build bug to link libssl.so with libcrypto.so.
134 -rm $(PKG_BUILD_DIR)/libssl.so.*.*.*
135 $(MAKE) -C $(PKG_BUILD_DIR) \
136 CC="$(TARGET_CC)" \
137 OPENWRT_OPTIMIZATION_FLAGS="$(TARGET_CFLAGS)" \
138 $(OPENSSL_MAKEFLAGS) \
139 do_linux-shared
140 $(MAKE) -C $(PKG_BUILD_DIR) \
141 CC="$(TARGET_CC)" \
142 INSTALL_PREFIX="$(PKG_INSTALL_DIR)" \
143 $(OPENSSL_MAKEFLAGS) \
144 install
145 endef
146
147 define Build/InstallDev
148 $(INSTALL_DIR) $(1)/usr/include
149 $(CP) $(PKG_INSTALL_DIR)/usr/include/openssl $(1)/usr/include/
150 $(INSTALL_DIR) $(1)/usr/lib/
151 $(CP) $(PKG_INSTALL_DIR)/usr/lib/lib{crypto,ssl}.{a,so*} $(1)/usr/lib/
152 $(INSTALL_DIR) $(1)/usr/lib/pkgconfig
153 $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/{openssl,libcrypto,libssl}.pc $(1)/usr/lib/pkgconfig/
154 [ -n "$(TARGET_LDFLAGS)" ] && $(SED) 's#$(TARGET_LDFLAGS)##g' $(1)/usr/lib/pkgconfig/{openssl,libcrypto,libssl}.pc || true
155 endef
156
157 define Package/libopenssl/install
158 $(INSTALL_DIR) $(1)/usr/lib
159 $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libcrypto.so.* $(1)/usr/lib/
160 $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libssl.so.* $(1)/usr/lib/
161 endef
162
163 define Package/openssl-util/install
164 $(INSTALL_DIR) $(1)/etc/ssl
165 $(CP) $(PKG_INSTALL_DIR)/etc/ssl/openssl.cnf $(1)/etc/ssl/
166 $(INSTALL_DIR) $(1)/etc/ssl/certs
167 $(INSTALL_DIR) $(1)/etc/ssl/private
168 chmod 0700 $(1)/etc/ssl/private
169 $(INSTALL_DIR) $(1)/usr/bin
170 $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/openssl $(1)/usr/bin/
171 endef
172
173 $(eval $(call BuildPackage,libopenssl))
174 $(eval $(call BuildPackage,openssl-util))