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