add openssl
[openwrt.git] / package / openssl / Makefile
1 # $Id$
2
3 include $(TOPDIR)/rules.mk
4
5 PKG_NAME:=openssl
6 PKG_VERSION:=0.9.8b
7 PKG_RELEASE:=1
8 PKG_MD5SUM:=12cedbeb6813a0d7919dbf1f82134b86
9
10 PKG_SOURCE_URL:=http://www.openssl.org/source/ \
11         ftp://ftp.funet.fi/pub/crypt/cryptography/libs/openssl/source/ \
12         ftp://ftp.webmonster.de/pub/openssl/source/ \
13         ftp://ftp.sunet.se/pub/security/tools/net/openssl/source/
14 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
15 PKG_CAT:=zcat
16
17 PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
18 PKG_INSTALL_DIR:=$(PKG_BUILD_DIR)/ipkg-install
19
20 OPENSSL_NO_CIPHERS:= no-idea no-md2 no-mdc2 no-rc5 no-sha0 no-rmd160 no-aes192
21 OPENSSL_OPTIONS:= shared no-ec no-err no-fips no-hw no-krb5 no-threads zlib-dynamic no-engines
22
23 include $(TOPDIR)/package/rules.mk
24
25 define Build/Configure
26         $(SED) 's,/CFLAG=,/CFLAG= $(TARGET_SOFT_FLOAT) ,g' $(PKG_BUILD_DIR)/Configure
27         $(SED) s/OPENWRT_OPTIMIZATION_FLAGS/$(BR2_TARGET_OPTIMIZATION)/g $(PKG_BUILD_DIR)/Configure
28         (cd $(PKG_BUILD_DIR); \
29                 PATH=$(TARGET_PATH) \
30                 ./Configure linux-openwrt \
31                   --prefix=/usr \
32                   --openssldir=/etc/ssl \
33                   -I$(STAGING_DIR)/usr/include \
34                   -L$(STAGING_DIR)/usr/lib -ldl \
35                   -DOPENSSL_SMALL_FOOTPRINT \
36                   $(OPENSSL_NO_CIPHERS) \
37                   $(OPENSSL_OPTIONS) \
38         )
39 endef
40
41 define Build/Compile
42         rm -rf $(PKG_INSTALL_DIR)
43         mkdir -p $(PKG_INSTALL_DIR)
44         $(MAKE) -C $(PKG_BUILD_DIR) -j1 \
45                 MAKEDEPPROG="$(TARGET_CC)" \
46                 depend
47         $(MAKE) -C $(PKG_BUILD_DIR) -j1 \
48                 CC="$(TARGET_CC)" \
49                 AR="$(TARGET_CROSS)ar r" \
50                 RANLIB="$(TARGET_CROSS)ranlib" \
51                 all build-shared
52         # Work around openssl build bug to link libssl.so with libcrypto.so.
53         -rm $(PKG_BUILD_DIR)/libssl.so.*.*.*
54         $(MAKE) -C $(PKG_BUILD_DIR) -j1 \
55                 CC=$(TARGET_CC) \
56                 CCOPTS="$(TARGET_CFLAGS) -fomit-frame-pointer" \
57                 do_linux-shared
58         $(MAKE) -C $(PKG_BUILD_DIR) -j1 \
59                 INSTALL_PREFIX="$(PKG_INSTALL_DIR)" \
60                 install
61 endef
62
63 define Build/InstallDev
64         mkdir -p $(STAGING_DIR)/usr/include
65         $(CP) $(PKG_INSTALL_DIR)/usr/include/openssl $(STAGING_DIR)/usr/include/
66         mkdir -p $(STAGING_DIR)/usr/lib/
67         $(CP) $(PKG_INSTALL_DIR)/usr/lib/lib{crypto,ssl}.{a,so*} $(STAGING_DIR)/usr/lib/
68 endef
69         
70 define Build/UninstallDev
71         rm -rf \
72                 $(STAGING_DIR)/usr/include/openssl \
73                 $(STAGING_DIR)/usr/lib/lib{crypto,ssl}.{a,so*}
74 endef
75
76
77 define Package/libopenssl
78  SECTION:=base
79  CATEGORY:=Libraries
80  TITLE:=Open source SSL libraries
81  DESCRIPTION:=Open source SSL (Secure Socket Layer) libraries
82  URL:=http://www.openssl.org/
83 endef
84
85 define Package/openssl-util
86  $(call Package/libopenssl)
87  DEPENDS:=libopenssl
88  TITLE:=OpenSSL command line utilities
89  DESCRIPTION:=OpenSSL command line utilities
90 endef
91
92
93 define Package/libopenssl/install
94         install -d -m0755 $(1)/usr/lib
95         $(CP) $(PKG_INSTALL_DIR)/usr/lib/lib{crypto,ssl}.so.* $(1)/usr/lib/
96         chmod 0644 $(1)/usr/lib/*
97 endef
98
99 define Package/openssl-util/install
100         install -d -m0755 $(1)/etc/ssl
101         $(CP) $(PKG_INSTALL_DIR)/etc/ssl/openssl.cnf $(1)/etc/ssl/
102         install -d -m0755 $(1)/etc/ssl/certs
103         install -d -m0755 $(1)/etc/ssl/private
104         chmod 0700 $(1)/etc/ssl/private
105         install -d -m0755 $(1)/usr/bin
106         $(CP) $(PKG_INSTALL_DIR)/usr/bin/openssl $(1)/usr/bin/
107 endef
108
109
110 $(eval $(call BuildPackage,libopenssl))
111 $(eval $(call BuildPackage,openssl-util))