Add configuration settings to disable certain features in nginx to
be able to reduce it's footprint and allow nginx to be built with
support for lua.

Signed-off-by: Karl Vogel <karl.vo...@gmail.com>
---
 net/nginx/Config.in                       |  131 +++++++++++++++++++++++++++++
 net/nginx/Makefile                        |  125 +++++++++++++++++++++++++++-
 net/nginx/patches-lua-nginx/300-ldl.patch |   23 +++++
 3 files changed, 277 insertions(+), 2 deletions(-)
 create mode 100644 net/nginx/patches-lua-nginx/300-ldl.patch

diff --git a/net/nginx/Config.in b/net/nginx/Config.in
index e451037..1396d10 100644
--- a/net/nginx/Config.in
+++ b/net/nginx/Config.in
@@ -36,4 +36,135 @@ config NGINX_DAV
        help
                Enable the HTTP and WebDAV methods PUT, DELETE, MKCOL, COPY and 
MOVE.
 
+config NGINX_MODULE_LUA
+       bool
+       prompt "Enable LUA module"
+       default n
+       help
+               Enable support for LUA scripts.
+
+       menu "Disable features"
+
+       config NGINX_DISABLE_PCRE
+             bool
+             prompt "Disable PCRE library usage"
+             default n
+
+       config NGINX_DISABLE_HTTP_CACHE
+             depends on NGINX_SSL=y
+             bool
+             prompt "Disable HTTP cache"
+             default y
+
+       config NGINX_DISABLE_HTTP_CHARSET_MODULE
+             bool
+             prompt "Disable HTTP charset module"
+             default n
+
+       config NGINX_DISABLE_HTTP_GZIP_MODULE
+             bool
+             prompt "Disable HTTP gzip module"
+             default n
+
+       config NGINX_DISABLE_HTTP_SSI_MODULE
+             bool
+             prompt "Disable HTTP ssi module"
+             default n
+
+       config NGINX_DISABLE_HTTP_USERID_MODULE
+             bool
+             prompt "Disable HTTP userid module"
+             default n
+
+       config NGINX_DISABLE_HTTP_ACCESS_MODULE
+             bool
+             prompt "Disable HTTP access module"
+             default n
+
+       config NGINX_DISABLE_HTTP_AUTH_BASIC_MODULE
+             bool
+             prompt "Disable HTTP auth basic"
+             default n
+
+       config NGINX_DISABLE_HTTP_AUTOINDEX_MODULE
+             bool
+             prompt "Disable HTTP autoindex module"
+             default n
+
+       config NGINX_DISABLE_HTTP_GEO_MODULE
+             bool
+             prompt "Disable HTTP geo module"
+             default n
+
+       config NGINX_DISABLE_HTTP_MAP_MODULE
+             bool
+             prompt "Disable HTTP map module"
+             default n
+
+       config NGINX_DISABLE_HTTP_SPLIT_CLIENTS_MODULE
+             bool
+             prompt "Disable HTTP split clients"
+             default n
+
+       config NGINX_DISABLE_HTTP_REFERER_MODULE
+             bool
+             prompt "Disable HTTP referer module"
+             default n
+
+       config NGINX_DISABLE_HTTP_REWRITE_MODULE
+             bool
+             prompt "Disable HTTP rewrite module"
+             default n
+
+       config NGINX_DISABLE_HTTP_PROXY_MODULE
+             bool
+             prompt "Disable HTTP proxy module"
+             default n
+
+       config NGINX_DISABLE_HTTP_FASTCGI_MODULE
+             bool
+             prompt "Disable HTTP fastcgi module"
+             default n
+
+       config NGINX_DISABLE_HTTP_UWSGI_MODULE
+             bool
+             prompt "Disable HTTP uwsgi module"
+             default n
+
+       config NGINX_DISABLE_HTTP_SCGI_MODULE
+             bool
+             prompt "Disable HTTP scgi module"
+             default n
+
+       config NGINX_DISABLE_HTTP_MEMCACHED_MODULE
+             bool
+             prompt "Disable HTTP memcached module"
+             default n
+
+       config NGINX_DISABLE_HTTP_LIMIT_CONN_MODULE
+             bool
+             prompt "Disable HTTP limit conn"
+             default n
+
+       config NGINX_DISABLE_HTTP_LIMIT_REQ_MODULE
+             bool
+             prompt "Disable HTTP limit req"
+             default n
+
+       config NGINX_DISABLE_HTTP_EMPTY_GIF_MODULE
+             bool
+             prompt "Disable HTTP empty gif"
+             default n
+
+       config NGINX_DISABLE_HTTP_BROWSER_MODULE
+             bool
+             prompt "Disable HTTP browser module"
+             default n
+
+       config NGINX_DISABLE_HTTP_UPSTREAM_IP_HASH_MODULE
+             bool
+             prompt "Disable HTTP IP hash module"
+             default n
+
+       endmenu
 endmenu
diff --git a/net/nginx/Makefile b/net/nginx/Makefile
index d56a729..e6fcbc8 100644
--- a/net/nginx/Makefile
+++ b/net/nginx/Makefile
@@ -22,7 +22,31 @@ PKG_CONFIG_DEPENDS := \
        CONFIG_NGINX_STUB_STATUS \
        CONFIG_NGINX_FLV \
        CONFIG_NGINX_SSL \
-       CONFIG_NGINX_DAV
+       CONFIG_NGINX_DAV \
+       CONFIG_NGINX_MODULE_LUA \
+       CONFIG_NGINX_DISABLE_PCRE \
+       CONFIG_NGINX_DISABLE_HTTP_CHARSET_MODULE \
+       CONFIG_NGINX_DISABLE_HTTP_GZIP_MODULE \
+       CONFIG_NGINX_DISABLE_HTTP_SSI_MODULE \
+       CONFIG_NGINX_DISABLE_HTTP_USERID_MODULE \
+       CONFIG_NGINX_DISABLE_HTTP_ACCESS_MODULE \
+       CONFIG_NGINX_DISABLE_HTTP_AUTH_BASIC_MODULE \
+       CONFIG_NGINX_DISABLE_HTTP_AUTOINDEX_MODULE \
+       CONFIG_NGINX_DISABLE_HTTP_GEO_MODULE \
+       CONFIG_NGINX_DISABLE_HTTP_MAP_MODULE \
+       CONFIG_NGINX_DISABLE_HTTP_SPLIT_CLIENTS_MODULE \
+       CONFIG_NGINX_DISABLE_HTTP_REFERER_MODULE \
+       CONFIG_NGINX_DISABLE_HTTP_REWRITE_MODULE \
+       CONFIG_NGINX_DISABLE_HTTP_PROXY_MODULE \
+       CONFIG_NGINX_DISABLE_HTTP_FASTCGI_MODULE \
+       CONFIG_NGINX_DISABLE_HTTP_UWSGI_MODULE \
+       CONFIG_NGINX_DISABLE_HTTP_SCGI_MODULE \
+       CONFIG_NGINX_DISABLE_HTTP_MEMCACHED_MODULE \
+       CONFIG_NGINX_DISABLE_HTTP_LIMIT_CONN_MODULE \
+       CONFIG_NGINX_DISABLE_HTTP_LIMIT_REQ_MODULE \
+       CONFIG_NGINX_DISABLE_HTTP_EMPTY_GIF_MODULE \
+       CONFIG_NGINX_DISABLE_HTTP_BROWSER_MODULE \
+       CONFIG_NGINX_DISABLE_HTTP_UPSTREAM_IP_HASH_MODULE
 
 include $(INCLUDE_DIR)/package.mk
 
@@ -32,7 +56,7 @@ define Package/nginx
   SUBMENU:=Web Servers/Proxies
   TITLE:=Nginx web server
   URL:=http://nginx.org/
-  DEPENDS:=+libpcre +libopenssl +zlib +libpthread
+  DEPENDS:=+!NGINX_DISABLE_PCRE:libpcre +NGINX_SSL:libopenssl 
+!NGINX_DISABLE_HTTP_GZIP_MODULE:zlib +libpthread +NGINX_MODULE_LUA:liblua
   MENU:=1
 endef
 
@@ -70,10 +94,87 @@ endif
 ifeq ($(CONFIG_NGINX_DAV),y)
   ADDITIONAL_MODULES += --with-http_dav_module
 endif
+ifeq ($(CONFIG_NGINX_MODULE_LUA),y)
+  ADDITIONAL_MODULES += --add-module=$(PKG_BUILD_DIR)/lua-nginx
+endif
+ifeq ($(CONFIG_NGINX_DISABLE_HTTP_CACHE),y)
+  ADDITIONAL_MODULES += --without-http-cache
+endif
+ifeq ($(CONFIG_NGINX_DISABLE_PCRE),y)
+  ADDITIONAL_MODULES += --without-pcre
+endif
+ifeq ($(CONFIG_NGINX_DISABLE_HTTP_CHARSET_MODULE),y)
+  ADDITIONAL_MODULES += --without-http_charset_module
+endif
+ifeq ($(CONFIG_NGINX_DISABLE_HTTP_GZIP_MODULE),y)
+  ADDITIONAL_MODULES += --without-http_gzip_module
+endif
+ifeq ($(CONFIG_NGINX_DISABLE_HTTP_SSI_MODULE),y)
+  ADDITIONAL_MODULES += --without-http_ssi_module
+endif
+ifeq ($(CONFIG_NGINX_DISABLE_HTTP_USERID_MODULE),y)
+  ADDITIONAL_MODULES += --without-http_userid_module
+endif
+ifeq ($(CONFIG_NGINX_DISABLE_HTTP_ACCESS_MODULE),y)
+  ADDITIONAL_MODULES += --without-http_access_module
+endif
+ifeq ($(CONFIG_NGINX_DISABLE_HTTP_AUTH_BASIC_MODULE),y)
+  ADDITIONAL_MODULES += --without-http_auth_basic_module
+endif
+ifeq ($(CONFIG_NGINX_DISABLE_HTTP_AUTOINDEX_MODULE),y)
+  ADDITIONAL_MODULES += --without-http_autoindex_module
+endif
+ifeq ($(CONFIG_NGINX_DISABLE_HTTP_GEO_MODULE),y)
+  ADDITIONAL_MODULES += --without-http_geo_module
+endif
+ifeq ($(CONFIG_NGINX_DISABLE_HTTP_MAP_MODULE),y)
+  ADDITIONAL_MODULES += --without-http_map_module
+endif
+ifeq ($(CONFIG_NGINX_DISABLE_HTTP_SPLIT_CLIENTS_MODULE),y)
+  ADDITIONAL_MODULES += --without-http_split_clients_module
+endif
+ifeq ($(CONFIG_NGINX_DISABLE_HTTP_REFERER_MODULE),y)
+  ADDITIONAL_MODULES += --without-http_referer_module
+endif
+ifeq ($(CONFIG_NGINX_DISABLE_HTTP_REWRITE_MODULE),y)
+  ADDITIONAL_MODULES += --without-http_rewrite_module
+endif
+ifeq ($(CONFIG_NGINX_DISABLE_HTTP_PROXY_MODULE),y)
+  ADDITIONAL_MODULES += --without-http_proxy_module
+endif
+ifeq ($(CONFIG_NGINX_DISABLE_HTTP_FASTCGI_MODULE),y)
+  ADDITIONAL_MODULES += --without-http_fastcgi_module
+endif
+ifeq ($(CONFIG_NGINX_DISABLE_HTTP_UWSGI_MODULE),y)
+  ADDITIONAL_MODULES += --without-http_uwsgi_module
+endif
+ifeq ($(CONFIG_NGINX_DISABLE_HTTP_SCGI_MODULE),y)
+  ADDITIONAL_MODULES += --without-http_scgi_module
+endif
+ifeq ($(CONFIG_NGINX_DISABLE_HTTP_MEMCACHED_MODULE),y)
+  ADDITIONAL_MODULES += --without-http_memcached_module
+endif
+ifeq ($(CONFIG_NGINX_DISABLE_HTTP_LIMIT_CONN_MODULE),y)
+  ADDITIONAL_MODULES += --without-http_limit_conn_module
+endif
+ifeq ($(CONFIG_NGINX_DISABLE_HTTP_LIMIT_REQ_MODULE),y)
+  ADDITIONAL_MODULES += --without-http_limit_req_module
+endif
+ifeq ($(CONFIG_NGINX_DISABLE_HTTP_EMPTY_GIF_MODULE),y)
+  ADDITIONAL_MODULES += --without-http_empty_gif_module
+endif
+ifeq ($(CONFIG_NGINX_DISABLE_HTTP_BROWSER_MODULE),y)
+  ADDITIONAL_MODULES += --without-http_browser_module
+endif
+ifeq ($(CONFIG_NGINX_DISABLE_HTTP_UPSTREAM_IP_HASH_MODULE),y)
+  ADDITIONAL_MODULES += --without-http_upstream_ip_hash_module
+endif
+
 
 define Build/Configure
        # TODO: fix --crossbuild
        (cd $(PKG_BUILD_DIR) ;\
+               $(if 
$(CONFIG_NGINX_MODULE_LUA),LUA_INC=$(STAGING_DIR)/usr/include 
LUA_LIB=$(STAGING_DIR)/usr/lib) \
                ./configure \
                        --crossbuild=Linux::$(ARCH) \
                        --prefix=/usr \
@@ -100,4 +201,24 @@ define Package/nginx/install
        $(INSTALL_BIN) ./files/nginx.init $(1)/etc/init.d/nginx
 endef
 
+define Build/Prepare
+       $(call Build/Prepare/Default)
+       $(if $(CONFIG_NGINX_MODULE_LUA),$(call Prepare/lua-nginx))
+endef
+
+define Download/lua-nginx
+       VERSION:=7c0948a08e8449f7a9ffbc35244954e6aaddac5b
+       SUBDIR:=lua-nginx
+       FILE:=lua-nginx-module-$(PKG_VERSION)-$$(VERSION).tar.gz
+       URL:=https://github.com/chaoslawful/lua-nginx-module.git
+       PROTO:=git
+endef
+
+define  Prepare/lua-nginx
+       $(eval $(call Download,lua-nginx))
+       gzip -dc $(DL_DIR)/$(FILE) | tar -C $(PKG_BUILD_DIR) $(TAR_OPTIONS)
+       $(call PatchDir,$(PKG_BUILD_DIR),./patches-lua-nginx)
+endef
+
+
 $(eval $(call BuildPackage,nginx))
diff --git a/net/nginx/patches-lua-nginx/300-ldl.patch 
b/net/nginx/patches-lua-nginx/300-ldl.patch
new file mode 100644
index 0000000..f5fecbb
--- /dev/null
+++ b/net/nginx/patches-lua-nginx/300-ldl.patch
@@ -0,0 +1,23 @@
+diff --git a/lua-nginx/config b/lua-nginx/config
+index ae7991e..da64692 100644
+--- a/lua-nginx/config
++++ b/lua-nginx/config
+@@ -1,5 +1,5 @@
+ ngx_feature="Lua library"
+-ngx_feature_libs="-llua -lm"
++ngx_feature_libs="-llua -lm -ldl"
+ ngx_feature_name=
+ ngx_feature_run=no
+ ngx_feature_incs="#include <lauxlib.h>"
+@@ -47,9 +47,9 @@ else
+         ngx_feature="Lua library in $LUA_LIB and $LUA_INC (specified by the 
LUA_LIB and LUA_INC env)"
+         ngx_feature_path="$LUA_INC"
+         if [ $NGX_RPATH = YES ]; then
+-            ngx_feature_libs="-R$LUA_LIB -L$LUA_LIB -llua -lm"
++            ngx_feature_libs="-R$LUA_LIB -L$LUA_LIB -llua -lm -ldl"
+         else
+-            ngx_feature_libs="-L$LUA_LIB -llua -lm"
++            ngx_feature_libs="-L$LUA_LIB -llua -lm -ldl"
+         fi
+ 
+         . auto/feature
-- 
1.7.1

_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to