From f0cb47e731ec24df58e3e1caa1a356afbb82f4fb Mon Sep 17 00:00:00 2001
From: florian <florian@3c298f89-4303-0410-b956-a3cf2f4a3e73>
Date: Tue, 27 Mar 2012 19:20:26 +0000
Subject: [PATCH] [package] lighttpd: configure with OpenSSL support only if
 the user asks for it

SSL support adds a quite large dependency to lighttpd when compiled
in. On a 32 bit platform, libcrypto is roughly 1MB, to which one must
add the size of libssl (roughly 250KB). This is 2 to 5 times the size
of a typical lighttpd embedded installation.

SSL support is only needed if one enables the SSL engine in the
lighttpd.conf configuration file.

This patch introduces a configuration option that allows the user to
choose whether or not he wants to compile SSL support in. It defaults
to 'y' only if libopenssl is already selected (either by active
selection or because libopenssl is a dependency of another package).

Signed-off-by: Emmanuel Deloget <logout@free.fr>

git-svn-id: svn://svn.openwrt.org/openwrt/packages@31097 3c298f89-4303-0410-b956-a3cf2f4a3e73
---
 net/lighttpd/Makefile | 24 +++++++++++++++++++++---
 1 file changed, 21 insertions(+), 3 deletions(-)

diff --git a/net/lighttpd/Makefile b/net/lighttpd/Makefile
index 81f1ba4a8..95e1644e7 100644
--- a/net/lighttpd/Makefile
+++ b/net/lighttpd/Makefile
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=lighttpd
 PKG_VERSION:=1.4.30
-PKG_RELEASE:=1
+PKG_RELEASE:=2
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
 PKG_SOURCE_URL:=http://download.lighttpd.net/lighttpd/releases-1.4.x
@@ -30,10 +30,21 @@ endef
 define Package/lighttpd
   $(call Package/lighttpd/Default)
   MENU:=1
-  DEPENDS:=+libopenssl +libpcre +libpthread
+  DEPENDS:=+LIGHTTPD_SSL:libopenssl +libpcre +libpthread
   TITLE:=A flexible and lightweight web server
 endef
 
+define Package/lighttpd/config
+config LIGHTTPD_SSL
+	bool "SSL support"
+	depends on PACKAGE_lighttpd
+	default y if PACKAGE_libopenssl
+	help
+	  Implements SSL support in lighttpd (using libopenssl). This
+	  option is required if you enable the SSL engine in your
+	  lighttpd confguration file.
+endef
+
 define Package/lighttpd-mod-access
   $(call Package/lighttpd/Default)
   DEPENDS:=lighttpd
@@ -222,7 +233,6 @@ CONFIGURE_ARGS+= \
 	--without-lua \
 	--without-memcache \
 	--without-mysql \
-	--with-openssl="$(STAGING_DIR)/usr" \
 	--with-pcre \
 	--without-valgrind \
 	 $(call autoconf_bool,CONFIG_IPV6,ipv6)
@@ -230,6 +240,14 @@ CONFIGURE_ARGS+= \
 CONFIGURE_VARS+= \
 	PCRE_LIB="-lpcre" \
 
+ifneq ($(strip $(CONFIG_LIGHTTPD_SSL)),)
+  CONFIGURE_ARGS+= \
+	--with-openssl="$(STAGING_DIR)/usr"
+else
+  CONFIGURE_ARGS+= \
+	--without-openssl
+endif
+
 ifneq ($(SDK)$(CONFIG_PACKAGE_lighttpd-mod-webdav),)
   CONFIGURE_ARGS+= \
 	--with-webdav-locks \